fixed : encrypted barcode id in viewlog

This commit is contained in:
Sibin Sabu 2025-08-18 16:22:52 +05:30
parent 66d50a12bc
commit 38e709842a
2 changed files with 24 additions and 65 deletions

View File

@ -240,6 +240,7 @@
<th>Tickets</th> <th>Tickets</th>
<th>Count</th> <th>Count</th>
<th>Amount</th> <th>Amount</th>
<th>Barcode</th> <!-- ✅ New Column -->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -250,6 +251,7 @@
<td>{{ log.ticketCountLabel }}</td> <td>{{ log.ticketCountLabel }}</td>
<td>{{ log.count }}</td> <td>{{ log.count }}</td>
<td>{{ log.amount }}</td> <td>{{ log.amount }}</td>
<td>{{ log.displayBarcode }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -32,7 +32,6 @@ export class NavbarComponent implements OnInit, OnDestroy {
showResultModal = false; showResultModal = false;
showMessagesModal = false; showMessagesModal = false;
showLogModal = false; showLogModal = false;
raceCardData: any = {}; raceCardData: any = {};
raceData: any[] = []; raceData: any[] = [];
objectKeys = Object.keys; objectKeys = Object.keys;
@ -359,58 +358,6 @@ formattedTicketLogs: {
// openViewLog() {
// const storedTickets = localStorage.getItem('localTicketsViewlog');
// //console.log('Stored Tickets (raw JSON):', storedTickets);
// if (storedTickets) {
// const tickets = JSON.parse(storedTickets);
// // console.log('Parsed Tickets:', tickets);
// this.formattedTicketLogs = tickets.map((ticket: any, index: number) => {
// const rawLabel = ticket.winLabels || '';
// const numbers = ticket.numbers || [];
// const count = ticket.ticketCount || 0;
// const amount = ticket.totalAmount || 0;
// let pool = '', horses = '', ticketCountLabel = '', price = '';
// // 🧠 Extract parts from rawLabel using RegExp
// const labelMatch = rawLabel.match(/^(\w+)\s+([\d,]+)\s+(\*\d+)\s+(Rs\s*\d+)/);
// if (labelMatch) {
// pool = labelMatch[1];
// horses = labelMatch[2];
// ticketCountLabel = labelMatch[3];
// price = labelMatch[4];
// }
// console.log(`--- Ticket ${index + 1} ---`);
// console.log('Pool:', pool);
// console.log('Horses:', horses);
// console.log('Ticket Label:', ticketCountLabel);
// console.log('Price:', price);
// console.log('Numbers:', numbers);
// console.log('Count:', count);
// console.log('Amount:', amount);
// return {
// pool,
// horses,
// ticketCountLabel,
// price,
// numbers,
// count,
// amount
// };
// });
// } else {
// console.log('No tickets found in localStorage.');
// this.formattedTicketLogs = [];
// }
// this.showLogModal = true;
// console.log('Log modal opened. Final formattedTicketLogs:', this.formattedTicketLogs);
// }
openViewLog() { openViewLog() {
const storedTickets = localStorage.getItem('localTicketsViewlog'); const storedTickets = localStorage.getItem('localTicketsViewlog');
@ -423,8 +370,8 @@ openViewLog() {
const numbers = ticket.numbers || []; const numbers = ticket.numbers || [];
const count = ticket.ticketCount || 0; const count = ticket.ticketCount || 0;
const amount = ticket.totalAmount || 0; const amount = ticket.totalAmount || 0;
const barcodeId = ticket.barcodeId || '';
let pool = '', horses = '', horsesArray: string[][] = [], ticketCountLabel = '', price = ''; let pool = '', horses = '', horsesArray: string[][] = [], ticketCountLabel = '', price = '', maskedBarcode = '' , displayBarcode = '';
if (rawLabel) { if (rawLabel) {
// 1⃣ Extract pool (first word) // 1⃣ Extract pool (first word)
@ -454,15 +401,23 @@ openViewLog() {
} }
} }
// console.log(`--- Ticket ${index + 1} ---`); if (barcodeId) {
// console.log('Pool:', pool); const last4 = barcodeId.slice(-4);
// console.log('Horses (raw):', horses);
// console.log('Horses (array):', horsesArray); // Encrypt everything except last4
// console.log('Ticket Label:', ticketCountLabel); const encryptedPart = btoa(barcodeId.slice(0, -4));
// console.log('Price:', price);
// console.log('Numbers:', numbers); // Store masked barcode (if you still need encrypted form)
// console.log('Count:', count); maskedBarcode = encryptedPart;
// console.log('Amount:', amount);
// For GUI → show ******** + last4
displayBarcode = '********' + last4;
}
console.log(maskedBarcode);
console.log('Decoded:', atob(maskedBarcode));
return { return {
pool, pool,
@ -472,7 +427,9 @@ openViewLog() {
price, price,
numbers, numbers,
count, count,
amount amount,
maskedBarcode,
displayBarcode
}; };
}); });
} else { } else {