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

103 lines
2.9 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Order} from '../order/order.model';
import { ReceiptService } from '../receipt.service';
import { Observable } from 'rxjs';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({
selector: 'app-receipt',
templateUrl: './receipt.component.html',
styleUrls: ['./receipt.component.css']
})
export class ReceiptComponent implements OnInit {
orderId;
public orderUpdate: Observable<Order>;
public nameUpdate: Observable<string>;
name: string = '';
error: boolean = false;
order:Order = {
address: '',
session: '',
timestamp: '',
closed: false,
currency: '',
price: 0,
total: 0,
totalZec: 0,
paid: false,
externalInvoice: '',
shortCode: '',
lines: [
{
qty: 1,
name: '',
cost:0
}
]
};
// -------------------------------------
//
// Language Support
//
vE = {
receiptReceiptLbl : '',
receiptOrderId : '',
receiptOrderDate : '',
receiptZcashPrice : '',
receiptOrderTotal : '',
receiptQtyLbl : '',
receiptOrderPrice : '',
receiptInvalidId : '',
receiptInfoNotavail : ''
}
constructor(
private languageService : LanguageService,
private _ActiveRoute:ActivatedRoute,
public receiptService: ReceiptService
) {
this.orderId = this._ActiveRoute.snapshot.paramMap.get("orderId");
this.orderUpdate = receiptService.orderUpdate;
this.nameUpdate = receiptService.nameUpdate;
receiptService.getOrderById(this.orderId!);
this.orderUpdate.subscribe(order => {
this.order = order;
});
this.nameUpdate.subscribe(name => {
this.name = name;
});
}
ngOnInit(): void {
this.chgUILanguage();
}
chgUILanguage(){
console.log('RECEIPT.chgUILanguage Called ');
this.languageService.getViewElements('receipt').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.receiptReceiptLbl = response.data.receipt_receipt_lbl;
this.vE.receiptOrderId = response.data.receipt_order_id;
this.vE.receiptOrderDate = response.data.receipt_order_date;
this.vE.receiptZcashPrice = response.data.receipt_zcash_price;
this.vE.receiptOrderTotal = response.data.receipt_order_total;
this.vE.receiptQtyLbl = response.data.receipt_qty_lbl;
this.vE.receiptOrderPrice = response.data.receipt_order_price;
this.vE.receiptInvalidId = response.data.receipt_invalid_id;
this.vE.receiptInfoNotavail = response.data.receipt_info_notavail;
},
error => { console.log('Error >> ',error); }
);
}
}