@mohasinac/appkit 2.7.58 → 2.8.0

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 (364) 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/scams/og.js +1 -1
  33. package/dist/_internal/server/features/seo/og-layout.d.ts +42 -0
  34. package/dist/_internal/server/features/seo/og-layout.js +69 -0
  35. package/dist/_internal/server/features/stores/og.js +8 -41
  36. package/dist/_internal/server/features/sublisting-categories/og.js +11 -42
  37. package/dist/_internal/shared/actions/bulk-helpers.d.ts +3 -0
  38. package/dist/_internal/shared/actions/bulk-helpers.js +19 -0
  39. package/dist/_internal/shared/config/schema.d.ts +4 -4
  40. package/dist/client.d.ts +13 -6
  41. package/dist/client.js +9 -3
  42. package/dist/configs/next.js +11 -0
  43. package/dist/constants/index.d.ts +4 -0
  44. package/dist/constants/index.js +2 -0
  45. package/dist/constants/notification-types.d.ts +20 -0
  46. package/dist/constants/notification-types.js +37 -0
  47. package/dist/constants/pagination-presets.d.ts +39 -0
  48. package/dist/constants/pagination-presets.js +38 -0
  49. package/dist/errors/messages.d.ts +0 -4
  50. package/dist/errors/messages.js +0 -4
  51. package/dist/features/account/components/AddressesIndexListing.js +3 -4
  52. package/dist/features/account/components/UserOffersPanel.js +1 -1
  53. package/dist/features/account/components/UserSidebar.js +14 -10
  54. package/dist/features/account/components/UserSupportView.d.ts +1 -2
  55. package/dist/features/account/components/UserSupportView.js +9 -1
  56. package/dist/features/admin/actions/admin-actions.js +16 -1
  57. package/dist/features/admin/components/AdminAllEventEntriesView.d.ts +2 -3
  58. package/dist/features/admin/components/AdminAllEventEntriesView.js +50 -89
  59. package/dist/features/admin/components/AdminBidsView.d.ts +2 -3
  60. package/dist/features/admin/components/AdminBidsView.js +64 -104
  61. package/dist/features/admin/components/AdminBlogView.d.ts +3 -7
  62. package/dist/features/admin/components/AdminBlogView.js +53 -88
  63. package/dist/features/admin/components/AdminBrandEditorView.js +14 -17
  64. package/dist/features/admin/components/AdminBrandsView.d.ts +2 -3
  65. package/dist/features/admin/components/AdminBrandsView.js +85 -89
  66. package/dist/features/admin/components/AdminBundlesView.js +68 -130
  67. package/dist/features/admin/components/AdminCarouselView.d.ts +2 -2
  68. package/dist/features/admin/components/AdminCarouselView.js +22 -70
  69. package/dist/features/admin/components/AdminCartsView.d.ts +2 -3
  70. package/dist/features/admin/components/AdminCartsView.js +39 -89
  71. package/dist/features/admin/components/AdminCategoriesView.d.ts +3 -3
  72. package/dist/features/admin/components/AdminCategoriesView.js +97 -96
  73. package/dist/features/admin/components/AdminCategoryEditorView.js +2 -6
  74. package/dist/features/admin/components/AdminClassifiedView.d.ts +3 -0
  75. package/dist/features/admin/components/AdminClassifiedView.js +44 -0
  76. package/dist/features/admin/components/AdminContactView.d.ts +2 -2
  77. package/dist/features/admin/components/AdminContactView.js +105 -130
  78. package/dist/features/admin/components/AdminCouponEditorView.js +14 -17
  79. package/dist/features/admin/components/AdminCouponsView.d.ts +3 -6
  80. package/dist/features/admin/components/AdminCouponsView.js +69 -97
  81. package/dist/features/admin/components/AdminDigitalCodesView.d.ts +3 -0
  82. package/dist/features/admin/components/AdminDigitalCodesView.js +51 -0
  83. package/dist/features/admin/components/AdminFaqEditorView.js +14 -17
  84. package/dist/features/admin/components/AdminFaqsView.d.ts +4 -4
  85. package/dist/features/admin/components/AdminFaqsView.js +79 -86
  86. package/dist/features/admin/components/AdminFeatureEditorView.js +7 -9
  87. package/dist/features/admin/components/AdminFeaturesView.d.ts +2 -3
  88. package/dist/features/admin/components/AdminFeaturesView.js +57 -70
  89. package/dist/features/admin/components/AdminGroupedListingsView.d.ts +3 -0
  90. package/dist/features/admin/components/AdminGroupedListingsView.js +43 -0
  91. package/dist/features/admin/components/AdminHistoryView.d.ts +2 -3
  92. package/dist/features/admin/components/AdminHistoryView.js +35 -52
  93. package/dist/features/admin/components/AdminListingScaffold.d.ts +2 -2
  94. package/dist/features/admin/components/AdminListingScaffold.js +3 -3
  95. package/dist/features/admin/components/AdminLiveView.d.ts +3 -0
  96. package/dist/features/admin/components/AdminLiveView.js +50 -0
  97. package/dist/features/admin/components/AdminNewsletterView.d.ts +2 -2
  98. package/dist/features/admin/components/AdminNewsletterView.js +68 -108
  99. package/dist/features/admin/components/AdminNotificationsView.d.ts +2 -3
  100. package/dist/features/admin/components/AdminNotificationsView.js +67 -99
  101. package/dist/features/admin/components/AdminOrderEditorView.js +10 -10
  102. package/dist/features/admin/components/AdminOrdersView.d.ts +2 -3
  103. package/dist/features/admin/components/AdminOrdersView.js +93 -113
  104. package/dist/features/admin/components/AdminPayoutsView.d.ts +2 -3
  105. package/dist/features/admin/components/AdminPayoutsView.js +51 -97
  106. package/dist/features/admin/components/AdminPrizeDrawsView.d.ts +2 -3
  107. package/dist/features/admin/components/AdminPrizeDrawsView.js +41 -83
  108. package/dist/features/admin/components/AdminProductEditorView.js +3 -7
  109. package/dist/features/admin/components/AdminProductsView.d.ts +4 -4
  110. package/dist/features/admin/components/AdminProductsView.js +166 -167
  111. package/dist/features/admin/components/AdminReturnRequestsView.d.ts +1 -1
  112. package/dist/features/admin/components/AdminReturnRequestsView.js +64 -66
  113. package/dist/features/admin/components/AdminReviewsView.d.ts +3 -7
  114. package/dist/features/admin/components/AdminReviewsView.js +94 -116
  115. package/dist/features/admin/components/AdminScammersView.d.ts +2 -3
  116. package/dist/features/admin/components/AdminScammersView.js +53 -103
  117. package/dist/features/admin/components/AdminSectionsView.js +1 -1
  118. package/dist/features/admin/components/AdminSessionsView.d.ts +2 -3
  119. package/dist/features/admin/components/AdminSessionsView.js +62 -95
  120. package/dist/features/admin/components/AdminStoreAddressesView.d.ts +1 -1
  121. package/dist/features/admin/components/AdminStoreAddressesView.js +39 -53
  122. package/dist/features/admin/components/AdminStoreEditorView.js +21 -8
  123. package/dist/features/admin/components/AdminStoresView.d.ts +2 -3
  124. package/dist/features/admin/components/AdminStoresView.js +67 -105
  125. package/dist/features/admin/components/AdminSublistingCategoriesView.d.ts +1 -1
  126. package/dist/features/admin/components/AdminSublistingCategoriesView.js +29 -49
  127. package/dist/features/admin/components/AdminSublistingCategoryEditorView.js +17 -20
  128. package/dist/features/admin/components/AdminSupportTicketDetailView.d.ts +10 -1
  129. package/dist/features/admin/components/AdminSupportTicketDetailView.js +191 -5
  130. package/dist/features/admin/components/AdminSupportTicketsView.d.ts +2 -3
  131. package/dist/features/admin/components/AdminSupportTicketsView.js +65 -102
  132. package/dist/features/admin/components/AdminTeamView.d.ts +2 -2
  133. package/dist/features/admin/components/AdminTeamView.js +42 -85
  134. package/dist/features/admin/components/AdminUserEditorView.d.ts +11 -1
  135. package/dist/features/admin/components/AdminUserEditorView.js +80 -6
  136. package/dist/features/admin/components/AdminUsersView.d.ts +2 -3
  137. package/dist/features/admin/components/AdminUsersView.js +108 -106
  138. package/dist/features/admin/components/AdminViewCards.d.ts +1 -1
  139. package/dist/features/admin/components/AdminWishlistsView.d.ts +2 -3
  140. package/dist/features/admin/components/AdminWishlistsView.js +36 -62
  141. package/dist/features/admin/components/DataListingView.d.ts +122 -0
  142. package/dist/features/admin/components/DataListingView.js +66 -0
  143. package/dist/features/admin/components/index.d.ts +10 -4
  144. package/dist/features/admin/components/index.js +6 -2
  145. package/dist/features/admin/constants/filter-tabs.d.ts +23 -17
  146. package/dist/features/admin/constants/filter-tabs.js +21 -17
  147. package/dist/features/admin/hooks/useAdminListing.d.ts +59 -0
  148. package/dist/features/admin/hooks/useAdminListing.js +71 -0
  149. package/dist/features/admin/schemas/firestore.js +6 -7
  150. package/dist/features/auctions/server.d.ts +0 -1
  151. package/dist/features/auctions/server.js +0 -1
  152. package/dist/features/auth/actions/realtime-token-actions.js +1 -1
  153. package/dist/features/auth/repository/user.repository.js +1 -1
  154. package/dist/features/auth/schemas/firestore.d.ts +1 -0
  155. package/dist/features/blog/components/BlogIndexListing.js +3 -6
  156. package/dist/features/cart/repository/cart.repository.d.ts +4 -1
  157. package/dist/features/cart/repository/cart.repository.js +12 -0
  158. package/dist/features/categories/components/CategoriesIndexListing.js +3 -6
  159. package/dist/features/checkout/hooks/useCheckoutApi.d.ts +0 -2
  160. package/dist/features/checkout/index.d.ts +1 -1
  161. package/dist/features/events/components/AdminEventsView.d.ts +3 -3
  162. package/dist/features/events/components/AdminEventsView.js +50 -86
  163. package/dist/features/events/components/EventOfferCard.d.ts +19 -0
  164. package/dist/features/events/components/EventOfferCard.js +29 -0
  165. package/dist/features/events/components/EventRaffleEntryForm.d.ts +25 -0
  166. package/dist/features/events/components/EventRaffleEntryForm.js +37 -0
  167. package/dist/features/events/components/EventRafflesSection.d.ts +1 -4
  168. package/dist/features/events/components/EventRafflesSection.js +17 -6
  169. package/dist/features/events/components/EventSaleBanner.d.ts +21 -0
  170. package/dist/features/events/components/EventSaleBanner.js +18 -0
  171. package/dist/features/events/components/EventsIndexListing.js +3 -4
  172. package/dist/features/events/components/index.d.ts +6 -0
  173. package/dist/features/events/components/index.js +4 -0
  174. package/dist/features/events/repository/event-entry.repository.d.ts +5 -0
  175. package/dist/features/events/repository/event-entry.repository.js +7 -0
  176. package/dist/features/filters/AsyncFacetSection.d.ts +1 -1
  177. package/dist/features/homepage/components/AnnouncementBar.d.ts +4 -1
  178. package/dist/features/homepage/components/AnnouncementBar.js +51 -4
  179. package/dist/features/homepage/components/FAQSection.d.ts +0 -5
  180. package/dist/features/homepage/components/MarketplaceHomepageView.d.ts +3 -1
  181. package/dist/features/homepage/components/MarketplaceHomepageView.js +2 -2
  182. package/dist/features/homepage/components/index.d.ts +1 -1
  183. package/dist/features/homepage/components/index.js +1 -1
  184. package/dist/features/homepage/lib/live-stats.js +1 -1
  185. package/dist/features/homepage/lib/section-renderer.d.ts +2 -2
  186. package/dist/features/homepage/lib/section-renderer.js +2 -2
  187. package/dist/features/homepage/schemas/firestore.d.ts +0 -2
  188. package/dist/features/layout/index.d.ts +0 -2
  189. package/dist/features/layout/index.js +0 -1
  190. package/dist/features/orders/repository/orders.repository.d.ts +0 -1
  191. package/dist/features/orders/repository/orders.repository.js +0 -1
  192. package/dist/features/orders/server.d.ts +1 -1
  193. package/dist/features/orders/server.js +1 -1
  194. package/dist/features/pre-orders/server.d.ts +0 -1
  195. package/dist/features/pre-orders/server.js +0 -1
  196. package/dist/features/products/components/GroupSettingsPanel.js +65 -49
  197. package/dist/features/products/components/PrizeDrawItemsEditor.js +2 -2
  198. package/dist/features/products/components/PrizeDrawsSection.d.ts +1 -4
  199. package/dist/features/products/components/PrizeDrawsSection.js +17 -6
  200. package/dist/features/products/components/PrizeRevealModal.js +1 -1
  201. package/dist/features/products/components/ProductCardMetadataSection.d.ts +11 -0
  202. package/dist/features/products/components/ProductCardMetadataSection.js +25 -0
  203. package/dist/features/products/components/ProductDetailPageView.js +3 -1
  204. package/dist/features/products/components/ProductFeaturesSelector.js +1 -1
  205. package/dist/features/products/components/ProductGradingTab.d.ts +13 -0
  206. package/dist/features/products/components/ProductGradingTab.js +25 -0
  207. package/dist/features/products/components/ProductGrid.js +14 -2
  208. package/dist/features/products/components/ProductTabsShell.d.ts +5 -1
  209. package/dist/features/products/components/ProductTabsShell.js +6 -1
  210. package/dist/features/products/components/index.d.ts +4 -0
  211. package/dist/features/products/components/index.js +3 -0
  212. package/dist/features/products/constants/action-defs.d.ts +5 -0
  213. package/dist/features/products/constants/action-defs.js +52 -32
  214. package/dist/features/products/constants/sieve.d.ts +24 -4
  215. package/dist/features/products/constants/sieve.js +20 -11
  216. package/dist/features/products/repository/products.repository.d.ts +0 -2
  217. package/dist/features/products/repository/products.repository.js +0 -2
  218. package/dist/features/products/schemas/firestore.d.ts +17 -0
  219. package/dist/features/products/schemas/product-features.validators.d.ts +2 -2
  220. package/dist/features/products/schemas/product-templates.d.ts +2 -4
  221. package/dist/features/products/server.d.ts +1 -1
  222. package/dist/features/products/server.js +1 -1
  223. package/dist/features/products/types/index.d.ts +4 -0
  224. package/dist/features/promotions/components/CouponCard.js +5 -5
  225. package/dist/features/promotions/components/CouponsIndexListing.js +3 -2
  226. package/dist/features/promotions/server.d.ts +0 -1
  227. package/dist/features/promotions/server.js +0 -1
  228. package/dist/features/reviews/components/ReviewsIndexListing.js +3 -4
  229. package/dist/features/reviews/repository/reviews.repository.d.ts +0 -1
  230. package/dist/features/reviews/repository/reviews.repository.js +0 -1
  231. package/dist/features/reviews/server.d.ts +1 -1
  232. package/dist/features/reviews/server.js +1 -1
  233. package/dist/features/search/api/route.js +44 -1
  234. package/dist/features/search/components/Search.js +2 -0
  235. package/dist/features/search/hooks/useNavSuggestions.d.ts +5 -1
  236. package/dist/features/search/hooks/useNavSuggestions.js +31 -4
  237. package/dist/features/seller/components/BrandInlineSelect.js +2 -2
  238. package/dist/features/seller/components/CategoryInlineSelect.js +2 -2
  239. package/dist/features/seller/components/SellerAddressesView.js +10 -20
  240. package/dist/features/seller/components/SellerAuctionsView.d.ts +3 -3
  241. package/dist/features/seller/components/SellerAuctionsView.js +67 -106
  242. package/dist/features/seller/components/SellerBidsView.js +6 -6
  243. package/dist/features/seller/components/SellerBundlesView.js +72 -105
  244. package/dist/features/seller/components/SellerClassifiedView.js +74 -105
  245. package/dist/features/seller/components/SellerCouponEditorView.js +1 -1
  246. package/dist/features/seller/components/SellerCouponsView.d.ts +2 -2
  247. package/dist/features/seller/components/SellerCouponsView.js +51 -96
  248. package/dist/features/seller/components/SellerDigitalCodesView.js +70 -103
  249. package/dist/features/seller/components/SellerGroupedListingsView.js +34 -54
  250. package/dist/features/seller/components/SellerLiveView.js +70 -99
  251. package/dist/features/seller/components/SellerOffersPanel.js +1 -1
  252. package/dist/features/seller/components/SellerOffersView.d.ts +2 -2
  253. package/dist/features/seller/components/SellerOffersView.js +37 -70
  254. package/dist/features/seller/components/SellerOrdersView.d.ts +2 -2
  255. package/dist/features/seller/components/SellerOrdersView.js +10 -24
  256. package/dist/features/seller/components/SellerPayoutMethodsView.js +12 -24
  257. package/dist/features/seller/components/SellerPayoutsView.d.ts +2 -2
  258. package/dist/features/seller/components/SellerPayoutsView.js +34 -69
  259. package/dist/features/seller/components/SellerPreOrdersView.d.ts +2 -2
  260. package/dist/features/seller/components/SellerPreOrdersView.js +55 -97
  261. package/dist/features/seller/components/SellerPrizeDrawsView.d.ts +2 -2
  262. package/dist/features/seller/components/SellerPrizeDrawsView.js +55 -97
  263. package/dist/features/seller/components/SellerProductShell.d.ts +1 -1
  264. package/dist/features/seller/components/SellerProductsFilterDrawer.d.ts +1 -1
  265. package/dist/features/seller/components/SellerProductsFilterDrawer.js +3 -6
  266. package/dist/features/seller/components/SellerProductsView.d.ts +2 -2
  267. package/dist/features/seller/components/SellerProductsView.js +24 -32
  268. package/dist/features/seller/components/SellerShippingConfigsView.js +12 -24
  269. package/dist/features/seller/components/SellerSidebar.d.ts +0 -4
  270. package/dist/features/seller/components/SellerSidebar.js +0 -2
  271. package/dist/features/seller/components/SellerStoreCategoriesView.js +15 -34
  272. package/dist/features/seller/components/SellerTemplatesView.js +27 -43
  273. package/dist/features/seller/components/SellersListView.d.ts +1 -2
  274. package/dist/features/seller/components/analytics/SellerAnalyticsStats.d.ts +5 -0
  275. package/dist/features/seller/components/analytics/SellerAnalyticsStats.js +2 -8
  276. package/dist/features/seller/components/index.d.ts +0 -3
  277. package/dist/features/seller/components/index.js +0 -2
  278. package/dist/features/seller/server.d.ts +0 -1
  279. package/dist/features/seller/server.js +0 -1
  280. package/dist/features/shell/FormShell.d.ts +1 -1
  281. package/dist/features/shell/FormShell.js +4 -1
  282. package/dist/features/shell/field-groups/ImageFieldGroup.d.ts +18 -0
  283. package/dist/features/shell/field-groups/ImageFieldGroup.js +15 -0
  284. package/dist/features/shell/field-groups/SeoFieldGroup.d.ts +22 -0
  285. package/dist/features/shell/field-groups/SeoFieldGroup.js +16 -0
  286. package/dist/features/shell/field-groups/StatusFieldGroup.d.ts +35 -0
  287. package/dist/features/shell/field-groups/StatusFieldGroup.js +16 -0
  288. package/dist/features/shell/field-groups/TitleDescriptionGroup.d.ts +40 -0
  289. package/dist/features/shell/field-groups/TitleDescriptionGroup.js +16 -0
  290. package/dist/features/shell/field-groups/index.d.ts +13 -0
  291. package/dist/features/shell/field-groups/index.js +9 -0
  292. package/dist/features/shell/index.d.ts +2 -0
  293. package/dist/features/shell/index.js +1 -0
  294. package/dist/features/stores/components/StoreCapabilitiesGuideView.d.ts +1 -2
  295. package/dist/features/stores/components/StoreFinanceGuideView.d.ts +1 -2
  296. package/dist/features/stores/components/StoreHeader.js +2 -1
  297. package/dist/features/stores/components/StoreListingsGuideView.d.ts +1 -2
  298. package/dist/features/stores/components/StoreOrdersGuideView.d.ts +1 -2
  299. package/dist/features/stores/components/StoreReviewsListing.js +3 -4
  300. package/dist/features/stores/components/StoreScopedSearch.d.ts +16 -0
  301. package/dist/features/stores/components/StoreScopedSearch.js +27 -0
  302. package/dist/features/stores/components/StoreSettingsGuideView.d.ts +1 -2
  303. package/dist/features/stores/components/StoresIndexListing.js +3 -4
  304. package/dist/features/stores/server.d.ts +0 -1
  305. package/dist/features/stores/server.js +0 -1
  306. package/dist/features/support/schemas/firestore.d.ts +22 -1
  307. package/dist/features/support/schemas/firestore.js +10 -0
  308. package/dist/features/wishlist/server.d.ts +0 -1
  309. package/dist/features/wishlist/server.js +0 -1
  310. package/dist/index.d.ts +11 -33
  311. package/dist/index.js +17 -62
  312. package/dist/next/routing/route-map.d.ts +8 -0
  313. package/dist/next/routing/route-map.js +4 -0
  314. package/dist/react/contexts/SessionContext.d.ts +2 -0
  315. package/dist/react/contexts/SessionContext.js +2 -0
  316. package/dist/react/hooks/useEntityDelete.d.ts +15 -0
  317. package/dist/react/hooks/useEntityDelete.js +39 -0
  318. package/dist/react/hooks/useListingTypeFlags.d.ts +32 -0
  319. package/dist/react/hooks/useListingTypeFlags.js +19 -0
  320. package/dist/react/index.d.ts +2 -0
  321. package/dist/react/index.js +2 -0
  322. package/dist/repositories/index.d.ts +3 -3
  323. package/dist/repositories/index.js +3 -3
  324. package/dist/security/index.d.ts +1 -1
  325. package/dist/security/index.js +1 -1
  326. package/dist/security/pii-redact.d.ts +8 -0
  327. package/dist/security/pii-redact.js +10 -1
  328. package/dist/seed/grouped-listings-seed-data.d.ts +4 -0
  329. package/dist/seed/products-preorders-seed-data.d.ts +4 -0
  330. package/dist/seed/products-prize-draws-seed-data.js +3 -0
  331. package/dist/seed/site-settings-seed-data.js +5 -5
  332. package/dist/seed/sub-listings-seed-data.d.ts +4 -0
  333. package/dist/server.d.ts +2 -0
  334. package/dist/server.js +4 -0
  335. package/dist/styles.css +54 -395
  336. package/dist/tailwind-utilities.css +1 -1
  337. package/dist/ui/components/BaseListingCard.d.ts +10 -0
  338. package/dist/ui/components/BaseListingCard.js +17 -1
  339. package/dist/ui/components/DetailPageGallery.d.ts +32 -0
  340. package/dist/ui/components/DetailPageGallery.js +47 -0
  341. package/dist/ui/components/DetailPageHero.d.ts +30 -0
  342. package/dist/ui/components/DetailPageHero.js +22 -0
  343. package/dist/ui/components/DetailPageTabs.d.ts +34 -0
  344. package/dist/ui/components/DetailPageTabs.js +38 -0
  345. package/dist/ui/components/HorizontalScroller.style.css +15 -2
  346. package/dist/ui/components/ListingFilterDrawer.d.ts +10 -0
  347. package/dist/ui/components/ListingFilterDrawer.js +8 -0
  348. package/dist/ui/components/ListingLayout.d.ts +11 -2
  349. package/dist/ui/components/ListingLayout.js +12 -6
  350. package/dist/ui/components/PaginatedSelect.d.ts +66 -0
  351. package/dist/ui/components/PaginatedSelect.js +201 -0
  352. package/dist/ui/components/PaginatedSelect.style.css +254 -0
  353. package/dist/ui/components/Semantic.d.ts +0 -4
  354. package/dist/ui/components/Semantic.js +0 -2
  355. package/dist/ui/components/SettingsSection.d.ts +47 -0
  356. package/dist/ui/components/SettingsSection.js +38 -0
  357. package/dist/ui/components/index.style.css +1 -4
  358. package/dist/ui/index.d.ts +14 -14
  359. package/dist/ui/index.js +7 -7
  360. package/dist/utils/id-generators.d.ts +1 -18
  361. package/dist/utils/id-generators.js +51 -18
  362. package/dist/validation/schemas.d.ts +25 -0
  363. package/dist/validation/schemas.js +28 -0
  364. package/package.json +1 -1
