@mohasinac/appkit 2.7.59 → 2.8.1

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 (324) hide show
  1. package/dist/_internal/client/features/filters/filter-load-options.d.ts +4 -5
  2. package/dist/_internal/server/features/auctions/og.js +8 -32
  3. package/dist/_internal/server/features/blog/og.js +10 -49
  4. package/dist/_internal/server/features/checkout/actions.js +6 -0
  5. package/dist/_internal/server/features/classified/og.js +9 -51
  6. package/dist/_internal/server/features/digital-code/actions.d.ts +11 -0
  7. package/dist/_internal/server/features/digital-code/actions.js +30 -0
  8. package/dist/_internal/server/features/digital-code/index.d.ts +1 -0
  9. package/dist/_internal/server/features/digital-code/index.js +1 -0
  10. package/dist/_internal/server/features/digital-code/og.js +9 -51
  11. package/dist/_internal/server/features/events/og.js +10 -49
  12. package/dist/_internal/server/features/item-requests/data.d.ts +17 -0
  13. package/dist/_internal/server/features/item-requests/data.js +20 -0
  14. package/dist/_internal/server/features/item-requests/index.d.ts +2 -0
  15. package/dist/_internal/server/features/item-requests/index.js +2 -0
  16. package/dist/_internal/server/features/item-requests/og.d.ts +40 -0
  17. package/dist/_internal/server/features/item-requests/og.js +136 -0
  18. package/dist/_internal/server/features/live/actions.d.ts +5 -0
  19. package/dist/_internal/server/features/live/actions.js +24 -0
  20. package/dist/_internal/server/features/live/index.d.ts +1 -0
  21. package/dist/_internal/server/features/live/index.js +1 -0
  22. package/dist/_internal/server/features/live/og.js +9 -51
  23. package/dist/_internal/server/features/media/contextGuards.js +19 -8
  24. package/dist/_internal/server/features/pre-orders/og.js +8 -32
  25. package/dist/_internal/server/features/prize-draws/data.d.ts +17 -0
  26. package/dist/_internal/server/features/prize-draws/data.js +20 -0
  27. package/dist/_internal/server/features/prize-draws/index.d.ts +2 -0
  28. package/dist/_internal/server/features/prize-draws/index.js +2 -0
  29. package/dist/_internal/server/features/prize-draws/og.d.ts +30 -0
  30. package/dist/_internal/server/features/prize-draws/og.js +50 -0
  31. package/dist/_internal/server/features/products/og.js +8 -33
  32. package/dist/_internal/server/features/seo/og-layout.d.ts +42 -0
  33. package/dist/_internal/server/features/seo/og-layout.js +69 -0
  34. package/dist/_internal/server/features/stores/og.js +8 -41
  35. package/dist/_internal/server/features/sublisting-categories/og.js +11 -42
  36. package/dist/client.d.ts +10 -6
  37. package/dist/client.js +7 -3
  38. package/dist/constants/index.d.ts +4 -0
  39. package/dist/constants/index.js +2 -0
  40. package/dist/constants/notification-types.d.ts +20 -0
  41. package/dist/constants/notification-types.js +37 -0
  42. package/dist/constants/pagination-presets.d.ts +39 -0
  43. package/dist/constants/pagination-presets.js +38 -0
  44. package/dist/errors/messages.d.ts +0 -4
  45. package/dist/errors/messages.js +0 -4
  46. package/dist/features/about/components/PublicProfileView.js +8 -8
  47. package/dist/features/account/components/UserOffersPanel.js +1 -1
  48. package/dist/features/account/components/UserSupportView.d.ts +1 -2
  49. package/dist/features/account/components/UserSupportView.js +9 -1
  50. package/dist/features/admin/actions/admin-actions.js +16 -1
  51. package/dist/features/admin/components/AdminAllEventEntriesView.d.ts +2 -3
  52. package/dist/features/admin/components/AdminAllEventEntriesView.js +50 -83
  53. package/dist/features/admin/components/AdminBidsView.d.ts +2 -3
  54. package/dist/features/admin/components/AdminBidsView.js +64 -98
  55. package/dist/features/admin/components/AdminBlogView.d.ts +3 -7
  56. package/dist/features/admin/components/AdminBlogView.js +53 -83
  57. package/dist/features/admin/components/AdminBrandsView.d.ts +2 -3
  58. package/dist/features/admin/components/AdminBrandsView.js +84 -83
  59. package/dist/features/admin/components/AdminBundlesView.js +82 -125
  60. package/dist/features/admin/components/AdminCarouselView.d.ts +2 -2
  61. package/dist/features/admin/components/AdminCarouselView.js +17 -52
  62. package/dist/features/admin/components/AdminCartsView.d.ts +2 -3
  63. package/dist/features/admin/components/AdminCartsView.js +39 -88
  64. package/dist/features/admin/components/AdminCategoriesView.d.ts +3 -3
  65. package/dist/features/admin/components/AdminCategoriesView.js +98 -92
  66. package/dist/features/admin/components/AdminCategoryEditorView.js +2 -2
  67. package/dist/features/admin/components/AdminClassifiedView.d.ts +3 -0
  68. package/dist/features/admin/components/AdminClassifiedView.js +44 -0
  69. package/dist/features/admin/components/AdminContactView.d.ts +2 -2
  70. package/dist/features/admin/components/AdminContactView.js +104 -111
  71. package/dist/features/admin/components/AdminCouponsView.d.ts +3 -6
  72. package/dist/features/admin/components/AdminCouponsView.js +66 -86
  73. package/dist/features/admin/components/AdminDigitalCodesView.d.ts +3 -0
  74. package/dist/features/admin/components/AdminDigitalCodesView.js +51 -0
  75. package/dist/features/admin/components/AdminFaqsView.d.ts +4 -4
  76. package/dist/features/admin/components/AdminFaqsView.js +77 -33
  77. package/dist/features/admin/components/AdminFeaturesView.d.ts +2 -3
  78. package/dist/features/admin/components/AdminFeaturesView.js +57 -70
  79. package/dist/features/admin/components/AdminGroupedListingsView.d.ts +3 -0
  80. package/dist/features/admin/components/AdminGroupedListingsView.js +43 -0
  81. package/dist/features/admin/components/AdminHistoryView.d.ts +2 -3
  82. package/dist/features/admin/components/AdminHistoryView.js +35 -52
  83. package/dist/features/admin/components/AdminListingScaffold.d.ts +2 -2
  84. package/dist/features/admin/components/AdminListingScaffold.js +3 -3
  85. package/dist/features/admin/components/AdminLiveView.d.ts +3 -0
  86. package/dist/features/admin/components/AdminLiveView.js +50 -0
  87. package/dist/features/admin/components/AdminNewsletterView.d.ts +2 -2
  88. package/dist/features/admin/components/AdminNewsletterView.js +67 -97
  89. package/dist/features/admin/components/AdminNotificationsView.d.ts +2 -3
  90. package/dist/features/admin/components/AdminNotificationsView.js +67 -93
  91. package/dist/features/admin/components/AdminOrderEditorView.js +10 -10
  92. package/dist/features/admin/components/AdminOrdersView.d.ts +2 -3
  93. package/dist/features/admin/components/AdminOrdersView.js +93 -107
  94. package/dist/features/admin/components/AdminPayoutsView.d.ts +2 -3
  95. package/dist/features/admin/components/AdminPayoutsView.js +51 -91
  96. package/dist/features/admin/components/AdminPrizeDrawsView.d.ts +2 -3
  97. package/dist/features/admin/components/AdminPrizeDrawsView.js +39 -76
  98. package/dist/features/admin/components/AdminProductEditorView.js +3 -3
  99. package/dist/features/admin/components/AdminProductsView.d.ts +4 -4
  100. package/dist/features/admin/components/AdminProductsView.js +167 -163
  101. package/dist/features/admin/components/AdminReturnRequestsView.d.ts +1 -1
  102. package/dist/features/admin/components/AdminReturnRequestsView.js +64 -66
  103. package/dist/features/admin/components/AdminReviewsView.d.ts +3 -7
  104. package/dist/features/admin/components/AdminReviewsView.js +94 -110
  105. package/dist/features/admin/components/AdminScammersView.d.ts +2 -3
  106. package/dist/features/admin/components/AdminScammersView.js +53 -97
  107. package/dist/features/admin/components/AdminSectionsView.js +1 -1
  108. package/dist/features/admin/components/AdminSessionsView.d.ts +2 -3
  109. package/dist/features/admin/components/AdminSessionsView.js +62 -89
  110. package/dist/features/admin/components/AdminSiteSettingsView.js +4 -5
  111. package/dist/features/admin/components/AdminStoreAddressesView.d.ts +1 -1
  112. package/dist/features/admin/components/AdminStoreAddressesView.js +39 -53
  113. package/dist/features/admin/components/AdminStoreEditorView.js +21 -8
  114. package/dist/features/admin/components/AdminStoresView.d.ts +2 -3
  115. package/dist/features/admin/components/AdminStoresView.js +67 -99
  116. package/dist/features/admin/components/AdminSublistingCategoriesView.d.ts +1 -1
  117. package/dist/features/admin/components/AdminSublistingCategoriesView.js +28 -44
  118. package/dist/features/admin/components/AdminSupportTicketDetailView.d.ts +10 -1
  119. package/dist/features/admin/components/AdminSupportTicketDetailView.js +191 -5
  120. package/dist/features/admin/components/AdminSupportTicketsView.d.ts +2 -3
  121. package/dist/features/admin/components/AdminSupportTicketsView.js +65 -96
  122. package/dist/features/admin/components/AdminTeamView.d.ts +2 -2
  123. package/dist/features/admin/components/AdminTeamView.js +40 -74
  124. package/dist/features/admin/components/AdminUserEditorView.d.ts +11 -1
  125. package/dist/features/admin/components/AdminUserEditorView.js +77 -7
  126. package/dist/features/admin/components/AdminUsersView.d.ts +2 -3
  127. package/dist/features/admin/components/AdminUsersView.js +108 -100
  128. package/dist/features/admin/components/AdminViewCards.d.ts +1 -1
  129. package/dist/features/admin/components/AdminViewCards.js +15 -15
  130. package/dist/features/admin/components/AdminWishlistsView.d.ts +2 -3
  131. package/dist/features/admin/components/AdminWishlistsView.js +36 -62
  132. package/dist/features/admin/components/DataListingView.d.ts +122 -0
  133. package/dist/features/admin/components/DataListingView.js +66 -0
  134. package/dist/features/admin/components/index.d.ts +10 -4
  135. package/dist/features/admin/components/index.js +6 -2
  136. package/dist/features/admin/constants/filter-tabs.d.ts +23 -17
  137. package/dist/features/admin/constants/filter-tabs.js +21 -17
  138. package/dist/features/admin/hooks/useAdminListing.d.ts +1 -0
  139. package/dist/features/admin/hooks/useAdminListing.js +1 -1
  140. package/dist/features/admin/schemas/firestore.js +6 -7
  141. package/dist/features/auctions/server.d.ts +0 -1
  142. package/dist/features/auctions/server.js +0 -1
  143. package/dist/features/auth/actions/realtime-token-actions.js +1 -1
  144. package/dist/features/auth/repository/user.repository.js +1 -1
  145. package/dist/features/blog/components/BlogFeaturedCard.js +1 -0
  146. package/dist/features/cart/repository/cart.repository.d.ts +4 -1
  147. package/dist/features/cart/repository/cart.repository.js +12 -0
  148. package/dist/features/checkout/hooks/useCheckoutApi.d.ts +0 -2
  149. package/dist/features/checkout/index.d.ts +1 -1
  150. package/dist/features/events/components/AdminEventEditorView.js +10 -13
  151. package/dist/features/events/components/AdminEventsView.d.ts +3 -3
  152. package/dist/features/events/components/AdminEventsView.js +50 -86
  153. package/dist/features/events/components/EventCard.js +1 -0
  154. package/dist/features/events/components/EventOfferCard.d.ts +19 -0
  155. package/dist/features/events/components/EventOfferCard.js +29 -0
  156. package/dist/features/events/components/EventRaffleEntryForm.d.ts +25 -0
  157. package/dist/features/events/components/EventRaffleEntryForm.js +37 -0
  158. package/dist/features/events/components/EventRafflesSection.d.ts +1 -4
  159. package/dist/features/events/components/EventRafflesSection.js +17 -6
  160. package/dist/features/events/components/EventSaleBanner.d.ts +21 -0
  161. package/dist/features/events/components/EventSaleBanner.js +18 -0
  162. package/dist/features/events/components/index.d.ts +6 -0
  163. package/dist/features/events/components/index.js +4 -0
  164. package/dist/features/events/repository/event-entry.repository.d.ts +5 -0
  165. package/dist/features/events/repository/event-entry.repository.js +7 -0
  166. package/dist/features/faq/components/FAQPageContent.js +1 -0
  167. package/dist/features/filters/AsyncFacetSection.d.ts +1 -1
  168. package/dist/features/homepage/components/AdvertisementBanner.js +6 -6
  169. package/dist/features/homepage/components/FAQSection.d.ts +0 -5
  170. package/dist/features/homepage/components/HomepageSkeleton.js +2 -2
  171. package/dist/features/homepage/components/WelcomeSection.js +3 -3
  172. package/dist/features/homepage/lib/live-stats.js +1 -1
  173. package/dist/features/homepage/schemas/firestore.d.ts +0 -2
  174. package/dist/features/layout/TitleBar.js +1 -0
  175. package/dist/features/layout/index.d.ts +0 -2
  176. package/dist/features/layout/index.js +0 -1
  177. package/dist/features/pre-orders/server.d.ts +0 -1
  178. package/dist/features/pre-orders/server.js +0 -1
  179. package/dist/features/products/components/GroupSettingsPanel.js +2 -2
  180. package/dist/features/products/components/PrizeDrawItemsEditor.js +2 -2
  181. package/dist/features/products/components/PrizeDrawsSection.d.ts +1 -4
  182. package/dist/features/products/components/PrizeDrawsSection.js +17 -6
  183. package/dist/features/products/components/PrizeRevealModal.js +1 -1
  184. package/dist/features/products/components/ProductCardMetadataSection.d.ts +11 -0
  185. package/dist/features/products/components/ProductCardMetadataSection.js +25 -0
  186. package/dist/features/products/components/ProductDetailPageView.js +3 -1
  187. package/dist/features/products/components/ProductFeaturesSelector.js +1 -1
  188. package/dist/features/products/components/ProductGradingTab.d.ts +13 -0
  189. package/dist/features/products/components/ProductGradingTab.js +25 -0
  190. package/dist/features/products/components/ProductGrid.js +15 -2
  191. package/dist/features/products/components/ProductTabsShell.d.ts +5 -1
  192. package/dist/features/products/components/ProductTabsShell.js +6 -1
  193. package/dist/features/products/components/index.d.ts +4 -0
  194. package/dist/features/products/components/index.js +3 -0
  195. package/dist/features/products/constants/action-defs.d.ts +5 -0
  196. package/dist/features/products/constants/action-defs.js +52 -32
  197. package/dist/features/products/constants/sieve.d.ts +24 -4
  198. package/dist/features/products/constants/sieve.js +20 -11
  199. package/dist/features/products/schemas/firestore.d.ts +17 -0
  200. package/dist/features/products/schemas/product-features.validators.d.ts +2 -2
  201. package/dist/features/products/schemas/product-templates.d.ts +2 -4
  202. package/dist/features/products/types/index.d.ts +4 -0
  203. package/dist/features/promotions/components/CouponsIndexListing.js +4 -4
  204. package/dist/features/promotions/server.d.ts +0 -1
  205. package/dist/features/promotions/server.js +0 -1
  206. package/dist/features/reviews/components/ReviewDetailShell.js +3 -3
  207. package/dist/features/search/api/route.js +44 -1
  208. package/dist/features/search/components/Search.js +2 -0
  209. package/dist/features/search/hooks/useNavSuggestions.d.ts +5 -1
  210. package/dist/features/search/hooks/useNavSuggestions.js +31 -4
  211. package/dist/features/seller/components/BrandInlineSelect.js +2 -2
  212. package/dist/features/seller/components/CategoryInlineSelect.js +2 -2
  213. package/dist/features/seller/components/SellerAddressesView.js +4 -5
  214. package/dist/features/seller/components/SellerAuctionsView.d.ts +3 -3
  215. package/dist/features/seller/components/SellerAuctionsView.js +60 -90
  216. package/dist/features/seller/components/SellerBidsView.js +1 -1
  217. package/dist/features/seller/components/SellerBundlesView.js +64 -89
  218. package/dist/features/seller/components/SellerClassifiedView.js +67 -90
  219. package/dist/features/seller/components/SellerCouponEditorView.js +1 -1
  220. package/dist/features/seller/components/SellerCouponsView.d.ts +2 -2
  221. package/dist/features/seller/components/SellerCouponsView.js +45 -84
  222. package/dist/features/seller/components/SellerDigitalCodesView.js +63 -88
  223. package/dist/features/seller/components/SellerGroupedListingsView.js +33 -49
  224. package/dist/features/seller/components/SellerLiveView.js +63 -84
  225. package/dist/features/seller/components/SellerOffersPanel.js +1 -1
  226. package/dist/features/seller/components/SellerOffersView.d.ts +2 -2
  227. package/dist/features/seller/components/SellerOffersView.js +37 -69
  228. package/dist/features/seller/components/SellerOrdersView.d.ts +2 -2
  229. package/dist/features/seller/components/SellerOrdersView.js +4 -4
  230. package/dist/features/seller/components/SellerPayoutMethodsView.js +1 -1
  231. package/dist/features/seller/components/SellerPayoutsView.d.ts +2 -2
  232. package/dist/features/seller/components/SellerPayoutsView.js +34 -68
  233. package/dist/features/seller/components/SellerPreOrdersView.d.ts +2 -2
  234. package/dist/features/seller/components/SellerPreOrdersView.js +49 -82
  235. package/dist/features/seller/components/SellerPrizeDrawsView.d.ts +2 -2
  236. package/dist/features/seller/components/SellerPrizeDrawsView.js +49 -82
  237. package/dist/features/seller/components/SellerProductShell.d.ts +1 -1
  238. package/dist/features/seller/components/SellerProductsView.d.ts +2 -2
  239. package/dist/features/seller/components/SellerProductsView.js +15 -10
  240. package/dist/features/seller/components/SellerShippingConfigsView.js +1 -1
  241. package/dist/features/seller/components/SellerSidebar.d.ts +0 -4
  242. package/dist/features/seller/components/SellerSidebar.js +0 -2
  243. package/dist/features/seller/components/SellerStoreCategoriesView.js +1 -1
  244. package/dist/features/seller/components/SellerTemplatesView.js +2 -2
  245. package/dist/features/seller/components/SellersListView.d.ts +1 -2
  246. package/dist/features/seller/components/analytics/SellerAnalyticsStats.d.ts +5 -0
  247. package/dist/features/seller/components/analytics/SellerAnalyticsStats.js +2 -8
  248. package/dist/features/seller/components/index.d.ts +0 -3
  249. package/dist/features/seller/components/index.js +0 -2
  250. package/dist/features/seller/server.d.ts +0 -1
  251. package/dist/features/seller/server.js +0 -1
  252. package/dist/features/shell/FormShell.d.ts +1 -1
  253. package/dist/features/shell/FormShell.js +7 -4
  254. package/dist/features/shell/field-groups/ImageFieldGroup.d.ts +18 -0
  255. package/dist/features/shell/field-groups/ImageFieldGroup.js +15 -0
  256. package/dist/features/shell/field-groups/SeoFieldGroup.d.ts +22 -0
  257. package/dist/features/shell/field-groups/SeoFieldGroup.js +16 -0
  258. package/dist/features/shell/field-groups/StatusFieldGroup.d.ts +35 -0
  259. package/dist/features/shell/field-groups/StatusFieldGroup.js +16 -0
  260. package/dist/features/shell/field-groups/TitleDescriptionGroup.d.ts +40 -0
  261. package/dist/features/shell/field-groups/TitleDescriptionGroup.js +16 -0
  262. package/dist/features/shell/field-groups/index.d.ts +13 -0
  263. package/dist/features/shell/field-groups/index.js +9 -0
  264. package/dist/features/shell/index.d.ts +2 -0
  265. package/dist/features/shell/index.js +1 -0
  266. package/dist/features/stores/components/StoreCapabilitiesGuideView.d.ts +1 -2
  267. package/dist/features/stores/components/StoreFinanceGuideView.d.ts +1 -2
  268. package/dist/features/stores/components/StoreHeader.js +2 -1
  269. package/dist/features/stores/components/StoreListingsGuideView.d.ts +1 -2
  270. package/dist/features/stores/components/StoreOrdersGuideView.d.ts +1 -2
  271. package/dist/features/stores/components/StoreScopedSearch.d.ts +16 -0
  272. package/dist/features/stores/components/StoreScopedSearch.js +27 -0
  273. package/dist/features/stores/components/StoreSettingsGuideView.d.ts +1 -2
  274. package/dist/features/stores/server.d.ts +0 -1
  275. package/dist/features/stores/server.js +0 -1
  276. package/dist/features/support/schemas/firestore.d.ts +22 -1
  277. package/dist/features/support/schemas/firestore.js +10 -0
  278. package/dist/features/wishlist/server.d.ts +0 -1
  279. package/dist/features/wishlist/server.js +0 -1
  280. package/dist/index.d.ts +9 -27
  281. package/dist/index.js +14 -50
  282. package/dist/next/routing/route-map.d.ts +8 -0
  283. package/dist/next/routing/route-map.js +4 -0
  284. package/dist/react/hooks/useListingTypeFlags.d.ts +32 -0
  285. package/dist/react/hooks/useListingTypeFlags.js +19 -0
  286. package/dist/security/index.d.ts +1 -1
  287. package/dist/security/index.js +1 -1
  288. package/dist/security/pii-redact.d.ts +8 -0
  289. package/dist/security/pii-redact.js +10 -1
  290. package/dist/seed/grouped-listings-seed-data.d.ts +4 -0
  291. package/dist/seed/products-preorders-seed-data.d.ts +4 -0
  292. package/dist/seed/products-prize-draws-seed-data.js +3 -0
  293. package/dist/seed/site-settings-seed-data.js +5 -5
  294. package/dist/seed/sub-listings-seed-data.d.ts +4 -0
  295. package/dist/server.d.ts +2 -0
  296. package/dist/server.js +4 -0
  297. package/dist/styles.css +54 -395
  298. package/dist/tailwind-utilities.css +1 -1
  299. package/dist/ui/components/BaseListingCard.d.ts +10 -0
  300. package/dist/ui/components/BaseListingCard.js +17 -1
  301. package/dist/ui/components/DetailPageGallery.d.ts +32 -0
  302. package/dist/ui/components/DetailPageGallery.js +47 -0
  303. package/dist/ui/components/DetailPageHero.d.ts +30 -0
  304. package/dist/ui/components/DetailPageHero.js +22 -0
  305. package/dist/ui/components/DetailPageTabs.d.ts +34 -0
  306. package/dist/ui/components/DetailPageTabs.js +38 -0
  307. package/dist/ui/components/HorizontalScroller.style.css +15 -2
  308. package/dist/ui/components/ListingLayout.d.ts +11 -2
  309. package/dist/ui/components/ListingLayout.js +12 -6
  310. package/dist/ui/components/PaginatedSelect.d.ts +66 -0
  311. package/dist/ui/components/PaginatedSelect.js +201 -0
  312. package/dist/ui/components/PaginatedSelect.style.css +254 -0
  313. package/dist/ui/components/Semantic.d.ts +0 -4
  314. package/dist/ui/components/Semantic.js +0 -2
  315. package/dist/ui/components/SettingsSection.d.ts +47 -0
  316. package/dist/ui/components/SettingsSection.js +38 -0
  317. package/dist/ui/components/index.style.css +1 -4
  318. package/dist/ui/index.d.ts +12 -14
  319. package/dist/ui/index.js +6 -7
  320. package/dist/utils/id-generators.d.ts +1 -18
  321. package/dist/utils/id-generators.js +51 -18
  322. package/dist/validation/schemas.d.ts +25 -0
  323. package/dist/validation/schemas.js +28 -0
  324. package/package.json +1 -1
