Fix : restructured the request params of payout and cancel

This commit is contained in:
Sibin Sabu 2025-09-21 11:50:20 +05:30
parent a72cc77007
commit 213385e55f
2 changed files with 26 additions and 16 deletions

View File

@ -164,15 +164,17 @@ async printTicketCancel() {
console.log('[✅ MATCH] Ticket No matches barcode. Proceeding to cancel...');
this.btid = localStorage.getItem('btid');
this.usrid = localStorage.getItem('employeeId');
const userid = this.usrid ? this.usrid.slice(-3) : '';
this.usrid = localStorage.getItem('userid');
const userid = this.usrid ;
const btmake = 'I' ;
console.log("empl id", this.usrid)
try {
const cancelReq = {
ticketNo: lastTicket.barcodeId,
btId: this.btid,
usrId: userid
usrId: userid,
btMake: btmake
};
console.log("📡 Sending cancel request:", cancelReq);
@ -291,9 +293,10 @@ async printPayoutTicket() {
const userName = localStorage.getItem('userName') || 'Unknown';
this.btid = localStorage.getItem('btid');
this.usrid = localStorage.getItem('employeeId');
const userid = this.usrid ? this.usrid.slice(-3) : '';
this.usrid = localStorage.getItem('userid');
const userid = this.usrid ;
console.log("empl id", this.usrid)
const btmake = 'I' ;
// Prepare request payload
const apiPayload = {
ticketNo: ticketNo,
@ -302,7 +305,8 @@ async printPayoutTicket() {
memAcctCardCode: "",
moneyTyp: "C",
btId: this.btid, // replace with dynamic btId if needed
usrId: userid // replace with dynamic usrId if needed
usrId: userid , // replace with dynamic usrId if needed
btMake: btmake
};
console.log("📡 Sending payout API request:", apiPayload);

View File

@ -284,10 +284,15 @@ export class LoginComponent implements OnInit, OnDestroy {
const rawLoginRes = localStorage.getItem('loginRes');
if (rawLoginRes) {
try {
// saving username to local storage here from raw login responce
const parsed = JSON.parse(rawLoginRes);
const username = parsed?.log?.cUsrNm || 'Unknown User';
console.log('🧑 Username from loginRes:', username);
localStorage.setItem('userName', username);
//saving user id to local storage here from raw login response
const userid = parsed?.log?.cUsrId || 'error'
localStorage.setItem('userid', userid);
} catch (e) {
console.error('❌ Failed to parse loginRes from localStorage', e);
}
@ -311,7 +316,17 @@ export class LoginComponent implements OnInit, OnDestroy {
type: 'login',
};
// 2) Print (commented out - uncomment if needed)
// 3) Fetch race card with DYNAMIC values - NO FALLBACKS
console.log('🔄 Fetching race card with:', { opCard: email, password, btId: fetchedBtid });
const rpInfo = await lastValueFrom(
this.btcService.fetchRaceCard(email, password, fetchedBtid) // Dynamic opCard, real BTID
);
console.log('📦 Race Card fetched successfully:', rpInfo);
localStorage.setItem('rpinfo', JSON.stringify(rpInfo));
// 2) Print (commented out - uncomment if needed)
/*
const printRes = await fetch('http://localhost:9100/print', {
method: 'POST',
@ -325,15 +340,6 @@ export class LoginComponent implements OnInit, OnDestroy {
console.log('🖨️ Print successful');
*/
// 3) Fetch race card with DYNAMIC values - NO FALLBACKS
console.log('🔄 Fetching race card with:', { opCard: email, password, btId: fetchedBtid });
const rpInfo = await lastValueFrom(
this.btcService.fetchRaceCard(email, password, fetchedBtid) // Dynamic opCard, real BTID
);
console.log('📦 Race Card fetched successfully:', rpInfo);
localStorage.setItem('rpinfo', JSON.stringify(rpInfo));
// NEW: Set initial race from rpInfo to localStorage for second screen initial display
// Adjust these extractions based on the actual structure of rpInfo (e.g., rpInfo.currentRace)
const initialRace = rpInfo.race || rpInfo.currentRace || 1; // Example: Adjust path to your rpInfo structure