@stacksjs/defaults 0.75.528 → 0.75.535

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/ai/skills/stacks-actions/SKILL.md +1 -1
  2. package/ai/skills/stacks-build/SKILL.md +1 -1
  3. package/ai/skills/stacks-dashboard/SKILL.md +2 -2
  4. package/ai/skills/stacks-database/SKILL.md +1 -1
  5. package/ai/skills/stacks-migrations/SKILL.md +2 -2
  6. package/ai/skills/stacks-native/CATALOG.md +4 -4
  7. package/app/Actions/Dashboard/Commerce/CommerceCouponsAction.ts +27 -15
  8. package/app/Actions/Dashboard/Commerce/CommerceCouponsExportAction.ts +45 -0
  9. package/app/Actions/Dashboard/Commerce/CommerceCustomersAction.ts +22 -12
  10. package/app/Actions/Dashboard/Commerce/CommerceCustomersExportAction.ts +44 -0
  11. package/app/Actions/Dashboard/Commerce/CommercePosCheckoutAction.ts +9 -29
  12. package/app/Actions/Dashboard/Commerce/CommercePrintDevicesAction.ts +7 -9
  13. package/app/Actions/Dashboard/Commerce/CommerceProductDetailAction.ts +9 -8
  14. package/app/Actions/Dashboard/Commerce/CommerceTaxesAction.ts +7 -9
  15. package/app/Actions/Dashboard/Commerce/ManufacturerIndexAction.ts +8 -20
  16. package/app/Actions/Dashboard/Commerce/commerce-coupon-list.test.ts +203 -0
  17. package/app/Actions/Dashboard/Commerce/commerce-coupon-list.ts +248 -0
  18. package/app/Actions/Dashboard/Commerce/commerce-customer-list.test.ts +183 -0
  19. package/app/Actions/Dashboard/Commerce/commerce-customer-list.ts +186 -0
  20. package/app/Actions/Dashboard/Commerce/commerce-customer-records.test.ts +1 -34
  21. package/app/Actions/Dashboard/Commerce/commerce-customer-records.ts +0 -11
  22. package/app/Actions/Dashboard/Commerce/commerce-manufacturer-list.test.ts +118 -0
  23. package/app/Actions/Dashboard/Commerce/commerce-manufacturer-list.ts +41 -0
  24. package/app/Actions/Dashboard/Commerce/commerce-pos-catalog.test.ts +17 -5
  25. package/app/Actions/Dashboard/Commerce/commerce-pos-catalog.ts +17 -3
  26. package/app/Actions/Dashboard/Commerce/commerce-print-device-list.test.ts +99 -0
  27. package/app/Actions/Dashboard/Commerce/commerce-print-device-list.ts +18 -0
  28. package/app/Actions/Dashboard/Commerce/commerce-product-list.ts +5 -5
  29. package/app/Actions/Dashboard/Commerce/commerce-product-options.test.ts +81 -0
  30. package/app/Actions/Dashboard/Commerce/commerce-tax-rate-list.test.ts +99 -0
  31. package/app/Actions/Dashboard/Commerce/commerce-tax-rate-list.ts +18 -0
  32. package/app/Actions/Dashboard/Commerce/coupon-records.test.ts +1 -16
  33. package/app/Actions/Dashboard/Commerce/coupon-records.ts +6 -10
  34. package/app/Actions/Dashboard/Commerce/manufacturer-records.test.ts +5 -17
  35. package/app/Actions/Dashboard/Commerce/manufacturer-records.ts +0 -29
  36. package/app/Actions/Dashboard/Email/captured-mail.test.ts +16 -0
  37. package/app/Actions/Dashboard/Email/captured-mail.ts +9 -1
  38. package/app/Actions/Dashboard/Models/model-write.ts +36 -3
  39. package/app/Actions/Dashboard/Notifications/NotificationDeliveryHistoryAction.ts +13 -58
  40. package/app/Actions/Dashboard/Notifications/notification-delivery-history.ts +74 -0
  41. package/app/Actions/SitemapAction.ts +3 -1
  42. package/app/Models/Notification.ts +3 -1
  43. package/app/Models/NotificationDelivery.ts +4 -0
  44. package/app/Models/User.ts +10 -1
  45. package/bootstrap.ts +10 -2
  46. package/functions/commerce/tax-types.ts +21 -0
  47. package/functions/dashboard-list.test.ts +16 -0
  48. package/functions/dashboard-list.ts +14 -6
  49. package/functions/dashboard-model-record.test.ts +139 -0
  50. package/functions/dashboard-model-record.ts +353 -0
  51. package/functions/monitoring/errors.ts +22 -103
  52. package/functions/notifications/deliveries.ts +7 -38
  53. package/functions/queries.ts +7 -10
  54. package/ide/vscode/package.json +1 -1
  55. package/package.json +5 -5
  56. package/resources/components/Dashboard/Analytics/AnalyticsHub.stx +2 -2
  57. package/resources/components/Dashboard/Analytics/CampaignAnalytics.stx +22 -28
  58. package/resources/components/Dashboard/Analytics/EventAnalytics.stx +26 -34
  59. package/resources/components/Dashboard/Analytics/SalesAnalytics.stx +29 -37
  60. package/resources/components/Dashboard/Analytics/WebAnalyticsBreakdown.stx +12 -16
  61. package/resources/components/Dashboard/Analytics/WebAnalyticsDashboard.stx +43 -53
  62. package/resources/components/Dashboard/App/RequestsOverview.stx +2 -1
  63. package/resources/components/Dashboard/App/SourceInventory.stx +2 -1
  64. package/resources/components/Dashboard/Auth/AccessTokens.stx +3 -5
  65. package/resources/components/Dashboard/Billing/BillingPaymentMethodsPanel.stx +9 -11
  66. package/resources/components/Dashboard/Billing/BillingSettings.stx +1 -1
  67. package/resources/components/Dashboard/Buddy/BuddyAssistant.stx +4 -6
  68. package/resources/components/Dashboard/Commerce/CommerceCategoriesDashboard.stx +2 -2
  69. package/resources/components/Dashboard/Commerce/CommerceCategoriesTable.stx +3 -3
  70. package/resources/components/Dashboard/Commerce/CommerceCategoryDialog.stx +2 -2
  71. package/resources/components/Dashboard/Commerce/CommerceCategoryHierarchy.stx +3 -5
  72. package/resources/components/Dashboard/Commerce/CommerceCouponBreakdown.stx +17 -13
  73. package/resources/components/Dashboard/Commerce/CommerceCouponDialog.stx +1 -1
  74. package/resources/components/Dashboard/Commerce/CommerceCouponsDashboard.stx +57 -85
  75. package/resources/components/Dashboard/Commerce/CommerceCouponsTable.stx +32 -9
  76. package/resources/components/Dashboard/Commerce/CommerceCustomerDialog.stx +1 -1
  77. package/resources/components/Dashboard/Commerce/CommerceCustomersDashboard.stx +49 -83
  78. package/resources/components/Dashboard/Commerce/CommerceCustomersTable.stx +32 -9
  79. package/resources/components/Dashboard/Commerce/CommerceGiftCardBreakdown.stx +9 -15
  80. package/resources/components/Dashboard/Commerce/CommerceGiftCardDialog.stx +1 -1
  81. package/resources/components/Dashboard/Commerce/CommerceGiftCardsDashboard.stx +35 -119
  82. package/resources/components/Dashboard/Commerce/CommerceGiftCardsTable.stx +3 -3
  83. package/resources/components/Dashboard/Commerce/CommerceManufacturerDialog.stx +1 -1
  84. package/resources/components/Dashboard/Commerce/CommerceManufacturersDashboard.stx +3 -5
  85. package/resources/components/Dashboard/Commerce/CommerceManufacturersTable.stx +2 -2
  86. package/resources/components/Dashboard/Commerce/CommerceOrderDialog.stx +4 -4
  87. package/resources/components/Dashboard/Commerce/CommerceOrdersDashboard.stx +42 -129
  88. package/resources/components/Dashboard/Commerce/CommerceOrdersTable.stx +3 -3
  89. package/resources/components/Dashboard/Commerce/CommerceOverviewDashboard.stx +1 -1
  90. package/resources/components/Dashboard/Commerce/CommerceOverviewOrdersTable.stx +9 -11
  91. package/resources/components/Dashboard/Commerce/CommerceOverviewProductsTable.stx +5 -7
  92. package/resources/components/Dashboard/Commerce/CommerceOverviewStats.stx +14 -16
  93. package/resources/components/Dashboard/Commerce/CommercePaymentsBreakdown.stx +12 -18
  94. package/resources/components/Dashboard/Commerce/CommercePaymentsDashboard.stx +41 -120
  95. package/resources/components/Dashboard/Commerce/CommercePaymentsTable.stx +1 -1
  96. package/resources/components/Dashboard/Commerce/CommercePosCart.stx +13 -15
  97. package/resources/components/Dashboard/Commerce/CommercePosCatalog.stx +17 -19
  98. package/resources/components/Dashboard/Commerce/CommercePosCheckoutDialog.stx +2 -2
  99. package/resources/components/Dashboard/Commerce/CommercePosDashboard.stx +1 -1
  100. package/resources/components/Dashboard/Commerce/CommercePosReceiptDialog.stx +1 -1
  101. package/resources/components/Dashboard/Commerce/CommerceProductDetailDashboard.stx +5 -5
  102. package/resources/components/Dashboard/Commerce/CommerceProductDialog.stx +3 -3
  103. package/resources/components/Dashboard/Commerce/CommerceProductsDashboard.stx +41 -122
  104. package/resources/components/Dashboard/Commerce/CommerceProductsTable.stx +3 -3
  105. package/resources/components/Dashboard/Commerce/CommerceReviewEditDialog.stx +1 -1
  106. package/resources/components/Dashboard/Commerce/CommerceReviewsDashboard.stx +38 -122
  107. package/resources/components/Dashboard/Commerce/CommerceReviewsTable.stx +2 -2
  108. package/resources/components/Dashboard/Commerce/CommerceTaxDialog.stx +3 -3
  109. package/resources/components/Dashboard/Commerce/CommerceTaxesDashboard.stx +5 -4
  110. package/resources/components/Dashboard/Commerce/CommerceTaxesTable.stx +4 -3
  111. package/resources/components/Dashboard/Commerce/CommerceUnitDialog.stx +3 -7
  112. package/resources/components/Dashboard/Commerce/CommerceUnitsDashboard.stx +3 -5
  113. package/resources/components/Dashboard/Commerce/CommerceUnitsTable.stx +2 -2
  114. package/resources/components/Dashboard/Commerce/CommerceVariantDialog.stx +3 -3
  115. package/resources/components/Dashboard/Commerce/CommerceVariantsDashboard.stx +4 -4
  116. package/resources/components/Dashboard/Commerce/CommerceVariantsTable.stx +3 -5
  117. package/resources/components/Dashboard/Commerce/Delivery/CourierDialog.stx +1 -1
  118. package/resources/components/Dashboard/Commerce/Delivery/CouriersDashboard.stx +1 -1
  119. package/resources/components/Dashboard/Commerce/Delivery/CouriersTable.stx +2 -2
  120. package/resources/components/Dashboard/Commerce/Delivery/DeliveryOverviewDashboard.stx +44 -52
  121. package/resources/components/Dashboard/Commerce/Delivery/DeliveryPagination.stx +2 -2
  122. package/resources/components/Dashboard/Commerce/Delivery/DeliveryRouteDialog.stx +1 -1
  123. package/resources/components/Dashboard/Commerce/Delivery/DeliveryRoutesDashboard.stx +1 -1
  124. package/resources/components/Dashboard/Commerce/Delivery/DeliveryRoutesTable.stx +2 -2
  125. package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveriesDashboard.stx +1 -1
  126. package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveryTable.stx +2 -2
  127. package/resources/components/Dashboard/Commerce/Delivery/LicenseKeyDialog.stx +3 -3
  128. package/resources/components/Dashboard/Commerce/Delivery/LicenseKeysDashboard.stx +1 -1
  129. package/resources/components/Dashboard/Commerce/Delivery/LicenseKeysTable.stx +2 -2
  130. package/resources/components/Dashboard/Commerce/Delivery/ShippingMethodsDashboard.stx +1 -1
  131. package/resources/components/Dashboard/Commerce/Delivery/ShippingMethodsTable.stx +2 -2
  132. package/resources/components/Dashboard/Commerce/Delivery/ShippingRateDialog.stx +2 -2
  133. package/resources/components/Dashboard/Commerce/Delivery/ShippingRatesDashboard.stx +1 -1
  134. package/resources/components/Dashboard/Commerce/Delivery/ShippingRatesTable.stx +2 -2
  135. package/resources/components/Dashboard/Commerce/Delivery/ShippingZoneDialog.stx +1 -1
  136. package/resources/components/Dashboard/Commerce/Delivery/ShippingZonesDashboard.stx +1 -1
  137. package/resources/components/Dashboard/Commerce/Delivery/ShippingZonesTable.stx +4 -8
  138. package/resources/components/Dashboard/Commerce/PaymentDetailsDialog.stx +1 -3
  139. package/resources/components/Dashboard/Commerce/PrintDeviceBreakdown.stx +9 -15
  140. package/resources/components/Dashboard/Commerce/PrintDeviceDialog.stx +1 -1
  141. package/resources/components/Dashboard/Commerce/PrintDevicesDashboard.stx +3 -3
  142. package/resources/components/Dashboard/Commerce/PrintDevicesTable.stx +3 -3
  143. package/resources/components/Dashboard/Commerce/PrintLogBreakdown.stx +3 -9
  144. package/resources/components/Dashboard/Commerce/PrintLogDetailsDialog.stx +1 -1
  145. package/resources/components/Dashboard/Commerce/PrintLogsDashboard.stx +4 -4
  146. package/resources/components/Dashboard/Commerce/PrintLogsTable.stx +8 -10
  147. package/resources/components/Dashboard/Commerce/ProductWaitlistDashboard.stx +37 -109
  148. package/resources/components/Dashboard/Commerce/ProductWaitlistEntryDialog.stx +3 -3
  149. package/resources/components/Dashboard/Commerce/ProductWaitlistTable.stx +2 -2
  150. package/resources/components/Dashboard/Commerce/RestaurantWaitlistDashboard.stx +38 -112
  151. package/resources/components/Dashboard/Commerce/RestaurantWaitlistEntryDialog.stx +2 -2
  152. package/resources/components/Dashboard/Commerce/RestaurantWaitlistTable.stx +2 -2
  153. package/resources/components/Dashboard/Content/AuthorsDashboard.stx +4 -4
  154. package/resources/components/Dashboard/Content/BlogDashboard.stx +4 -4
  155. package/resources/components/Dashboard/Content/CommentsDashboard.stx +36 -83
  156. package/resources/components/Dashboard/Content/ContentDashboard.stx +12 -14
  157. package/resources/components/Dashboard/Content/ContentTaxonomyDashboard.stx +2 -2
  158. package/resources/components/Dashboard/Content/FileManagerDashboard.stx +8 -12
  159. package/resources/components/Dashboard/Content/FileStoragePanel.stx +6 -10
  160. package/resources/components/Dashboard/Content/FileUploadDialog.stx +1 -3
  161. package/resources/components/Dashboard/Content/PagesDashboard.stx +39 -78
  162. package/resources/components/Dashboard/Content/PostEditorDialog.stx +4 -8
  163. package/resources/components/Dashboard/Content/PostsDashboard.stx +44 -85
  164. package/resources/components/Dashboard/Content/SeoDashboard.stx +5 -4
  165. package/resources/components/Dashboard/Data/DataRecords.stx +140 -12
  166. package/resources/components/Dashboard/Deployments/DeploymentList.stx +4 -4
  167. package/resources/components/Dashboard/Deployments/DeploymentTable.stx +3 -1
  168. package/resources/components/Dashboard/Elements/DropdownNavigation.stx +5 -7
  169. package/resources/components/Dashboard/Email/CapturedMailDashboard.stx +1 -3
  170. package/resources/components/Dashboard/Email/CapturedMailList.stx +18 -20
  171. package/resources/components/Dashboard/Email/EmailActivityDashboard.stx +24 -28
  172. package/resources/components/Dashboard/Email/EmailSettingsList.stx +6 -8
  173. package/resources/components/Dashboard/Email/EmailSettingsNavigation.stx +10 -12
  174. package/resources/components/Dashboard/Email/EmailSidebar.stx +33 -37
  175. package/resources/components/Dashboard/Email/InboxMessageDetail.stx +1 -1
  176. package/resources/components/Dashboard/Email/InboxMessageList.stx +16 -18
  177. package/resources/components/Dashboard/Email/InboxSettingsDashboard.stx +1 -1
  178. package/resources/components/Dashboard/Environment/EnvironmentDashboard.stx +2 -2
  179. package/resources/components/Dashboard/GlobalSearch.stx +19 -21
  180. package/resources/components/Dashboard/Home/DashboardHome.stx +8 -1
  181. package/resources/components/Dashboard/Infrastructure/CloudDashboard.stx +1 -1
  182. package/resources/components/Dashboard/Infrastructure/DnsDashboard.stx +27 -13
  183. package/resources/components/Dashboard/Infrastructure/LogsDashboard.stx +1 -1
  184. package/resources/components/Dashboard/Infrastructure/MailboxesDashboard.stx +46 -8
  185. package/resources/components/Dashboard/Infrastructure/ServerlessDashboard.stx +1 -1
  186. package/resources/components/Dashboard/Infrastructure/ServersDashboard.stx +1 -1
  187. package/resources/components/Dashboard/Jobs/JobDetail.stx +1 -1
  188. package/resources/components/Dashboard/Jobs/JobHistory.stx +44 -57
  189. package/resources/components/Dashboard/Jobs/JobTable.stx +23 -25
  190. package/resources/components/Dashboard/Kanban/KanbanCardDialog.stx +1 -1
  191. package/resources/components/Dashboard/Library/ComponentsDashboard.stx +1 -1
  192. package/resources/components/Dashboard/Management/AssignmentDrawer.stx +5 -7
  193. package/resources/components/Dashboard/Management/PermissionsDashboard.stx +35 -43
  194. package/resources/components/Dashboard/Marketing/AbandonedCartsDashboard.stx +11 -13
  195. package/resources/components/Dashboard/Marketing/CampaignDialog.stx +1 -3
  196. package/resources/components/Dashboard/Marketing/CampaignsDashboard.stx +2 -2
  197. package/resources/components/Dashboard/Marketing/CampaignsTable.stx +2 -2
  198. package/resources/components/Dashboard/Marketing/MarketingListsDashboard.stx +1 -1
  199. package/resources/components/Dashboard/Marketing/MarketingListsTable.stx +2 -2
  200. package/resources/components/Dashboard/Marketing/SocialPostDialog.stx +1 -3
  201. package/resources/components/Dashboard/Marketing/SocialPostsDashboard.stx +2 -2
  202. package/resources/components/Dashboard/Marketing/SocialPostsTable.stx +2 -2
  203. package/resources/components/Dashboard/Models/ModelRecordActions.stx +11 -2
  204. package/resources/components/Dashboard/Models/ModelRecordCreate.stx +193 -0
  205. package/resources/components/Dashboard/Models/ModelRecordDetail.stx +144 -0
  206. package/resources/components/Dashboard/Models/ModelRecordEdit.stx +176 -0
  207. package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +52 -186
  208. package/resources/components/Dashboard/Models/ModelsOverview.stx +2 -4
  209. package/resources/components/Dashboard/Monitoring/ErrorDashboard.stx +47 -81
  210. package/resources/components/Dashboard/Monitoring/ErrorTable.stx +4 -2
  211. package/resources/components/Dashboard/NotFoundDashboard.stx +4 -4
  212. package/resources/components/Dashboard/Notifications/NotificationDeliveryHistory.stx +43 -77
  213. package/resources/components/Dashboard/Notifications/NotificationDeliveryOverview.stx +15 -17
  214. package/resources/components/Dashboard/Notifications/NotificationDeliveryTable.stx +1 -1
  215. package/resources/components/Dashboard/Operations/AuditDashboard.stx +1 -1
  216. package/resources/components/Dashboard/Operations/ChangeDashboard.stx +1 -1
  217. package/resources/components/Dashboard/Operations/IncidentDashboard.stx +1 -1
  218. package/resources/components/Dashboard/Operations/MigrationDashboard.stx +2 -2
  219. package/resources/components/Dashboard/Operations/RecoveryDashboard.stx +1 -1
  220. package/resources/components/Dashboard/Operations/SchedulerDashboard.stx +1 -1
  221. package/resources/components/Dashboard/Queries/QueryDashboard.stx +60 -86
  222. package/resources/components/Dashboard/Queries/QueryDetail.stx +5 -9
  223. package/resources/components/Dashboard/Realtime/RealtimeDashboard.stx +6 -8
  224. package/resources/components/Dashboard/Remote/RemoteConsole.stx +14 -20
  225. package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +48 -54
  226. package/resources/components/Dashboard/Settings/MailSettingsDashboard.stx +8 -8
  227. package/resources/components/Dashboard/Settings/SettingsDashboard.stx +43 -47
  228. package/resources/components/Dashboard/Teams/TeamInvitationDashboard.stx +2 -2
  229. package/resources/components/Dashboard/UI/ActivityTable.stx +2 -1
  230. package/resources/components/Dashboard/UI/Button.stx +15 -0
  231. package/resources/components/Dashboard/UI/MetricCards.stx +5 -7
  232. package/resources/components/Dashboard/UI/Pagination.stx +3 -5
  233. package/resources/components/Dashboard/UI/QuickLinks.stx +2 -2
  234. package/resources/components/Dashboard/UI/Select.stx +1 -0
  235. package/resources/components/Dashboard/UI/Table.stx +139 -96
  236. package/resources/components/Dashboard/UI/Tabs.stx +18 -20
  237. package/routes/dashboard-api.ts +2 -0
  238. package/routes/dashboard.ts +246 -253
  239. package/routes/storefront.ts +31 -0
  240. package/stx-components-plugin.ts +12 -1
  241. package/views/dashboard/content/categories/index.stx +1 -1
  242. package/views/dashboard/content/tags/index.stx +1 -1
  243. package/views/dashboard/layouts/default.stx +27 -12
  244. package/views/dashboard/models/[model]/[id]/edit.stx +8 -0
  245. package/views/dashboard/models/[model]/[id].stx +8 -0
  246. package/views/dashboard/models/[model]/create.stx +8 -0
  247. package/resources/components/Dashboard/CreateRecordModal.stx +0 -138
  248. package/resources/components/Dashboard/Models/EditRecordModal.stx +0 -81
