import { Inject, Component, OnInit} from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; import { NotifierService } from '../notifier.service'; import { faCopy } from '@fortawesome/free-solid-svg-icons'; import { LanguageService } from '../language.service'; import { LanguageData } from '../language.model'; var URLSafeBase64 = require('urlsafe-base64'); var Buffer = require('buffer/').Buffer; @Component({ selector: 'app-prompt-invoice', templateUrl: './prompt-invoice.component.html', styleUrls: ['./prompt-invoice.component.css'] }) export class PromptInvoiceComponent implements OnInit { orderId: string; invoiceUrl: string; // ------------------------------------ // faCopy = faCopy; // ------------------------------------ // ------------------------------------- // Language Support // vE = { promptinvoiceSendLink : '', promptinvoiceNotservClose : '', promptinvoiceNotservError : '', promptinvoiceNotservSuccess : '', propmtinvoiceInvoiceClipboard : '', promptinvoiceFuncNotavail : '', promptinvoiceInvoiceUrl : '', promptinvoiceInvoiceSent : '', promptinvoiceInvoiceCancel : '' } // constructor( private languageService : LanguageService, private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: {orderId: string}, private notifierService : NotifierService ) { this.orderId = data.orderId; this.invoiceUrl = 'https://app.zgo.cash/invoice/'+this.orderId; } ngOnInit(): void { this.chgUILanguage(); } confirm() { this.dialogRef.close(true); } close() { this.dialogRef.close(false); } copyUrl() { // console.log("Inside copyUrl()"); if (navigator.clipboard) { }; try { navigator.clipboard.writeText(this.invoiceUrl); this.notifierService .showNotification(this.vE.propmtinvoiceInvoiceClipboard, this.vE.promptinvoiceNotservClose, 'success', this.vE.promptinvoiceNotservSuccess); } catch (err) { // console.error("Error", err); this.notifierService .showNotification(this.vE.promptinvoiceFuncNotavail, this.vE.promptinvoiceNotservClose, 'error', this.vE.promptinvoiceNotservError); } } chgUILanguage(){ console.log('PROMPTINVOICE.chgUILanguage Called '); this.languageService.getViewElements('promptinvoice').subscribe( response => { console.log('Received >> ', response ); console.log('Language Code : ', response.language); console.log('Component Name : ',response.component); console.log('Language data : ',response.data); this.vE.promptinvoiceSendLink = response.data.promptinvoice_send_link; this.vE.promptinvoiceNotservClose = response.data.promptinvoice_notserv_close; this.vE.promptinvoiceNotservError = response.data.promptinvoice_notserv_error; this.vE.promptinvoiceNotservSuccess = response.data.promptinvoice_notserv_success; this.vE.propmtinvoiceInvoiceClipboard = response.data.promptinvoice_invoice_clipboard; this.vE.promptinvoiceFuncNotavail = response.data.promptinvoice_func_notavail; this.vE.promptinvoiceInvoiceUrl = response.data.promptinvoice_invoice_url; this.vE.promptinvoiceInvoiceSent = response.data.promptinvoice_invoice_sent; this.vE.promptinvoiceInvoiceCancel = response.data.promptinvoice_invoice_cancel; }, error => { console.log('Error >> ',error); } ); } }