@mohasinac/appkit 2.7.59 → 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 (311) 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/account/components/UserOffersPanel.js +1 -1
  47. package/dist/features/account/components/UserSupportView.d.ts +1 -2
  48. package/dist/features/account/components/UserSupportView.js +9 -1
  49. package/dist/features/admin/actions/admin-actions.js +16 -1
  50. package/dist/features/admin/components/AdminAllEventEntriesView.d.ts +2 -3
  51. package/dist/features/admin/components/AdminAllEventEntriesView.js +50 -83
  52. package/dist/features/admin/components/AdminBidsView.d.ts +2 -3
  53. package/dist/features/admin/components/AdminBidsView.js +64 -98
  54. package/dist/features/admin/components/AdminBlogView.d.ts +3 -7
  55. package/dist/features/admin/components/AdminBlogView.js +53 -83
  56. package/dist/features/admin/components/AdminBrandsView.d.ts +2 -3
  57. package/dist/features/admin/components/AdminBrandsView.js +84 -83
  58. package/dist/features/admin/components/AdminBundlesView.js +82 -125
  59. package/dist/features/admin/components/AdminCarouselView.d.ts +2 -2
  60. package/dist/features/admin/components/AdminCarouselView.js +17 -52
  61. package/dist/features/admin/components/AdminCartsView.d.ts +2 -3
  62. package/dist/features/admin/components/AdminCartsView.js +39 -88
  63. package/dist/features/admin/components/AdminCategoriesView.d.ts +3 -3
  64. package/dist/features/admin/components/AdminCategoriesView.js +98 -92
  65. package/dist/features/admin/components/AdminCategoryEditorView.js +2 -2
  66. package/dist/features/admin/components/AdminClassifiedView.d.ts +3 -0
  67. package/dist/features/admin/components/AdminClassifiedView.js +44 -0
  68. package/dist/features/admin/components/AdminContactView.d.ts +2 -2
  69. package/dist/features/admin/components/AdminContactView.js +104 -111
  70. package/dist/features/admin/components/AdminCouponsView.d.ts +3 -6
  71. package/dist/features/admin/components/AdminCouponsView.js +66 -86
  72. package/dist/features/admin/components/AdminDigitalCodesView.d.ts +3 -0
  73. package/dist/features/admin/components/AdminDigitalCodesView.js +51 -0
  74. package/dist/features/admin/components/AdminFaqsView.d.ts +4 -4
  75. package/dist/features/admin/components/AdminFaqsView.js +77 -33
  76. package/dist/features/admin/components/AdminFeaturesView.d.ts +2 -3
  77. package/dist/features/admin/components/AdminFeaturesView.js +57 -70
  78. package/dist/features/admin/components/AdminGroupedListingsView.d.ts +3 -0
  79. package/dist/features/admin/components/AdminGroupedListingsView.js +43 -0
  80. package/dist/features/admin/components/AdminHistoryView.d.ts +2 -3
  81. package/dist/features/admin/components/AdminHistoryView.js +35 -52
  82. package/dist/features/admin/components/AdminListingScaffold.d.ts +2 -2
  83. package/dist/features/admin/components/AdminListingScaffold.js +3 -3
  84. package/dist/features/admin/components/AdminLiveView.d.ts +3 -0
  85. package/dist/features/admin/components/AdminLiveView.js +50 -0
  86. package/dist/features/admin/components/AdminNewsletterView.d.ts +2 -2
  87. package/dist/features/admin/components/AdminNewsletterView.js +67 -97
  88. package/dist/features/admin/components/AdminNotificationsView.d.ts +2 -3
  89. package/dist/features/admin/components/AdminNotificationsView.js +67 -93
  90. package/dist/features/admin/components/AdminOrderEditorView.js +10 -10
  91. package/dist/features/admin/components/AdminOrdersView.d.ts +2 -3
  92. package/dist/features/admin/components/AdminOrdersView.js +93 -107
  93. package/dist/features/admin/components/AdminPayoutsView.d.ts +2 -3
  94. package/dist/features/admin/components/AdminPayoutsView.js +51 -91
  95. package/dist/features/admin/components/AdminPrizeDrawsView.d.ts +2 -3
  96. package/dist/features/admin/components/AdminPrizeDrawsView.js +39 -76
  97. package/dist/features/admin/components/AdminProductEditorView.js +3 -3
  98. package/dist/features/admin/components/AdminProductsView.d.ts +4 -4
  99. package/dist/features/admin/components/AdminProductsView.js +167 -163
  100. package/dist/features/admin/components/AdminReturnRequestsView.d.ts +1 -1
  101. package/dist/features/admin/components/AdminReturnRequestsView.js +64 -66
  102. package/dist/features/admin/components/AdminReviewsView.d.ts +3 -7
  103. package/dist/features/admin/components/AdminReviewsView.js +94 -110
  104. package/dist/features/admin/components/AdminScammersView.d.ts +2 -3
  105. package/dist/features/admin/components/AdminScammersView.js +53 -97
  106. package/dist/features/admin/components/AdminSectionsView.js +1 -1
  107. package/dist/features/admin/components/AdminSessionsView.d.ts +2 -3
  108. package/dist/features/admin/components/AdminSessionsView.js +62 -89
  109. package/dist/features/admin/components/AdminStoreAddressesView.d.ts +1 -1
  110. package/dist/features/admin/components/AdminStoreAddressesView.js +39 -53
  111. package/dist/features/admin/components/AdminStoreEditorView.js +21 -8
  112. package/dist/features/admin/components/AdminStoresView.d.ts +2 -3
  113. package/dist/features/admin/components/AdminStoresView.js +67 -99
  114. package/dist/features/admin/components/AdminSublistingCategoriesView.d.ts +1 -1
  115. package/dist/features/admin/components/AdminSublistingCategoriesView.js +28 -44
  116. package/dist/features/admin/components/AdminSupportTicketDetailView.d.ts +10 -1
  117. package/dist/features/admin/components/AdminSupportTicketDetailView.js +191 -5
  118. package/dist/features/admin/components/AdminSupportTicketsView.d.ts +2 -3
  119. package/dist/features/admin/components/AdminSupportTicketsView.js +65 -96
  120. package/dist/features/admin/components/AdminTeamView.d.ts +2 -2
  121. package/dist/features/admin/components/AdminTeamView.js +40 -74
  122. package/dist/features/admin/components/AdminUserEditorView.d.ts +11 -1
  123. package/dist/features/admin/components/AdminUserEditorView.js +80 -6
  124. package/dist/features/admin/components/AdminUsersView.d.ts +2 -3
  125. package/dist/features/admin/components/AdminUsersView.js +108 -100
  126. package/dist/features/admin/components/AdminViewCards.d.ts +1 -1
  127. package/dist/features/admin/components/AdminWishlistsView.d.ts +2 -3
  128. package/dist/features/admin/components/AdminWishlistsView.js +36 -62
  129. package/dist/features/admin/components/DataListingView.d.ts +122 -0
  130. package/dist/features/admin/components/DataListingView.js +66 -0
  131. package/dist/features/admin/components/index.d.ts +10 -4
  132. package/dist/features/admin/components/index.js +6 -2
  133. package/dist/features/admin/constants/filter-tabs.d.ts +23 -17
  134. package/dist/features/admin/constants/filter-tabs.js +21 -17
  135. package/dist/features/admin/hooks/useAdminListing.d.ts +1 -0
  136. package/dist/features/admin/hooks/useAdminListing.js +1 -1
  137. package/dist/features/admin/schemas/firestore.js +6 -7
  138. package/dist/features/auctions/server.d.ts +0 -1
  139. package/dist/features/auctions/server.js +0 -1
  140. package/dist/features/auth/actions/realtime-token-actions.js +1 -1
  141. package/dist/features/auth/repository/user.repository.js +1 -1
  142. package/dist/features/cart/repository/cart.repository.d.ts +4 -1
  143. package/dist/features/cart/repository/cart.repository.js +12 -0
  144. package/dist/features/checkout/hooks/useCheckoutApi.d.ts +0 -2
  145. package/dist/features/checkout/index.d.ts +1 -1
  146. package/dist/features/events/components/AdminEventsView.d.ts +3 -3
  147. package/dist/features/events/components/AdminEventsView.js +50 -86
  148. package/dist/features/events/components/EventOfferCard.d.ts +19 -0
  149. package/dist/features/events/components/EventOfferCard.js +29 -0
  150. package/dist/features/events/components/EventRaffleEntryForm.d.ts +25 -0
  151. package/dist/features/events/components/EventRaffleEntryForm.js +37 -0
  152. package/dist/features/events/components/EventRafflesSection.d.ts +1 -4
  153. package/dist/features/events/components/EventRafflesSection.js +17 -6
  154. package/dist/features/events/components/EventSaleBanner.d.ts +21 -0
  155. package/dist/features/events/components/EventSaleBanner.js +18 -0
  156. package/dist/features/events/components/index.d.ts +6 -0
  157. package/dist/features/events/components/index.js +4 -0
  158. package/dist/features/events/repository/event-entry.repository.d.ts +5 -0
  159. package/dist/features/events/repository/event-entry.repository.js +7 -0
  160. package/dist/features/filters/AsyncFacetSection.d.ts +1 -1
  161. package/dist/features/homepage/components/FAQSection.d.ts +0 -5
  162. package/dist/features/homepage/lib/live-stats.js +1 -1
  163. package/dist/features/homepage/schemas/firestore.d.ts +0 -2
  164. package/dist/features/layout/index.d.ts +0 -2
  165. package/dist/features/layout/index.js +0 -1
  166. package/dist/features/pre-orders/server.d.ts +0 -1
  167. package/dist/features/pre-orders/server.js +0 -1
  168. package/dist/features/products/components/GroupSettingsPanel.js +2 -2
  169. package/dist/features/products/components/PrizeDrawItemsEditor.js +2 -2
  170. package/dist/features/products/components/PrizeDrawsSection.d.ts +1 -4
  171. package/dist/features/products/components/PrizeDrawsSection.js +17 -6
  172. package/dist/features/products/components/PrizeRevealModal.js +1 -1
  173. package/dist/features/products/components/ProductCardMetadataSection.d.ts +11 -0
  174. package/dist/features/products/components/ProductCardMetadataSection.js +25 -0
  175. package/dist/features/products/components/ProductDetailPageView.js +3 -1
  176. package/dist/features/products/components/ProductFeaturesSelector.js +1 -1
  177. package/dist/features/products/components/ProductGradingTab.d.ts +13 -0
  178. package/dist/features/products/components/ProductGradingTab.js +25 -0
  179. package/dist/features/products/components/ProductGrid.js +14 -2
  180. package/dist/features/products/components/ProductTabsShell.d.ts +5 -1
  181. package/dist/features/products/components/ProductTabsShell.js +6 -1
  182. package/dist/features/products/components/index.d.ts +4 -0
  183. package/dist/features/products/components/index.js +3 -0
  184. package/dist/features/products/constants/action-defs.d.ts +5 -0
  185. package/dist/features/products/constants/action-defs.js +52 -32
  186. package/dist/features/products/constants/sieve.d.ts +24 -4
  187. package/dist/features/products/constants/sieve.js +20 -11
  188. package/dist/features/products/schemas/firestore.d.ts +17 -0
  189. package/dist/features/products/schemas/product-features.validators.d.ts +2 -2
  190. package/dist/features/products/schemas/product-templates.d.ts +2 -4
  191. package/dist/features/products/types/index.d.ts +4 -0
  192. package/dist/features/promotions/server.d.ts +0 -1
  193. package/dist/features/promotions/server.js +0 -1
  194. package/dist/features/search/api/route.js +44 -1
  195. package/dist/features/search/components/Search.js +2 -0
  196. package/dist/features/search/hooks/useNavSuggestions.d.ts +5 -1
  197. package/dist/features/search/hooks/useNavSuggestions.js +31 -4
  198. package/dist/features/seller/components/BrandInlineSelect.js +2 -2
  199. package/dist/features/seller/components/CategoryInlineSelect.js +2 -2
  200. package/dist/features/seller/components/SellerAddressesView.js +1 -1
  201. package/dist/features/seller/components/SellerAuctionsView.d.ts +3 -3
  202. package/dist/features/seller/components/SellerAuctionsView.js +60 -90
  203. package/dist/features/seller/components/SellerBidsView.js +1 -1
  204. package/dist/features/seller/components/SellerBundlesView.js +64 -89
  205. package/dist/features/seller/components/SellerClassifiedView.js +67 -90
  206. package/dist/features/seller/components/SellerCouponEditorView.js +1 -1
  207. package/dist/features/seller/components/SellerCouponsView.d.ts +2 -2
  208. package/dist/features/seller/components/SellerCouponsView.js +45 -84
  209. package/dist/features/seller/components/SellerDigitalCodesView.js +63 -88
  210. package/dist/features/seller/components/SellerGroupedListingsView.js +33 -49
  211. package/dist/features/seller/components/SellerLiveView.js +63 -84
  212. package/dist/features/seller/components/SellerOffersPanel.js +1 -1
  213. package/dist/features/seller/components/SellerOffersView.d.ts +2 -2
  214. package/dist/features/seller/components/SellerOffersView.js +37 -69
  215. package/dist/features/seller/components/SellerOrdersView.d.ts +2 -2
  216. package/dist/features/seller/components/SellerOrdersView.js +4 -4
  217. package/dist/features/seller/components/SellerPayoutMethodsView.js +1 -1
  218. package/dist/features/seller/components/SellerPayoutsView.d.ts +2 -2
  219. package/dist/features/seller/components/SellerPayoutsView.js +34 -68
  220. package/dist/features/seller/components/SellerPreOrdersView.d.ts +2 -2
  221. package/dist/features/seller/components/SellerPreOrdersView.js +49 -82
  222. package/dist/features/seller/components/SellerPrizeDrawsView.d.ts +2 -2
  223. package/dist/features/seller/components/SellerPrizeDrawsView.js +49 -82
  224. package/dist/features/seller/components/SellerProductShell.d.ts +1 -1
  225. package/dist/features/seller/components/SellerProductsView.d.ts +2 -2
  226. package/dist/features/seller/components/SellerProductsView.js +15 -10
  227. package/dist/features/seller/components/SellerShippingConfigsView.js +1 -1
  228. package/dist/features/seller/components/SellerSidebar.d.ts +0 -4
  229. package/dist/features/seller/components/SellerSidebar.js +0 -2
  230. package/dist/features/seller/components/SellerStoreCategoriesView.js +1 -1
  231. package/dist/features/seller/components/SellerTemplatesView.js +2 -2
  232. package/dist/features/seller/components/SellersListView.d.ts +1 -2
  233. package/dist/features/seller/components/analytics/SellerAnalyticsStats.d.ts +5 -0
  234. package/dist/features/seller/components/analytics/SellerAnalyticsStats.js +2 -8
  235. package/dist/features/seller/components/index.d.ts +0 -3
  236. package/dist/features/seller/components/index.js +0 -2
  237. package/dist/features/seller/server.d.ts +0 -1
  238. package/dist/features/seller/server.js +0 -1
  239. package/dist/features/shell/FormShell.d.ts +1 -1
  240. package/dist/features/shell/FormShell.js +4 -1
  241. package/dist/features/shell/field-groups/ImageFieldGroup.d.ts +18 -0
  242. package/dist/features/shell/field-groups/ImageFieldGroup.js +15 -0
  243. package/dist/features/shell/field-groups/SeoFieldGroup.d.ts +22 -0
  244. package/dist/features/shell/field-groups/SeoFieldGroup.js +16 -0
  245. package/dist/features/shell/field-groups/StatusFieldGroup.d.ts +35 -0
  246. package/dist/features/shell/field-groups/StatusFieldGroup.js +16 -0
  247. package/dist/features/shell/field-groups/TitleDescriptionGroup.d.ts +40 -0
  248. package/dist/features/shell/field-groups/TitleDescriptionGroup.js +16 -0
  249. package/dist/features/shell/field-groups/index.d.ts +13 -0
  250. package/dist/features/shell/field-groups/index.js +9 -0
  251. package/dist/features/shell/index.d.ts +2 -0
  252. package/dist/features/shell/index.js +1 -0
  253. package/dist/features/stores/components/StoreCapabilitiesGuideView.d.ts +1 -2
  254. package/dist/features/stores/components/StoreFinanceGuideView.d.ts +1 -2
  255. package/dist/features/stores/components/StoreHeader.js +2 -1
  256. package/dist/features/stores/components/StoreListingsGuideView.d.ts +1 -2
  257. package/dist/features/stores/components/StoreOrdersGuideView.d.ts +1 -2
  258. package/dist/features/stores/components/StoreScopedSearch.d.ts +16 -0
  259. package/dist/features/stores/components/StoreScopedSearch.js +27 -0
  260. package/dist/features/stores/components/StoreSettingsGuideView.d.ts +1 -2
  261. package/dist/features/stores/server.d.ts +0 -1
  262. package/dist/features/stores/server.js +0 -1
  263. package/dist/features/support/schemas/firestore.d.ts +22 -1
  264. package/dist/features/support/schemas/firestore.js +10 -0
  265. package/dist/features/wishlist/server.d.ts +0 -1
  266. package/dist/features/wishlist/server.js +0 -1
  267. package/dist/index.d.ts +9 -27
  268. package/dist/index.js +14 -50
  269. package/dist/next/routing/route-map.d.ts +8 -0
  270. package/dist/next/routing/route-map.js +4 -0
  271. package/dist/react/hooks/useListingTypeFlags.d.ts +32 -0
  272. package/dist/react/hooks/useListingTypeFlags.js +19 -0
  273. package/dist/security/index.d.ts +1 -1
  274. package/dist/security/index.js +1 -1
  275. package/dist/security/pii-redact.d.ts +8 -0
  276. package/dist/security/pii-redact.js +10 -1
  277. package/dist/seed/grouped-listings-seed-data.d.ts +4 -0
  278. package/dist/seed/products-preorders-seed-data.d.ts +4 -0
  279. package/dist/seed/products-prize-draws-seed-data.js +3 -0
  280. package/dist/seed/site-settings-seed-data.js +5 -5
  281. package/dist/seed/sub-listings-seed-data.d.ts +4 -0
  282. package/dist/server.d.ts +2 -0
  283. package/dist/server.js +4 -0
  284. package/dist/styles.css +54 -395
  285. package/dist/tailwind-utilities.css +1 -1
  286. package/dist/ui/components/BaseListingCard.d.ts +10 -0
  287. package/dist/ui/components/BaseListingCard.js +17 -1
  288. package/dist/ui/components/DetailPageGallery.d.ts +32 -0
  289. package/dist/ui/components/DetailPageGallery.js +47 -0
  290. package/dist/ui/components/DetailPageHero.d.ts +30 -0
  291. package/dist/ui/components/DetailPageHero.js +22 -0
  292. package/dist/ui/components/DetailPageTabs.d.ts +34 -0
  293. package/dist/ui/components/DetailPageTabs.js +38 -0
  294. package/dist/ui/components/HorizontalScroller.style.css +15 -2
  295. package/dist/ui/components/ListingLayout.d.ts +11 -2
  296. package/dist/ui/components/ListingLayout.js +12 -6
  297. package/dist/ui/components/PaginatedSelect.d.ts +66 -0
  298. package/dist/ui/components/PaginatedSelect.js +201 -0
  299. package/dist/ui/components/PaginatedSelect.style.css +254 -0
  300. package/dist/ui/components/Semantic.d.ts +0 -4
  301. package/dist/ui/components/Semantic.js +0 -2
  302. package/dist/ui/components/SettingsSection.d.ts +47 -0
  303. package/dist/ui/components/SettingsSection.js +38 -0
  304. package/dist/ui/components/index.style.css +1 -4
  305. package/dist/ui/index.d.ts +12 -14
  306. package/dist/ui/index.js +6 -7
  307. package/dist/utils/id-generators.d.ts +1 -18
  308. package/dist/utils/id-generators.js +51 -18
  309. package/dist/validation/schemas.d.ts +25 -0
  310. package/dist/validation/schemas.js +28 -0
  311. package/package.json +1 -1