@@ -1,92 +1,93 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React, { useState, useCallback } from "react";
4
- import { Plus } from "lucide-react";
5
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
6
- import { usePanelUrlSync } from "../../../react/hooks/use-panel-url-sync";
7
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
8
- import { BulkActionBar, Button, ListingToolbar, ListingViewShell, Pagination, SideDrawer, Text, ListingFilterDrawer } from "../../../ui";
9
- import { AdminViewCards } from "./AdminViewCards";
3
+ import React from "react";
4
+ import { ListingLayout, Text } from "../../../ui";
10
5
  import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
11
6
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
12
- import { toRecordArray, toRelativeDate, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
13
- import { DataTable } from "./DataTable";
7
+ import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
8
+ import { DataListingView } from "./DataListingView";
14
9
  import { AdminBrandEditorView } from "./AdminBrandEditorView";
15
- import { useBottomActions } from "../../layout";
16
- const PAGE_SIZE = 25;
17
- const FILTER_KEYS = ["isActive"];
18
- const DEFAULT_SORT = "displayOrder";
19
- const SORT_OPTIONS = [
20
- { value: "displayOrder", label: "Display order" },
21
- { value: "name", label: "Name A–Z" },
22
- { value: "-name", label: "Name Z–A" },
23
- { value: "-createdAt", label: "Newest" },
10
+ import { Span } from "../../../ui";
11
+ const COLUMNS = [
12
+ {
13
+ key: "primary",
14
+ header: "Brand",
15
+ sortable: true,
16
+ render: (row) => (_jsxs("div", { className: "space-y-1", children: [_jsx(Text, { className: "font-semibold text-zinc-900 dark:text-zinc-100", children: row.primary }), _jsx(Text, { className: "text-xs text-zinc-500 dark:text-zinc-400", children: row.secondary })] })),
17
+ },
18
+ {
19
+ key: "status",
20
+ header: "Status",
21
+ className: "w-32",
22
+ render: (row) => (_jsx(Span, { className: "inline-flex rounded-full bg-primary-50 px-2.5 py-1 text-xs font-medium text-primary-800 dark:bg-secondary-900/30 dark:text-secondary-300", children: row.status })),
23
+ },
24
+ {
25
+ key: "updatedAt",
26
+ header: "Updated",
27
+ className: "w-32",
28
+ render: (row) => (_jsx(Text, { className: "text-sm text-zinc-500 dark:text-zinc-400", children: row.updatedAt })),
29
+ },
24
30
  ];
31
+ const ADMIN_BRANDS_CONFIG = {
32
+ portal: "admin",
33
+ title: "Brands",
34
+ searchPlaceholder: "Search brands by name or slug",
35
+ emptyLabel: "No brands found",
36
+ filterKeys: ["isActive"],
37
+ defaultSort: "displayOrder",
38
+ queryKey: ["admin", "brands", "listing"],
39
+ endpoint: ADMIN_ENDPOINTS.BRANDS,
40
+ sortOptions: [
41
+ { value: "displayOrder", label: "Display order" },
42
+ { value: "name", label: "Name A–Z" },
43
+ { value: "-name", label: "Name Z–A" },
44
+ { value: "-createdAt", label: "Newest" },
45
+ ],
46
+ columns: COLUMNS,
47
+ mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
48
+ id: toStringValue(item.id, `brand-${index}`),
49
+ primary: toStringValue(item.name, "Untitled brand"),
50
+ secondary: `Slug: ${toStringValue(item.slug, "no-slug")}${item.website ? ` · ${item.website}` : ""}`,
51
+ status: typeof item.isActive === "boolean"
52
+ ? item.isActive
53
+ ? "Active"
54
+ : "Inactive"
55
+ : "Active",
56
+ updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
57
+ })),
58
+ getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
59
+ buildFilters: (state) => state.isActive ? `isActive==${state.isActive}` : undefined,
60
+ primaryAction: {
61
+ label: "Add Brand",
62
+ onClick: ({ openCreatePanel }) => openCreatePanel(),
63
+ },
64
+ buildBulkActions: (selection) => [
65
+ {
66
+ id: "edit",
67
+ label: ACTIONS.ADMIN["edit-brand"].label,
68
+ variant: "primary",
69
+ onClick: () => {
70
+ const id = selection.selectedIds[0];
71
+ if (id)
72
+ selection.openEditPanel(id);
73
+ selection.clearSelection();
74
+ },
75
+ },
76
+ ],
77
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
78
+ { label: "All", value: "" },
79
+ { label: "Active", value: "true" },
80
+ { label: "Inactive", value: "false" },
81
+ ].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, isActive: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.isActive || "") === opt.value
82
+ ? "bg-primary text-white border-primary"
83
+ : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] })),
84
+ renderEditor: ({ editId, closePanel }) => (_jsx(AdminBrandEditorView, { brandId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })),
85
+ resolveEditorTitle: ({ isCreate }) => (isCreate ? "Add Brand" : "Edit Brand"),
86
+ };
25
87
  export function AdminBrandsView({ children, ...props }) {
26
- const hasChildren = React.Children.count(children) > 0;
27
- const [view, setView] = useState("table");
28
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
29
- const { openCreatePanel, openEditPanel, closePanel, isCreateOpen, isEditOpen, editId } = usePanelUrlSync();
30
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
31
- const [filterOpen, setFilterOpen] = useState(false);
32
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
33
- const openFilters = useCallback(() => {
34
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
35
- setFilterOpen(true);
36
- }, [table]);
37
- const applyFilters = useCallback(() => {
38
- const updates = { page: "1" };
39
- for (const k of FILTER_KEYS)
40
- updates[k] = pendingFilters[k] ?? "";
41
- table.setMany(updates);
42
- setFilterOpen(false);
43
- }, [pendingFilters, table]);
44
- const clearFilters = useCallback(() => {
45
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
46
- }, []);
47
- const resetAll = useCallback(() => {
48
- const updates = { q: "", sort: "" };
49
- for (const k of FILTER_KEYS)
50
- updates[k] = "";
51
- table.setMany(updates);
52
- setSearchInput("");
53
- }, [table]);
54
- const commitSearch = useCallback(() => {
55
- table.set("q", searchInput.trim());
56
- }, [searchInput, table]);
57
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
58
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
59
- const isActiveRaw = table.get("isActive");
60
- const filters = isActiveRaw ? `isActive==${isActiveRaw}` : undefined;
61
- const { rows, total, isLoading, errorMessage } = useAdminListingData({
62
- queryKey: ["admin", "brands", "listing"],
63
- endpoint: ADMIN_ENDPOINTS.BRANDS,
64
- page: table.getNumber("page", 1),
65
- pageSize: PAGE_SIZE,
66
- sorts: table.get("sort") || DEFAULT_SORT,
67
- filters,
68
- q: table.get("q") || undefined,
69
- mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
70
- id: toStringValue(item.id, `brand-${index}`),
71
- primary: toStringValue(item.name, "Untitled brand"),
72
- secondary: `Slug: ${toStringValue(item.slug, "no-slug")}${item.website ? ` · ${item.website}` : ""}`,
73
- status: typeof item.isActive === "boolean" ? (item.isActive ? "Active" : "Inactive") : "Active",
74
- updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
75
- })),
76
- getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
77
- });
78
- const currentPage = table.getNumber("page", 1);
79
- const totalPages = Math.ceil(total / PAGE_SIZE);
80
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
81
- if (hasChildren) {
82
- return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
88
+ // Backward-compat passthrough some page shims wrap with custom children.
89
+ if (React.Children.count(children) > 0) {
90
+ return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
83
91
  }
84
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
85
- { id: "edit", label: ACTIONS.ADMIN["edit-brand"].label, variant: "primary", onClick: () => { const id = selection.selectedIds[0]; if (id)
86
- openEditPanel(id); selection.clearSelection(); } },
87
- ] } } : {});
88
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search brands by name or slug", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set("sort", v); }, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState, extra: _jsxs(Button, { size: "sm", onClick: openCreatePanel, className: "flex items-center gap-1.5", children: [_jsx(Plus, { className: "h-4 w-4" }), "Add Brand"] }) }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
89
- { id: "edit", label: ACTIONS.ADMIN["edit-brand"].label, variant: "primary", onClick: () => { const id = selection.selectedIds[0]; if (id)
90
- openEditPanel(id); selection.clearSelection(); } },
91
- ] }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-error-surface px-4 py-3 text-sm text-error dark:border-red-900/60", children: errorMessage })), view === "table" ? (_jsx(DataTable, { rows: rows, isLoading: isLoading, emptyLabel: "No brands found", selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: (next) => next ? selection.setSelectedIds(rows.map(r => r.id)) : selection.clearSelection(), onRowClick: (row) => openEditPanel(row.id) })) : (_jsx(AdminViewCards, { rows: rows, view: view, isLoading: isLoading, emptyLabel: "No brands found", onRowClick: (row) => openEditPanel(row.id), selectedIdSet: selection.selectedIdSet, onToggleSelect: selection.toggle }))] }), _jsx(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [{ label: "All", value: "" }, { label: "Active", value: "true" }, { label: "Inactive", value: "false" }].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, isActive: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.isActive || "") === opt.value ? "bg-primary text-white border-primary" : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }) }), _jsx(SideDrawer, { isOpen: isCreateOpen || isEditOpen, onClose: closePanel, title: isCreateOpen ? "Add Brand" : "Edit Brand", mode: isCreateOpen ? "create" : "edit", children: (isCreateOpen || isEditOpen) && (_jsx(AdminBrandEditorView, { brandId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })) })] }));
92
+ return _jsx(DataListingView, { config: ADMIN_BRANDS_CONFIG });
92
93
  }
