zgo/src/app/prompt-receipt/prompt-receipt.component.ts

112 lines
3.4 KiB
TypeScript

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-receipt',
templateUrl: './prompt-receipt.component.html',
styleUrls: ['./prompt-receipt.component.css']
})
export class PromptReceiptComponent implements OnInit {
orderId: string;
receiptUrl: string;
// ------------------------------------
//
faCopy = faCopy;
// ------------------------------------
// -------------------------------------
//
// Language Support
//
vE = {
promptreceiptNotservClose : '',
promptreceiptNotservError : '',
promptreceiptNotservSuccess : '',
propmtreceiptReceiptClipboard : '',
promptreceiptFuncNotavail : '',
promptreceiptSendLink : '',
promptreceiptReceiptUrl : '',
promptreceiptCloseLbl : ''
}
//
constructor(
private languageService : LanguageService,
private dialogRef: MatDialogRef<PromptReceiptComponent>,
@Inject(MAT_DIALOG_DATA) public data: {orderId: string},
private notifierService : NotifierService ) {
this.orderId = data.orderId;
this.receiptUrl = 'https://app.zgo.cash/receipt/'+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.receiptUrl);
this.notifierService
.showNotification( this.vE.propmtreceiptReceiptClipboard,
this.vE.promptreceiptNotservClose,
'success',
this.vE.promptreceiptNotservSuccess);
} catch (err) {
// console.error("Error", err);
this.notifierService
.showNotification( this.vE.promptreceiptFuncNotavail,
this.vE.promptreceiptNotservClose,
'error',
this.vE.promptreceiptNotservError);
}
}
chgUILanguage(){
console.log('PROMPTRECEIPT.chgUILanguage Called ');
this.languageService.getViewElements('promptreceipt').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.promptreceiptNotservClose = response.data.promptreceipt_notserv_close;
this.vE.promptreceiptNotservError = response.data.promptreceipt_notserv_error;
this.vE.promptreceiptNotservSuccess = response.data.promptreceipt_notserv_success;
this.vE.propmtreceiptReceiptClipboard = response.data.promptreceipt_receipt_clipboard;
this.vE.promptreceiptFuncNotavail = response.data.promptreceipt_func_notavail;
this.vE.promptreceiptSendLink = response.data.promptreceipt_send_link;
this.vE.promptreceiptReceiptUrl = response.data.promptreceipt_receipt_url;
this.vE.promptreceiptCloseLbl = response.data.promptreceipt_close_lbl;
},
error => { console.log('Error >> ',error); }
);
}
}