@@ -1,82 +1,17 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React, { useState, useCallback } from "react";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import React 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 { FilterChipGroup, ListingToolbar, Pagination, ListingViewShell, RowActionMenu, useToast, ListingFilterDrawer } from "../../../ui";
5
+ import { FilterChipGroup, ListingLayout, RowActionMenu, useToast } 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_EVENT_ENTRY_STATUS_TABS } from "../constants/filter-tabs";
11
- import { toRecordArray, toRelativeDate, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
12
- import { DataTable } from "./DataTable";
9
+ import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
10
+ import { DataListingView } from "./DataListingView";
13
11
  import { apiClient } from "../../../http";
14
- const PAGE_SIZE = 25;
15
- const FILTER_KEYS = ["status"];
16
- const DEFAULT_SORT = "-submittedAt";
17
- const SORT_OPTIONS = [
18
- { value: "-submittedAt", label: "Newest" },
19
- { value: "submittedAt", label: "Oldest" },
20
- ];
21
- const STATUS_OPTIONS = ADMIN_EVENT_ENTRY_STATUS_TABS;
22
12
  export function AdminAllEventEntriesView({ children, ...props }) {
23
- const hasChildren = React.Children.count(children) > 0;
24
- const [view, setView] = useState("table");
25
13
  const queryClient = useQueryClient();
26
14
  const { showToast } = useToast();
27
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
28
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
29
- const [filterOpen, setFilterOpen] = useState(false);
30
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
31
- const openFilters = useCallback(() => {
32
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
33
- setFilterOpen(true);
34
- }, [table]);
35
- const applyFilters = useCallback(() => {
36
- const updates = { page: "1" };
37
- for (const k of FILTER_KEYS)
38
- updates[k] = pendingFilters[k] ?? "";
39
- table.setMany(updates);
40
- setFilterOpen(false);
41
- }, [pendingFilters, table]);
42
- const clearFilters = useCallback(() => {
43
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
44
- }, []);
45
- const resetAll = useCallback(() => {
46
- const updates = { q: "", sort: "" };
47
- for (const k of FILTER_KEYS)
48
- updates[k] = "";
49
- table.setMany(updates);
50
- setSearchInput("");
51
- }, [table]);
52
- const commitSearch = useCallback(() => {
53
- table.set("q", searchInput.trim());
54
- }, [searchInput, table]);
55
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
56
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
57
- const statusRaw = table.get("status");
58
- const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
59
- const { rows, total, isLoading, errorMessage } = useAdminListingData({
60
- queryKey: ["admin", "event-entries", "listing"],
61
- endpoint: ADMIN_ENDPOINTS.ADMIN_EVENT_ENTRIES,
62
- page: table.getNumber("page", 1),
63
- pageSize: PAGE_SIZE,
64
- sorts: table.get("sort") || DEFAULT_SORT,
65
- filters,
66
- q: table.get("q") || undefined,
67
- mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
68
- id: toStringValue(item.id, `entry-${index}`),
69
- primary: toStringValue(item.userDisplayName ?? item.userName, "Unknown user"),
70
- secondary: [
71
- toStringValue(item.eventId, ""),
72
- toStringValue(item.userEmail, ""),
73
- ].filter(Boolean).join(" · "),
74
- status: toStringValue(item.status ?? item.reviewStatus, "PENDING"),
75
- updatedAt: toRelativeDate(item.submittedAt ?? item.createdAt),
76
- eventId: toStringValue(item.eventId, ""),
77
- })),
78
- getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
79
- });
80
15
  const updateMutation = useMutation({
81
16
  mutationFn: async ({ id, status }) => {
82
17
  await apiClient.patch(ADMIN_ENDPOINTS.ADMIN_EVENT_ENTRY_BY_ID(id), { status });
@@ -89,18 +24,50 @@ export function AdminAllEventEntriesView({ children, ...props }) {
89
24
  showToast(err?.message ?? "Failed to update entry.", "error");
90
25
  },
91
26
  });
92
- const currentPage = table.getNumber("page", 1);
93
- const totalPages = Math.ceil(total / PAGE_SIZE);
94
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
95
- if (hasChildren) {
96
- return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
27
+ if (React.Children.count(children) > 0) {
28
+ return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
97
29
  }
98
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search by user name or event ID", 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 }), 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 entries found", renderRowActions: (row) => {
99
- const er = row;
100
- return (_jsx(RowActionMenu, { actions: [
101
- { label: ACTIONS.ADMIN["confirm-entry"].label, onClick: () => updateMutation.mutate({ id: er.id, status: "CONFIRMED" }) },
102
- { label: ACTIONS.ADMIN["waitlist-entry"].label, onClick: () => updateMutation.mutate({ id: er.id, status: "WAITLISTED" }) },
103
- { label: ACTIONS.ADMIN["cancel-entry"].label, destructive: true, onClick: () => updateMutation.mutate({ id: er.id, status: "CANCELLED" }) },
104
- ] }));
105
- } })] }), _jsx(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: _jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }) })] }));
30
+ const config = {
31
+ portal: "admin",
32
+ title: "Event Entries",
33
+ searchPlaceholder: "Search by user name or event ID",
34
+ emptyLabel: "No entries found",
35
+ filterKeys: ["status"],
36
+ defaultSort: "-submittedAt",
37
+ queryKey: ["admin", "event-entries", "listing"],
38
+ endpoint: ADMIN_ENDPOINTS.ADMIN_EVENT_ENTRIES,
39
+ sortOptions: [
40
+ { value: "-submittedAt", label: "Newest" },
41
+ { value: "submittedAt", label: "Oldest" },
42
+ ],
43
+ mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
44
+ id: toStringValue(item.id, `entry-${index}`),
45
+ primary: toStringValue(item.userDisplayName ?? item.userName, "Unknown user"),
46
+ secondary: [toStringValue(item.eventId, ""), toStringValue(item.userEmail, "")]
47
+ .filter(Boolean)
48
+ .join(" · "),
49
+ status: toStringValue(item.status ?? item.reviewStatus, "PENDING"),
50
+ updatedAt: toRelativeDate(item.submittedAt ?? item.createdAt),
51
+ eventId: toStringValue(item.eventId, ""),
52
+ })),
53
+ getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
54
+ buildFilters: (state) => state.status && state.status !== "All" ? `status==${state.status}` : undefined,
55
+ renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
56
+ {
57
+ label: ACTIONS.ADMIN["confirm-entry"].label,
58
+ onClick: () => updateMutation.mutate({ id: row.id, status: "CONFIRMED" }),
59
+ },
60
+ {
61
+ label: ACTIONS.ADMIN["waitlist-entry"].label,
62
+ onClick: () => updateMutation.mutate({ id: row.id, status: "WAITLISTED" }),
63
+ },
64
+ {
65
+ label: ACTIONS.ADMIN["cancel-entry"].label,
66
+ destructive: true,
67
+ onClick: () => updateMutation.mutate({ id: row.id, status: "CANCELLED" }),
68
+ },
69
+ ] })),
70
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_EVENT_ENTRY_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
71
+ };
72
+ return _jsx(DataListingView, { config: config });
106
73
  }
