diff --git a/app/modules/loyalty/locales/en.json b/app/modules/loyalty/locales/en.json index 702b3021..f090b3c3 100644 --- a/app/modules/loyalty/locales/en.json +++ b/app/modules/loyalty/locales/en.json @@ -761,7 +761,8 @@ "col_location": "Location", "col_notes": "Notes", "no_transactions": "No transactions yet", - "card_label": "Card" + "card_label": "Card", + "page_x_of_y": "Page {page} of {pages}" }, "enroll": { "title": "Enroll Customer", diff --git a/app/modules/loyalty/static/store/js/loyalty-card-detail.js b/app/modules/loyalty/static/store/js/loyalty-card-detail.js index 5c321551..a808b99a 100644 --- a/app/modules/loyalty/static/store/js/loyalty-card-detail.js +++ b/app/modules/loyalty/static/store/js/loyalty-card-detail.js @@ -11,6 +11,7 @@ function storeLoyaltyCardDetail() { cardId: null, card: null, transactions: [], + txPagination: { page: 1, perPage: 20, total: 0, pages: 0 }, loading: false, error: null, @@ -38,6 +39,13 @@ function storeLoyaltyCardDetail() { return; } + // Use platform pagination setting if available + if (window.PlatformSettings) { + try { + this.txPagination.perPage = await window.PlatformSettings.getRowsPerPage(); + } catch (e) { /* use default */ } + } + await this.loadData(); loyaltyCardDetailLog.info('=== LOYALTY CARD DETAIL PAGE INITIALIZATION COMPLETE ==='); }, @@ -67,18 +75,32 @@ function storeLoyaltyCardDetail() { } }, - async loadTransactions() { + async loadTransactions(page = 1) { try { - const response = await apiClient.get(`/store/loyalty/cards/${this.cardId}/transactions?limit=50`); + const skip = (page - 1) * this.txPagination.perPage; + const response = await apiClient.get( + `/store/loyalty/cards/${this.cardId}/transactions?skip=${skip}&limit=${this.txPagination.perPage}` + ); if (response && response.transactions) { this.transactions = response.transactions; - loyaltyCardDetailLog.info(`Loaded ${this.transactions.length} transactions`); + this.txPagination.total = response.total || 0; + this.txPagination.page = page; + this.txPagination.pages = Math.ceil(this.txPagination.total / this.txPagination.perPage); + loyaltyCardDetailLog.info(`Loaded ${this.transactions.length} of ${this.txPagination.total} transactions (page ${page})`); } } catch (error) { loyaltyCardDetailLog.warn('Failed to load transactions:', error.message); } }, + txPreviousPage() { + if (this.txPagination.page > 1) this.loadTransactions(this.txPagination.page - 1); + }, + + txNextPage() { + if (this.txPagination.page < this.txPagination.pages) this.loadTransactions(this.txPagination.page + 1); + }, + formatNumber(num) { return num == null ? '0' : new Intl.NumberFormat('en-US').format(num); }, diff --git a/app/modules/loyalty/templates/loyalty/store/card-detail.html b/app/modules/loyalty/templates/loyalty/store/card-detail.html index 75c6673f..8a18f693 100644 --- a/app/modules/loyalty/templates/loyalty/store/card-detail.html +++ b/app/modules/loyalty/templates/loyalty/store/card-detail.html @@ -151,6 +151,23 @@ {% endcall %} + + +
+ + + + +
{% endblock %}