@@ -1,79 +1,45 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React, { useState, useCallback } from "react";
4
- import { X } from "lucide-react";
5
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
6
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
7
- import { BulkActionBar, FilterChipGroup, ListingToolbar, Pagination, ListingViewShell, useToast } from "../../../ui";
4
+ import { FilterChipGroup, ListingLayout, useToast } from "../../../ui";
8
5
  import { apiClient } from "../../../http";
9
6
  import { QuickEditMenu } from "./QuickEditMenu";
10
- import { AdminViewCards } from "./AdminViewCards";
11
7
  import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
12
8
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
13
9
  import { ADMIN_ORDER_STATUS_TABS } from "../constants/filter-tabs";
14
- import { toRecordArray, toRelativeDate, toRupees, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
15
- import { DataTable } from "./DataTable";
10
+ import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../hooks/useAdminListingData";
11
+ import { DataListingView } from "./DataListingView";
16
12
  import { AdminOrderEditorView } from "./AdminOrderEditorView";
17
- import { useBottomActions } from "../../layout";
18
- const PAGE_SIZE = 25;
19
- const FILTER_KEYS = ["status"];
20
- const DEFAULT_SORT = "-createdAt";
21
- const SORT_OPTIONS = [
22
- { value: "-createdAt", label: "Newest" },
23
- { value: "createdAt", label: "Oldest" },
24
- ];
25
- const STATUS_OPTIONS = ADMIN_ORDER_STATUS_TABS;
26
- function OrdersFilterDrawer({ filterOpen, setFilterOpen, activeFilterCount, clearFilters, pendingFilters, setPendingFilters, applyFilters, }) {
27
- if (!filterOpen)
28
- return null;
29
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40 bg-black/40", "aria-hidden": "true", onClick: () => setFilterOpen(false) }), _jsxs("div", { className: "fixed inset-y-0 left-0 z-50 flex w-80 flex-col bg-white dark:bg-slate-900 shadow-2xl", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: [_jsx("span", { className: "text-base font-semibold text-zinc-900 dark:text-zinc-100", children: "Filters" }), _jsxs("div", { className: "flex items-center gap-2", children: [activeFilterCount > 0 && (_jsx("button", { type: "button", onClick: clearFilters, className: "text-xs text-zinc-500 hover:text-rose-500 dark:text-zinc-400 transition-colors", children: "Clear all" })), _jsx("button", { type: "button", onClick: () => setFilterOpen(false), "aria-label": "Close", className: "rounded-lg p-1.5 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors", children: _jsx(X, { className: "h-5 w-5" }) })] })] }), _jsx("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5", children: _jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }) }), _jsx("div", { className: "border-t border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: _jsxs("button", { type: "button", onClick: applyFilters, className: "w-full rounded-lg bg-primary py-2.5 text-sm font-semibold text-white hover:bg-primary-600 transition-colors active:scale-[0.98]", children: ["Apply Filters", activeFilterCount > 0 ? ` (${activeFilterCount})` : ""] }) })] })] }));
30
- }
31
13
  export function AdminOrdersView({ children, ...props }) {
32
- const hasChildren = React.Children.count(children) > 0;
33
14
  const { showToast } = useToast();
34
- const [view, setView] = useState("table");
35
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
36
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
37
- const [filterOpen, setFilterOpen] = useState(false);
38
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
39
15
  const [drawerOpen, setDrawerOpen] = useState(false);
40
16
  const [selectedRow, setSelectedRow] = useState(null);
41
- const openFilters = useCallback(() => {
42
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
43
- setFilterOpen(true);
44
- }, [table]);
45
- const applyFilters = useCallback(() => {
46
- const updates = { page: "1" };
47
- for (const k of FILTER_KEYS)
48
- updates[k] = pendingFilters[k] ?? "";
49
- table.setMany(updates);
50
- setFilterOpen(false);
51
- }, [pendingFilters, table]);
52
- const clearFilters = useCallback(() => {
53
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
54
- }, []);
55
- const resetAll = useCallback(() => {
56
- const updates = { q: "", sort: "" };
57
- for (const k of FILTER_KEYS)
58
- updates[k] = "";
59
- table.setMany(updates);
60
- setSearchInput("");
61
- }, [table]);
62
- const commitSearch = useCallback(() => {
63
- table.set("q", searchInput.trim());
64
- }, [searchInput, table]);
65
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
66
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
67
- const statusRaw = table.get("status");
68
- const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
69
- const { rows, total, isLoading, errorMessage } = useAdminListingData({
17
+ const handleQuickStatus = useCallback(async (id, status) => {
18
+ try {
19
+ await apiClient.patch(ADMIN_ENDPOINTS.ORDER_BY_ID(id), { status });
20
+ showToast("Order status updated.", "success");
21
+ }
22
+ catch (err) {
23
+ showToast(err?.message ?? "Failed to update order.", "error");
24
+ throw err;
25
+ }
26
+ }, [showToast]);
27
+ if (React.Children.count(children) > 0) {
28
+ return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
29
+ }
30
+ const config = {
31
+ portal: "admin",
32
+ title: "Orders",
33
+ searchPlaceholder: "Search orders, buyers, or tracking IDs",
34
+ emptyLabel: "No orders found",
35
+ filterKeys: ["status"],
36
+ defaultSort: "-createdAt",
70
37
  queryKey: ["admin", "orders", "listing"],
71
38
  endpoint: ADMIN_ENDPOINTS.ORDERS,
72
- page: table.getNumber("page", 1),
73
- pageSize: PAGE_SIZE,
74
- sorts: table.get("sort") || DEFAULT_SORT,
75
- filters,
76
- q: table.get("q") || undefined,
39
+ sortOptions: [
40
+ { value: "-createdAt", label: "Newest" },
41
+ { value: "createdAt", label: "Oldest" },
42
+ ],
77
43
  mapRows: (response) => toRecordArray(response.orders).map((item, index) => ({
78
44
  id: toStringValue(item.id, `order-${index}`),
79
45
  primary: `Order ${toStringValue(item.orderNumber ?? item.id, "-")}`,
@@ -83,57 +49,71 @@ export function AdminOrdersView({ children, ...props }) {
83
49
  ].join(" · "),
84
50
  status: toStringValue(item.status, "Unknown"),
85
51
  updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
86
- _raw: item,
87
52
  })),
88
53
  getTotal: (response, mappedRows) => typeof response.meta?.total === "number" ? response.meta.total : mappedRows.length,
89
- });
90
- const handleQuickStatus = useCallback(async (id, status) => {
91
- try {
92
- await apiClient.patch(ADMIN_ENDPOINTS.ORDER_BY_ID(id), { status });
93
- showToast("Order status updated.", "success");
94
- }
95
- catch (err) {
96
- showToast(err?.message ?? "Failed to update order.", "error");
97
- throw err;
98
- }
99
- }, [showToast]);
100
- const currentPage = table.getNumber("page", 1);
101
- const totalPages = Math.ceil(total / PAGE_SIZE);
102
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
103
- if (hasChildren) {
104
- return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
105
- }
106
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
107
- { id: "mark-shipped", label: ACTIONS.ADMIN["mark-shipped"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
108
- void handleQuickStatus(id, "SHIPPED"); selection.clearSelection(); } },
109
- { id: "mark-delivered", label: ACTIONS.ADMIN["mark-delivered"].label, variant: "primary", onClick: () => { for (const id of selection.selectedIds)
110
- void handleQuickStatus(id, "DELIVERED"); selection.clearSelection(); } },
111
- { id: "mark-cancelled", label: ACTIONS.ADMIN["cancel-order"].label, variant: "danger", onClick: () => { for (const id of selection.selectedIds)
112
- void handleQuickStatus(id, "CANCELLED"); selection.clearSelection(); } },
113
- ] } } : {});
114
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search orders, buyers, or tracking IDs", 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 }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
115
- { id: "mark-shipped", label: ACTIONS.ADMIN["mark-shipped"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
116
- void handleQuickStatus(id, "SHIPPED"); selection.clearSelection(); } },
117
- { id: "mark-delivered", label: ACTIONS.ADMIN["mark-delivered"].label, variant: "primary", onClick: () => { for (const id of selection.selectedIds)
118
- void handleQuickStatus(id, "DELIVERED"); selection.clearSelection(); } },
119
- { id: "mark-cancelled", label: ACTIONS.ADMIN["cancel-order"].label, variant: "danger", onClick: () => { for (const id of selection.selectedIds)
120
- void handleQuickStatus(id, "CANCELLED"); selection.clearSelection(); } },
121
- ] }), 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 orders found", selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: (next) => next ? selection.setSelectedIds(rows.map(r => r.id)) : selection.clearSelection(), renderRowActions: (row) => (_jsx(QuickEditMenu, { actions: [
122
- {
123
- label: "View full details",
124
- onClick: () => { setSelectedRow(row); setDrawerOpen(true); },
125
- },
126
- {
127
- label: "Update status",
128
- separator: true,
129
- formTitle: "Update Order Status",
130
- fields: [
131
- { name: "status", label: "Status", type: "select", required: true,
132
- options: STATUS_OPTIONS.filter((t) => t.id !== "All").map((t) => ({ value: t.id, label: t.label })) },
133
- ],
134
- defaultValues: { status: row.status },
135
- onSubmit: (vals) => handleQuickStatus(row.id, String(vals.status ?? "")),
136
- submitLabel: "Update",
137
- },
138
- ] })) })) : (_jsx(AdminViewCards, { rows: rows, view: view, isLoading: isLoading, emptyLabel: "No orders found", onRowClick: (row) => { setSelectedRow(row); setDrawerOpen(true); }, selectedIdSet: selection.selectedIdSet, onToggleSelect: selection.toggle }))] }), _jsx(OrdersFilterDrawer, { filterOpen: filterOpen, setFilterOpen: setFilterOpen, activeFilterCount: activeFilterCount, clearFilters: clearFilters, pendingFilters: pendingFilters, setPendingFilters: setPendingFilters, applyFilters: applyFilters })] }), _jsx(AdminOrderEditorView, { open: drawerOpen, onClose: () => setDrawerOpen(false), orderId: selectedRow?.id, orderLabel: selectedRow?.primary, currentStatus: selectedRow?.status })] }));
54
+ buildFilters: (f) => (f.status && f.status !== "All" ? `status==${f.status}` : undefined),
55
+ buildBulkActions: (selection) => [
56
+ {
57
+ id: "mark-shipped",
58
+ label: ACTIONS.ADMIN["mark-shipped"].label,
59
+ variant: "secondary",
60
+ onClick: () => {
61
+ for (const id of selection.selectedIds)
62
+ void handleQuickStatus(id, "shipped");
63
+ selection.clearSelection();
64
+ },
65
+ },
66
+ {
67
+ id: "mark-delivered",
68
+ label: ACTIONS.ADMIN["mark-delivered"].label,
69
+ variant: "primary",
70
+ onClick: () => {
71
+ for (const id of selection.selectedIds)
72
+ void handleQuickStatus(id, "delivered");
73
+ selection.clearSelection();
74
+ },
75
+ },
76
+ {
77
+ id: "mark-cancelled",
78
+ label: ACTIONS.ADMIN["cancel-order"].label,
79
+ variant: "danger",
80
+ onClick: () => {
81
+ for (const id of selection.selectedIds)
82
+ void handleQuickStatus(id, "cancelled");
83
+ selection.clearSelection();
84
+ },
85
+ },
86
+ ],
87
+ renderRowActions: (row) => (_jsx(QuickEditMenu, { actions: [
88
+ {
89
+ label: "View full details",
90
+ onClick: () => {
91
+ setSelectedRow(row);
92
+ setDrawerOpen(true);
93
+ },
94
+ },
95
+ {
96
+ label: "Update status",
97
+ separator: true,
98
+ formTitle: "Update Order Status",
99
+ fields: [
100
+ {
101
+ name: "status",
102
+ label: "Status",
103
+ type: "select",
104
+ required: true,
105
+ options: ADMIN_ORDER_STATUS_TABS.filter((t) => t.id !== "All").map((t) => ({
106
+ value: t.id,
107
+ label: t.label,
108
+ })),
109
+ },
110
+ ],
111
+ defaultValues: { status: row.status },
112
+ onSubmit: (vals) => handleQuickStatus(row.id, String(vals.status ?? "")),
113
+ submitLabel: "Update",
114
+ },
115
+ ] })),
116
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_ORDER_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
117
+ };
118
+ return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), _jsx(AdminOrderEditorView, { open: drawerOpen, onClose: () => setDrawerOpen(false), orderId: selectedRow?.id, orderLabel: selectedRow?.primary, currentStatus: selectedRow?.status })] }));
139
119
  }
