diff --git a/btc-UI/src/app/components/sidebar/sidebar.component.html b/btc-UI/src/app/components/sidebar/sidebar.component.html index cd18dbb..3e92366 100755 --- a/btc-UI/src/app/components/sidebar/sidebar.component.html +++ b/btc-UI/src/app/components/sidebar/sidebar.component.html @@ -99,20 +99,37 @@
+ type="text" + [(ngModel)]="depositOperatorId" + class="deposit-input" + maxlength="12" + inputmode="numeric" + pattern="\d*" + (input)="checkDepositOperatorLength()" + aria-label="Deposit Operator ID" +/> + + #depositShroffIdInput + type="text" + [(ngModel)]="depositShroffId" + class="deposit-input" + maxlength="12" + inputmode="numeric" + pattern="\d*" + aria-label="Deposit Shroff ID" + (input)="checkDepositShroffLength()" +/> - +
@@ -184,24 +201,34 @@
+ type="text" + [(ngModel)]="withdrawOperatorId" + class="withdraw-input" + maxlength="12" + inputmode="numeric" + pattern="\d*" + (input)="checkWithdrawOperatorLength()" +/> + #withdrawShroffIdInput + type="text" + [(ngModel)]="withdrawShroffId" + class="withdraw-input" + maxlength="12" + inputmode="numeric" + pattern="\d*" + (input)="checkWithdrawShroffLength()" +/> + #withdrawAmountInput + type="text" + [(ngModel)]="withdrawAmount" + class="withdraw-input" +/>
diff --git a/btc-UI/src/app/components/sidebar/sidebar.component.ts b/btc-UI/src/app/components/sidebar/sidebar.component.ts index 07bb864..ce2e00e 100755 --- a/btc-UI/src/app/components/sidebar/sidebar.component.ts +++ b/btc-UI/src/app/components/sidebar/sidebar.component.ts @@ -1,4 +1,4 @@ -import { Component, Output, EventEmitter } from '@angular/core'; +import { Component, Output, EventEmitter,ViewChild, ElementRef } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { BtcService } from '../../service/btc.service'; @@ -17,6 +17,14 @@ export class SidebarComponent { @Output() payoutClick = new EventEmitter(); @Output() cancelClick = new EventEmitter(); + + +@ViewChild('depositShroffIdInput') depositShroffIdInput!: ElementRef; +@ViewChild('withdrawShroffIdInput') withdrawShroffIdInput!: ElementRef; +@ViewChild('depositAmountInput') depositAmountInput!: ElementRef; +@ViewChild('withdrawAmountInput') withdrawAmountInput!: ElementRef; + + showCancel: boolean = false; ticketNo: string = ''; @@ -40,6 +48,65 @@ export class SidebarComponent { loadingMessage: string = ''; +checkDepositShroffLength() { + const shroff = (this.depositShroffId || '').toString(); + if (shroff.length === 12) { + setTimeout(() => { + try { + this.depositAmountInput?.nativeElement?.focus(); + this.depositAmountInput?.nativeElement?.select(); + } catch (e) { + console.warn('focus failed for depositAmountInput', e); + } + }, 0); + } +} + +checkWithdrawShroffLength() { + const shroff = (this.withdrawShroffId || '').toString(); + if (shroff.length === 12) { + setTimeout(() => { + try { + this.withdrawAmountInput?.nativeElement?.focus(); + this.withdrawAmountInput?.nativeElement?.select(); + } catch (e) { + console.warn('focus failed for withdrawAmountInput', e); + } + }, 0); + } +} + + checkDepositOperatorLength() { + const op = (this.depositOperatorId || '').toString(); + // if exactly 12 characters, focus the shroff input + if (op.length === 12) { + // focus in next macrotask so DOM is stable + setTimeout(() => { + try { + this.depositShroffIdInput?.nativeElement?.focus(); + this.depositShroffIdInput?.nativeElement?.select(); + } catch (e) { + console.warn('focus failed for depositShroffIdInput', e); + } + }, 0); + } + } + + // withdraw + checkWithdrawOperatorLength() { + const op = (this.withdrawOperatorId || '').toString(); + if (op.length === 12) { + setTimeout(() => { + try { + this.withdrawShroffIdInput?.nativeElement?.focus(); + this.withdrawShroffIdInput?.nativeElement?.select(); + } catch (e) { + console.warn('focus failed for withdrawShroffIdInput', e); + } + }, 0); + } + } + // Modal handlers... openCancelPopup() { this.cancelClick.emit(); @@ -740,7 +807,7 @@ async printWithdraw() { btId: resolvedBtId, btMake: resolvedBtMake }; - + this.loadingMessage = 'Printing Withdraw — please wait...'; console.log("📡 Sending withdraw API request:", apiPayload); try { @@ -900,6 +967,9 @@ ${receiptText} console.error("❌ Withdraw API call failed:", err); this.withdrawWarning = '❌ Withdraw API call failed. Please try again.'; } + finally { + this.loadingMessage = ''; // ALWAYS clear loading message + } } //----------------------------------------------PRINT WITHDRAW TICKET ENDS HERE -----------------------------