fix(loyalty): translate transaction types + notes on card detail page
Some checks failed
Some checks failed
Card detail transaction history now shows translated transaction type labels and system-generated notes. Uses server-rendered labels object (same pattern as terminal) to avoid async i18n flicker. - Transaction types: server-rendered txLabels lookup (all 11 types) - Notes: txNotes lookup maps English DB strings to translated text (e.g., "Welcome bonus on enrollment" → "Bonus de bienvenue...") - Added welcome_bonus_note key to all 4 locales Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -161,13 +161,13 @@
|
||||
'text-green-700 bg-green-100 dark:bg-green-700 dark:text-green-100': tx.points_delta > 0,
|
||||
'text-orange-700 bg-orange-100 dark:bg-orange-700 dark:text-orange-100': tx.points_delta < 0
|
||||
}"
|
||||
x-text="tx.transaction_type.replace(/_/g, ' ')"></span>
|
||||
x-text="txLabels[tx.transaction_type] || tx.transaction_type.replace(/_/g, ' ')"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm font-medium"
|
||||
:class="tx.points_delta > 0 ? 'text-green-600' : 'text-orange-600'"
|
||||
x-text="(tx.points_delta > 0 ? '+' : '') + formatNumber(tx.points_delta)"></td>
|
||||
<td class="px-4 py-3 text-sm" x-text="tx.store_name || '-'"></td>
|
||||
<td class="px-4 py-3 text-sm text-gray-500" x-text="tx.notes || '-'"></td>
|
||||
<td class="px-4 py-3 text-sm text-gray-500" x-text="txNotes[tx.notes] || tx.notes || '-'"></td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
@@ -179,5 +179,26 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
// Server-rendered transaction type labels + system note translations
|
||||
window._cardDetailLabels = {
|
||||
txLabels: {
|
||||
card_created: {{ _('loyalty.transactions.card_created')|tojson }},
|
||||
welcome_bonus: {{ _('loyalty.transactions.welcome_bonus')|tojson }},
|
||||
stamp_earned: {{ _('loyalty.transactions.stamp_earned')|tojson }},
|
||||
stamp_redeemed: {{ _('loyalty.transactions.stamp_redeemed')|tojson }},
|
||||
stamp_voided: {{ _('loyalty.transactions.stamp_voided')|tojson }},
|
||||
points_earned: {{ _('loyalty.transactions.points_earned')|tojson }},
|
||||
points_redeemed: {{ _('loyalty.transactions.points_redeemed')|tojson }},
|
||||
points_voided: {{ _('loyalty.transactions.points_voided')|tojson }},
|
||||
points_adjustment: {{ _('loyalty.transactions.points_adjustment')|tojson }},
|
||||
points_expired: {{ _('loyalty.transactions.points_expired')|tojson }},
|
||||
reward_redeemed: {{ _('loyalty.transactions.reward_redeemed')|tojson }},
|
||||
},
|
||||
txNotes: {
|
||||
"Welcome bonus on enrollment": {{ _('loyalty.transactions.welcome_bonus_note')|tojson }},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script defer src="{{ url_for('loyalty_static', path='store/js/loyalty-card-detail.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user