From 3e31f5c2dd7b9dc7df76358a02fd76c1ed24872b Mon Sep 17 00:00:00 2001 From: Sibin Sabu Date: Sun, 21 Sep 2025 13:23:08 +0530 Subject: [PATCH] Fixed : proper structure for payout and cancel then added the warnings for print buttons in sidebar --- .../components/sidebar/sidebar.component.css | 5 ++ .../components/sidebar/sidebar.component.html | 70 +++---------------- .../components/sidebar/sidebar.component.ts | 26 +++++-- 3 files changed, 35 insertions(+), 66 deletions(-) diff --git a/btc-UI/src/app/components/sidebar/sidebar.component.css b/btc-UI/src/app/components/sidebar/sidebar.component.css index 06a56af..28220da 100755 --- a/btc-UI/src/app/components/sidebar/sidebar.component.css +++ b/btc-UI/src/app/components/sidebar/sidebar.component.css @@ -528,4 +528,9 @@ h4{ strong{ padding-left: 2rem; margin-top: 2rem; +} + +.modal-loading{ + color: red; + font-weight: bold; } \ No newline at end of file diff --git a/btc-UI/src/app/components/sidebar/sidebar.component.html b/btc-UI/src/app/components/sidebar/sidebar.component.html index 1b3839f..c3a152f 100755 --- a/btc-UI/src/app/components/sidebar/sidebar.component.html +++ b/btc-UI/src/app/components/sidebar/sidebar.component.html @@ -39,12 +39,19 @@
{{ cancelWarning }}
+ - @@ -62,7 +69,9 @@ [(ngModel)]="payoutTicketNo" /> +
{{ payoutWarning }}
+ - - -

VIEW RC

diff --git a/btc-UI/src/app/components/sidebar/sidebar.component.ts b/btc-UI/src/app/components/sidebar/sidebar.component.ts index 8093801..2778b8e 100755 --- a/btc-UI/src/app/components/sidebar/sidebar.component.ts +++ b/btc-UI/src/app/components/sidebar/sidebar.component.ts @@ -38,6 +38,8 @@ export class SidebarComponent { balanceWithdraw: number = 0; balanceDeposit: number = 0; + loadingMessage: string = ''; + // Modal handlers... openCancelPopup() { this.cancelClick.emit(); @@ -66,6 +68,7 @@ export class SidebarComponent { } + //--------------------------------------- UPDATED CANCEL PRINT ------------------------------------------- cancelWarning: string = ''; // For showing inline warnings @@ -118,9 +121,13 @@ updateAllBalances() { async printTicketCancel() { + + this.cancelWarning = "Requested please wait"; const enteredTicketNo = this.ticketNo?.trim(); console.log('[STEP 1] Entered Ticket No:', enteredTicketNo); this.cancelWarning = ''; + this.loadingMessage = 'Printing cancel ticket β€” please wait...'; + const localTicketsStr = localStorage.getItem('canceltickets'); if (!localTicketsStr) { @@ -166,7 +173,7 @@ async printTicketCancel() { this.btid = localStorage.getItem('btid'); this.usrid = localStorage.getItem('userid'); const userid = this.usrid ; - const btmake = 'I' ; + const btMake = 'I' console.log("empl id", this.usrid) try { @@ -174,7 +181,7 @@ async printTicketCancel() { ticketNo: lastTicket.barcodeId, btId: this.btid, usrId: userid, - btMake: btmake + btMake: btMake }; console.log("πŸ“‘ Sending cancel request:", cancelReq); @@ -255,6 +262,9 @@ Original Total: β‚Ή${cancelTicketData.totalAmount} console.error("❌ Cancel API call failed:", e); this.cancelWarning = '❌ Cancel API call failed. Please try again.'; } + finally { + this.loadingMessage = ''; // ALWAYS clear loading message + } } //-------------------------------- COMPLETED THE CANCEL PRINT WITH API CALL -------------------------------- @@ -283,7 +293,7 @@ payoutWarning = ''; // show GUI message when payout response is not as expected async printPayoutTicket() { console.log("πŸ–¨οΈ Print payout clicked"); this.payoutWarning = ''; - + this.loadingMessage = 'Printing cancel ticket β€” please wait...'; const ticketNo = this.payoutTicketNo?.toString().trim(); if (!ticketNo) { console.warn("⚠️ No payout ticket number set."); @@ -294,9 +304,8 @@ async printPayoutTicket() { const userName = localStorage.getItem('userName') || 'Unknown'; this.btid = localStorage.getItem('btid'); this.usrid = localStorage.getItem('userid'); - const userid = this.usrid ; - console.log("empl id", this.usrid) - const btmake = 'I' ; + const userid = this.usrid ; + const btMake = 'I' // Prepare request payload const apiPayload = { ticketNo: ticketNo, @@ -306,7 +315,7 @@ async printPayoutTicket() { moneyTyp: "C", btId: this.btid, // replace with dynamic btId if needed usrId: userid , // replace with dynamic usrId if needed - btMake: btmake + btMake: btMake }; console.log("πŸ“‘ Sending payout API request:", apiPayload); @@ -409,6 +418,9 @@ Date : ${new Date().toLocaleString()} } catch (err) { console.error("❌ Payout API call failed:", err); this.payoutWarning = '❌ Payout API call failed. Please try again.'; + } + finally { + this.loadingMessage = ''; // ALWAYS clear loading message } }