From 53ba8bdce2a1c53096bbee59cefb86ce13f37538 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 2 May 2023 09:08:42 -0500 Subject: [PATCH] Add dialog to purchase sessions --- src/app/listorders/listorders.component.html | 2 +- src/app/listorders/listorders.component.ts | 34 ++++++++++++++++++++ src/app/sessionpay/sessionpay.component.css | 20 ++++++++++++ src/app/sessionpay/sessionpay.component.html | 6 ++-- src/app/sessionpay/sessionpay.component.ts | 13 ++++++-- 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/app/listorders/listorders.component.html b/src/app/listorders/listorders.component.html index a267f68..63bbd6d 100644 --- a/src/app/listorders/listorders.component.html +++ b/src/app/listorders/listorders.component.html @@ -8,7 +8,7 @@ {{ vE.listordersEndDate }}{{(ownerUpdate | async)!.expiration | date: 'YYYY-MM-dd'}} - diff --git a/src/app/listorders/listorders.component.ts b/src/app/listorders/listorders.component.ts index 0accc90..64afc8b 100644 --- a/src/app/listorders/listorders.component.ts +++ b/src/app/listorders/listorders.component.ts @@ -4,6 +4,7 @@ import { Order } from '../order/order.model'; import { FullnodeService } from '../fullnode.service'; import { UserService } from '../user.service'; import { Owner } from '../owner.model'; +import { User } from '../user.model'; import { OrderService } from '../order/order.service'; import { MatDialog, MatDialogConfig} from '@angular/material/dialog'; @@ -20,6 +21,7 @@ import { faTrash } from '@fortawesome/free-solid-svg-icons'; import { LanguageService } from '../language.service'; import { LanguageData } from '../language.model'; +import {SessionpayComponent} from '../sessionpay/sessionpay.component'; @Component({ selector: 'app-list-orders', @@ -71,6 +73,12 @@ export class ListOrdersComponent implements OnInit, OnDestroy{ viewkey: '', crmToken: '' }; + zecPrice: number = 1; + nodeAddress: string = ''; + session: string = ''; + addrUpdate: Observable; + priceUpdate: Observable; + userUpdate: Observable; // ------------------------------------- // ------------------------------------- // @@ -97,11 +105,24 @@ export class ListOrdersComponent implements OnInit, OnDestroy{ private languageService : LanguageService, public orderService: OrderService, public userService: UserService, + public fullnodeService: FullnodeService, private dialog: MatDialog) { this.ownerUpdate = userService.ownerUpdate; + this.userUpdate = userService.userUpdate; this.orderService.getAllOrders(); this.ordersUpdate = orderService.allOrdersUpdate; + this.addrUpdate = fullnodeService.addrUpdate; + this.priceUpdate = fullnodeService.priceUpdate; + this.priceUpdate.subscribe(price => { + this.zecPrice = price; + }); + this.addrUpdate.subscribe(nAddress => { + this.nodeAddress = nAddress; + }); + this.userUpdate.subscribe(user => { + this.session = user.session; + }); } ngOnInit(){ @@ -237,4 +258,17 @@ export class ListOrdersComponent implements OnInit, OnDestroy{ ); } + paySession() { + const dialogConfig = new MatDialogConfig(); + + dialogConfig.disableClose = true; + dialogConfig.autoFocus = true; + dialogConfig.data = { + addr: this.nodeAddress, + session: this.session, + zecPrice: this.zecPrice + }; + + const dialogRef = this.dialog.open(SessionpayComponent, dialogConfig); + } } diff --git a/src/app/sessionpay/sessionpay.component.css b/src/app/sessionpay/sessionpay.component.css index e69de29..a203629 100644 --- a/src/app/sessionpay/sessionpay.component.css +++ b/src/app/sessionpay/sessionpay.component.css @@ -0,0 +1,20 @@ + +* { + font-family: 'Spartan', sans-serif; +} + +.settings-title { + font-family: 'Spartan', sans-serif; + background: #ff5722; + color: white; + font-size: 30px; + text-align: center; + padding: 5px; + margin-bottom: 10px; +} + +.container { + display: flex; + justify-content: space-between; + align-items: center; +} diff --git a/src/app/sessionpay/sessionpay.component.html b/src/app/sessionpay/sessionpay.component.html index 92be1f4..bc1ce7d 100644 --- a/src/app/sessionpay/sessionpay.component.html +++ b/src/app/sessionpay/sessionpay.component.html @@ -1,3 +1,4 @@ +
Purchase Session
Select session: @@ -7,7 +8,8 @@ - +
+ - +
diff --git a/src/app/sessionpay/sessionpay.component.ts b/src/app/sessionpay/sessionpay.component.ts index 21f6435..bd2c100 100644 --- a/src/app/sessionpay/sessionpay.component.ts +++ b/src/app/sessionpay/sessionpay.component.ts @@ -1,7 +1,7 @@ import { Inject, Component } from '@angular/core'; import { ScanComponent } from '../scan/scan.component'; import { Validators, UntypedFormGroup, FormBuilder } from '@angular/forms'; -import { MatDialog, MatDialogConfig, MAT_DIALOG_DATA} from '@angular/material/dialog'; +import { MatDialog, MatDialogConfig, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; @Component({ selector: 'app-sessionpay', @@ -29,10 +29,10 @@ export class SessionpayComponent { ]; payForm: UntypedFormGroup; session: string; - zecPrice: number; constructor( private dialog: MatDialog, + private dialogRef: MatDialogRef, private fb: FormBuilder, @Inject(MAT_DIALOG_DATA) public data: { addr: string, session: string, zecPrice: number } ) { @@ -56,6 +56,13 @@ export class SessionpayComponent { pay: true }; - const dialogRef = this.dialog.open(ScanComponent, dialogConfig); + const dialogRef1 = this.dialog.open(ScanComponent, dialogConfig); + dialogRef1.afterClosed().subscribe(val => { + this.dialogRef.close(); + }); + } + + close(){ + this.dialogRef.close(); } }