@@ -5,6 +5,7 @@ import type {
5
5
  GiftCardSummary,
6
6
  } from '../../../../app/Actions/Dashboard/Commerce/gift-card-records'
7
7
  import { DashboardApiError, dashboardApi } from '../../../../functions/dashboard-api'
8
+ import { useServerList } from '../../../../functions/dashboard-list'
8
9
  import { pushToast } from '../../../../functions/toasts'
9
10
 
10
11
  interface GiftCardIndexResponse {
@@ -43,24 +44,11 @@ const emptySummary: GiftCardSummary = {
43
44
  statuses: { ACTIVE: 0, USED: 0, EXPIRED: 0, DEACTIVATED: 0 },
44
45
  currencies: [],
45
46
  }
46
- const records = state<GiftCardRecord[]>([])
47
47
  const summary = state<GiftCardSummary>({ ...emptySummary })
48
- const search = state('')
49
48
  const statusFilter = state('all')
50
49
  const enabledFilter = state('all')
51
50
  const deliveryFilter = state('all')
52
51
  const sort = state('newest')
53
- // The server searches, filters, sorts and pages (stacksjs/stacks#3218), where
54
- // this page used to do all of that with the newest 500.
55
- const matchingTotal = state(0)
56
- const page = state(1)
57
- const perPage = state(25)
58
- const appliedSearch = state('')
59
- const headerSort = state<{ sort: string, direction: string } | null>(null)
60
- let listRequest = 0
61
- let searchTimer: ReturnType<typeof setTimeout> | null = null
62
- const loading = state(true)
63
- const loadError = state('')
64
52
  const dialogOpen = state(false)
65
53
  const dialogMode = state<'add' | 'edit'>('add')
66
54
  const editingRecord = state<GiftCardRecord | null>(null)
@@ -70,7 +58,7 @@ const saving = state(false)
70
58
  const deleting = state(false)
71
59
  const validationErrors = state<Record<string, string>>({})
72
60
 
73
- const SELECT_SORTS: Record<string, { sort: string, direction: string }> = {
61
+ const SELECT_SORTS: Record<string, { sort: string, direction: 'asc' | 'desc' }> = {
74
62
  newest: { sort: 'created', direction: 'desc' },
75
63
  code: { sort: 'code', direction: 'asc' },
76
64
  balance: { sort: 'balance', direction: 'desc' },
@@ -87,26 +75,35 @@ const COLUMN_SORTS: Record<string, string> = {
87
75
  expiryDate: 'expiry',
88
76
  }
89
77
 
90
- /** The search, filters and order, as the query the server takes. */
91
- function filterParams(): URLSearchParams {
92
- const params = new URLSearchParams()
93
- const order = headerSort() ?? SELECT_SORTS[sort()] ?? SELECT_SORTS.newest
94
- params.set('sort', order.sort)
95
- params.set('direction', order.direction)
96
- if (appliedSearch())
97
- params.set('q', appliedSearch())
98
- if (statusFilter() !== 'all')
99
- params.set('status', statusFilter())
100
- if (enabledFilter() !== 'all')
101
- params.set('enabled', enabledFilter())
102
- if (deliveryFilter() !== 'all')
103
- params.set('delivery', deliveryFilter())
104
- return params
105
- }
78
+ // The server searches, filters, sorts and pages (stacksjs/stacks#3218), where
79
+ // this page used to do all of that with the newest 500.
80
+ const {
81
+ records,
82
+ total,
83
+ page,
84
+ perPage,
85
+ search,
86
+ loading,
87
+ loadError,
88
+ params,
89
+ load,
90
+ changePage,
91
+ changePageSize,
92
+ changeSort,
93
+ } = useServerList<GiftCardRecord>({
94
+ fetch: query => dashboardApi<GiftCardIndexResponse>(`/api/dashboard/commerce/gift-cards?${query}`),
95
+ defaultSort: () => SELECT_SORTS[sort()] ?? SELECT_SORTS.newest!,
96
+ columnSorts: COLUMN_SORTS,
97
+ filters: () => ({ status: statusFilter(), enabled: enabledFilter(), delivery: deliveryFilter() }),
98
+ onLoad: (result) => {
99
+ summary.set((result as GiftCardIndexResponse).summary ?? { ...emptySummary })
100
+ },
101
+ onError: error => pushToast('error', 'Could not load gift cards', { detail: error instanceof Error ? error.message : String(error) }),
102
+ })
106
103
 
107
104
  function matchingLabel(): string {
108
- const count = matchingTotal()
109
- return `${count} matching ${count === 1 ? 'gift card' : 'gift cards'}`
105
+ const count = total()
106
+ return `${count.toLocaleString()} matching ${count === 1 ? 'gift card' : 'gift cards'}`
110
107
  }
111
108
 
112
109
  function metricCards(): Array<{ label: string, value: string, detail: string }> {
@@ -121,94 +118,13 @@ function metricCards(): Array<{ label: string, value: string, detail: string }>
121
118
 
122
119
  /** Every matching gift card as CSV, built by the server, not just the page shown. */
123
120
  function exportHref(): string {
124
- return `/api/dashboard/commerce/gift-cards/export?${filterParams()}`
125
- }
126
-
127
- async function loadGiftCards(): Promise<void> {
128
- const request = ++listRequest
129
- loading.set(true)
130
- loadError.set('')
131
- try {
132
- const params = filterParams()
133
- params.set('page', String(page()))
134
- params.set('per_page', String(perPage()))
135
- const data = await dashboardApi<GiftCardIndexResponse>(`/api/dashboard/commerce/gift-cards?${params}`)
136
- // Only the newest request lands.
137
- if (request !== listRequest)
138
- return
139
- records.set(Array.isArray(data.records) ? data.records : [])
140
- matchingTotal.set(Number(data.total) || 0)
141
- page.set(Number(data.page) || 1)
142
- summary.set(data.summary ?? { ...emptySummary })
143
- }
144
- catch (error) {
145
- if (request !== listRequest)
146
- return
147
- loadError.set('Gift cards could not be loaded.')
148
- pushToast('error', 'Could not load gift cards', {
149
- detail: error instanceof Error ? error.message : String(error),
150
- })
151
- }
152
- finally {
153
- if (request === listRequest)
154
- loading.set(false)
155
- }
121
+ return `/api/dashboard/commerce/gift-cards/export?${params()}`
156
122
  }
157
123
 
158
- function eventValue<T>(value: T | CustomEvent<T>): T {
159
- return value instanceof CustomEvent ? value.detail : value
124
+ function loadGiftCards(): Promise<void> {
125
+ return load()
160
126
  }
161
127
 
162
- function changePage(value: number | CustomEvent<number>): void {
163
- page.set(Number(eventValue(value)) || 1)
164
- void loadGiftCards()
165
- }
166
-
167
- function changePageSize(value: number | CustomEvent<number>): void {
168
- perPage.set(Number(eventValue(value)) || 25)
169
- page.set(1)
170
- void loadGiftCards()
171
- }
172
-
173
- function changeColumnSort(value: { key: string, direction: string } | CustomEvent<{ key: string, direction: string }>): void {
174
- const column = eventValue(value)
175
- const serverSort = COLUMN_SORTS[column.key]
176
- headerSort.set(serverSort ? { sort: serverSort, direction: column.direction === 'asc' ? 'asc' : 'desc' } : null)
177
- page.set(1)
178
- void loadGiftCards()
179
- }
180
-
181
- // The filters and the select ask the server for page 1 when they change, and
182
- // the search once typing pauses. A select change hands the order back from a
183
- // column header.
184
- let shownFilters = JSON.stringify([statusFilter(), enabledFilter(), deliveryFilter(), sort()])
185
- effect(() => {
186
- const filters = JSON.stringify([statusFilter(), enabledFilter(), deliveryFilter(), sort()])
187
- if (filters === shownFilters)
188
- return
189
- const sortChanged = JSON.parse(shownFilters)[3] !== sort()
190
- shownFilters = filters
191
- if (sortChanged)
192
- headerSort.set(null)
193
- page.set(1)
194
- void loadGiftCards()
195
- })
196
-
197
- let shownSearch = search().trim()
198
- effect(() => {
199
- const term = search().trim()
200
- if (term === shownSearch)
201
- return
202
- shownSearch = term
203
- if (searchTimer)
204
- clearTimeout(searchTimer)
205
- searchTimer = setTimeout(() => {
206
- appliedSearch.set(term)
207
- page.set(1)
208
- void loadGiftCards()
209
- }, 250)
210
- })
211
-
212
128
  function openAdd(): void {
213
129
  dialogMode.set('add')
214
130
  editingRecord.set(null)
@@ -303,7 +219,7 @@ onMount(() => {
303
219
  })
304
220
  </script>
305
221
 
306
- <div class="space-y-6">
222
+ <div class="flex flex-col gap-6">
307
223
  <PageHeader title="Gift Cards" description="Manage native GiftCard balances, recipients, delivery, and lifecycle state.">
308
224
  <div class="flex flex-wrap gap-2">
309
225
  <Button variant="secondary" :loading="loading()" @click="loadGiftCards()"><span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>Refresh</Button>
@@ -318,7 +234,7 @@ onMount(() => {
318
234
 
319
235
  <CommerceGiftCardBreakdown :summary="summary()" />
320
236
 
321
- <section class="space-y-3">
237
+ <section class="flex flex-col gap-3">
322
238
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-6">
323
239
  <label class="relative sm:col-span-2">
324
240
  <span class="sr-only">Search gift cards</span>
@@ -335,7 +251,7 @@ onMount(() => {
335
251
  <p class="text-gray-500 text-sm dark:text-neutral-400">{{ matchingLabel() }}</p>
336
252
  </div>
337
253
 
338
- <CommerceGiftCardsTable :sort-reset-key="sort()" :records="records()" :total="matchingTotal()" :current-page="page()" :per-page="perPage()" :loading="loading()" @view="openDetails" @edit="openEdit" @delete="openDelete" @page-change="changePage" @page-size-change="changePageSize" @sort="changeColumnSort" />
254
+ <CommerceGiftCardsTable :sort-reset-key="sort()" :records="records()" :total="total()" :current-page="page()" :per-page="perPage()" :loading="loading()" @view="openDetails" @edit="openEdit" @delete="openDelete" @page-change="changePage" @page-size-change="changePageSize" @sort="changeSort" />
339
255
  </section>
340
256
  </div>
341
257
 
@@ -48,9 +48,9 @@ const COLUMNS = [
48
48
  ]
49
49
 
50
50
  const ROW_ACTIONS = [
51
- { action: 'view', label: 'View', icon: 'i-hugeicons-view' },
52
- { action: 'edit', label: 'Edit', icon: 'i-hugeicons-edit-02' },
53
- { action: 'delete', label: 'Delete', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
51
+ { action: 'view', label: 'View' },
52
+ { action: 'edit', label: 'Edit' },
53
+ { action: 'delete', label: 'Delete' },
54
54
  ]
55
55
 
56
56
  const rows = derived(() => records().map(record => ({
@@ -55,7 +55,7 @@ function errorMessages(): string[] {
55
55
  >
56
56
  <form id="manufacturer-form" @submit.prevent="submit">
57
57
  <ul :if="errorMessages().length > 0" class="mb-5 p-3 space-y-1 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/30 border border-red-200 rounded-lg dark:border-red-900">
58
- <template :for="message in errorMessages()" :key="message"><li>{{ message }}</li></template>
58
+ <li :for="message in errorMessages()" :key="message">{{ message }}</li>
59
59
  </ul>
60
60
  <div class="space-y-4">
61
61
  <label class="block">
@@ -174,7 +174,7 @@ onMount(() => {
174
174
  })
175
175
  </script>
176
176
 
177
- <div class="space-y-6">
177
+ <div class="flex flex-col gap-6">
178
178
  <PageHeader title="Manufacturers" description="Manage native Manufacturer records and their product relationships.">
179
179
  <div class="flex gap-2">
180
180
  <Button variant="secondary" :loading="loading()" @click="loadManufacturers">
@@ -192,7 +192,7 @@ onMount(() => {
192
192
 
193
193
  <MetricCards label="Manufacturer metrics" columns="grid-cols-2 lg:grid-cols-4" :items="metricCards()" />
194
194
 
195
- <section class="space-y-3">
195
+ <section class="flex flex-col gap-3">
196
196
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-4">
197
197
  <label class="relative sm:col-span-2">
198
198
  <span class="sr-only">Search manufacturers</span>
@@ -213,9 +213,7 @@ onMount(() => {
213
213
  <span class="sr-only">Country</span>
214
214
  <select x-model="countryFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700">
215
215
  <option value="all">All countries</option>
216
- <template :for="country in countries()" :key="country">
217
- <option :value="country">{{ country }}</option>
218
- </template>
216
+ <option :for="country in countries()" :key="country" :value="country">{{ country }}</option>
219
217
  </select>
220
218
  </label>
221
219
  </div>
@@ -36,8 +36,8 @@ const COLUMNS = [
36
36
  ]
37
37
 
38
38
  const ROW_ACTIONS = [
39
- { action: 'edit', label: 'Edit', icon: 'i-hugeicons-edit-01' },
40
- { action: 'delete', label: 'Delete', icon: 'i-hugeicons-waste', class: 'text-red-500' },
39
+ { action: 'edit', label: 'Edit' },
40
+ { action: 'delete', label: 'Delete' },
41
41
  ]
42
42
 
43
43
  /** A badge column maps a row field, so the flag needs one. */
@@ -175,16 +175,16 @@ function errorMessages(): string[] {
175
175
  >
176
176
  <form id="order-form" @submit.prevent="submit">
177
177
  <ul :if="errorMessages().length > 0" class="mb-5 p-3 space-y-1 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/30 border border-red-200 rounded-lg dark:border-red-900">
178
- <template :for="message in errorMessages()" :key="message"><li>{{ message }}</li></template>
178
+ <li :for="message in errorMessages()" :key="message">{{ message }}</li>
179
179
  </ul>
180
180
  <div class="grid gap-4 grid-cols-1 sm:grid-cols-2">
181
181
  <div class="block">
182
182
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Customer</span><input x-model="customerQuery" @input="searchCustomersSoon()" type="search" name="customer_search" aria-label="Search customers by name or email" placeholder="Search by name or email" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
183
- <select x-model="customerId" aria-label="Customer" class="mt-2 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><option value="">Unassigned customer</option><template :for="option in customers()" :key="option.id"><option :value="option.id" :selected="option.id === customerId()">{{ option.label }}</option></template></select>
183
+ <select x-model="customerId" aria-label="Customer" class="mt-2 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><option value="">Unassigned customer</option><option :for="option in customers()" :key="option.id" :value="option.id" :selected="option.id === customerId()">{{ option.label }}</option></select>
184
184
  <p :if="moreCustomersLabel()" class="mt-1 text-gray-500 text-xs dark:text-neutral-400" :text="moreCustomersLabel()"></p>
185
185
  </div>
186
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Status</span><select x-model="status" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><template :for="option in statuses()" :key="option"><option :value="option">{{ label(option) }}</option></template></select></label>
187
- <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Order type</span><select x-model="orderType" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><template :for="option in orderTypes()" :key="option"><option :value="option">{{ label(option) }}</option></template></select></label>
186
+ <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Status</span><select x-model="status" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><option :for="option in statuses()" :key="option" :value="option">{{ label(option) }}</option></select></label>
187
+ <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Order type</span><select x-model="orderType" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><option :for="option in orderTypes()" :key="option" :value="option">{{ label(option) }}</option></select></label>
188
188
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Currency</span><input x-model="currency" type="text" minlength="3" maxlength="3" required spellcheck="false" class="mt-1 px-3 py-2 w-full font-mono text-gray-900 text-sm uppercase dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
189
189
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Total amount</span><input x-model="totalAmount" type="number" min="0" :step="moneyInputStep(currency())" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
190
190
  <label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Tax amount</span><input x-model="taxAmount" type="number" min="0" :step="moneyInputStep(currency())" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
@@ -4,6 +4,7 @@ import type {
4
4
  CommerceOrderSummary,
5
5
  } from '../../../../app/Actions/Dashboard/Commerce/commerce-order-records'
6
6
  import { DashboardApiError, dashboardApi } from '../../../../functions/dashboard-api'
7
+ import { useServerList } from '../../../../functions/dashboard-list'
7
8
  import { pushToast } from '../../../../functions/toasts'
8
9
  import { formatCurrency } from '@stacksjs/commerce/money'
9
10
 
@@ -43,26 +44,13 @@ const emptySummary: CommerceOrderSummary = {
43
44
  cancelled: 0,
44
45
  currencyTotals: [],
45
46
  }
46
- const records = state<CommerceOrderRecord[]>([])
47
47
  const summary = state<CommerceOrderSummary>({ ...emptySummary })
48
48
  const statuses = state<string[]>([])
49
49
  const orderTypes = state<string[]>([])
50
50
  const defaultCurrency = state('USD')
51
- const search = state('')
52
51
  const statusFilter = state('all')
53
52
  const typeFilter = state('all')
54
53
  const sort = state('newest')
55
- // A column header's sort, which takes over from the select until it changes.
56
- const headerSort = state<{ sort: string, direction: string } | null>(null)
57
- // How many orders match the search and filters, across every page.
58
- const matchingTotal = state(0)
59
- const page = state(1)
60
- const perPage = state(25)
61
- const appliedSearch = state('')
62
- let listRequest = 0
63
- let searchTimer: ReturnType<typeof setTimeout> | null = null
64
- const loading = state(true)
65
- const loadError = state('')
66
54
  const dialogOpen = state(false)
67
55
  const dialogMode = state<'add' | 'edit'>('add')
68
56
  const editingRecord = state<CommerceOrderRecord | null>(null)
@@ -81,7 +69,7 @@ function label(value: string): string {
81
69
  }
82
70
 
83
71
  /** The select's four orders, as the server's sort and direction. */
84
- const SELECT_SORTS: Record<string, { sort: string, direction: string }> = {
72
+ const SELECT_SORTS: Record<string, { sort: string, direction: 'asc' | 'desc' }> = {
85
73
  'newest': { sort: 'created', direction: 'desc' },
86
74
  'oldest': { sort: 'created', direction: 'asc' },
87
75
  'total-high': { sort: 'total', direction: 'desc' },
@@ -98,27 +86,39 @@ const COLUMN_SORTS: Record<string, string> = {
98
86
  createdAt: 'created',
99
87
  }
100
88
 
101
- /**
102
- * The search, filters and order, as the query the server takes
103
- * (stacksjs/stacks#3218): it searches, filters, sorts and pages every order,
104
- * where this page used to do all of that with the newest 500.
105
- */
106
- function filterParams(): URLSearchParams {
107
- const params = new URLSearchParams()
108
- const order = headerSort() ?? SELECT_SORTS[sort()] ?? SELECT_SORTS.newest
109
- params.set('sort', order.sort)
110
- params.set('direction', order.direction)
111
- if (appliedSearch())
112
- params.set('q', appliedSearch())
113
- if (statusFilter() !== 'all')
114
- params.set('status', statusFilter())
115
- if (typeFilter() !== 'all')
116
- params.set('type', typeFilter())
117
- return params
118
- }
89
+ // The server searches, filters, sorts and pages (stacksjs/stacks#3218);
90
+ // useServerList keeps the request order, paging, header sort and search
91
+ // debounce this page used to keep itself.
92
+ const {
93
+ records,
94
+ total,
95
+ page,
96
+ perPage,
97
+ search,
98
+ loading,
99
+ loadError,
100
+ params,
101
+ load,
102
+ changePage,
103
+ changePageSize,
104
+ changeSort,
105
+ } = useServerList<CommerceOrderRecord>({
106
+ fetch: query => dashboardApi<OrderIndexResponse>(`/api/dashboard/commerce/orders?${query}`),
107
+ defaultSort: () => SELECT_SORTS[sort()] ?? SELECT_SORTS["newest"]!,
108
+ columnSorts: COLUMN_SORTS,
109
+ filters: () => ({ status: statusFilter(), type: typeFilter() }),
110
+ onLoad: (result) => {
111
+ const data = result as OrderIndexResponse
112
+ summary.set(data.summary ?? { ...emptySummary })
113
+ statuses.set(Array.isArray(data.statuses) ? data.statuses : [])
114
+ orderTypes.set(Array.isArray(data.orderTypes) ? data.orderTypes : [])
115
+ defaultCurrency.set(data.defaultCurrency || 'USD')
116
+ },
117
+ onError: error => pushToast('error', "Could not load orders", { detail: error instanceof Error ? error.message : String(error) }),
118
+ })
119
119
 
120
120
  function matchingLabel(): string {
121
- const count = matchingTotal()
121
+ const count = total()
122
122
  return `${count.toLocaleString()} matching ${count === 1 ? 'order' : 'orders'}`
123
123
  }
124
124
 
@@ -135,100 +135,13 @@ function metricCards(): Array<{ label: string, value: string, detail: string }>
135
135
 
136
136
  /** Every matching order as CSV, built by the server, not just the page shown. */
137
137
  function exportHref(): string {
138
- return `/api/dashboard/commerce/orders/export?${filterParams()}`
139
- }
140
-
141
- async function loadOrders(): Promise<void> {
142
- const request = ++listRequest
143
- loading.set(true)
144
- loadError.set('')
145
- try {
146
- const params = filterParams()
147
- params.set('page', String(page()))
148
- params.set('per_page', String(perPage()))
149
- const data = await dashboardApi<OrderIndexResponse>(`/api/dashboard/commerce/orders?${params}`)
150
- // Only the newest request lands: a slower answer to an older search does
151
- // not overwrite the one for what is typed now.
152
- if (request !== listRequest)
153
- return
154
- records.set(Array.isArray(data.records) ? data.records : [])
155
- matchingTotal.set(Number(data.total) || 0)
156
- // The server moves back to the last page when a delete or a narrower
157
- // filter leaves this one past the end.
158
- page.set(Number(data.page) || 1)
159
- summary.set(data.summary ?? { ...emptySummary })
160
- statuses.set(Array.isArray(data.statuses) ? data.statuses : [])
161
- orderTypes.set(Array.isArray(data.orderTypes) ? data.orderTypes : [])
162
- defaultCurrency.set(data.defaultCurrency || 'USD')
163
- }
164
- catch (error) {
165
- if (request !== listRequest)
166
- return
167
- loadError.set('Order records could not be loaded.')
168
- pushToast('error', 'Could not load orders', {
169
- detail: error instanceof Error ? error.message : String(error),
170
- })
171
- }
172
- finally {
173
- if (request === listRequest)
174
- loading.set(false)
175
- }
176
- }
177
-
178
- function eventValue<T>(value: T | CustomEvent<T>): T {
179
- return value instanceof CustomEvent ? value.detail : value
180
- }
181
-
182
- function changePage(value: number | CustomEvent<number>): void {
183
- page.set(Number(eventValue(value)) || 1)
184
- void loadOrders()
185
- }
186
-
187
- function changePageSize(value: number | CustomEvent<number>): void {
188
- perPage.set(Number(eventValue(value)) || 25)
189
- page.set(1)
190
- void loadOrders()
138
+ return `/api/dashboard/commerce/orders/export?${params()}`
191
139
  }
192
140
 
193
- function changeColumnSort(value: { key: string, direction: string } | CustomEvent<{ key: string, direction: string }>): void {
194
- const column = eventValue(value)
195
- const serverSort = COLUMN_SORTS[column.key]
196
- headerSort.set(serverSort ? { sort: serverSort, direction: column.direction === 'asc' ? 'asc' : 'desc' } : null)
197
- page.set(1)
198
- void loadOrders()
141
+ function loadOrders(): Promise<void> {
142
+ return load()
199
143
  }
200
144
 
201
- // The filters and the select ask the server for page 1 when they change, and
202
- // the search once typing pauses. A select change also hands the order back
203
- // from a column header.
204
- let shownFilters = JSON.stringify([statusFilter(), typeFilter(), sort()])
205
- effect(() => {
206
- const filters = JSON.stringify([statusFilter(), typeFilter(), sort()])
207
- if (filters === shownFilters)
208
- return
209
- const sortChanged = JSON.parse(shownFilters)[2] !== sort()
210
- shownFilters = filters
211
- if (sortChanged)
212
- headerSort.set(null)
213
- page.set(1)
214
- void loadOrders()
215
- })
216
-
217
- let shownSearch = search().trim()
218
- effect(() => {
219
- const term = search().trim()
220
- if (term === shownSearch)
221
- return
222
- shownSearch = term
223
- if (searchTimer)
224
- clearTimeout(searchTimer)
225
- searchTimer = setTimeout(() => {
226
- appliedSearch.set(term)
227
- page.set(1)
228
- void loadOrders()
229
- }, 250)
230
- })
231
-
232
145
  function openAdd(): void {
233
146
  dialogMode.set('add')
234
147
  editingRecord.set(null)
@@ -323,7 +236,7 @@ onMount(() => {
323
236
  })
324
237
  </script>
325
238
 
326
- <div class="space-y-6">
239
+ <div class="flex flex-col gap-6">
327
240
  <PageHeader title="Orders" description="Manage native Order records, customer assignments, totals, and fulfillment state.">
328
241
  <div class="flex flex-wrap gap-2">
329
242
  <Button variant="secondary" :loading="loading()" @click="loadOrders()"><span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>Refresh</Button>
@@ -338,18 +251,18 @@ onMount(() => {
338
251
 
339
252
  <section :if="summary().currencyTotals.length > 0" aria-label="Order currency totals" class="flex flex-wrap gap-2 items-center">
340
253
  <span class="text-gray-500 text-xs dark:text-neutral-400">Recorded order value</span>
341
- <template :for="total in summary().currencyTotals" :key="total.currency"><span class="px-2.5 py-1 font-medium text-gray-700 text-xs dark:text-neutral-200 bg-white dark:bg-neutral-800 border border-gray-200 rounded-full dark:border-neutral-700">{{ formatMoney(total.amount, total.currency) }}</span></template>
254
+ <span :for="value in summary().currencyTotals" :key="value.currency" class="px-2.5 py-1 font-medium text-gray-700 text-xs dark:text-neutral-200 bg-white dark:bg-neutral-800 border border-gray-200 rounded-full dark:border-neutral-700">{{ formatMoney(value.amount, value.currency) }}</span>
342
255
  </section>
343
256
 
344
- <section class="space-y-3">
257
+ <section class="flex flex-col gap-3">
345
258
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-5">
346
259
  <label class="relative sm:col-span-2">
347
260
  <span class="sr-only">Search orders</span>
348
261
  <span class="flex absolute inset-y-0 left-0 items-center pl-3 text-gray-400 pointer-events-none"><span class="h-4 w-4 i-hugeicons-search-01"></span></span>
349
262
  <input x-model="search" type="search" placeholder="Search order, customer, status, or address" class="pl-9 pr-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700" />
350
263
  </label>
351
- <label><span class="sr-only">Order status</span><select x-model="statusFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">Any status</option><template :for="option in statuses()" :key="option"><option :value="option">{{ label(option) }}</option></template></select></label>
352
- <label><span class="sr-only">Order type</span><select x-model="typeFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">Any order type</option><template :for="option in orderTypes()" :key="option"><option :value="option">{{ label(option) }}</option></template></select></label>
264
+ <label><span class="sr-only">Order status</span><select x-model="statusFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">Any status</option><option :for="option in statuses()" :key="option" :value="option">{{ label(option) }}</option></select></label>
265
+ <label><span class="sr-only">Order type</span><select x-model="typeFilter" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="all">Any order type</option><option :for="option in orderTypes()" :key="option" :value="option">{{ label(option) }}</option></select></label>
353
266
  <label><span class="sr-only">Sort orders</span><select x-model="sort" class="px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-800 border border-gray-300 rounded-md dark:border-neutral-700"><option value="newest">Newest first</option><option value="oldest">Oldest first</option><option value="total-high">Highest total</option><option value="total-low">Lowest total</option></select></label>
354
267
  </div>
355
268
 
@@ -357,7 +270,7 @@ onMount(() => {
357
270
  <p class="text-gray-500 text-sm dark:text-neutral-400">{{ matchingLabel() }}</p>
358
271
  </div>
359
272
 
360
- <CommerceOrdersTable :sort-reset-key="sort()" :records="records()" :total="matchingTotal()" :current-page="page()" :per-page="perPage()" :loading="loading()" @view="openDetails" @edit="openEdit" @delete="openDelete" @page-change="changePage" @page-size-change="changePageSize" @sort="changeColumnSort" />
273
+ <CommerceOrdersTable :sort-reset-key="sort()" :records="records()" :total="total()" :current-page="page()" :per-page="perPage()" :loading="loading()" @view="openDetails" @edit="openEdit" @delete="openDelete" @page-change="changePage" @page-size-change="changePageSize" @sort="changeSort" />
361
274
  </section>
362
275
  </div>
363
276
 
@@ -59,9 +59,9 @@ const COLUMNS = [
59
59
  ]
60
60
 
61
61
  const ROW_ACTIONS = [
62
- { action: 'view', label: 'View order', icon: 'i-hugeicons-view' },
63
- { action: 'edit', label: 'Edit order', icon: 'i-hugeicons-edit-02' },
64
- { action: 'delete', label: 'Delete order', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
62
+ { action: 'view', label: 'View order' },
63
+ { action: 'edit', label: 'Edit order' },
64
+ { action: 'delete', label: 'Delete order' },
65
65
  ]
66
66
 
67
67
  const rows = derived(() => records().map(record => ({
@@ -61,7 +61,7 @@ onMount(() => {
61
61
  })
62
62
  </script>
63
63
 
64
- <div class="space-y-8">
64
+ <div class="flex flex-col gap-8">
65
65
  <PageHeader title="Commerce Dashboard" :description="`Persisted order performance for ${rangeLabel().toLowerCase()}.`">
66
66
  <div class="flex gap-2">
67
67
  <Button variant="secondary" :loading="loading()" @click="loadDashboard">
@@ -64,17 +64,15 @@ function statusClass(status: string): string {
64
64
  </tr>
65
65
  </thead>
66
66
  <tbody class="divide-gray-100 divide-y dark:divide-neutral-700">
67
- <template :for="order in orders()" :key="order.id">
68
- <tr>
69
- <td class="px-5 py-3 font-medium font-mono text-gray-900 text-sm whitespace-nowrap dark:text-white">{{ order.id }}</td>
70
- <td class="px-5 py-3 text-gray-600 text-sm dark:text-neutral-300">{{ order.customer }}</td>
71
- <td class="px-5 py-3 font-medium text-gray-700 text-right text-sm whitespace-nowrap dark:text-neutral-200">{{ order.total }}</td>
72
- <td class="px-5 py-3">
73
- <span :class="'inline-flex px-2 py-1 font-medium text-xs capitalize rounded-full ' + statusClass(order.status)">{{ order.status.toLowerCase() }}</span>
74
- </td>
75
- <td class="px-5 py-3 text-gray-500 text-right text-sm whitespace-nowrap dark:text-neutral-400">{{ formatRelativeTime(order.createdAt) }}</td>
76
- </tr>
77
- </template>
67
+ <tr :for="order in orders()" :key="order.id">
68
+ <td class="px-5 py-3 font-medium font-mono text-gray-900 text-sm whitespace-nowrap dark:text-white">{{ order.id }}</td>
69
+ <td class="px-5 py-3 text-gray-600 text-sm dark:text-neutral-300">{{ order.customer }}</td>
70
+ <td class="px-5 py-3 font-medium text-gray-700 text-right text-sm whitespace-nowrap dark:text-neutral-200">{{ order.total }}</td>
71
+ <td class="px-5 py-3">
72
+ <span :class="'inline-flex px-2 py-1 font-medium text-xs capitalize rounded-full ' + statusClass(order.status)">{{ order.status.toLowerCase() }}</span>
73
+ </td>
74
+ <td class="px-5 py-3 text-gray-500 text-right text-sm whitespace-nowrap dark:text-neutral-400">{{ formatRelativeTime(order.createdAt) }}</td>
75
+ </tr>
78
76
  </tbody>
79
77
  </table>
80
78
  </div>
@@ -28,13 +28,11 @@ const loading = useReactiveProp('loading', false)
28
28
  </tr>
29
29
  </thead>
30
30
  <tbody class="divide-gray-100 divide-y dark:divide-neutral-700">
31
- <template :for="product in products()" :key="product.id">
32
- <tr>
33
- <td class="px-5 py-3 font-medium text-gray-900 text-sm dark:text-white">{{ product.name }}</td>
34
- <td class="px-5 py-3 font-mono text-gray-600 text-right text-sm dark:text-neutral-300">{{ product.sales }}</td>
35
- <td class="px-5 py-3 font-medium text-gray-700 text-right text-sm dark:text-neutral-200">{{ product.revenue }}</td>
36
- </tr>
37
- </template>
31
+ <tr :for="product in products()" :key="product.id">
32
+ <td class="px-5 py-3 font-medium text-gray-900 text-sm dark:text-white">{{ product.name }}</td>
33
+ <td class="px-5 py-3 font-mono text-gray-600 text-right text-sm dark:text-neutral-300">{{ product.sales }}</td>
34
+ <td class="px-5 py-3 font-medium text-gray-700 text-right text-sm dark:text-neutral-200">{{ product.revenue }}</td>
35
+ </tr>
38
36
  </tbody>
39
37
  </table>
40
38
  </div>