@@ -1,4 +1,3 @@
1
- import type { ListingViewShellProps } from "../../../ui";
2
- export interface AdminBidsViewProps extends ListingViewShellProps {
3
- }
1
+ import type { ListingLayoutProps } from "../../../ui";
2
+ export type AdminBidsViewProps = ListingLayoutProps;
4
3
  export declare function AdminBidsView({ children, ...props }: AdminBidsViewProps): import("react/jsx-runtime").JSX.Element;
@@ -1,87 +1,20 @@
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";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React, { useState } 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, FilterChipGroup, ListingToolbar, Pagination, ListingViewShell, ConfirmDeleteModal, RowActionMenu, useToast, ListingFilterDrawer } from "../../../ui";
5
+ import { ConfirmDeleteModal, FilterChipGroup, ListingLayout, RowActionMenu, useToast } from "../../../ui";
8
6
  import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
9
7
  import { ADMIN_BID_STATUS_TABS } from "../constants/filter-tabs";
10
8
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
11
9
  import { ROW_ACTION_META, ROW_ACTION_ID } from "../../products/constants/action-defs";
12
- import { toRecordArray, toRelativeDate, toRupees, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
13
- import { DataTable } from "./DataTable";
10
+ import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../hooks/useAdminListingData";
11
+ import { DataListingView } from "./DataListingView";
14
12
  import { apiClient } from "../../../http";
15
- import { useBottomActions } from "../../layout";
16
- const PAGE_SIZE = 25;
17
- const FILTER_KEYS = ["status"];
18
- const DEFAULT_SORT = "-bidTime";
19
- const SORT_OPTIONS = [
20
- { value: "-bidTime", label: "Newest" },
21
- { value: "bidTime", label: "Oldest" },
22
- { value: "-amount", label: "Highest amount" },
23
- ];
24
- const STATUS_OPTIONS = ADMIN_BID_STATUS_TABS;
25
13
  export function AdminBidsView({ children, ...props }) {
26
- const hasChildren = React.Children.count(children) > 0;
27
- const [view, setView] = useState("table");
28
14
  const queryClient = useQueryClient();
29
15
  const { showToast } = useToast();
30
16
  const [cancelOpen, setCancelOpen] = useState(false);
31
17
  const [selectedRow, setSelectedRow] = useState(null);
32
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
33
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
34
- const [filterOpen, setFilterOpen] = useState(false);
35
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
36
- const openFilters = useCallback(() => {
37
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
38
- setFilterOpen(true);
39
- }, [table]);
40
- const applyFilters = useCallback(() => {
41
- const updates = { page: "1" };
42
- for (const k of FILTER_KEYS)
43
- updates[k] = pendingFilters[k] ?? "";
44
- table.setMany(updates);
45
- setFilterOpen(false);
46
- }, [pendingFilters, table]);
47
- const clearFilters = useCallback(() => {
48
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
49
- }, []);
50
- const resetAll = useCallback(() => {
51
- const updates = { q: "", sort: "" };
52
- for (const k of FILTER_KEYS)
53
- updates[k] = "";
54
- table.setMany(updates);
55
- setSearchInput("");
56
- }, [table]);
57
- const commitSearch = useCallback(() => {
58
- table.set("q", searchInput.trim());
59
- }, [searchInput, table]);
60
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
61
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
62
- const statusRaw = table.get("status");
63
- const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
64
- const { rows, total, isLoading, errorMessage } = useAdminListingData({
65
- queryKey: ["admin", "bids", "listing"],
66
- endpoint: ADMIN_ENDPOINTS.BIDS,
67
- page: table.getNumber("page", 1),
68
- pageSize: PAGE_SIZE,
69
- sorts: table.get("sort") || DEFAULT_SORT,
70
- filters,
71
- q: table.get("q") || undefined,
72
- mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
73
- id: toStringValue(item.id, `bid-${index}`),
74
- primary: [
75
- toStringValue(item.productName ?? item.productTitle, "Unknown item"),
76
- toRupees(item.amount),
77
- ].join(" · "),
78
- secondary: toStringValue(item.bidderId ?? item.bidderName ?? item.userId, "Unknown bidder"),
79
- status: toStringValue(item.status, "active"),
80
- updatedAt: toRelativeDate(item.bidTime ?? item.bidDate ?? item.updatedAt ?? item.createdAt),
81
- _raw: item,
82
- })),
83
- getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
84
- });
85
18
  const cancelMutation = useMutation({
86
19
  mutationFn: async (bidId) => {
87
20
  await apiClient.patch(ADMIN_ENDPOINTS.BID_BY_ID(bidId), { status: "cancelled" });
@@ -96,31 +29,64 @@ export function AdminBidsView({ children, ...props }) {
96
29
  showToast(err?.message ?? "Failed to cancel bid.", "error");
97
30
  },
98
31
  });
99
- const currentPage = table.getNumber("page", 1);
100
- const totalPages = Math.ceil(total / PAGE_SIZE);
101
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
102
- if (hasChildren) {
103
- return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
32
+ if (React.Children.count(children) > 0) {
33
+ return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
104
34
  }
105
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search bids, products, or bidder 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: [
106
- { id: ROW_ACTION_ID.CANCEL, label: ACTIONS.ADMIN["cancel-bid"].label, variant: "secondary", onClick: () => { selection.clearSelection(); } },
107
- ] }), 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 bids found", renderRowActions: (row) => {
108
- const bidRow = row;
109
- const isCancelled = bidRow.status === "cancelled" || bidRow.status === "voided";
110
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
111
- { id: ROW_ACTION_ID.CANCEL, label: ACTIONS.ADMIN["cancel-bid"].label, variant: "secondary", onClick: () => { selection.clearSelection(); } },
112
- ] } } : {});
113
- return (_jsx(RowActionMenu, { actions: [
114
- {
115
- label: ROW_ACTION_META[ROW_ACTION_ID.CANCEL].label,
116
- destructive: ROW_ACTION_META[ROW_ACTION_ID.CANCEL].destructive,
117
- disabled: isCancelled,
118
- onClick: () => {
119
- setSelectedRow(bidRow);
120
- setCancelOpen(true);
121
- },
122
- },
123
- ] }));
124
- } })] }), _jsx(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: _jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }) })] }), _jsx(ConfirmDeleteModal, { isOpen: cancelOpen, onClose: () => { setCancelOpen(false); setSelectedRow(null); }, onConfirm: () => { if (selectedRow)
125
- cancelMutation.mutate(selectedRow.id); }, isDeleting: cancelMutation.isPending, title: "Cancel this bid?", message: "This will mark the bid as cancelled and notify the bidder. The auction will continue with remaining active bids.", confirmText: "Cancel bid", variant: "warning" })] }));
35
+ const config = {
36
+ portal: "admin",
37
+ title: "Bids",
38
+ searchPlaceholder: "Search bids, products, or bidder IDs",
39
+ emptyLabel: "No bids found",
40
+ filterKeys: ["status"],
41
+ defaultSort: "-bidTime",
42
+ queryKey: ["admin", "bids", "listing"],
43
+ endpoint: ADMIN_ENDPOINTS.BIDS,
44
+ sortOptions: [
45
+ { value: "-bidTime", label: "Newest" },
46
+ { value: "bidTime", label: "Oldest" },
47
+ { value: "-amount", label: "Highest amount" },
48
+ ],
49
+ mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
50
+ id: toStringValue(item.id, `bid-${index}`),
51
+ primary: [
52
+ toStringValue(item.productName ?? item.productTitle, "Unknown item"),
53
+ toRupees(item.amount),
54
+ ].join(" · "),
55
+ secondary: toStringValue(item.bidderId ?? item.bidderName ?? item.userId, "Unknown bidder"),
56
+ status: toStringValue(item.status, "active"),
57
+ updatedAt: toRelativeDate(item.bidTime ?? item.bidDate ?? item.updatedAt ?? item.createdAt),
58
+ })),
59
+ getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
60
+ buildFilters: (state) => state.status && state.status !== "All" ? `status==${state.status}` : undefined,
61
+ buildBulkActions: (selection) => [
62
+ {
63
+ id: ROW_ACTION_ID.CANCEL,
64
+ label: ACTIONS.ADMIN["cancel-bid"].label,
65
+ variant: "secondary",
66
+ onClick: () => selection.clearSelection(),
67
+ },
68
+ ],
69
+ renderRowActions: (row) => {
70
+ const isCancelled = row.status === "cancelled" || row.status === "voided";
71
+ return (_jsx(RowActionMenu, { actions: [
72
+ {
73
+ label: ROW_ACTION_META[ROW_ACTION_ID.CANCEL].label,
74
+ destructive: ROW_ACTION_META[ROW_ACTION_ID.CANCEL].destructive,
75
+ disabled: isCancelled,
76
+ onClick: () => {
77
+ setSelectedRow(row);
78
+ setCancelOpen(true);
79
+ },
80
+ },
81
+ ] }));
82
+ },
83
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_BID_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
84
+ };
85
+ return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), _jsx(ConfirmDeleteModal, { isOpen: cancelOpen, onClose: () => {
86
+ setCancelOpen(false);
87
+ setSelectedRow(null);
88
+ }, onConfirm: () => {
89
+ if (selectedRow)
90
+ cancelMutation.mutate(selectedRow.id);
91
+ }, isDeleting: cancelMutation.isPending, title: "Cancel this bid?", message: "This will mark the bid as cancelled and notify the bidder. The auction will continue with remaining active bids.", confirmText: "Cancel bid", variant: "warning" })] }));
126
92
  }
