Invoice form working with notifications added
This commit is contained in:
parent
8223e10a52
commit
a0b07d8315
7 changed files with 169 additions and 45 deletions
|
@ -13,6 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- (2022-07-22) Invoice dialog completed. Notifications to inform
|
||||||
|
successful/fail of URL copy to clipboard added.
|
||||||
- (2022-07-22) Notifier service created - replaces snackbar used for
|
- (2022-07-22) Notifier service created - replaces snackbar used for
|
||||||
reporting invalid viewing key.
|
reporting invalid viewing key.
|
||||||
Notifier component created - used to apply custom style to message sent by Notifier service.
|
Notifier component created - used to apply custom style to message sent by Notifier service.
|
||||||
|
|
|
@ -34,3 +34,19 @@ img.total{
|
||||||
.small{
|
.small{
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.invoice {
|
||||||
|
font-family: Roboto Mono !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-title {
|
||||||
|
font-size: 19px;
|
||||||
|
font-weight: 700;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.invoice-detail {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,32 +10,46 @@
|
||||||
<div align="center" *ngIf="!error" id="invoice">
|
<div align="center" *ngIf="!error" id="invoice">
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-title>
|
<mat-card-title>
|
||||||
Total: <img class="total" src="/assets/spartan-zec.png" height="18px" />{{order.totalZec | number: '1.0-6'}}
|
Total: <img class="total" src="/assets/zec_rv.png" height="18px" />{{order.totalZec | number: '1.08'}}
|
||||||
</mat-card-title>
|
</mat-card-title>
|
||||||
<mat-card-subtitle>
|
<mat-card-subtitle>
|
||||||
{{order.timestamp | date}}
|
{{order.timestamp | date}}
|
||||||
</mat-card-subtitle>
|
</mat-card-subtitle>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<p class="small">Order ID: {{orderId}}</p>
|
<p class="small">Order ID: {{orderId}}</p>
|
||||||
<p class="small">Zcash Price: {{order.price | currency: order.currency.toUpperCase()}}</p>
|
<p class="small">Zcash Price: {{order.price | number: '1.02' | currency: order.currency.toUpperCase()}}</p>
|
||||||
<div align="center">
|
<div class="invoice" align="center">
|
||||||
<table>
|
<table style="width: 100%;"
|
||||||
<tr>
|
cellspacing="0">
|
||||||
<th align="left">
|
<tr class="invoice-title">
|
||||||
|
<th width="55%"
|
||||||
|
style="text-align: center;">
|
||||||
Item
|
Item
|
||||||
</th>
|
</th>
|
||||||
<th align="center">
|
<th width="15%"
|
||||||
|
style="text-align: center;">
|
||||||
Qty.
|
Qty.
|
||||||
</th>
|
</th>
|
||||||
<th align="right">
|
<th width="30%"
|
||||||
|
style="text-align: center;">
|
||||||
Price ({{order.currency.toUpperCase()}})
|
Price ({{order.currency.toUpperCase()}})
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr *ngFor="let item of order.lines">
|
<tr class="invoice-detail"
|
||||||
<td align="left">{{item.name}}</td>
|
*ngFor="let item of order.lines">
|
||||||
<td align="center">{{item.qty}}</td>
|
<td width="55%"
|
||||||
<td align="right">{{(item.qty * item.cost) | currency: order.currency.toUpperCase()}} </td>
|
align="left">
|
||||||
<tr>
|
{{item.name}}
|
||||||
|
</td>
|
||||||
|
<td width="15%"
|
||||||
|
align="center">
|
||||||
|
{{item.qty}}
|
||||||
|
</td>
|
||||||
|
<td width="30%"
|
||||||
|
align="right">
|
||||||
|
{{( item.qty * item.cost ) | number : '1.02' | currency: order.currency.toUpperCase()}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="qrcode" id="payment-qr" *ngIf="!order.paid"></div>
|
<div class="qrcode" id="payment-qr" *ngIf="!order.paid"></div>
|
||||||
<span *ngIf="order.paid"><fa-icon [icon]="faCheck" color="primary"></fa-icon>Payment confirmed</span>
|
<span *ngIf="order.paid"><fa-icon [icon]="faCheck" color="primary"></fa-icon>Payment confirmed</span>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
.notifier {
|
.notifier {
|
||||||
font-family: Spartan, sans-serif;
|
font-family: Roboto, sans-serif;
|
||||||
color: black;
|
color: black;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -21,11 +21,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep .mat-snack-bar-container.error {
|
::ng-deep .mat-snack-bar-container.error {
|
||||||
background: lightgray;
|
background: antiquewhite;
|
||||||
color: black;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep .mat-snack-bar-container.success {
|
::ng-deep .mat-snack-bar-container.success {
|
||||||
background: lightgray;
|
background: whitesmoke;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,42 @@
|
||||||
.text {
|
|
||||||
font-family: 'Spartan', sans-serif;
|
::ng-deep .invoice {
|
||||||
|
font-family: "Spartan";
|
||||||
|
background: #ff5722;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 18px;
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
line-height: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::ng-deep .invoice-content {
|
||||||
|
font-family: Roboto mono;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copy-button {
|
||||||
|
color: dodgerblue;
|
||||||
|
font-size: 20px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.urlLabel {
|
||||||
|
font-family: "Spartan";
|
||||||
|
font-size: 14px;
|
||||||
|
color: dimgray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.urlDetail {
|
||||||
|
font-family: "Spartan";
|
||||||
|
font-size: 14px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.urlCopyBtn {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,64 @@
|
||||||
<div align="center" mat-dialog-title class="text">
|
<div class="container" style="margin-top: 10px;">
|
||||||
Send the invoice link to your client:
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<mat-dialog-content class="text">
|
<div class="invoice" >
|
||||||
{{invoiceUrl}} <button mat-raised-button (click)="copyUrl()"><mat-icon class="icon">content_copy</mat-icon></button>
|
Send the invoice link to your client:
|
||||||
</mat-dialog-content>
|
</div>
|
||||||
|
|
||||||
|
<table style="width:100%;
|
||||||
|
margin-top: 10px;">
|
||||||
|
<thead style="width: 100%;">
|
||||||
|
<tr>
|
||||||
|
<th class="urlLabel"
|
||||||
|
style="text-align: left;"
|
||||||
|
width="94%">Invoice URL:
|
||||||
|
</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<td class="urlDetail"
|
||||||
|
style="text-align: left;"
|
||||||
|
width="94%">
|
||||||
|
<div>
|
||||||
|
<textarea
|
||||||
|
style="border: none;
|
||||||
|
outline: none;
|
||||||
|
width: 95%;"
|
||||||
|
cdkTextareaAutosize
|
||||||
|
cdkAutosizeMinRows="1"
|
||||||
|
cdkAutosizeMaxRows="4">{{ invoiceUrl }}
|
||||||
|
</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
<mat-dialog-actions>
|
|
||||||
<table cellspacing="0" width="100%">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<button mat-raised-button class="text" color="primary" (click)="confirm()">
|
|
||||||
<mat-icon class="icon">verified_user</mat-icon>Sent!
|
|
||||||
</button>
|
|
||||||
</td>
|
</td>
|
||||||
<td align="right">
|
<td class="urlCopyBtn">
|
||||||
<button mat-raised-button class="text" (click)="close()">
|
<a (click)='copyUrl()' >
|
||||||
<mat-icon class="icon">close</mat-icon>Cancel
|
<fa-icon [icon]="faCopy"
|
||||||
</button>
|
class="copy-button">
|
||||||
|
</fa-icon>
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</mat-dialog-actions>
|
<mat-dialog-actions>
|
||||||
|
<table cellspacing="0" width="100%">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<button mat-raised-button
|
||||||
|
class="text"
|
||||||
|
color="primary" (click)="confirm()">
|
||||||
|
<mat-icon class="icon">verified_user</mat-icon>Sent!
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
<td align="right">
|
||||||
|
<button mat-raised-button class="text" (click)="close()">
|
||||||
|
<mat-icon class="icon">close</mat-icon>Cancel
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</mat-dialog-actions>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import { Inject, Component, OnInit} from '@angular/core';
|
import { Inject, Component, OnInit} from '@angular/core';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
||||||
|
|
||||||
|
import { NotifierService } from '../notifier.service';
|
||||||
|
import { faCopy } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
var URLSafeBase64 = require('urlsafe-base64');
|
var URLSafeBase64 = require('urlsafe-base64');
|
||||||
var Buffer = require('buffer/').Buffer;
|
var Buffer = require('buffer/').Buffer;
|
||||||
|
|
||||||
|
@ -9,14 +12,20 @@ var Buffer = require('buffer/').Buffer;
|
||||||
templateUrl: './prompt-invoice.component.html',
|
templateUrl: './prompt-invoice.component.html',
|
||||||
styleUrls: ['./prompt-invoice.component.css']
|
styleUrls: ['./prompt-invoice.component.css']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class PromptInvoiceComponent implements OnInit {
|
export class PromptInvoiceComponent implements OnInit {
|
||||||
orderId: string;
|
orderId: string;
|
||||||
invoiceUrl: string;
|
invoiceUrl: string;
|
||||||
|
|
||||||
|
// ------------------------------------
|
||||||
|
//
|
||||||
|
faCopy = faCopy;
|
||||||
|
// ------------------------------------
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dialogRef: MatDialogRef<PromptInvoiceComponent>,
|
private dialogRef: MatDialogRef<PromptInvoiceComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: {orderId: string}
|
@Inject(MAT_DIALOG_DATA) public data: {orderId: string},
|
||||||
) {
|
private notifierService : NotifierService ) {
|
||||||
this.orderId = data.orderId;
|
this.orderId = data.orderId;
|
||||||
this.invoiceUrl = 'https://app.zgo.cash/invoice/'+this.orderId;
|
this.invoiceUrl = 'https://app.zgo.cash/invoice/'+this.orderId;
|
||||||
}
|
}
|
||||||
|
@ -34,13 +43,18 @@ export class PromptInvoiceComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
copyUrl() {
|
copyUrl() {
|
||||||
if (!navigator.clipboard) {
|
// console.log("Inside copyUrl()");
|
||||||
alert("Copy functionality not supported");
|
if (navigator.clipboard) {
|
||||||
}
|
};
|
||||||
try {
|
try {
|
||||||
navigator.clipboard.writeText(this.invoiceUrl);
|
navigator.clipboard.writeText(this.invoiceUrl);
|
||||||
|
this.notifierService
|
||||||
|
.showNotification("Invoice's URL copied to Clipboard!!","Close",'success');
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error", err);
|
// console.error("Error", err);
|
||||||
|
this.notifierService
|
||||||
|
.showNotification("Functionality not available for your browser. Use send button instead.","Close",'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue