fix: implement handleSort method for sortable table headers
- Update th_sortable macro to call handleSort(key) instead of inline logic - Add handleSort method to subscriptions.js, subscription-tiers.js, billing-history.js - Add sort_by and sort_order params to API calls in all three files - Reset to page 1 when sort changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -144,6 +144,8 @@ function adminSubscriptions() {
|
||||
if (this.filters.status) params.append('status', this.filters.status);
|
||||
if (this.filters.tier) params.append('tier', this.filters.tier);
|
||||
if (this.filters.search) params.append('search', this.filters.search);
|
||||
if (this.sortBy) params.append('sort_by', this.sortBy);
|
||||
if (this.sortOrder) params.append('sort_order', this.sortOrder);
|
||||
|
||||
const data = await apiClient.get(`/admin/subscriptions?${params}`);
|
||||
this.subscriptions = data.subscriptions || [];
|
||||
@@ -168,6 +170,17 @@ function adminSubscriptions() {
|
||||
this.loadSubscriptions();
|
||||
},
|
||||
|
||||
handleSort(key) {
|
||||
if (this.sortBy === key) {
|
||||
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
this.sortBy = key;
|
||||
this.sortOrder = 'asc';
|
||||
}
|
||||
this.pagination.page = 1;
|
||||
this.loadSubscriptions();
|
||||
},
|
||||
|
||||
previousPage() {
|
||||
if (this.pagination.page > 1) {
|
||||
this.pagination.page--;
|
||||
|
||||
Reference in New Issue
Block a user