@@ -1,7 +1,3 @@
1
- import type { ListingViewShellProps } from "../../../ui";
2
- import type { AdminListingScaffoldRow } from "./AdminListingScaffold";
3
- export interface AdminBlogViewProps extends ListingViewShellProps {
4
- actionHref?: string;
5
- getRowHref?: (row: AdminListingScaffoldRow) => string;
6
- }
7
- export declare function AdminBlogView({ children, getRowHref, ...props }: AdminBlogViewProps): import("react/jsx-runtime").JSX.Element;
1
+ import type { ListingLayoutProps } from "../../../ui";
2
+ export type AdminBlogViewProps = ListingLayoutProps;
3
+ export declare function AdminBlogView({ children, ...props }: AdminBlogViewProps): import("react/jsx-runtime").JSX.Element;
@@ -1,82 +1,36 @@
1
1
  "use client";
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, FilterChipGroup, Heading, ListingToolbar, ListingViewShell, Pagination, SideDrawer, ListingFilterDrawer } from "../../../ui";
9
- import { AdminViewCards } from "./AdminViewCards";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React from "react";
4
+ import { FilterChipGroup, ListingLayout } from "../../../ui";
10
5
  import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
11
6
  import { ADMIN_BLOG_STATUS_TABS } from "../constants/filter-tabs";
