From 38e709842a06486e17c1d27767fe6de9f21c433b Mon Sep 17 00:00:00 2001 From: Sibin Sabu Date: Mon, 18 Aug 2025 16:22:52 +0530 Subject: [PATCH] fixed : encrypted barcode id in viewlog --- .../components/navbar/navbar.component.html | 2 + .../app/components/navbar/navbar.component.ts | 87 +++++-------------- 2 files changed, 24 insertions(+), 65 deletions(-) diff --git a/btc-UI/src/app/components/navbar/navbar.component.html b/btc-UI/src/app/components/navbar/navbar.component.html index ed530d6..f60719f 100755 --- a/btc-UI/src/app/components/navbar/navbar.component.html +++ b/btc-UI/src/app/components/navbar/navbar.component.html @@ -240,6 +240,7 @@ Tickets Count Amount + Barcode @@ -250,6 +251,7 @@ {{ log.ticketCountLabel }} {{ log.count }} {{ log.amount }} + {{ log.displayBarcode }} diff --git a/btc-UI/src/app/components/navbar/navbar.component.ts b/btc-UI/src/app/components/navbar/navbar.component.ts index d7fb1d0..a53364d 100755 --- a/btc-UI/src/app/components/navbar/navbar.component.ts +++ b/btc-UI/src/app/components/navbar/navbar.component.ts @@ -32,7 +32,6 @@ export class NavbarComponent implements OnInit, OnDestroy { showResultModal = false; showMessagesModal = false; showLogModal = false; - raceCardData: any = {}; raceData: any[] = []; 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() { const storedTickets = localStorage.getItem('localTicketsViewlog'); @@ -423,8 +370,8 @@ openViewLog() { const numbers = ticket.numbers || []; const count = ticket.ticketCount || 0; const amount = ticket.totalAmount || 0; - - let pool = '', horses = '', horsesArray: string[][] = [], ticketCountLabel = '', price = ''; + const barcodeId = ticket.barcodeId || ''; + let pool = '', horses = '', horsesArray: string[][] = [], ticketCountLabel = '', price = '', maskedBarcode = '' , displayBarcode = ''; if (rawLabel) { // 1️⃣ Extract pool (first word) @@ -454,15 +401,23 @@ openViewLog() { } } - // console.log(`--- Ticket ${index + 1} ---`); - // console.log('Pool:', pool); - // console.log('Horses (raw):', horses); - // console.log('Horses (array):', horsesArray); - // console.log('Ticket Label:', ticketCountLabel); - // console.log('Price:', price); - // console.log('Numbers:', numbers); - // console.log('Count:', count); - // console.log('Amount:', amount); + if (barcodeId) { + const last4 = barcodeId.slice(-4); + + // Encrypt everything except last4 + const encryptedPart = btoa(barcodeId.slice(0, -4)); + + // Store masked barcode (if you still need encrypted form) + maskedBarcode = encryptedPart; + + // For GUI → show ******** + last4 + displayBarcode = '********' + last4; +} + + + console.log(maskedBarcode); + console.log('Decoded:', atob(maskedBarcode)); + return { pool, @@ -472,7 +427,9 @@ openViewLog() { price, numbers, count, - amount + amount, + maskedBarcode, + displayBarcode }; }); } else {