@@ -1,28 +1,13 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useState, useCallback } from "react";
4
- import { Plus } from "lucide-react";
5
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
6
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
7
- import { Badge, BulkActionBar, Button, Heading, ListingToolbar, Pagination, Stack, Text, useToast, ListingFilterDrawer } from "../../../ui";
4
+ import { Badge, Button, Stack, Text, useToast } from "../../../ui";
8
5
  import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
9
- import { toRecordArray, toRelativeDate, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
10
- import { DataTable } from "./DataTable";
6
+ import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
7
+ import { DataListingView } from "./DataListingView";
11
8
  import { BUNDLE_COPY, BUNDLE_STOCK_VARIANT, } from "../../../_internal/shared/features/categories/bundle-copy";
12
9
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
13
10
  import { buildBulkAction } from "../../../_internal/shared/actions/bulk-helpers";
14
- import { useBottomActions } from "../../layout";
15
- const PAGE_SIZE = 25;
16
- const FILTER_KEYS = ["isActive", "bundleStockStatus"];
17
- const DEFAULT_SORT = "name";
18
- const SORT_OPTIONS = [
19
- { value: "name", label: "Name A–Z" },
20
- { value: "-name", label: "Name Z–A" },
21
- { value: "-bundlePriceInPaise", label: "Price high→low" },
22
- { value: "bundlePriceInPaise", label: "Price low→high" },
23
- { value: "-createdAt", label: "Newest" },
24
- { value: "createdAt", label: "Oldest" },
25
- ];
26
11
  function formatPrice(paise) {
27
12
  if (typeof paise !== "number" || paise <= 0)
28
13
  return "—";
@@ -53,54 +38,41 @@ const COLUMNS = [
53
38
  { key: "updatedAt", header: "Updated", className: "w-28" },
54
39
  ];
55
40
  export function AdminBundlesView({ getEditHref, newHref }) {
56
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
57
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
58
- const [filterOpen, setFilterOpen] = useState(false);
59
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
60
41
  const [rebuildingId, setRebuildingId] = useState(null);
61
42
  const toast = useToast();
62
- const openFilters = useCallback(() => {
63
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
64
- setFilterOpen(true);
65
- }, [table]);
66
- const applyFilters = useCallback(() => {
67
- const updates = { page: "1" };
68
- for (const k of FILTER_KEYS)
69
- updates[k] = pendingFilters[k] ?? "";
70
- table.setMany(updates);
71
- setFilterOpen(false);
72
- }, [pendingFilters, table]);
73
- const clearFilters = useCallback(() => {
74
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
75
- }, []);
76
- const resetAll = useCallback(() => {
77
- const updates = { q: "", sort: "" };
78
- for (const k of FILTER_KEYS)
79
- updates[k] = "";
80
- table.setMany(updates);
81
- setSearchInput("");
82
- }, [table]);
83
- const commitSearch = useCallback(() => {
84
- table.set("q", searchInput.trim());
85
- }, [searchInput, table]);
86
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
87
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
88
- const filterParts = [];
89
- const isActiveRaw = table.get("isActive");
90
- if (isActiveRaw)
91
- filterParts.push(`isActive==${isActiveRaw}`);
92
- const stockStatusRaw = table.get("bundleStockStatus");
93
- if (stockStatusRaw)
94
- filterParts.push(`bundleStockStatus==${stockStatusRaw}`);
95
- const filters = filterParts.join(",") || undefined;
96
- const { rows, total, isLoading, errorMessage, refetch } = useAdminListingData({
43
+ const handleRebuild = useCallback(async (bundleId) => {
44
+ setRebuildingId(bundleId);
45
+ try {
46
+ const res = await fetch(ADMIN_ENDPOINTS.BUNDLE_REBUILD(bundleId), { method: "POST" });
47
+ if (!res.ok)
48
+ throw new Error("Rebuild failed");
49
+ toast.showToast("Bundle stock rebuilt.", "success");
50
+ }
51
+ catch {
52
+ toast.showToast("Failed to rebuild bundle stock.", "error");
53
+ }
54
+ finally {
55
+ setRebuildingId(null);
56
+ }
57
+ }, [toast]);
58
+ const config = {
59
+ portal: "admin",
60
+ title: "Bundles",
61
+ searchPlaceholder: "Search bundles by name or slug…",
62
+ emptyLabel: BUNDLE_COPY.adminList.empty,
63
+ filterKeys: ["isActive", "bundleStockStatus"],
64
+ defaultSort: "name",
97
65
  queryKey: ["admin", "bundles", "listing"],
98
66
  endpoint: ADMIN_ENDPOINTS.BUNDLES,
99
- page: table.getNumber("page", 1),
100
- pageSize: PAGE_SIZE,
101
- sorts: table.get("sort") || DEFAULT_SORT,
102
- filters,
103
- q: table.get("q") || undefined,
67
+ sortOptions: [
68
+ { value: "name", label: "Name A–Z" },
69
+ { value: "-name", label: "Name Z–A" },
70
+ { value: "-bundlePriceInPaise", label: "Price high→low" },
71
+ { value: "bundlePriceInPaise", label: "Price low→high" },
72
+ { value: "-createdAt", label: "Newest" },
73
+ { value: "createdAt", label: "Oldest" },
74
+ ],
75
+ columns: COLUMNS,
104
76
  mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
105
77
  id: toStringValue(item.id, `bundle-${index}`),
106
78
  primary: toStringValue(item.name, "Untitled bundle"),
@@ -115,66 +87,51 @@ export function AdminBundlesView({ getEditHref, newHref }) {
115
87
  updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
116
88
  })),
117
89
  getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
118
- });
119
- const currentPage = table.getNumber("page", 1);
120
- const totalPages = Math.ceil(total / PAGE_SIZE);
121
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
122
- const handleRebuild = useCallback(async (bundleId) => {
123
- setRebuildingId(bundleId);
124
- try {
125
- const res = await fetch(ADMIN_ENDPOINTS.BUNDLE_REBUILD(bundleId), { method: "POST" });
126
- if (!res.ok)
127
- throw new Error("Rebuild failed");
128
- toast.showToast("Bundle stock rebuilt.", "success");
129
- }
130
- catch {
131
- toast.showToast("Failed to rebuild bundle stock.", "error");
132
- }
133
- finally {
134
- setRebuildingId(null);
135
- refetch();
136
- }
137
- }, [refetch, toast]);
138
- const bulkActions = [
139
- buildBulkAction(ACTIONS.ADMIN["activate-bundle"], async () => {
140
- await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), {
141
- method: "PUT",
142
- headers: { "Content-Type": "application/json" },
143
- body: JSON.stringify({ isActive: true }),
144
- })));
145
- selection.clearSelection();
146
- refetch();
147
- }),
148
- buildBulkAction(ACTIONS.ADMIN["deactivate-bundle"], async () => {
149
- await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), {
150
- method: "PUT",
151
- headers: { "Content-Type": "application/json" },
152
- body: JSON.stringify({ isActive: false }),
153
- })));
154
- selection.clearSelection();
155
- refetch();
156
- }),
157
- buildBulkAction(ACTIONS.ADMIN["delete-bundle"], async () => {
158
- await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), { method: "DELETE" })));
159
- selection.clearSelection();
160
- refetch();
161
- }),
162
- ];
163
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
164
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(Heading, { level: 1, className: "sr-only", children: "Bundles" }), _jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search bundles by name or slug\u2026", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => {
165
- table.set("sort", v);
166
- }, onResetAll: resetAll, hasActiveState: hasActiveState, extra: _jsx(Button, { asChild: true, size: "sm", variant: "primary", children: _jsxs("a", { href: newHref, className: "flex items-center gap-1.5", children: [_jsx(Plus, { className: "h-4 w-4" }), BUNDLE_COPY.adminList.newButton] }) }) }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-error-surface px-4 py-3 text-sm text-error dark:border-red-900/60", children: errorMessage })), _jsx(DataTable, { columns: COLUMNS, rows: rows, isLoading: isLoading, emptyLabel: BUNDLE_COPY.adminList.empty, getRowHref: getEditHref, selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: (next) => next
167
- ? selection.setSelectedIds(rows.map((r) => r.id))
168
- : selection.clearSelection(), renderRowActions: (row) => (_jsx(Button, { variant: "ghost", size: "sm", isLoading: rebuildingId === row.id, disabled: rebuildingId === row.id, onClick: () => void handleRebuild(row.id), children: ACTIONS.ADMIN["rebuild-bundle"].label })) })] }), _jsxs(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
169
- { label: "All", value: "" },
170
- { label: "Active", value: "true" },
171
- { label: "Inactive", value: "false" },
172
- ].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, isActive: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.isActive || "") === opt.value
173
- ? "bg-primary text-white border-primary"
174
- : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Stock" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
175
- { label: "All", value: "" },
176
- { label: "Sold out", value: "out_of_stock" },
177
- ].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, bundleStockStatus: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.bundleStockStatus || "") === opt.value
178
- ? "bg-primary text-white border-primary"
179
- : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] })] })] }));
90
+ buildFilters: (filterState) => {
91
+ const parts = [];
92
+ if (filterState.isActive)
93
+ parts.push(`isActive==${filterState.isActive}`);
94
+ if (filterState.bundleStockStatus)
95
+ parts.push(`bundleStockStatus==${filterState.bundleStockStatus}`);
96
+ return parts.join(",") || undefined;
97
+ },
98
+ getRowHref: getEditHref,
99
+ toolbarExtra: (_jsx(Button, { asChild: true, size: "sm", variant: "primary", children: _jsxs("a", { href: newHref, className: "flex items-center gap-1.5", children: ["+ ", BUNDLE_COPY.adminList.newButton] }) })),
100
+ buildBulkActions: (selection) => [
101
+ buildBulkAction(ACTIONS.ADMIN["activate-bundle"], async () => {
102
+ await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), {
103
+ method: "PUT",
104
+ headers: { "Content-Type": "application/json" },
105
+ body: JSON.stringify({ isActive: true }),
106
+ })));
107
+ selection.clearSelection();
108
+ }),
109
+ buildBulkAction(ACTIONS.ADMIN["deactivate-bundle"], async () => {
110
+ await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), {
111
+ method: "PUT",
112
+ headers: { "Content-Type": "application/json" },
113
+ body: JSON.stringify({ isActive: false }),
114
+ })));
115
+ selection.clearSelection();
116
+ }),
117
+ buildBulkAction(ACTIONS.ADMIN["delete-bundle"], async () => {
118
+ await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), { method: "DELETE" })));
119
+ selection.clearSelection();
120
+ }),
121
+ ],
122
+ renderRowActions: (row) => (_jsx(Button, { variant: "ghost", size: "sm", isLoading: rebuildingId === row.id, disabled: rebuildingId === row.id, onClick: () => void handleRebuild(row.id), children: ACTIONS.ADMIN["rebuild-bundle"].label })),
123
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
124
+ { label: "All", value: "" },
125
+ { label: "Active", value: "true" },
126
+ { label: "Inactive", value: "false" },
127
+ ].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, isActive: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.isActive || "") === opt.value
128
+ ? "bg-primary text-white border-primary"
129
+ : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Stock" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
130
+ { label: "All", value: "" },
131
+ { label: "Sold out", value: "out_of_stock" },
132
+ ].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, bundleStockStatus: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.bundleStockStatus || "") === opt.value
133
+ ? "bg-primary text-white border-primary"
134
+ : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] })] })),
135
+ };
136
+ return _jsx(DataListingView, { config: config });
180
137
  }
