From 316ec42566506eade2fa799dd0342b5f0843fc62 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Mon, 23 Mar 2026 20:50:20 +0100 Subject: [PATCH] fix(loyalty): use card_id instead of id in terminal JS The terminal's selectedCard comes from CardLookupResponse which uses card_id field, but the JS was referencing selectedCard.id (undefined). This caused all terminal transactions to fail with "LoyaltyCard with identifier 'unknown' not found" instead of processing the transaction or showing proper PIN validation errors. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../loyalty/static/store/js/loyalty-terminal.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/modules/loyalty/static/store/js/loyalty-terminal.js b/app/modules/loyalty/static/store/js/loyalty-terminal.js index cc648680..8ea4ed16 100644 --- a/app/modules/loyalty/static/store/js/loyalty-terminal.js +++ b/app/modules/loyalty/static/store/js/loyalty-terminal.js @@ -225,7 +225,7 @@ function storeLoyaltyTerminal() { loyaltyTerminalLog.info('Adding stamp...'); await apiClient.post('/store/loyalty/stamp', { - card_id: this.selectedCard.id, + card_id: this.selectedCard.card_id, staff_pin: this.pinDigits }); @@ -237,7 +237,7 @@ function storeLoyaltyTerminal() { loyaltyTerminalLog.info('Redeeming stamps...'); await apiClient.post('/store/loyalty/stamp/redeem', { - card_id: this.selectedCard.id, + card_id: this.selectedCard.card_id, staff_pin: this.pinDigits }); @@ -249,7 +249,7 @@ function storeLoyaltyTerminal() { loyaltyTerminalLog.info('Earning points...', { amount: this.earnAmount }); const response = await apiClient.post('/store/loyalty/points/earn', { - card_id: this.selectedCard.id, + card_id: this.selectedCard.card_id, purchase_amount_cents: Math.round(this.earnAmount * 100), staff_pin: this.pinDigits }); @@ -268,7 +268,7 @@ function storeLoyaltyTerminal() { loyaltyTerminalLog.info('Redeeming reward...', { reward: reward.name }); await apiClient.post('/store/loyalty/points/redeem', { - card_id: this.selectedCard.id, + card_id: this.selectedCard.card_id, reward_id: this.selectedReward, staff_pin: this.pinDigits }); @@ -281,7 +281,7 @@ function storeLoyaltyTerminal() { // Refresh card data async refreshCard() { try { - const response = await apiClient.get(`/store/loyalty/cards/${this.selectedCard.id}`); + const response = await apiClient.get(`/store/loyalty/cards/${this.selectedCard.card_id}`); if (response) { this.selectedCard = response; }