12
7
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
13
- import { toRecordArray, toRelativeDate, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
14
- import { DataTable } from "./DataTable";
8
+ import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
9
+ import { DataListingView } from "./DataListingView";
15
10
  import { AdminBlogEditorView } from "./AdminBlogEditorView";
16
- import { useBottomActions } from "../../layout";
17
- const PAGE_SIZE = 25;
18
- const FILTER_KEYS = ["status", "isFeatured"];
19
- const DEFAULT_SORT = "-publishedAt";
20
- const SORT_OPTIONS = [
21
- { value: "-publishedAt", label: "Latest" },
22
- { value: "publishedAt", label: "Oldest" },
23
- { value: "-createdAt", label: "Newest draft" },
24
- { value: "title", label: "Title A–Z" },
25
- ];
26
- const STATUS_OPTIONS = ADMIN_BLOG_STATUS_TABS;
27
11
  const FEATURED_TABS = [
28
12
  { id: "", label: "All" },
29
13
  { id: "true", label: "Featured only" },
30
14
  ];
31
- export function AdminBlogView({ children, getRowHref, ...props }) {
32
- const hasChildren = React.Children.count(children) > 0;
33
- const [view, setView] = useState("table");
34
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
35
- const { openCreatePanel, openEditPanel, closePanel, isCreateOpen, isEditOpen, editId } = usePanelUrlSync();
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
- const openFilters = useCallback(() => {
40
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
41
- setFilterOpen(true);
42
- }, [table]);
43
- const applyFilters = useCallback(() => {
44
- const updates = { page: "1" };
45
- for (const k of FILTER_KEYS)
46
- updates[k] = pendingFilters[k] ?? "";
47
- table.setMany(updates);
48
- setFilterOpen(false);
49
- }, [pendingFilters, table]);
50
- const clearFilters = useCallback(() => {
51
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
52
- }, []);
53
- const resetAll = useCallback(() => {
54
- const updates = { q: "", sort: "" };
55
- for (const k of FILTER_KEYS)
56
- updates[k] = "";
57
- table.setMany(updates);
58
- setSearchInput("");
59
- }, [table]);
60
- const commitSearch = useCallback(() => {
61
- table.set("q", searchInput.trim());
62
- }, [searchInput, table]);
63
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
64
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
65
- const filterParts = [];
66
- const statusRaw = table.get("status");
67
- if (statusRaw && statusRaw !== "All")
68
- filterParts.push(`status==${statusRaw}`);
69
- if (table.get("isFeatured") === "true")
70
- filterParts.push("isFeatured==true");
71
- const filters = filterParts.join(",") || undefined;
72
- const { rows, total, isLoading, errorMessage } = useAdminListingData({
15
+ export function AdminBlogView({ children, ...props }) {
16
+ if (React.Children.count(children) > 0) {
17
+ return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
18
+ }
19
+ const config = {
20
+ portal: "admin",
21
+ title: "Blog Posts",
22
+ searchPlaceholder: "Search articles, authors, or tags",
23
+ emptyLabel: "No blog posts found",
24
+ filterKeys: ["status", "isFeatured"],
25
+ defaultSort: "-publishedAt",
73
26
  queryKey: ["admin", "blog", "listing"],
74
27
  endpoint: ADMIN_ENDPOINTS.BLOG,
75
- page: table.getNumber("page", 1),
76
- pageSize: PAGE_SIZE,
77
- sorts: table.get("sort") || DEFAULT_SORT,
78
- filters,
79
- q: table.get("q") || undefined,
28
+ sortOptions: [
29
+ { value: "-publishedAt", label: "Latest" },
30
+ { value: "publishedAt", label: "Oldest" },
31
+ { value: "-createdAt", label: "Newest draft" },
32
+ { value: "title", label: "Title A–Z" },
33
+ ],
80
34
  mapRows: (response) => toRecordArray(response.posts).map((item, index) => ({
81
35
  id: toStringValue(item.id, `post-${index}`),
82
36
  primary: toStringValue(item.title, "Untitled post"),
@@ -94,19 +48,35 @@ export function AdminBlogView({ children, getRowHref, ...props }) {
94
48
  return response.meta.total;
95
49
  return mappedRows.length;
96
50
  },
97
- });
98
- const currentPage = table.getNumber("page", 1);
99
- const totalPages = Math.ceil(total / PAGE_SIZE);
100
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
101
- if (hasChildren) {
102
- return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
103
- }
104
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
105
- { id: "publish", label: ACTIONS.ADMIN["publish-blog"].label, variant: "primary", onClick: () => { selection.clearSelection(); } },
106
- { id: "draft", label: ACTIONS.ADMIN["draft-blog"].label, variant: "secondary", onClick: () => { selection.clearSelection(); } },
107
- ] } } : {});
108
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(Heading, { level: 1, className: "sr-only", children: "Blog Posts" }), _jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search articles, authors, or tags", 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" }), "New Post"] }) }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
109
- { id: "publish", label: ACTIONS.ADMIN["publish-blog"].label, variant: "primary", onClick: () => { selection.clearSelection(); } },
110
- { id: "draft", label: ACTIONS.ADMIN["draft-blog"].label, variant: "secondary", onClick: () => { selection.clearSelection(); } },
111
- ] }), 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 blog posts 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 blog posts found", onRowClick: (row) => openEditPanel(row.id), selectedIdSet: selection.selectedIdSet, onToggleSelect: selection.toggle }))] }), _jsxs(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: [_jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }), _jsx(FilterChipGroup, { label: "Featured", tabs: FEATURED_TABS, value: pendingFilters.isFeatured ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, isFeatured: id })), allId: "" })] }), _jsx(SideDrawer, { isOpen: isCreateOpen || isEditOpen, onClose: closePanel, title: isCreateOpen ? "New Post" : "Edit Post", mode: isCreateOpen ? "create" : "edit", children: (isCreateOpen || isEditOpen) && (_jsx(AdminBlogEditorView, { postId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })) })] }));
51
+ buildFilters: (state) => {
52
+ const filterParts = [];
53
+ if (state.status && state.status !== "All")
54
+ filterParts.push(`status==${state.status}`);
55
+ if (state.isFeatured === "true")
56
+ filterParts.push("isFeatured==true");
57
+ return filterParts.join(",") || undefined;
58
+ },
59
+ primaryAction: {
60
+ label: "New Post",
61
+ onClick: ({ openCreatePanel }) => openCreatePanel(),
62
+ },
63
+ buildBulkActions: (selection) => [
64
+ {
65
+ id: "publish",
66
+ label: ACTIONS.ADMIN["publish-blog"].label,
67
+ variant: "primary",
68
+ onClick: () => selection.clearSelection(),
69
+ },
70
+ {
71
+ id: "draft",
72
+ label: ACTIONS.ADMIN["draft-blog"].label,
73
+ variant: "secondary",
74
+ onClick: () => selection.clearSelection(),
75
+ },
76
+ ],
77
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsxs(_Fragment, { children: [_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_BLOG_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }), _jsx(FilterChipGroup, { label: "Featured", tabs: FEATURED_TABS, value: pendingFilters.isFeatured ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, isFeatured: id })), allId: "" })] })),
78
+ renderEditor: ({ editId, closePanel }) => (_jsx(AdminBlogEditorView, { postId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })),
79
+ resolveEditorTitle: ({ isCreate }) => (isCreate ? "New Post" : "Edit Post"),
80
+ };
81
+ return _jsx(DataListingView, { config: config });
112
82
  }
@@ -1,4 +1,3 @@
1
- import type { ListingViewShellProps } from "../../../ui";
2
- export interface AdminBrandsViewProps extends ListingViewShellProps {
3
- }
1
+ import type { ListingLayoutProps } from "../../../ui";
2
+ export type AdminBrandsViewProps = ListingLayoutProps;
4
3
  export declare function AdminBrandsView({ children, ...props }: AdminBrandsViewProps): import("react/jsx-runtime").JSX.Element;