@stacksjs/defaults 0.75.529 → 0.75.537

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 +6 -6
  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
@@ -6,6 +6,7 @@ import type {
6
6
  ProductWritePayload,
7
7
  } from '../../../../app/Actions/Dashboard/Commerce/commerce-product-records'
8
8
  import { DashboardApiError, dashboardApi } from '../../../../functions/dashboard-api'
9
+ import { useServerList } from '../../../../functions/dashboard-list'
9
10
  import { pushToast } from '../../../../functions/toasts'
10
11
 
11
12
  interface ProductIndexResponse {
@@ -26,27 +27,13 @@ const emptySummary: CommerceProductSummary = {
26
27
  outOfStock: 0,
27
28
  totalInventory: 0,
28
29
  }
29
- const records = state<CommerceProductRecord[]>([])
30
30
  const summary = state<CommerceProductSummary>({ ...emptySummary })
31
31
  const categories = state<ProductOption[]>([])
32
32
  const manufacturers = state<ProductOption[]>([])
33
33
  const defaultCurrency = state('USD')
34
- const search = state('')
35
34
  const categoryFilter = state('all')
36
35
  const availabilityFilter = state('all')
37
36
  const sort = state('newest')
38
- // The server's answer for the current search and filters
39
- // (stacksjs/stacks#3218): it searches, filters, sorts and pages every product,
40
- // where this page used to do all of that with the newest 500.
41
- const matchingTotal = state(0)
42
- const page = state(1)
43
- const perPage = state(25)
44
- const appliedSearch = state('')
45
- const headerSort = state<{ sort: string, direction: string } | null>(null)
46
- let listRequest = 0
47
- let searchTimer: ReturnType<typeof setTimeout> | null = null
48
- const loading = state(true)
49
- const loadError = state('')
50
37
  const dialogOpen = state(false)
51
38
  const dialogMode = state<'add' | 'edit'>('add')
52
39
  const editingRecord = state<CommerceProductRecord | null>(null)
@@ -56,7 +43,7 @@ const deleting = state(false)
56
43
  const validationErrors = state<Record<string, string>>({})
57
44
 
58
45
  /** The select's orders, as the server's sort and direction. */
59
- const SELECT_SORTS: Record<string, { sort: string, direction: string }> = {
46
+ const SELECT_SORTS: Record<string, { sort: string, direction: 'asc' | 'desc' }> = {
60
47
  'newest': { sort: 'created', direction: 'desc' },
61
48
  'oldest': { sort: 'created', direction: 'asc' },
62
49
  'name': { sort: 'name', direction: 'asc' },
@@ -74,24 +61,40 @@ const COLUMN_SORTS: Record<string, string> = {
74
61
  availability: 'available',
75
62
  }
76
63
 
77
- /** The search, filters and order, as the query the server takes. */
78
- function filterParams(): URLSearchParams {
79
- const params = new URLSearchParams()
80
- const order = headerSort() ?? SELECT_SORTS[sort()] ?? SELECT_SORTS.newest
81
- params.set('sort', order.sort)
82
- params.set('direction', order.direction)
83
- if (appliedSearch())
84
- params.set('q', appliedSearch())
85
- if (categoryFilter() !== 'all')
86
- params.set('category', categoryFilter())
87
- if (availabilityFilter() !== 'all')
88
- params.set('availability', availabilityFilter())
89
- return params
90
- }
64
+ // The server searches, filters, sorts and pages (stacksjs/stacks#3218);
65
+ // useServerList keeps the request order, paging, header sort and search
66
+ // debounce this page used to keep itself.
67
+ const {
68
+ records,
69
+ total,
70
+ page,
71
+ perPage,
72
+ search,
73
+ loading,
74
+ loadError,
75
+ params,
76
+ load,
77
+ changePage,
78
+ changePageSize,
79
+ changeSort,
80
+ } = useServerList<CommerceProductRecord>({
81
+ fetch: query => dashboardApi<ProductIndexResponse>(`/api/dashboard/commerce/products?${query}`),
82
+ defaultSort: () => SELECT_SORTS[sort()] ?? SELECT_SORTS["newest"]!,
83
+ columnSorts: COLUMN_SORTS,
84
+ filters: () => ({ category: categoryFilter(), availability: availabilityFilter() }),
85
+ onLoad: (result) => {
86
+ const data = result as ProductIndexResponse
87
+ summary.set(data.summary ?? { ...emptySummary })
88
+ categories.set(Array.isArray(data.categories) ? data.categories : [])
89
+ manufacturers.set(Array.isArray(data.manufacturers) ? data.manufacturers : [])
90
+ defaultCurrency.set(data.defaultCurrency || 'USD')
91
+ },
92
+ onError: error => pushToast('error', "Could not load products", { detail: error instanceof Error ? error.message : String(error) }),
93
+ })
91
94
 
92
95
  function matchingLabel(): string {
93
- const count = matchingTotal()
94
- return `${count} matching ${count === 1 ? 'product' : 'products'}`
96
+ const count = total()
97
+ return `${count.toLocaleString()} matching ${count === 1 ? 'product' : 'products'}`
95
98
  }
96
99
 
97
100
  function metricCards(): Array<{ label: string, value: string, detail: string }> {
@@ -107,97 +110,13 @@ function metricCards(): Array<{ label: string, value: string, detail: string }>
107
110
 
108
111
  /** Every matching product as CSV, built by the server, not just the page shown. */
109
112
  function exportHref(): string {
110
- return `/api/dashboard/commerce/products/export?${filterParams()}`
111
- }
112
-
113
- async function loadProducts(): Promise<void> {
114
- const request = ++listRequest
115
- loading.set(true)
116
- loadError.set('')
117
- try {
118
- const params = filterParams()
119
- params.set('page', String(page()))
120
- params.set('per_page', String(perPage()))
121
- const data = await dashboardApi<ProductIndexResponse>(`/api/dashboard/commerce/products?${params}`)
122
- // Only the newest request lands.
123
- if (request !== listRequest)
124
- return
125
- records.set(Array.isArray(data.records) ? data.records : [])
126
- matchingTotal.set(Number(data.total) || 0)
127
- page.set(Number(data.page) || 1)
128
- summary.set(data.summary ?? { ...emptySummary })
129
- categories.set(Array.isArray(data.categories) ? data.categories : [])
130
- manufacturers.set(Array.isArray(data.manufacturers) ? data.manufacturers : [])
131
- defaultCurrency.set(data.defaultCurrency || 'USD')
132
- }
133
- catch (error) {
134
- if (request !== listRequest)
135
- return
136
- loadError.set('Product records could not be loaded.')
137
- pushToast('error', 'Could not load products', {
138
- detail: error instanceof Error ? error.message : String(error),
139
- })
140
- }
141
- finally {
142
- if (request === listRequest)
143
- loading.set(false)
144
- }
145
- }
146
-
147
- function eventValue<T>(value: T | CustomEvent<T>): T {
148
- return value instanceof CustomEvent ? value.detail : value
149
- }
150
-
151
- function changePage(value: number | CustomEvent<number>): void {
152
- page.set(Number(eventValue(value)) || 1)
153
- void loadProducts()
154
- }
155
-
156
- function changePageSize(value: number | CustomEvent<number>): void {
157
- perPage.set(Number(eventValue(value)) || 25)
158
- page.set(1)
159
- void loadProducts()
113
+ return `/api/dashboard/commerce/products/export?${params()}`
160
114
  }
161
115
 
162
- function changeColumnSort(value: { key: string, direction: string } | CustomEvent<{ key: string, direction: string }>): void {
163
- const column = eventValue(value)
164
- const serverSort = COLUMN_SORTS[column.key]
165
- headerSort.set(serverSort ? { sort: serverSort, direction: column.direction === 'asc' ? 'asc' : 'desc' } : null)
166
- page.set(1)
167
- void loadProducts()
116
+ function loadProducts(): Promise<void> {
117
+ return load()
168
118
  }
169
119
 
170
- // The filters and the select ask the server for page 1 when they change, and
171
- // the search once typing pauses. A select change hands the order back from a
172
- // column header.
173
- let shownFilters = JSON.stringify([categoryFilter(), availabilityFilter(), sort()])
174
- effect(() => {
175
- const filters = JSON.stringify([categoryFilter(), availabilityFilter(), sort()])
176
- if (filters === shownFilters)
177
- return
178
- const sortChanged = JSON.parse(shownFilters)[2] !== sort()
179
- shownFilters = filters
180
- if (sortChanged)
181
- headerSort.set(null)
182
- page.set(1)
183
- void loadProducts()
184
- })
185
-
186
- let shownSearch = search().trim()
187
- effect(() => {
188
- const term = search().trim()
189
- if (term === shownSearch)
190
- return
191
- shownSearch = term
192
- if (searchTimer)
193
- clearTimeout(searchTimer)
194
- searchTimer = setTimeout(() => {
195
- appliedSearch.set(term)
196
- page.set(1)
197
- void loadProducts()
198
- }, 250)
199
- })
200
-
201
120
  function openAdd(): void {
202
121
  dialogMode.set('add')
203
122
  editingRecord.set(null)
@@ -286,7 +205,7 @@ onMount(() => {
286
205
  })
287
206
  </script>
288
207
 
289
- <div class="space-y-6">
208
+ <div class="flex flex-col gap-6">
290
209
  <PageHeader title="Products" description="Manage native Product records, commerce availability, inventory, and relationships.">
291
210
  <div class="flex flex-wrap gap-2">
292
211
  <Button variant="secondary" :loading="loading()" @click="loadProducts()"><span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>Refresh</Button>
@@ -299,14 +218,14 @@ onMount(() => {
299
218
 
300
219
  <MetricCards label="Product metrics" columns="grid-cols-2 lg:grid-cols-5" :items="metricCards()" />
301
220
 
302
- <section class="space-y-3">
221
+ <section class="flex flex-col gap-3">
303
222
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-5">
304
223
  <label class="relative sm:col-span-2">
305
224
  <span class="sr-only">Search products</span>
306
225
  <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>
307
226
  <input x-model="search" type="search" placeholder="Search name, category, manufacturer, or allergen" 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" />
308
227
  </label>
309
- <label><span class="sr-only">Product category</span><select x-model="categoryFilter" 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 category</option><template :for="option in categories()" :key="option.id"><option :value="option.id">{{ option.label }}</option></template></select></label>
228
+ <label><span class="sr-only">Product category</span><select x-model="categoryFilter" 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 category</option><option :for="option in categories()" :key="option.id" :value="option.id">{{ option.label }}</option></select></label>
310
229
  <label><span class="sr-only">Product availability</span><select x-model="availabilityFilter" 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 availability</option><option value="available">Available</option><option value="unavailable">Unavailable</option><option value="out-of-stock">Out of stock</option></select></label>
311
230
  <label><span class="sr-only">Sort products</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="name">Name</option><option value="price-high">Highest price</option><option value="price-low">Lowest price</option><option value="inventory-high">Highest inventory</option></select></label>
312
231
  </div>
@@ -315,7 +234,7 @@ onMount(() => {
315
234
  <p class="text-gray-500 text-sm dark:text-neutral-400">{{ matchingLabel() }}</p>
316
235
  </div>
317
236
 
318
- <CommerceProductsTable :sort-reset-key="sort()" :records="records()" :total="matchingTotal()" :current-page="page()" :per-page="perPage()" :loading="loading()" :currency="defaultCurrency()" @view="viewProduct" @edit="openEdit" @delete="openDelete" @page-change="changePage" @page-size-change="changePageSize" @sort="changeColumnSort" />
237
+ <CommerceProductsTable :sort-reset-key="sort()" :records="records()" :total="total()" :current-page="page()" :per-page="perPage()" :loading="loading()" :currency="defaultCurrency()" @view="viewProduct" @edit="openEdit" @delete="openDelete" @page-change="changePage" @page-size-change="changePageSize" @sort="changeSort" />
319
238
  </section>
320
239
  </div>
321
240
 
@@ -43,9 +43,9 @@ const COLUMNS = [
43
43
  ]
44
44
 
45
45
  const ROW_ACTIONS = [
46
- { action: 'view', label: 'View product', icon: 'i-hugeicons-view' },
47
- { action: 'edit', label: 'Edit product', icon: 'i-hugeicons-edit-02' },
48
- { action: 'delete', label: 'Delete product', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
46
+ { action: 'view', label: 'View product' },
47
+ { action: 'edit', label: 'Edit product' },
48
+ { action: 'delete', label: 'Delete product' },
49
49
  ]
50
50
 
51
51
  const rows = derived(() => records().map(record => ({
@@ -57,7 +57,7 @@ function errorMessages(): string[] {
57
57
  >
58
58
  <form id="review-form" @submit.prevent="submit">
59
59
  <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">
60
- <template :for="message in errorMessages()" :key="message"><li>{{ message }}</li></template>
60
+ <li :for="message in errorMessages()" :key="message">{{ message }}</li>
61
61
  </ul>
62
62
 
63
63
  <div class="space-y-4">
@@ -5,6 +5,7 @@ import type {
5
5
  ReviewSummary,
6
6
  } from '../../../../app/Actions/Dashboard/Commerce/review-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 ReviewIndexResponse {
@@ -38,25 +39,12 @@ const emptySummary: ReviewSummary = {
38
39
  averageRating: 0,
39
40
  }
40
41
 
41
- const records = state<ReviewRecord[]>([])
42
42
  const summary = state<ReviewSummary>({ ...emptySummary })
43
43
  const products = state<ReviewProductOption[]>([])
44
- const search = state('')
45
44
  const productFilter = state('all')
46
45
  const ratingFilter = state('all')
47
46
  const moderationFilter = state('all')
48
47
  const sort = state('newest')
49
- // The server searches, filters, sorts and pages (stacksjs/stacks#3218), where
50
- // this page used to do all of that with the newest 500.
51
- const matchingTotal = state(0)
52
- const page = state(1)
53
- const perPage = state(25)
54
- const appliedSearch = state('')
55
- const headerSort = state<{ sort: string, direction: string } | null>(null)
56
- let listRequest = 0
57
- let searchTimer: ReturnType<typeof setTimeout> | null = null
58
- const loading = state(true)
59
- const loadError = state('')
60
48
  const editingReview = state<ReviewRecord | null>(null)
61
49
  const deletingReview = state<ReviewRecord | null>(null)
62
50
  const saving = state(false)
@@ -64,7 +52,7 @@ const deleting = state(false)
64
52
  const busyId = state('')
65
53
  const validationErrors = state<Record<string, string>>({})
66
54
 
67
- const SELECT_SORTS: Record<string, { sort: string, direction: string }> = {
55
+ const SELECT_SORTS: Record<string, { sort: string, direction: 'asc' | 'desc' }> = {
68
56
  'newest': { sort: 'created', direction: 'desc' },
69
57
  'oldest': { sort: 'created', direction: 'asc' },
70
58
  'rating-high': { sort: 'rating', direction: 'desc' },
@@ -80,25 +68,37 @@ const COLUMN_SORTS: Record<string, string> = {
80
68
  moderation: 'approved',
81
69
  }
82
70
 
83
- /** The search, filters and order, as the query the server takes. */
84
- function filterParams(): URLSearchParams {
85
- const params = new URLSearchParams()
86
- const order = headerSort() ?? SELECT_SORTS[sort()] ?? SELECT_SORTS.newest
87
- params.set('sort', order.sort)
88
- params.set('direction', order.direction)
89
- if (appliedSearch())
90
- params.set('q', appliedSearch())
91
- if (productFilter() !== 'all')
92
- params.set('product', productFilter())
93
- if (ratingFilter() !== 'all')
94
- params.set('rating', ratingFilter())
95
- if (moderationFilter() !== 'all')
96
- params.set('moderation', moderationFilter())
97
- return params
98
- }
71
+ // The server searches, filters, sorts and pages (stacksjs/stacks#3218);
72
+ // useServerList keeps the request order, paging, header sort and search
73
+ // debounce this page used to keep itself.
74
+ const {
75
+ records,
76
+ total,
77
+ page,
78
+ perPage,
79
+ search,
80
+ loading,
81
+ loadError,
82
+ params,
83
+ load,
84
+ changePage,
85
+ changePageSize,
86
+ changeSort,
87
+ } = useServerList<ReviewRecord>({
88
+ fetch: query => dashboardApi<ReviewIndexResponse>(`/api/dashboard/commerce/reviews?${query}`),
89
+ defaultSort: () => SELECT_SORTS[sort()] ?? SELECT_SORTS["newest"]!,
90
+ columnSorts: COLUMN_SORTS,
91
+ filters: () => ({ product: productFilter(), rating: ratingFilter(), moderation: moderationFilter() }),
92
+ onLoad: (result) => {
93
+ const data = result as ReviewIndexResponse
94
+ summary.set(data.summary ?? { ...emptySummary })
95
+ products.set(Array.isArray(data.products) ? data.products : [])
96
+ },
97
+ onError: error => pushToast('error', "Could not load reviews", { detail: error instanceof Error ? error.message : String(error) }),
98
+ })
99
99
 
100
100
  function matchingLabel(): string {
101
- const count = matchingTotal()
101
+ const count = total()
102
102
  return `${count} matching ${count === 1 ? 'review' : 'reviews'}`
103
103
  }
104
104
 
@@ -112,92 +112,10 @@ function metricCards(): Array<{ label: string, value: string }> {
112
112
  ]
113
113
  }
114
114
 
115
- async function loadReviews(): Promise<void> {
116
- const request = ++listRequest
117
- loading.set(true)
118
- loadError.set('')
119
- try {
120
- const params = filterParams()
121
- params.set('page', String(page()))
122
- params.set('per_page', String(perPage()))
123
- const data = await dashboardApi<ReviewIndexResponse>(`/api/dashboard/commerce/reviews?${params}`)
124
- // Only the newest request lands.
125
- if (request !== listRequest)
126
- return
127
- records.set(Array.isArray(data.records) ? data.records : [])
128
- matchingTotal.set(Number(data.total) || 0)
129
- page.set(Number(data.page) || 1)
130
- summary.set(data.summary ?? { ...emptySummary })
131
- products.set(Array.isArray(data.products) ? data.products : [])
132
- }
133
- catch (error) {
134
- if (request !== listRequest)
135
- return
136
- loadError.set('Review records could not be loaded.')
137
- pushToast('error', 'Could not load reviews', {
138
- detail: error instanceof Error ? error.message : String(error),
139
- })
140
- }
141
- finally {
142
- if (request === listRequest)
143
- loading.set(false)
144
- }
145
- }
146
-
147
- function eventValue<T>(value: T | CustomEvent<T>): T {
148
- return value instanceof CustomEvent ? value.detail : value
115
+ function loadReviews(): Promise<void> {
116
+ return load()
149
117
  }
150
118
 
151
- function changePage(value: number | CustomEvent<number>): void {
152
- page.set(Number(eventValue(value)) || 1)
153
- void loadReviews()
154
- }
155
-
156
- function changePageSize(value: number | CustomEvent<number>): void {
157
- perPage.set(Number(eventValue(value)) || 25)
158
- page.set(1)
159
- void loadReviews()
160
- }
161
-
162
- function changeColumnSort(value: { key: string, direction: string } | CustomEvent<{ key: string, direction: string }>): void {
163
- const column = eventValue(value)
164
- const serverSort = COLUMN_SORTS[column.key]
165
- headerSort.set(serverSort ? { sort: serverSort, direction: column.direction === 'asc' ? 'asc' : 'desc' } : null)
166
- page.set(1)
167
- void loadReviews()
168
- }
169
-
170
- // The filters and the select ask the server for page 1 when they change, and
171
- // the search once typing pauses. A select change hands the order back from a
172
- // column header.
173
- let shownFilters = JSON.stringify([productFilter(), ratingFilter(), moderationFilter(), sort()])
174
- effect(() => {
175
- const filters = JSON.stringify([productFilter(), ratingFilter(), moderationFilter(), sort()])
176
- if (filters === shownFilters)
177
- return
178
- const sortChanged = JSON.parse(shownFilters)[3] !== sort()
179
- shownFilters = filters
180
- if (sortChanged)
181
- headerSort.set(null)
182
- page.set(1)
183
- void loadReviews()
184
- })
185
-
186
- let shownSearch = search().trim()
187
- effect(() => {
188
- const term = search().trim()
189
- if (term === shownSearch)
190
- return
191
- shownSearch = term
192
- if (searchTimer)
193
- clearTimeout(searchTimer)
194
- searchTimer = setTimeout(() => {
195
- appliedSearch.set(term)
196
- page.set(1)
197
- void loadReviews()
198
- }, 250)
199
- })
200
-
201
119
  async function patchReview(review: ReviewRecord, payload: Record<string, unknown>, successMessage: string): Promise<void> {
202
120
  busyId.set(review.id)
203
121
  try {
@@ -310,7 +228,7 @@ onMount(() => {
310
228
  })
311
229
  </script>
312
230
 
313
- <div class="space-y-6">
231
+ <div class="flex flex-col gap-6">
314
232
  <PageHeader :title="title()" :description="description()">
315
233
  <Button variant="secondary" :loading="loading()" @click="loadReviews">
316
234
  <span :if="!loading()" class="h-4 w-4 i-hugeicons-refresh"></span>
@@ -322,7 +240,7 @@ onMount(() => {
322
240
 
323
241
  <MetricCards label="Review metrics" columns="grid-cols-2 lg:grid-cols-5" :items="metricCards()" />
324
242
 
325
- <section class="space-y-3">
243
+ <section class="flex flex-col gap-3">
326
244
  <div class="grid gap-3 grid-cols-1 md:grid-cols-2 xl:grid-cols-5">
327
245
  <div class="relative xl:col-span-2">
328
246
  <label class="sr-only" for="review-search">Search reviews</label>
@@ -335,9 +253,7 @@ onMount(() => {
335
253
  <span class="sr-only">Product</span>
336
254
  <select x-model="productFilter" 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">
337
255
  <option value="all">All products</option>
338
- <template :for="product in products()" :key="product.id">
339
- <option :value="product.id">{{ product.label }}</option>
340
- </template>
256
+ <option :for="product in products()" :key="product.id" :value="product.id">{{ product.label }}</option>
341
257
  </select>
342
258
  </label>
343
259
  <label>
@@ -383,7 +299,7 @@ onMount(() => {
383
299
  <CommerceReviewsTable
384
300
  :sort-reset-key="sort()"
385
301
  :reviews="records()"
386
- :total="matchingTotal()"
302
+ :total="total()"
387
303
  :current-page="page()"
388
304
  :per-page="perPage()"
389
305
  :loading="loading()"
@@ -394,7 +310,7 @@ onMount(() => {
394
310
  @delete="openDelete"
395
311
  @page-change="changePage"
396
312
  @page-size-change="changePageSize"
397
- @sort="changeColumnSort"
313
+ @sort="changeSort"
398
314
  />
399
315
 
400
316
  </section>
@@ -59,8 +59,8 @@ const ROW_ACTIONS = [
59
59
  { action: 'approve', label: 'Return review to pending', icon: 'i-hugeicons-cancel-circle', class: 'text-green-500', when: { key: 'approved', equals: true } },
60
60
  { action: 'feature', label: 'Feature review', icon: 'i-hugeicons-star', class: 'text-amber-500', when: { key: 'featured', equals: false } },
61
61
  { action: 'feature', label: 'Remove review from featured', icon: 'i-hugeicons-star-off', class: 'text-amber-500', when: { key: 'featured', equals: true } },
62
- { action: 'edit', label: 'Edit review', icon: 'i-hugeicons-edit-01' },
63
- { action: 'delete', label: 'Delete review', icon: 'i-hugeicons-waste', class: 'text-red-500' },
62
+ { action: 'edit', label: 'Edit review' },
63
+ { action: 'delete', label: 'Delete review' },
64
64
  ]
65
65
 
66
66
  const rows = derived(() => reviews().map(review => ({
@@ -73,7 +73,7 @@ function errorMessages(): string[] {
73
73
  >
74
74
  <form id="tax-rate-form" @submit.prevent="submit">
75
75
  <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">
76
- <template :for="message in errorMessages()" :key="message"><li>{{ message }}</li></template>
76
+ <li :for="message in errorMessages()" :key="message">{{ message }}</li>
77
77
  </ul>
78
78
  <div class="space-y-4">
79
79
  <label class="block">
@@ -88,7 +88,7 @@ function errorMessages(): string[] {
88
88
  <label class="block">
89
89
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Type</span>
90
90
  <input x-model="type" type="text" list="tax-rate-types" maxlength="100" 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" />
91
- <datalist id="tax-rate-types"><template :for="taxType in types()" :key="taxType"><option :value="taxType"></option></template></datalist>
91
+ <datalist id="tax-rate-types"><option :for="taxType in types()" :key="taxType" :value="taxType"></option></datalist>
92
92
  </label>
93
93
  </div>
94
94
  <label class="block">
@@ -99,7 +99,7 @@ function errorMessages(): string[] {
99
99
  <label class="block">
100
100
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Region</span>
101
101
  <select x-model="region" 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">
102
- <template :for="regionOption in regions" :key="regionOption"><option :value="regionOption">{{ regionOption }}</option></template>
102
+ <option :for="regionOption in regions" :key="regionOption" :value="regionOption">{{ regionOption }}</option>
103
103
  </select>
104
104
  </label>
105
105
  <label class="block">
@@ -1,5 +1,6 @@
1
1
  <script client>
2
2
  import type { TaxRateRecord, TaxRateSummary } from '../../../../app/Actions/Dashboard/Commerce/tax-rate-records'
3
+ import { taxTypeLabel } from '../../../../functions/commerce/tax-types'
3
4
  import { DashboardApiError, dashboardApi } from '../../../../functions/dashboard-api'
4
5
  import { pushToast } from '../../../../functions/toasts'
5
6
 
@@ -202,7 +203,7 @@ onMount(() => {
202
203
  })
203
204
  </script>
204
205
 
205
- <div class="space-y-6">
206
+ <div class="flex flex-col gap-6">
206
207
  <PageHeader title="Tax rates" description="Manage native TaxRate records used by commerce calculations.">
207
208
  <div class="flex gap-2">
208
209
  <Button variant="secondary" :loading="loading()" @click="loadTaxes">
@@ -224,7 +225,7 @@ onMount(() => {
224
225
 
225
226
  <MetricCards label="Tax rate metrics" columns="grid-cols-2 lg:grid-cols-4" :items="metricCards()" />
226
227
 
227
- <section class="space-y-3">
228
+ <section class="flex flex-col gap-3">
228
229
  <div class="grid gap-3 grid-cols-1 sm:grid-cols-2 xl:grid-cols-5">
229
230
  <label class="relative sm:col-span-2">
230
231
  <span class="sr-only">Search tax rates</span>
@@ -243,14 +244,14 @@ onMount(() => {
243
244
  <span class="sr-only">Tax country</span>
244
245
  <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">
245
246
  <option value="all">All countries</option>
246
- <template :for="country in countries()" :key="country"><option :value="country">{{ country }}</option></template>
247
+ <option :for="country in countries()" :key="country" :value="country">{{ country }}</option>
247
248
  </select>
248
249
  </label>
249
250
  <label>
250
251
  <span class="sr-only">Tax type</span>
251
252
  <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">
252
253
  <option value="all">All tax types</option>
253
- <template :for="type in taxTypes()" :key="type"><option :value="type">{{ type }}</option></template>
254
+ <option :for="type in taxTypes()" :key="type" :value="type">{{ taxTypeLabel(type) }}</option>
254
255
  </select>
255
256
  </label>
256
257
  </div>
@@ -2,6 +2,7 @@
2
2
 
3
3
  <script client>
4
4
  import type { TaxRateRecord } from '../../../../app/Actions/Dashboard/Commerce/tax-rate-records'
5
+ import { taxTypeLabel } from '../../../../functions/commerce/tax-types'
5
6
 
6
7
  const records = useReactiveProp('records', [] as TaxRateRecord[])
7
8
  const loading = useReactiveProp('loading', false)
@@ -31,8 +32,8 @@ const COLUMNS = [
31
32
  ]
32
33
 
33
34
  const ROW_ACTIONS = [
34
- { action: 'edit', label: 'Edit', icon: 'i-hugeicons-edit-01' },
35
- { action: 'delete', label: 'Delete', icon: 'i-hugeicons-delete-02', class: 'text-red-500' },
35
+ { action: 'edit', label: 'Edit' },
36
+ { action: 'delete', label: 'Delete' },
36
37
  ]
37
38
 
38
39
  const rows = derived(() => records().map(record => ({
@@ -71,6 +72,6 @@ function handleRowAction(payload: { action: string, row: TaxRateRecord }): void
71
72
  <span :if="row.code" class="px-2 py-0.5 font-mono text-gray-600 text-xs dark:text-neutral-300 bg-gray-100 dark:bg-neutral-700 rounded-full" x-text="row.code"></span>
72
73
  <span :if="row.exemptible" class="px-2 py-0.5 font-medium text-amber-700 text-xs dark:text-amber-300 bg-amber-50 dark:bg-amber-950/40 rounded-full" x-tooltip="Not charged to a customer who qualifies for an exemption" title="Not charged to a customer who qualifies for an exemption">Exemptible</span>
73
74
  </div>
74
- <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400" x-text="row.type"></p>
75
+ <p class="mt-1 text-gray-500 text-xs dark:text-neutral-400" x-text="taxTypeLabel(row.type || '')"></p>
75
76
  </template>
76
77
  </Table>
@@ -117,7 +117,7 @@ function errorMessages(): string[] {
117
117
  >
118
118
  <form id="product-unit-form" @submit.prevent="submit">
119
119
  <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">
120
- <template :for="message in errorMessages()" :key="message"><li>{{ message }}</li></template>
120
+ <li :for="message in errorMessages()" :key="message">{{ message }}</li>
121
121
  </ul>
122
122
  <div class="space-y-4">
123
123
  <div class="grid gap-4 sm:grid-cols-2">
@@ -134,9 +134,7 @@ function errorMessages(): string[] {
134
134
  <span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Type</span>
135
135
  <input x-model="type" type="text" list="product-unit-types" 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" />
136
136
  <datalist id="product-unit-types">
137
- <template :for="unitType in types()" :key="unitType">
138
- <option :value="unitType"></option>
139
- </template>
137
+ <option :for="unitType in types()" :key="unitType" :value="unitType"></option>
140
138
  </datalist>
141
139
  </label>
142
140
  <label class="block">
@@ -146,9 +144,7 @@ function errorMessages(): string[] {
146
144
  <div>
147
145
  <select x-model="productId" aria-label="Product" class="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">
148
146
  <option value="">Unassigned</option>
149
- <template :for="product in products()" :key="product.id">
150
- <option :value="product.id" :selected="product.id === productId()">{{ product.label }}</option>
151
- </template>
147
+ <option :for="product in products()" :key="product.id" :value="product.id" :selected="product.id === productId()">{{ product.label }}</option>
152
148
  </select>
153
149
  <p :if="moreProductsLabel()" class="mt-1 text-gray-500 text-xs dark:text-neutral-400" :text="moreProductsLabel()"></p>
154
150
  </div>