fix: show proper transaction type labels on loyalty terminal
Some checks failed
Some checks failed
Replace naive points_delta > 0 check with actual transaction_type labels. Previously card_created showed as "Redeemed" because points_delta was 0. Now uses a label map matching all TransactionType enum values with appropriate color coding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -263,6 +263,38 @@ function storeLoyaltyTerminal() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Format number
|
// Format number
|
||||||
|
getTransactionLabel(tx) {
|
||||||
|
const labels = {
|
||||||
|
'card_created': 'Enrolled',
|
||||||
|
'welcome_bonus': 'Welcome Bonus',
|
||||||
|
'stamp_earned': 'Stamp Earned',
|
||||||
|
'stamp_redeemed': 'Stamp Redeemed',
|
||||||
|
'stamp_voided': 'Stamp Voided',
|
||||||
|
'stamp_adjustment': 'Stamp Adjusted',
|
||||||
|
'points_earned': 'Points Earned',
|
||||||
|
'points_redeemed': 'Points Redeemed',
|
||||||
|
'points_voided': 'Points Voided',
|
||||||
|
'points_adjustment': 'Points Adjusted',
|
||||||
|
'points_expired': 'Points Expired',
|
||||||
|
'card_deactivated': 'Deactivated',
|
||||||
|
};
|
||||||
|
return labels[tx.transaction_type] || tx.transaction_type?.replace(/_/g, ' ') || 'Unknown';
|
||||||
|
},
|
||||||
|
|
||||||
|
getTransactionColor(tx) {
|
||||||
|
const type = tx.transaction_type || '';
|
||||||
|
if (['card_created', 'welcome_bonus', 'stamp_earned', 'points_earned'].includes(type)) {
|
||||||
|
return 'text-green-700 bg-green-100 dark:bg-green-700 dark:text-green-100';
|
||||||
|
}
|
||||||
|
if (['stamp_redeemed', 'points_redeemed'].includes(type)) {
|
||||||
|
return 'text-blue-700 bg-blue-100 dark:bg-blue-700 dark:text-blue-100';
|
||||||
|
}
|
||||||
|
if (['stamp_voided', 'points_voided', 'points_expired', 'card_deactivated'].includes(type)) {
|
||||||
|
return 'text-red-700 bg-red-100 dark:bg-red-700 dark:text-red-100';
|
||||||
|
}
|
||||||
|
return 'text-gray-700 bg-gray-100 dark:bg-gray-700 dark:text-gray-100';
|
||||||
|
},
|
||||||
|
|
||||||
formatNumber(num) {
|
formatNumber(num) {
|
||||||
if (num === null || num === undefined) return '0';
|
if (num === null || num === undefined) return '0';
|
||||||
return new Intl.NumberFormat('en-US').format(num);
|
return new Intl.NumberFormat('en-US').format(num);
|
||||||
|
|||||||
@@ -235,11 +235,8 @@
|
|||||||
<td class="px-4 py-3 text-sm" x-text="tx.customer_name || 'Unknown'"></td>
|
<td class="px-4 py-3 text-sm" x-text="tx.customer_name || 'Unknown'"></td>
|
||||||
<td class="px-4 py-3">
|
<td class="px-4 py-3">
|
||||||
<span class="px-2 py-1 text-xs font-semibold rounded-full"
|
<span class="px-2 py-1 text-xs font-semibold rounded-full"
|
||||||
:class="{
|
:class="getTransactionColor(tx)"
|
||||||
'text-green-700 bg-green-100 dark:bg-green-700 dark:text-green-100': tx.points_delta > 0,
|
x-text="getTransactionLabel(tx)"></span>
|
||||||
'text-orange-700 bg-orange-100 dark:bg-orange-700 dark:text-orange-100': tx.points_delta < 0
|
|
||||||
}"
|
|
||||||
x-text="tx.points_delta > 0 ? 'Earned' : 'Redeemed'"></span>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="px-4 py-3 text-sm text-right font-medium"
|
<td class="px-4 py-3 text-sm text-right font-medium"
|
||||||
:class="tx.points_delta > 0 ? 'text-green-600' : 'text-orange-600'"
|
:class="tx.points_delta > 0 ? 'text-green-600' : 'text-orange-600'"
|
||||||
|
|||||||
Reference in New Issue
Block a user