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) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 20:50:20 +01:00
parent 894832c62b
commit 316ec42566

View File

@@ -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;
}