@@ -1,4 +1,3 @@
1
- import type { ListingViewShellProps } from "../../../ui";
2
- export interface AdminPayoutsViewProps extends ListingViewShellProps {
3
- }
1
+ import type { ListingLayoutProps } from "../../../ui";
2
+ export type AdminPayoutsViewProps = ListingLayoutProps;
4
3
  export declare function AdminPayoutsView({ children, ...props }: AdminPayoutsViewProps): import("react/jsx-runtime").JSX.Element;
@@ -1,89 +1,20 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import React, { useState, useCallback } from "react";
4
- import { X } from "lucide-react";
3
+ import React, { useState } from "react";
5
4
  import { useMutation, useQueryClient } from "@tanstack/react-query";
6
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
7
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
8
- import { BulkActionBar, Button, Form, FormActions, FilterChipGroup, Input, ListingToolbar, ListingViewShell, Modal, Pagination, RowActionMenu, useToast, } from "../../../ui";
5
+ import { Button, FilterChipGroup, Form, FormActions, Input, ListingLayout, Modal, RowActionMenu, useToast, } from "../../../ui";
9
6
  import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
10
7
  import { ADMIN_PAYOUT_STATUS_TABS } from "../constants/filter-tabs";
11
8
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
12
- import { toRecordArray, toRelativeDate, toRupees, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
13
- import { DataTable } from "./DataTable";
9
+ import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../hooks/useAdminListingData";
10
+ import { DataListingView } from "./DataListingView";
14
11
  import { apiClient } from "../../../http";
15
- import { useBottomActions } from "../../layout";
16
- const PAGE_SIZE = 25;
17
- const FILTER_KEYS = ["status"];
18
- const DEFAULT_SORT = "-createdAt";
19
- const SORT_OPTIONS = [
20
- { value: "-createdAt", label: "Newest" },
21
- { value: "createdAt", label: "Oldest" },
22
- { value: "-amount", label: "Highest amount" },
23
- ];
24
- const STATUS_OPTIONS = ADMIN_PAYOUT_STATUS_TABS;
25
- function PayoutsFilterDrawer({ filterOpen, setFilterOpen, activeFilterCount, clearFilters, pendingFilters, setPendingFilters, applyFilters, }) {
26
- if (!filterOpen)
27
- return null;
28
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40 bg-black/40", "aria-hidden": "true", onClick: () => setFilterOpen(false) }), _jsxs("div", { className: "fixed inset-y-0 left-0 z-50 flex w-80 flex-col bg-white dark:bg-slate-900 shadow-2xl", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: [_jsx("span", { className: "text-base font-semibold text-zinc-900 dark:text-zinc-100", children: "Filters" }), _jsxs("div", { className: "flex items-center gap-2", children: [activeFilterCount > 0 && (_jsx("button", { type: "button", onClick: clearFilters, className: "text-xs text-zinc-500 hover:text-rose-500 dark:text-zinc-400 transition-colors", children: "Clear all" })), _jsx("button", { type: "button", onClick: () => setFilterOpen(false), "aria-label": "Close", className: "rounded-lg p-1.5 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors", children: _jsx(X, { className: "h-5 w-5" }) })] })] }), _jsx("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5", children: _jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }) }), _jsx("div", { className: "border-t border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: _jsxs("button", { type: "button", onClick: applyFilters, className: "w-full rounded-lg bg-primary py-2.5 text-sm font-semibold text-white hover:bg-primary-600 transition-colors active:scale-[0.98]", children: ["Apply Filters", activeFilterCount > 0 ? ` (${activeFilterCount})` : ""] }) })] })] }));
29
- }
30
12
  export function AdminPayoutsView({ children, ...props }) {
31
- const hasChildren = React.Children.count(children) > 0;
32
- const [view, setView] = useState("table");
33
13
  const [markPaidOpen, setMarkPaidOpen] = useState(false);
34
14
  const [selectedPayoutId, setSelectedPayoutId] = useState(null);
35
15
  const [transactionId, setTransactionId] = useState("");
36
16
  const toast = useToast();
37
17
  const queryClient = useQueryClient();
38
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
39
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
40
- const [filterOpen, setFilterOpen] = useState(false);
41
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
42
- const openFilters = useCallback(() => {
43
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
44
- setFilterOpen(true);
45
- }, [table]);
46
- const applyFilters = useCallback(() => {
47
- const updates = { page: "1" };
48
- for (const k of FILTER_KEYS)
49
- updates[k] = pendingFilters[k] ?? "";
50
- table.setMany(updates);
51
- setFilterOpen(false);
52
- }, [pendingFilters, table]);
53
- const clearFilters = useCallback(() => {
54
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
55
- }, []);
56
- const resetAll = useCallback(() => {
57
- const updates = { q: "", sort: "" };
58
- for (const k of FILTER_KEYS)
59
- updates[k] = "";
60
- table.setMany(updates);
61
- setSearchInput("");
62
- }, [table]);
63
- const commitSearch = useCallback(() => {
64
- table.set("q", searchInput.trim());
65
- }, [searchInput, table]);
66
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
67
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
68
- const statusRaw = table.get("status");
69
- const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
70
- const { rows, total, isLoading, errorMessage } = useAdminListingData({
71
- queryKey: ["admin", "payouts", "listing"],
72
- endpoint: ADMIN_ENDPOINTS.PAYOUTS,
73
- page: table.getNumber("page", 1),
74
- pageSize: PAGE_SIZE,
75
- sorts: table.get("sort") || DEFAULT_SORT,
76
- filters,
77
- q: table.get("q") || undefined,
78
- mapRows: (response) => toRecordArray(response.payouts).map((item, index) => ({
79
- id: toStringValue(item.id, `payout-${index}`),
80
- primary: [`Payout ${toStringValue(item.id, "-")}`, toRupees(item.amount)].join(" · "),
81
- secondary: toStringValue(item.storeName ?? item.sellerName, "Unknown store"),
82
- status: toStringValue(item.status, "Pending"),
83
- updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
84
- })),
85
- getTotal: (response, mappedRows) => typeof response.meta?.total === "number" ? response.meta.total : mappedRows.length,
86
- });
87
18
  const markPaid = useMutation({
88
19
  mutationFn: () => {
89
20
  if (!selectedPayoutId)
@@ -125,31 +56,54 @@ export function AdminPayoutsView({ children, ...props }) {
125
56
  setMarkPaidOpen(false);
126
57
  setTransactionId("");
127
58
  };
128
- const currentPage = table.getNumber("page", 1);
129
- const totalPages = Math.ceil(total / PAGE_SIZE);
130
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
131
- if (hasChildren) {
132
- return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
59
+ if (React.Children.count(children) > 0) {
60
+ return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
133
61
  }
134
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search stores, payout IDs, or order groups", 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: _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: handleExportCsv, children: ACTIONS.ADMIN["export-csv"].label }) }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
135
- { id: "mark-paid", label: ACTIONS.ADMIN["mark-paid"].label, variant: "primary", onClick: () => { selection.clearSelection(); } },
136
- ] }), 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, { rows: rows, isLoading: isLoading, emptyLabel: "No payouts found", renderRowActions: (row) => {
137
- const pr = row;
138
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
139
- { id: "mark-paid", label: ACTIONS.ADMIN["mark-paid"].label, variant: "primary", onClick: () => { selection.clearSelection(); } },
140
- ] } } : {});
141
- return (_jsx(RowActionMenu, { actions: [
142
- {
143
- label: ACTIONS.ADMIN["grant-payout"].label,
144
- onClick: () => {
145
- setSelectedPayoutId(pr.id);
146
- setMarkPaidOpen(true);
147
- },
148
- disabled: pr.status.toLowerCase() === "paid" ||
149
- pr.status.toLowerCase() === "cancelled",
150
- },
151
- ] }));
152
- } })] }), _jsx(PayoutsFilterDrawer, { filterOpen: filterOpen, setFilterOpen: setFilterOpen, activeFilterCount: activeFilterCount, clearFilters: clearFilters, pendingFilters: pendingFilters, setPendingFilters: setPendingFilters, applyFilters: applyFilters })] }), _jsx(Modal, { isOpen: markPaidOpen, onClose: closePaidModal, title: "Mark payout as paid", children: _jsxs(Form, { className: "space-y-4", onSubmit: (e) => {
62
+ const config = {
63
+ portal: "admin",
64
+ title: "Payouts",
65
+ searchPlaceholder: "Search stores, payout IDs, or order groups",
66
+ emptyLabel: "No payouts found",
67
+ filterKeys: ["status"],
68
+ defaultSort: "-createdAt",
69
+ queryKey: ["admin", "payouts", "listing"],
70
+ endpoint: ADMIN_ENDPOINTS.PAYOUTS,
71
+ sortOptions: [
72
+ { value: "-createdAt", label: "Newest" },
73
+ { value: "createdAt", label: "Oldest" },
74
+ { value: "-amount", label: "Highest amount" },
75
+ ],
76
+ mapRows: (response) => toRecordArray(response.payouts).map((item, index) => ({
77
+ id: toStringValue(item.id, `payout-${index}`),
78
+ primary: [`Payout ${toStringValue(item.id, "-")}`, toRupees(item.amount)].join(" · "),
79
+ secondary: toStringValue(item.storeName ?? item.sellerName, "Unknown store"),
80
+ status: toStringValue(item.status, "Pending"),
81
+ updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
82
+ })),
83
+ getTotal: (response, mappedRows) => typeof response.meta?.total === "number" ? response.meta.total : mappedRows.length,
84
+ buildFilters: (state) => state.status && state.status !== "All" ? `status==${state.status}` : undefined,
85
+ toolbarExtra: (_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: handleExportCsv, children: ACTIONS.ADMIN["export-csv"].label })),
86
+ buildBulkActions: (selection) => [
87
+ {
88
+ id: "mark-paid",
89
+ label: ACTIONS.ADMIN["mark-paid"].label,
90
+ variant: "primary",
91
+ onClick: () => selection.clearSelection(),
92
+ },
93
+ ],
94
+ renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
95
+ {
96
+ label: ACTIONS.ADMIN["grant-payout"].label,
97
+ onClick: () => {
98
+ setSelectedPayoutId(row.id);
99
+ setMarkPaidOpen(true);
100
+ },
101
+ disabled: row.status.toLowerCase() === "paid" || row.status.toLowerCase() === "cancelled",
102
+ },
103
+ ] })),
104
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_PAYOUT_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
105
+ };
106
+ return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), _jsx(Modal, { isOpen: markPaidOpen, onClose: closePaidModal, title: "Mark payout as paid", children: _jsxs(Form, { className: "space-y-4", onSubmit: (e) => {
153
107
  e.preventDefault();
154
108
  markPaid.mutate();
155
109
  }, children: [_jsx(Input, { label: "Transaction / reference ID", value: transactionId, onChange: (e) => setTransactionId(e.target.value), placeholder: "UTR, UPI ref, or bank transfer ID (optional)" }), _jsxs(FormActions, { align: "right", children: [_jsx(Button, { type: "button", variant: "outline", onClick: closePaidModal, children: "Cancel" }), _jsx(Button, { type: "submit", variant: "primary", disabled: markPaid.isPending, children: markPaid.isPending ? "Saving..." : "Confirm paid" })] })] }) })] }));
