feat : almost done full sidebar functinalities
This commit is contained in:
parent
6dbe85bfcc
commit
f00629cf45
@ -124,7 +124,7 @@ async printTicketCancel() {
|
|||||||
const cancelReq = {
|
const cancelReq = {
|
||||||
ticketNo: lastTicket.barcodeId,
|
ticketNo: lastTicket.barcodeId,
|
||||||
btId: lastTicket.btId || "0485",
|
btId: lastTicket.btId || "0485",
|
||||||
usrId: lastTicket.usrId || "341"
|
usrId: lastTicket.usrId || "066"
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("📡 Sending cancel request:", cancelReq);
|
console.log("📡 Sending cancel request:", cancelReq);
|
||||||
@ -229,122 +229,7 @@ Original Total: ₹${cancelTicketData.totalAmount}
|
|||||||
payoutWarning = ''; // show GUI message when payout response is not as expected
|
payoutWarning = ''; // show GUI message when payout response is not as expected
|
||||||
|
|
||||||
|
|
||||||
// async printPayoutTicket() {
|
|
||||||
// console.log("🖨️ Print payout clicked");
|
|
||||||
|
|
||||||
// const ticketNo = this.payoutTicketNo?.toString().trim();
|
|
||||||
// if (!ticketNo) {
|
|
||||||
// console.warn("⚠️ No payout ticket number set.");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const userName = localStorage.getItem('userName') || 'Unknown';
|
|
||||||
|
|
||||||
// // Prepare request payload (same as your curl)
|
|
||||||
// const apiPayload = {
|
|
||||||
// ticketNo: ticketNo,
|
|
||||||
// voucherNo: "",
|
|
||||||
// memAcctNum: "",
|
|
||||||
// memAcctCardCode: "",
|
|
||||||
// moneyTyp: "C",
|
|
||||||
// btId: "0485", // replace with dynamic btId if needed
|
|
||||||
// usrId: "341" // replace with dynamic usrId if needed
|
|
||||||
// };
|
|
||||||
|
|
||||||
// console.log("📡 Sending payout API request:", apiPayload);
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// const apiUrl = "http://localhost:8086/payout/ticket?debug=1";
|
|
||||||
|
|
||||||
// const resp = await fetch(apiUrl, {
|
|
||||||
// method: "POST",
|
|
||||||
// headers: { "Content-Type": "application/json" },
|
|
||||||
// body: JSON.stringify(apiPayload)
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (!resp.ok) {
|
|
||||||
// console.error("❌ Payout API HTTP error:", resp.status, resp.statusText);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const json = await resp.json();
|
|
||||||
// console.log("📩 Payout API response JSON:", json);
|
|
||||||
|
|
||||||
// // ✅ Save only the response (no request) to localStorage
|
|
||||||
// try {
|
|
||||||
// localStorage.setItem("payout", JSON.stringify(json));
|
|
||||||
// console.log("[localStorage] saved payout response only");
|
|
||||||
// } catch (e) {
|
|
||||||
// console.warn("⚠️ Failed to save payout to localStorage:", e);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!json.ok) {
|
|
||||||
// console.error("❌ Payout API returned ok: false -", json.error || json);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// // ✅ Load the payout response from localStorage
|
|
||||||
// let payoutResp: any = null;
|
|
||||||
// try {
|
|
||||||
// const stored = localStorage.getItem("payout");
|
|
||||||
// if (stored) payoutResp = JSON.parse(stored);
|
|
||||||
// } catch (e) {
|
|
||||||
// console.warn("⚠️ Failed to parse stored payout:", e);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Default dividend fallback
|
|
||||||
// let dividend = "0";
|
|
||||||
// if (payoutResp && payoutResp.data && typeof payoutResp.data.cashAmount !== "undefined") {
|
|
||||||
// dividend = String(payoutResp.data.cashAmount);
|
|
||||||
// }
|
|
||||||
// // Success: proceed to build print payload
|
|
||||||
// const backendData = json.data || {};
|
|
||||||
// const printData = {
|
|
||||||
// type: 'payout',
|
|
||||||
// ticketNumber: ticketNo,
|
|
||||||
// printedBy: userName,
|
|
||||||
// dividend: dividend,
|
|
||||||
// backend: backendData
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const layoutPreview = `
|
|
||||||
// -------------------------------
|
|
||||||
// 🎉 PAYOUT TICKET 🎉
|
|
||||||
// -------------------------------
|
|
||||||
// Ticket No : ${printData.ticketNumber}
|
|
||||||
// Dividend : ${printData.dividend}
|
|
||||||
// Printed By : ${printData.printedBy}
|
|
||||||
// Backend Amt : ${backendData.cashAmount ?? 'N/A'}
|
|
||||||
// User Name : ${backendData.userName ?? 'N/A'}
|
|
||||||
// Date : ${new Date().toLocaleString()}
|
|
||||||
// -------------------------------
|
|
||||||
// 💸 Thank you for playing 💸
|
|
||||||
// -------------------------------
|
|
||||||
// `;
|
|
||||||
// console.log("[🧾 PAYOUT LAYOUT PREVIEW]");
|
|
||||||
// console.log(layoutPreview);
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// const printResp = await fetch('http://localhost:9100/print', {
|
|
||||||
// method: 'POST',
|
|
||||||
// headers: { 'Content-Type': 'application/json' },
|
|
||||||
// body: JSON.stringify(printData)
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (!printResp.ok) throw new Error(`Printer HTTP ${printResp.status}`);
|
|
||||||
// const printResult = await printResp.text();
|
|
||||||
// console.log("✅ Payout print successful:", printResult);
|
|
||||||
// } catch (printErr) {
|
|
||||||
// console.error("❌ Payout print failed:", printErr);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.closePayoutPopup();
|
|
||||||
|
|
||||||
// } catch (err) {
|
|
||||||
// console.error("❌ Payout API call failed:", err);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
async printPayoutTicket() {
|
async printPayoutTicket() {
|
||||||
console.log("🖨️ Print payout clicked");
|
console.log("🖨️ Print payout clicked");
|
||||||
this.payoutWarning = '';
|
this.payoutWarning = '';
|
||||||
@ -492,10 +377,11 @@ Date : ${new Date().toLocaleString()}
|
|||||||
|
|
||||||
|
|
||||||
//------------------------------------PRINT DEPOSIT TICKET STARTS HERE-------------------------------------------
|
//------------------------------------PRINT DEPOSIT TICKET STARTS HERE-------------------------------------------
|
||||||
|
//------------------------------------PRINT DEPOSIT TICKET STARTS HERE-------------------------------------------
|
||||||
printDeposit() {
|
async printDeposit() {
|
||||||
const userName = localStorage.getItem('userName') || 'Unknown';
|
console.log("🖨️ Print deposit clicked");
|
||||||
this.depositWarning = '';
|
this.depositWarning = '';
|
||||||
|
|
||||||
// ✅ Validation — stop if any of the required fields are missing
|
// ✅ Validation — stop if any of the required fields are missing
|
||||||
if (
|
if (
|
||||||
!this.depositOperatorId?.toString().trim() ||
|
!this.depositOperatorId?.toString().trim() ||
|
||||||
@ -504,9 +390,67 @@ printDeposit() {
|
|||||||
) {
|
) {
|
||||||
console.warn("❌ Cannot print deposit — missing required fields.");
|
console.warn("❌ Cannot print deposit — missing required fields.");
|
||||||
this.depositWarning = '❌ Please fill Operator ID, Shroff ID, and Amount before printing.';
|
this.depositWarning = '❌ Please fill Operator ID, Shroff ID, and Amount before printing.';
|
||||||
return; // Stop here — no print
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const userName = localStorage.getItem('userName') || 'Unknown';
|
||||||
|
const btid = localStorage.getItem('btid') || "0648"; // fallback if not in localStorage
|
||||||
|
const btMake = "I";
|
||||||
|
|
||||||
|
// Build the API payload to mirror your curl
|
||||||
|
const apiPayload = {
|
||||||
|
opCardCd: String(this.depositOperatorId).trim(),
|
||||||
|
suCardCd: String(this.depositShroffId).trim(),
|
||||||
|
amount: Number(this.depositAmount),
|
||||||
|
btId: btid,
|
||||||
|
btMake: btMake
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("📡 Sending deposit API request:", apiPayload);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const apiUrl = "http://localhost:8088/deposit";
|
||||||
|
const resp = await fetch(apiUrl, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(apiPayload)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!resp.ok) {
|
||||||
|
console.error("❌ Deposit API HTTP error:", resp.status, resp.statusText);
|
||||||
|
this.depositWarning = `❌ Deposit API HTTP ${resp.status}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await resp.json();
|
||||||
|
console.log("📩 Deposit API response JSON:", json);
|
||||||
|
|
||||||
|
// Save only the response
|
||||||
|
try {
|
||||||
|
localStorage.setItem("deposit", JSON.stringify(json));
|
||||||
|
console.log("[localStorage] saved deposit response only");
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("⚠️ Failed to save deposit to localStorage:", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json.ok === false) {
|
||||||
|
console.error("❌ Deposit API returned ok: false -", json.error || json);
|
||||||
|
this.depositWarning = `❌ Deposit failed: ${json.error ?? 'server error'}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accept either nested or flat amount
|
||||||
|
const nestedAmt = (json.data && typeof json.data.amount !== 'undefined') ? json.data.amount : undefined;
|
||||||
|
const flatAmt = (typeof json.amount !== 'undefined') ? json.amount : undefined;
|
||||||
|
|
||||||
|
if (typeof nestedAmt === 'undefined' && typeof flatAmt === 'undefined') {
|
||||||
|
console.warn("Deposit response missing amount in both expected places.");
|
||||||
|
this.depositWarning = '⚠️ Deposit incomplete — server not responding correctly. Printing request amount instead.';
|
||||||
|
}
|
||||||
|
|
||||||
|
const backendAmount = (typeof nestedAmt !== 'undefined') ? nestedAmt : (typeof flatAmt !== 'undefined' ? flatAmt : null);
|
||||||
|
const printedAmount = backendAmount !== null ? backendAmount : Number(this.depositAmount);
|
||||||
|
|
||||||
// Denomination voucher section
|
// Denomination voucher section
|
||||||
const content = `
|
const content = `
|
||||||
🧾 Denomination Voucher
|
🧾 Denomination Voucher
|
||||||
@ -534,7 +478,8 @@ DEPOSIT RECEIPT
|
|||||||
-------------------------------
|
-------------------------------
|
||||||
Operator : ${this.depositOperatorId}
|
Operator : ${this.depositOperatorId}
|
||||||
Shroff : ${this.depositShroffId}
|
Shroff : ${this.depositShroffId}
|
||||||
Amount : ₹${this.depositAmount}
|
Requested : ₹${this.depositAmount}
|
||||||
|
Settled : ₹${printedAmount}
|
||||||
Printed By: ${userName}
|
Printed By: ${userName}
|
||||||
Date : ${date}
|
Date : ${date}
|
||||||
Time : ${time}
|
Time : ${time}
|
||||||
@ -545,33 +490,41 @@ ${content}
|
|||||||
console.log("🖨️ DEPOSIT PRINT LAYOUT:\n" + previewReceipt);
|
console.log("🖨️ DEPOSIT PRINT LAYOUT:\n" + previewReceipt);
|
||||||
|
|
||||||
// ✅ Send to print server
|
// ✅ Send to print server
|
||||||
|
const backendData = json.data ? json.data : { ...json };
|
||||||
const payload = {
|
const payload = {
|
||||||
type: 'deposit',
|
type: 'deposit',
|
||||||
printedBy: userName,
|
printedBy: userName,
|
||||||
operatorId: this.depositOperatorId,
|
operatorId: this.depositOperatorId,
|
||||||
shroffId: this.depositShroffId,
|
shroffId: this.depositShroffId,
|
||||||
amount: this.depositAmount,
|
amountRequested: Number(this.depositAmount),
|
||||||
content: content
|
amountSettled: printedAmount,
|
||||||
|
content: content,
|
||||||
|
backend: backendData
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch('http://localhost:9100/print', {
|
try {
|
||||||
|
const printResp = await fetch('http://localhost:9100/print', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) throw new Error(`Printer error: ${response.status}`);
|
|
||||||
return response.text();
|
|
||||||
})
|
|
||||||
.then(result => {
|
|
||||||
console.log("✅ Deposit print successful:", result);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error("❌ Deposit print failed:", error);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!printResp.ok) throw new Error(`Printer error: ${printResp.status}`);
|
||||||
|
const result = await printResp.text();
|
||||||
|
console.log("✅ Deposit print successful:", result);
|
||||||
|
} catch (printErr) {
|
||||||
|
console.error("❌ Deposit print failed:", printErr);
|
||||||
|
this.depositWarning = '❌ Print failed. Check printer server.';
|
||||||
|
}
|
||||||
|
|
||||||
this.closeDepositPopup();
|
this.closeDepositPopup();
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ Deposit API call failed:", err);
|
||||||
|
this.depositWarning = '❌ Deposit API call failed. Please try again.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//--------------------------------------PRINT DEPOSIT TICKET ENDS HERE -------------------------------------------------------------
|
||||||
|
|
||||||
//--------------------------------------PRINT DEPOSIT TICKETS ENDS HERE -------------------------------------------------------------
|
//--------------------------------------PRINT DEPOSIT TICKETS ENDS HERE -------------------------------------------------------------
|
||||||
|
|
||||||
@ -590,23 +543,104 @@ ${content}
|
|||||||
|
|
||||||
|
|
||||||
//---------------------------------------PRINT WITHDRAW STARTS HERE --------------------------------------------------------
|
//---------------------------------------PRINT WITHDRAW STARTS HERE --------------------------------------------------------
|
||||||
|
// component class properties (place near other field declarations)
|
||||||
|
userName = '';
|
||||||
|
btid: string | null = null;
|
||||||
|
|
||||||
printWithdraw() {
|
withdrawBtId = "";
|
||||||
const userName = localStorage.getItem('userName') || 'Unknown';
|
withdrawBtMake = "I" ;
|
||||||
|
|
||||||
// Clear previous warning
|
// ngOnInit - ensure you already have this in your component life-cycle
|
||||||
|
ngOnInit() {
|
||||||
|
this.userName = localStorage.getItem('userName') || '';
|
||||||
|
this.btid = localStorage.getItem('btid'); // <- pulled from localStorage like your navbar
|
||||||
|
// any other init code...
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------PRINT WITHDRAW STARTS HERE --------------------------------------------------------
|
||||||
|
async printWithdraw() {
|
||||||
|
console.log("🖨️ Print withdraw clicked");
|
||||||
this.withdrawWarning = '';
|
this.withdrawWarning = '';
|
||||||
|
|
||||||
// ✅ Validation
|
// Basic validation
|
||||||
if (
|
if (
|
||||||
!this.withdrawOperatorId?.toString().trim() ||
|
!this.withdrawOperatorId?.toString().trim() ||
|
||||||
!this.withdrawShroffId?.toString().trim() ||
|
!this.withdrawShroffId?.toString().trim() ||
|
||||||
!this.withdrawAmount?.toString().trim()
|
!this.withdrawAmount?.toString().trim()
|
||||||
) {
|
) {
|
||||||
|
console.warn("⚠️ Missing operator/shroff/amount.");
|
||||||
this.withdrawWarning = '❌ Please fill Operator ID, Shroff ID, and Amount before printing.';
|
this.withdrawWarning = '❌ Please fill Operator ID, Shroff ID, and Amount before printing.';
|
||||||
return; // Stop here — no print
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const userName = localStorage.getItem('userName') || this.userName || 'Unknown';
|
||||||
|
|
||||||
|
// Resolve btId: prefer global btid from localStorage (this.btid), fallback to withdrawBtId, then fallback literal "0648"
|
||||||
|
const resolvedBtId = (this.btid && this.btid.toString().trim()) ? this.btid.toString().trim()
|
||||||
|
: (this.withdrawBtId && this.withdrawBtId.toString().trim()) ? this.withdrawBtId.toString().trim()
|
||||||
|
: "0648";
|
||||||
|
|
||||||
|
// btMake is always "I"
|
||||||
|
const resolvedBtMake = "I";
|
||||||
|
|
||||||
|
// Build the API payload to mirror your curl
|
||||||
|
const apiPayload = {
|
||||||
|
opCardCd: String(this.withdrawOperatorId).trim(),
|
||||||
|
suCardCd: String(this.withdrawShroffId).trim(),
|
||||||
|
amount: Number(this.withdrawAmount),
|
||||||
|
btId: resolvedBtId,
|
||||||
|
btMake: resolvedBtMake
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("📡 Sending withdraw API request:", apiPayload);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const apiUrl = "http://localhost:8088/withdraw";
|
||||||
|
const resp = await fetch(apiUrl, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(apiPayload)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!resp.ok) {
|
||||||
|
console.error("❌ Withdraw API HTTP error:", resp.status, resp.statusText);
|
||||||
|
this.withdrawWarning = `❌ Withdraw API HTTP ${resp.status}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await resp.json();
|
||||||
|
console.log("📩 Withdraw API response JSON:", json);
|
||||||
|
|
||||||
|
// Persist only the response (similar to payout)
|
||||||
|
try {
|
||||||
|
localStorage.setItem("withdraw", JSON.stringify(json));
|
||||||
|
console.log("[localStorage] saved withdraw response only");
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("⚠️ Failed to save withdraw to localStorage:", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If backend uses ok:false semantics
|
||||||
|
if (json.ok === false) {
|
||||||
|
console.error("❌ Withdraw API returned ok: false -", json.error || json);
|
||||||
|
this.withdrawWarning = `❌ Withdraw failed: ${json.error ?? 'server error'}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accept either nested or flat numeric amount/cash fields if present
|
||||||
|
const nestedAmt = (json.data && typeof json.data.amount !== 'undefined') ? json.data.amount : undefined;
|
||||||
|
const flatAmt = (typeof json.amount !== 'undefined') ? json.amount : undefined;
|
||||||
|
|
||||||
|
// If there's no amount at all, we still allow printing but warn the user
|
||||||
|
if (typeof nestedAmt === 'undefined' && typeof flatAmt === 'undefined') {
|
||||||
|
console.warn("Withdraw response missing amount/cash in both expected places.");
|
||||||
|
this.withdrawWarning = '⚠️ Withdraw incomplete — server not responding correctly. Printing request amount instead.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prefer backend provided amount if available, otherwise use user's input
|
||||||
|
const backendAmount = (typeof nestedAmt !== 'undefined') ? nestedAmt : (typeof flatAmt !== 'undefined' ? flatAmt : null);
|
||||||
|
const printedAmount = backendAmount !== null ? backendAmount : Number(this.withdrawAmount);
|
||||||
|
|
||||||
|
// Prepare the same receipt text you used (denominations etc.)
|
||||||
const receiptText = `
|
const receiptText = `
|
||||||
🧾 Denomination Voucher
|
🧾 Denomination Voucher
|
||||||
2000 x _____________ = _____________
|
2000 x _____________ = _____________
|
||||||
@ -622,18 +656,18 @@ Total = ____________________________
|
|||||||
=====================================
|
=====================================
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const date = now.toISOString().split('T')[0];
|
const date = now.toISOString().split('T')[0];
|
||||||
const time = now.toTimeString().split(' ')[0];
|
const time = now.toTimeString().split(' ')[0];
|
||||||
|
|
||||||
const previewReceipt = `
|
const previewReceipt = `
|
||||||
Bangalore Turf Club
|
Bangalore Turf Club
|
||||||
DEPOSIT RECEIPT
|
WITHDRAW RECEIPT
|
||||||
-------------------------------
|
-------------------------------
|
||||||
Operator : ${this.withdrawOperatorId}
|
Operator : ${this.withdrawOperatorId}
|
||||||
Shroff : ${this.withdrawShroffId}
|
Shroff : ${this.withdrawShroffId}
|
||||||
Amount : ₹${this.withdrawAmount}
|
Requested : ₹${this.withdrawAmount}
|
||||||
|
Settled : ₹${printedAmount}
|
||||||
Printed By: ${userName}
|
Printed By: ${userName}
|
||||||
Date : ${date}
|
Date : ${date}
|
||||||
Time : ${time}
|
Time : ${time}
|
||||||
@ -643,34 +677,45 @@ ${receiptText}
|
|||||||
|
|
||||||
console.log(previewReceipt);
|
console.log(previewReceipt);
|
||||||
|
|
||||||
const payload = {
|
// Prepare payload for printer (include backend data for reference)
|
||||||
|
const backendData = json.data ? json.data : { ...json };
|
||||||
|
const printData = {
|
||||||
type: 'withdraw',
|
type: 'withdraw',
|
||||||
|
ticketNumber: null,
|
||||||
printedBy: userName,
|
printedBy: userName,
|
||||||
operatorId: this.withdrawOperatorId,
|
operatorId: this.withdrawOperatorId,
|
||||||
shroffId: this.withdrawShroffId,
|
shroffId: this.withdrawShroffId,
|
||||||
amount: this.withdrawAmount,
|
amountRequested: Number(this.withdrawAmount),
|
||||||
content: receiptText
|
amountSettled: printedAmount,
|
||||||
|
content: receiptText,
|
||||||
|
backend: backendData
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch('http://localhost:9100/print', {
|
// Send print job
|
||||||
|
try {
|
||||||
|
const printResp = await fetch('http://localhost:9100/print', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(printData)
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) throw new Error(`Printer error: ${response.status}`);
|
|
||||||
return response.text();
|
|
||||||
})
|
|
||||||
.then(result => {
|
|
||||||
console.log("✅ Withdraw print successful:", result);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error("❌ Withdraw print failed:", error);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.closeWithdrawPopup();
|
if (!printResp.ok) throw new Error(`Printer HTTP ${printResp.status}`);
|
||||||
}
|
const printResult = await printResp.text();
|
||||||
|
console.log("✅ Withdraw print successful:", printResult);
|
||||||
|
} catch (printErr) {
|
||||||
|
console.error("❌ Withdraw print failed:", printErr);
|
||||||
|
this.withdrawWarning = '❌ Print failed. Check printer server.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// close withdraw modal
|
||||||
|
this.closeWithdrawPopup();
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error("❌ Withdraw API call failed:", err);
|
||||||
|
this.withdrawWarning = '❌ Withdraw API call failed. Please try again.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------PRINT WITHDRAW TICKET ENDS HERE -----------------------------
|
||||||
|
|
||||||
//----------------------------------------------PRINT WITHDRAW TICKET ENDS HERE -----------------------------
|
//----------------------------------------------PRINT WITHDRAW TICKET ENDS HERE -----------------------------
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user