@@ -1,5 +1,5 @@
1
- import type { ListingViewShellProps } from "../../../ui";
2
- export interface AdminCarouselViewProps extends ListingViewShellProps {
1
+ import type { ListingLayoutProps } from "../../../ui";
2
+ export interface AdminCarouselViewProps extends ListingLayoutProps {
3
3
  onBulkDelete?: (ids: string[]) => Promise<void>;
4
4
  }
5
5
  export declare function AdminCarouselView({ children, onBulkDelete, ...props }: AdminCarouselViewProps): import("react/jsx-runtime").JSX.Element;
@@ -2,14 +2,13 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React, { useState, useCallback } from "react";
4
4
  import { useMutation, useQueryClient } from "@tanstack/react-query";
5
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
6
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
7
- import { BulkActionBar, ConfirmDeleteModal, ListingFilterDrawer, ListingToolbar, ListingViewShell, Pagination, Text } from "../../../ui";
5
+ import { BulkActionBar, ConfirmDeleteModal, ListingFilterDrawer, ListingToolbar, ListingLayout, Pagination, Text } from "../../../ui";
8
6
  import { useBottomActions } from "../../layout";
9
7
  import { ADMIN_ENDPOINTS, HOMEPAGE_ENDPOINTS } from "../../../constants/api-endpoints";
10
8
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
11
9
  import { buildBulkAction } from "../../../_internal/shared/actions/bulk-helpers";
12
- import { toRecordArray, toRelativeDate, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
10
+ import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
11
+ import { useAdminListing } from "../hooks/useAdminListing";
13
12
  import { DataTable } from "./DataTable";
14
13
  import { RowActionMenu } from "../../../ui/components/RowActionMenu";
15
14
  import { apiClient } from "../../../http";
@@ -18,55 +17,16 @@ const FILTER_KEYS = ["active"];
18
17
  const DEFAULT_SORT = "order";
19
18
  export function AdminCarouselView({ children, onBulkDelete, ...props }) {
20
19
  const hasChildren = React.Children.count(children) > 0;
21
- const [view, setView] = useState("table");
22
20
  const [draggingId, setDraggingId] = useState(null);
23
21
  const [deleteTargetId, setDeleteTargetId] = useState(null);
24
22
  const [localRows, setLocalRows] = useState([]);
25
23
  const queryClient = useQueryClient();
26
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
27
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
28
- const [filterOpen, setFilterOpen] = useState(false);
29
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
30
- const openFilters = useCallback(() => {
31
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
32
- setFilterOpen(true);
33
- }, [table]);
34
- const applyFilters = useCallback(() => {
35
- const updates = { page: "1" };
36
- for (const k of FILTER_KEYS)
37
- updates[k] = pendingFilters[k] ?? "";
38
- table.setMany(updates);
39
- setFilterOpen(false);
40
- }, [pendingFilters, table]);
41
- const clearFilters = useCallback(() => {
42
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
43
- }, []);
44
- const resetAll = useCallback(() => {
45
- const updates = { q: "", sort: "" };
46
- for (const k of FILTER_KEYS)
47
- updates[k] = "";
48
- table.setMany(updates);
49
- setSearchInput("");
50
- }, [table]);
51
- const commitSearch = useCallback(() => {
52
- table.set("q", searchInput.trim());
53
- }, [searchInput, table]);
54
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
55
- const hasActiveState = !!table.get("q") || activeFilterCount > 0;
56
- const activeRaw = table.get("active");
57
- const filterParts = [];
58
- if (activeRaw === "true")
59
- filterParts.push("active==true");
60
- else if (activeRaw === "false")
61
- filterParts.push("active==false");
62
- const filters = filterParts.join(",") || undefined;
63
- const { rows: fetchedRows, total, isLoading, errorMessage } = useAdminListingData({
24
+ const { view, setView, table, searchInput, setSearchInput, commitSearch, filterOpen, setFilterOpen, openFilters, applyFilters, clearFilters, pendingFilters, setPendingFilters, activeFilterCount, hasActiveState, resetAll, rows: fetchedRows, total, isLoading, errorMessage, currentPage, totalPages, selection, } = useAdminListing({
25
+ filterKeys: FILTER_KEYS,
26
+ defaultSort: DEFAULT_SORT,
27
+ pageSize: PAGE_SIZE,
64
28
  queryKey: ["admin", "carousel", "listing"],
65
29
  endpoint: `${HOMEPAGE_ENDPOINTS.CAROUSEL}?includeInactive=true`,
66
- page: table.getNumber("page", 1),
67
- pageSize: PAGE_SIZE,
68
- filters,
69
- q: table.get("q") || undefined,
70
30
  mapRows: (response) => {
71
31
  const sourceItems = Array.isArray(response.data) ? response.data : response.items;
72
32
  return toRecordArray(sourceItems)
@@ -89,6 +49,14 @@ export function AdminCarouselView({ children, onBulkDelete, ...props }) {
89
49
  });
90
50
  },
91
51
  getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
52
+ buildFilters: (filterState) => {
53
+ const activeRaw = filterState.active;
54
+ if (activeRaw === "true")
55
+ return "active==true";
56
+ if (activeRaw === "false")
57
+ return "active==false";
58
+ return undefined;
59
+ },
92
60
  });
93
61
  React.useEffect(() => {
94
62
  setLocalRows(fetchedRows);
@@ -125,15 +93,12 @@ export function AdminCarouselView({ children, onBulkDelete, ...props }) {
125
93
  setDraggingId(null);
126
94
  reorderMutation.mutate(next.map((r) => r.id));
127
95
  };
128
- const currentPage = table.getNumber("page", 1);
129
- const totalPages = Math.ceil(total / PAGE_SIZE);
130
- const selection = useBulkSelection({ items: fetchedRows, keyExtractor: (r) => r.id });
131
96
  const bulkActions = [
132
97
  ...(onBulkDelete ? [buildBulkAction(ACTIONS.ADMIN["delete-carousel"], async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); })] : []),
133
98
  ];
134
99
  useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
135
100
  if (hasChildren) {
136
- return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
101
+ return _jsx(ListingLayout, { portal: "admin", ...props, children: children });
137
102
  }
138
103
  const displayRows = (localRows.length > 0 ? localRows : fetchedRows).map((row) => ({
139
104
  ...row,
@@ -178,5 +143,5 @@ export function AdminCarouselView({ children, onBulkDelete, ...props }) {
178
143
  ] })),
179
144
  },
180
145
  ];
181
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search slide titles", onSearchChange: setSearchInput, onSearchCommit: commitSearch, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), selection.selectedCount > 0 && bulkActions.length > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-error-surface px-4 py-3 text-sm text-error dark:border-red-900/60", children: errorMessage })), _jsx(DataTable, { rows: displayRows, columns: columns, isLoading: isLoading, emptyLabel: "No carousel slides \u2014 use 'New slide' to add one", getRowHref: (row) => `/admin/carousel/${row.id}/edit` })] }), _jsx(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [{ label: "All", value: "" }, { label: "Active", value: "true" }, { label: "Inactive", value: "false" }].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, active: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.active || "") === opt.value ? "bg-primary text-white border-primary" : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }) }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Carousel Slide", message: "Delete this carousel slide? This cannot be undone.", onConfirm: () => { deleteMutation.mutate(deleteTargetId); setDeleteTargetId(null); }, onClose: () => setDeleteTargetId(null), isDeleting: deleteMutation.isPending }))] }));
146
+ return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search slide titles", onSearchChange: setSearchInput, onSearchCommit: commitSearch, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), selection.selectedCount > 0 && bulkActions.length > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-error/20 bg-error-surface px-4 py-3 text-sm text-error", children: errorMessage })), _jsx(DataTable, { rows: displayRows, columns: columns, isLoading: isLoading, emptyLabel: "No carousel slides \u2014 use 'New slide' to add one", getRowHref: (row) => `/admin/carousel/${row.id}/edit` })] }), _jsx(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [{ label: "All", value: "" }, { label: "Active", value: "true" }, { label: "Inactive", value: "false" }].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, active: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.active || "") === opt.value ? "bg-primary text-white border-primary" : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }) }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Carousel Slide", message: "Delete this carousel slide? This cannot be undone.", onConfirm: () => { deleteMutation.mutate(deleteTargetId); setDeleteTargetId(null); }, onClose: () => setDeleteTargetId(null), isDeleting: deleteMutation.isPending }))] }));
182
147
  }
@@ -1,4 +1,3 @@
1
- import type { ListingViewShellProps } from "../../../ui";
2
- export interface AdminCartsViewProps extends ListingViewShellProps {
3
- }
1
+ import type { ListingLayoutProps } from "../../../ui";
2
+ export type AdminCartsViewProps = ListingLayoutProps;
4
3
  export declare function AdminCartsView({ children, ...props }: AdminCartsViewProps): import("react/jsx-runtime").JSX.Element;