@@ -1,4 +1,3 @@
1
- import type { ListingViewShellProps } from "../../../ui";
2
- export interface AdminPrizeDrawsViewProps extends ListingViewShellProps {
3
- }
1
+ import type { ListingLayoutProps } from "../../../ui";
2
+ export type AdminPrizeDrawsViewProps = ListingLayoutProps;
4
3
  export declare function AdminPrizeDrawsView({ children, ...props }: AdminPrizeDrawsViewProps): import("react/jsx-runtime").JSX.Element;
@@ -1,29 +1,14 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import React, { useState, useCallback } from "react";
4
- import { Pencil, X } from "lucide-react";
5
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
6
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
7
- import { Alert, Badge, BulkActionBar, Button, FilterChipGroup, ListingToolbar, ListingViewShell, Pagination, Text } from "../../../ui";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React from "react";
4
+ import { Pencil } from "lucide-react";
5
+ import { Badge, Button, FilterChipGroup, ListingLayout, Text } from "../../../ui";
8
6
  import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
9
7
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
10
8
  import { ADMIN_PRODUCT_STATUS_TABS } from "../constants/filter-tabs";
11
9
  import { ROUTES } from "../../../constants";
12
- import { toRecordArray, toRelativeDate, toRupees, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
13
- import { DataTable } from "./DataTable";
14
- import { useBottomActions } from "../../layout";
15
- const PAGE_SIZE = 25;
16
- const FILTER_KEYS = ["status"];
17
- const DEFAULT_SORT = "-createdAt";
18
- // Hardcoded sieve clause — this view only ever shows prize draws.
19
- const LISTING_TYPE_FILTER = "listingType==prize-draw";
20
- const SORT_OPTIONS = [
21
- { value: "-createdAt", label: "Newest" },
22
- { value: "createdAt", label: "Oldest" },
23
- { value: "title", label: "Title A–Z" },
24
- { value: "prizeDrawEndDate", label: "Draw Date Soon" },
25
- ];
26
- const STATUS_OPTIONS = ADMIN_PRODUCT_STATUS_TABS;
10
+ import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../hooks/useAdminListingData";
11
+ import { DataListingView } from "./DataListingView";
27
12
  const STATUS_VARIANT = {
28
13
  published: "success",
29
14
  active: "success",
@@ -50,7 +35,7 @@ const PRIZE_DRAW_COLUMNS = [
50
35
  header: "Status",
51
36
  sortable: true,
52
37
  className: "w-28",
53
- render: (row) => (_jsx(Badge, { variant: STATUS_VARIANT[row.status] ?? "default", children: row.status })),
38
+ render: (row) => _jsx(Badge, { variant: STATUS_VARIANT[row.status] ?? "default", children: row.status }),
54
39
  },
55
40
  {
56
41
  key: "drawDate",
@@ -66,55 +51,26 @@ const PRIZE_DRAW_COLUMNS = [
66
51
  render: (row) => (_jsx("span", { className: "text-sm text-[var(--appkit-color-text-muted)]", children: row.updatedAt })),
67
52
  },
68
53
  ];
69
- function PrizeDrawsFilterDrawer({ filterOpen, setFilterOpen, activeFilterCount, clearFilters, pendingFilters, setPendingFilters, applyFilters, }) {
70
- if (!filterOpen)
71
- return null;
72
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40 bg-black/40", "aria-hidden": "true", onClick: () => setFilterOpen(false) }), _jsxs("div", { className: "fixed inset-y-0 left-0 z-50 flex w-80 flex-col bg-[var(--appkit-color-surface)] shadow-2xl", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-[var(--appkit-color-border)] px-4 py-3.5", children: [_jsx("span", { className: "text-base font-semibold text-[var(--appkit-color-text)]", children: "Filters" }), _jsxs("div", { className: "flex items-center gap-2", children: [activeFilterCount > 0 && (_jsx("button", { type: "button", onClick: clearFilters, className: "text-xs text-[var(--appkit-color-text-muted)] hover:text-[var(--appkit-color-error)] transition-colors", children: "Clear all" })), _jsx("button", { type: "button", onClick: () => setFilterOpen(false), "aria-label": "Close", className: "rounded-lg p-1.5 text-[var(--appkit-color-text-muted)] hover:bg-[var(--appkit-color-border-subtle)] transition-colors", children: _jsx(X, { className: "h-5 w-5" }) })] })] }), _jsx("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5", children: _jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }) }), _jsx("div", { className: "border-t border-[var(--appkit-color-border)] px-4 py-3.5", children: _jsxs("button", { type: "button", onClick: applyFilters, className: "w-full rounded-lg bg-[var(--appkit-color-primary)] py-2.5 text-sm font-semibold text-white hover:opacity-90 transition-opacity active:scale-[0.98]", children: ["Apply Filters", activeFilterCount > 0 ? ` (${activeFilterCount})` : ""] }) })] })] }));
73
- }
74
54
  export function AdminPrizeDrawsView({ children, ...props }) {
75
- const hasChildren = React.Children.count(children) > 0;
76
- const [view, setView] = useState("table");
77
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
78
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
79
- const [filterOpen, setFilterOpen] = useState(false);
80
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
81
- const openFilters = useCallback(() => {
82
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
83
- setFilterOpen(true);
84
- }, [table]);
85
- const applyFilters = useCallback(() => {
86
- const updates = { page: "1" };
87
- for (const k of FILTER_KEYS)
88
- updates[k] = pendingFilters[k] ?? "";
89
- table.setMany(updates);
90
- setFilterOpen(false);
91
- }, [pendingFilters, table]);
92
- const clearFilters = useCallback(() => {
93
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
94
- }, []);
95
- const resetAll = useCallback(() => {
96
- const updates = { q: "", sort: "" };
97
- for (const k of FILTER_KEYS)
98
- updates[k] = "";
99
- table.setMany(updates);
100
- setSearchInput("");
101
- }, [table]);
102
- const commitSearch = useCallback(() => {
103
- table.set("q", searchInput.trim());
104
- }, [searchInput, table]);
105
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
106
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
107
- const statusRaw = table.get("status");
108
- const statusFilter = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
109
- const filters = [LISTING_TYPE_FILTER, statusFilter].filter(Boolean).join(",") || undefined;
110
- const { rows, total, isLoading, errorMessage } = useAdminListingData({
55
+ if (React.Children.count(children) > 0) {
56
+ return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
57
+ }
58
+ const config = {
59
+ portal: "admin",
60
+ title: "Prize Draws",
61
+ searchPlaceholder: "Search prize draws by name or store…",
62
+ emptyLabel: "No prize draws found",
63
+ filterKeys: ["status"],
64
+ defaultSort: "-createdAt",
111
65
  queryKey: ["admin", "prize-draws", "listing"],
112
66
  endpoint: ADMIN_ENDPOINTS.PRODUCTS,
113
- page: table.getNumber("page", 1),
114
- pageSize: PAGE_SIZE,
115
- sorts: table.get("sort") || DEFAULT_SORT,
116
- filters,
117
- q: table.get("q") || undefined,
67
+ sortOptions: [
68
+ { value: "-createdAt", label: "Newest" },
69
+ { value: "createdAt", label: "Oldest" },
70
+ { value: "title", label: "Title A–Z" },
71
+ { value: "prizeDrawEndDate", label: "Draw Date Soon" },
72
+ ],
73
+ columns: PRIZE_DRAW_COLUMNS,
118
74
  mapRows: (response) => toRecordArray(response.items).map((item, index) => {
119
75
  const priceRaw = typeof item.price === "number" ? item.price : 0;
120
76
  return {
@@ -131,19 +87,21 @@ export function AdminPrizeDrawsView({ children, ...props }) {
131
87
  };
132
88
  }),
133
89
  getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
134
- });
135
- const currentPage = table.getNumber("page", 1);
136
- const totalPages = Math.ceil(total / PAGE_SIZE);
137
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
138
- if (hasChildren) {
139
- return (_jsx(ListingViewShell, { portal: "admin", ...props, children: children }));
140
- }
141
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
142
- { id: "delete", label: ACTIONS.ADMIN["delete-prize-draw"].label, variant: "secondary", onClick: () => { selection.clearSelection(); } },
143
- ] } } : {});
144
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search prize draws by name or store\u2026", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => {
145
- table.set("sort", v);
146
- }, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
147
- { id: "delete", label: ACTIONS.ADMIN["delete-prize-draw"].label, variant: "secondary", onClick: () => { selection.clearSelection(); } },
148
- ] }), totalPages > 1 && (_jsx("div", { className: "sticky z-10 flex justify-center bg-[var(--appkit-color-surface)]/95 backdrop-blur-sm border-b border-[var(--appkit-color-border)] px-3 py-1.5", style: { top: "calc(var(--header-height, 0px) + 44px)" }, 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(Alert, { variant: "error", className: "mb-4", children: errorMessage })), _jsx(DataTable, { columns: PRIZE_DRAW_COLUMNS, rows: rows, isLoading: isLoading, emptyLabel: "No prize draws found", getRowHref: (row) => String(ROUTES.ADMIN.PRIZE_DRAWS_EDIT(row.id)), renderRowActions: (row) => (_jsx(Button, { variant: "ghost", size: "sm", asChild: true, children: _jsx("a", { href: String(ROUTES.ADMIN.PRIZE_DRAWS_EDIT(row.id)), "aria-label": "Edit", children: _jsx(Pencil, { className: "w-4 h-4" }) }) })) })] }), _jsx(PrizeDrawsFilterDrawer, { filterOpen: filterOpen, setFilterOpen: setFilterOpen, activeFilterCount: activeFilterCount, clearFilters: clearFilters, pendingFilters: pendingFilters, setPendingFilters: setPendingFilters, applyFilters: applyFilters })] }));
90
+ buildFilters: (state) => {
91
+ const status = state.status && state.status !== "All" ? `status==${state.status}` : null;
92
+ return ["listingType==prize-draw", status].filter(Boolean).join(",");
93
+ },
94
+ getRowHref: (row) => String(ROUTES.ADMIN.PRIZE_DRAWS_EDIT(row.id)),
95
+ buildBulkActions: (selection) => [
96
+ {
97
+ id: "delete",
98
+ label: ACTIONS.ADMIN["delete-prize-draw"].label,
99
+ variant: "secondary",
100
+ onClick: () => selection.clearSelection(),
101
+ },
102
+ ],
103
+ renderRowActions: (row) => (_jsx(Button, { variant: "ghost", size: "sm", asChild: true, children: _jsx("a", { href: String(ROUTES.ADMIN.PRIZE_DRAWS_EDIT(row.id)), "aria-label": "Edit", children: _jsx(Pencil, { className: "w-4 h-4" }) }) })),
104
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_PRODUCT_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
105
+ };
106
+ return _jsx(DataListingView, { config: config });
149
107
  }