@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,31 +1,15 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } 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
4
  import { useEntityDelete } from "../../../react/hooks/useEntityDelete";
5
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
6
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
7
- import { AdminViewCards } from "../../admin/components/AdminViewCards";
8
- import { BulkActionBar, ConfirmDeleteModal, FilterChipGroup, ListingFilterDrawer, ListingToolbar, Pagination, ListingViewShell, RowActionMenu } from "../../../ui";
9
- import { useBottomActions } from "../../layout";
5
+ import { ConfirmDeleteModal, FilterChipGroup, ListingLayout, RowActionMenu } from "../../../ui";
10
6
  import { SELLER_ENDPOINTS } from "../../../constants/api-endpoints";
11
7
  import { SELLER_AUCTION_STATUS_TABS } from "../../admin/constants/filter-tabs";
12
8
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
13
9
  import { ROUTES } from "../../../constants";
14
- import { toRecordArray, toRelativeDate, toRupees, toStringValue, useSellerListingData, } from "../hooks/useSellerListingData";
15
- import { DataTable } from "../../admin/components/DataTable";
16
- const PAGE_SIZE = 25;
17
- const FILTER_KEYS = ["status"];
18
- const DEFAULT_SORT = "endsAt";
19
- const SORT_OPTIONS = [
20
- { value: "endsAt", label: "Ending soon" },
21
- { value: "-endsAt", label: "Ending latest" },
22
- { value: "-createdAt", label: "Newest" },
23
- { value: "createdAt", label: "Oldest" },
24
- ];
25
- const STATUS_OPTIONS = SELLER_AUCTION_STATUS_TABS;
26
- export function SellerAuctionsView({ renderHeader, children, onEditClick, onDelete, onBulkDelete, ...props }) {
27
- const hasChildren = React.Children.count(children) > 0;
28
- const [view, setView] = useState("table");
10
+ import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../../admin/hooks/useAdminListingData";
11
+ import { DataListingView } from "../../admin/components/DataListingView";
12
+ export function SellerAuctionsView({ children, onEditClick, onDelete, onBulkDelete, ...props }) {
29
13
  const [deleteTargetId, setDeleteTargetId] = useState(null);
30
14
  const { deletingId, handleDelete: performDelete } = useEntityDelete({
31
15
  endpoint: (id) => `/api/store/products/${id}`,
@@ -33,46 +17,34 @@ export function SellerAuctionsView({ renderHeader, children, onEditClick, onDele
33
17
  successMessage: "Auction deleted.",
34
18
  fetchOptions: { credentials: "include" },
35
19
  });
36
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
37
- const [searchInput, setSearchInput] = useState(table.get("q") || "");
38
- const [filterOpen, setFilterOpen] = useState(false);
39
- const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
40
- const openFilters = useCallback(() => {
41
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
42
- setFilterOpen(true);
43
- }, [table]);
44
- const applyFilters = useCallback(() => {
45
- const updates = { page: "1" };
46
- for (const k of FILTER_KEYS)
47
- updates[k] = pendingFilters[k] ?? "";
48
- table.setMany(updates);
49
- setFilterOpen(false);
50
- }, [pendingFilters, table]);
51
- const clearFilters = useCallback(() => {
52
- setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
53
- }, []);
54
- const resetAll = useCallback(() => {
55
- const updates = { q: "", sort: "" };
56
- for (const k of FILTER_KEYS)
57
- updates[k] = "";
58
- table.setMany(updates);
59
- setSearchInput("");
60
- }, [table]);
61
- const commitSearch = useCallback(() => {
62
- table.set("q", searchInput.trim());
63
- }, [searchInput, table]);
64
- const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
65
- const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
66
- const statusRaw = table.get("status");
67
- const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
68
- const { rows, total, isLoading, errorMessage } = useSellerListingData({
20
+ const handleDelete = useCallback(async (id) => {
21
+ await performDelete(id);
22
+ setDeleteTargetId(null);
23
+ }, [performDelete]);
24
+ const handleEdit = useCallback((id) => {
25
+ if (onEditClick)
26
+ onEditClick(id);
27
+ else
28
+ window.location.href = String(ROUTES.STORE.PRODUCTS_EDIT(id));
29
+ }, [onEditClick]);
30
+ if (React.Children.count(children) > 0) {
31
+ return (_jsx(ListingLayout, { portal: "seller", ...props, children: children }));
32
+ }
33
+ const config = {
34
+ portal: "seller",
35
+ title: "Auctions",
36
+ searchPlaceholder: "Search auctions by product name",
37
+ emptyLabel: "No auctions found",
38
+ filterKeys: ["status"],
39
+ defaultSort: "endsAt",
69
40
  queryKey: ["seller", "auctions", "listing"],
70
41
  endpoint: SELLER_ENDPOINTS.AUCTIONS,
71
- page: table.getNumber("page", 1),
72
- pageSize: PAGE_SIZE,
73
- sorts: table.get("sort") || DEFAULT_SORT,
74
- filters,
75
- q: table.get("q") || undefined,
42
+ sortOptions: [
43
+ { value: "endsAt", label: "Ending soon" },
44
+ { value: "-endsAt", label: "Ending latest" },
45
+ { value: "-createdAt", label: "Newest" },
46
+ { value: "createdAt", label: "Oldest" },
47
+ ],
76
48
  mapRows: (response) => toRecordArray(response.auctions).map((item, index) => ({
77
49
  id: toStringValue(item.id, `auction-${index}`),
78
50
  primary: toStringValue(item.productTitle ?? item.title, "Untitled auction"),
@@ -83,35 +55,33 @@ export function SellerAuctionsView({ renderHeader, children, onEditClick, onDele
83
55
  status: toStringValue(item.status, "Unknown"),
84
56
  updatedAt: toRelativeDate(item.endsAt ?? item.updatedAt ?? item.createdAt),
85
57
  })),
86
- getTotal: (response, mappedRows) => typeof response.meta?.total === "number" ? response.meta.total : mappedRows.length,
87
- });
88
- const currentPage = table.getNumber("page", 1);
89
- const totalPages = Math.ceil(total / PAGE_SIZE);
90
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
91
- const bulkActions = onBulkDelete
92
- ? [{
93
- id: "bulk-delete",
94
- label: ACTIONS.STORE["delete-listing"].label,
95
- variant: "danger",
96
- onClick: async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); },
97
- }]
98
- : [];
99
- const handleDelete = useCallback(async (id) => {
100
- await performDelete(id);
101
- setDeleteTargetId(null);
102
- }, [performDelete]);
103
- const handleEdit = useCallback((id) => {
104
- if (onEditClick)
105
- onEditClick(id);
106
- else
107
- window.location.href = String(ROUTES.STORE.PRODUCTS_EDIT(id));
108
- }, [onEditClick]);
109
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
110
- if (hasChildren) {
111
- return _jsx(ListingViewShell, { portal: "seller", ...props, children: children });
112
- }
113
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search auctions by product name", 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) }) })), selection.selectedCount > 0 && bulkActions.length > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-error-surface px-4 py-3 text-sm text-error dark:border-red-900/60", children: errorMessage })), view === "table" ? (_jsx(DataTable, { rows: rows, isLoading: isLoading, emptyLabel: "No auctions found", selectedIds: selection.selectedIdSet, onToggleSelect: (id) => selection.toggle(id), onToggleSelectAll: () => selection.toggleAll(), renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
114
- { label: ACTIONS.STORE["edit-listing"].label, onClick: () => handleEdit(row.id) },
115
- { label: ACTIONS.STORE["delete-listing"].label, destructive: true, onClick: () => setDeleteTargetId(row.id), disabled: deletingId === row.id },
116
- ] })) })) : (_jsx(AdminViewCards, { rows: rows, view: view, isLoading: isLoading, emptyLabel: "No auctions found", onRowClick: undefined, selectedIdSet: selection.selectedIdSet, onToggleSelect: selection.toggle }))] }), _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 })) }) }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Auction", message: "Are you sure you want to delete this auction? This cannot be undone.", onConfirm: () => handleDelete(deleteTargetId), onClose: () => setDeleteTargetId(null), isDeleting: deletingId === deleteTargetId }))] }));
58
+ getTotal: (response, mappedRows) => typeof response.meta?.total === "number"
59
+ ? response.meta.total
60
+ : mappedRows.length,
61
+ buildFilters: (state) => state.status && state.status !== "All" ? `status==${state.status}` : undefined,
62
+ buildBulkActions: onBulkDelete
63
+ ? (selection) => [
64
+ {
65
+ id: "bulk-delete",
66
+ label: ACTIONS.STORE["delete-listing"].label,
67
+ variant: "danger",
68
+ onClick: async () => {
69
+ await onBulkDelete(selection.selectedIds);
70
+ selection.clearSelection();
71
+ },
72
+ },
73
+ ]
74
+ : undefined,
75
+ renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
76
+ { label: ACTIONS.STORE["edit-listing"].label, onClick: () => handleEdit(row.id) },
77
+ {
78
+ label: ACTIONS.STORE["delete-listing"].label,
79
+ destructive: true,
80
+ onClick: () => setDeleteTargetId(row.id),
81
+ disabled: deletingId === row.id,
82
+ },
83
+ ] })),
84
+ renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: SELLER_AUCTION_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
85
+ };
86
+ return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Auction", message: "Are you sure you want to delete this auction? This cannot be undone.", onConfirm: () => handleDelete(deleteTargetId), onClose: () => setDeleteTargetId(null), isDeleting: deletingId === deleteTargetId }))] }));
117
87
  }
@@ -165,7 +165,7 @@ export function SellerBidsView({ endpoint = SELLER_ENDPOINTS.BIDS }) {
165
165
  buildBulkAction(ACTIONS.SELLER["cancel-bid"], () => void bulkCancel()),
166
166
  ];
167
167
  useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
168
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search by bidder name", 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) }) })), selection.selectedIds.length > 0 && (_jsx("div", { className: "sticky z-20 px-3 sm:px-4 py-2 bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700", style: { top: "calc(var(--header-height, 0px) + 88px)" }, children: _jsx(BulkActionBar, { selectedCount: selection.selectedIds.length, onClearSelection: selection.clearSelection, actions: bulkActions }) })), _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 dark:border-red-900/60 px-4 py-3 text-sm text-error", children: errorMessage })), table.get("grouped") === "0" ? (_jsx(DataTable, { rows: rows, columns: columns, isLoading: isLoading, emptyLabel: "No bids found for your auctions", selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: () => selection.toggleAll() })) : (_jsxs("div", { className: "space-y-3", children: [groupedRows.length === 0 && !isLoading && (_jsx(Text, { className: "text-sm text-zinc-500 dark:text-zinc-400", children: "No bids found for your auctions." })), groupedRows.map((group) => {
168
+ return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search by bidder name", 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) }) })), selection.selectedIds.length > 0 && (_jsx("div", { className: "sticky z-20 px-3 sm:px-4 py-2 bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700", style: { top: "calc(var(--header-height, 0px) + 88px)" }, children: _jsx(BulkActionBar, { selectedCount: selection.selectedIds.length, onClearSelection: selection.clearSelection, actions: bulkActions }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx(Div, { className: "mb-4 rounded-xl border border-error/20 bg-error-surface px-4 py-3 text-sm text-error", children: errorMessage })), table.get("grouped") === "0" ? (_jsx(DataTable, { rows: rows, columns: columns, isLoading: isLoading, emptyLabel: "No bids found for your auctions", selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: () => selection.toggleAll() })) : (_jsxs("div", { className: "space-y-3", children: [groupedRows.length === 0 && !isLoading && (_jsx(Text, { className: "text-sm text-zinc-500 dark:text-zinc-400", children: "No bids found for your auctions." })), groupedRows.map((group) => {
169
169
  const collapsed = collapsedGroups.has(group.id);
170
170
  return (_jsxs(Div, { className: "rounded-lg border border-[var(--appkit-color-border)] bg-[var(--appkit-color-surface)]", children: [_jsxs("button", { type: "button", onClick: () => toggleGroup(group.id), className: "w-full flex items-center justify-between px-4 py-2.5 text-sm font-semibold text-[var(--appkit-color-text)] hover:bg-[var(--appkit-color-surface-raised)]", children: [_jsxs("span", { className: "truncate", children: [group.title, " ", _jsxs("span", { className: "text-xs text-[var(--appkit-color-text-muted)] font-normal", children: ["\u00B7 ", group.bids.length, " bid", group.bids.length === 1 ? "" : "s"] })] }), _jsx("span", { "aria-hidden": true, className: "text-[var(--appkit-color-text-muted)]", children: collapsed ? "▸" : "▾" })] }), !collapsed && (_jsx("div", { className: "border-t border-[var(--appkit-color-border)]", children: _jsx(DataTable, { rows: group.bids, columns: columns, isLoading: false, emptyLabel: "", selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle }) }))] }, group.id));
171
171
  })] }))] }), _jsx(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: _jsx(FilterChipGroup, { label: "Bid Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })), allId: "" }) })] }));
@@ -1,38 +1,16 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useCallback } from "react";
4
4
  import { useEntityDelete } from "../../../react/hooks/useEntityDelete";
5
- import { Plus } from "lucide-react";
6
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
7
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
8
- import { BulkActionBar, Button, ConfirmDeleteModal, DataTable, Div, ListingToolbar, Pagination, RowActionMenu, Text, } from "../../../ui";
9
- import { useBottomActions } from "../../layout";
5
+ import { ConfirmDeleteModal, RowActionMenu, Text } from "../../../ui";
10
6
  import { SELLER_ENDPOINTS } from "../../../constants/api-endpoints";
11
7
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
12
8
  import { ROUTES } from "../../..";
13
- import { toRecordArray, toRelativeDate, toRupees, toStringValue, useSellerListingData, } from "../hooks/useSellerListingData";
14
- import { TABLE_KEYS } from "../../../constants/table-keys";
15
- const PAGE_SIZE = 25;
16
- const DEFAULT_SORT = "-createdAt";
17
- const SORT_OPTIONS = [
18
- { value: "-createdAt", label: "Newest" },
19
- { value: "createdAt", label: "Oldest" },
20
- { value: "productTitle", label: "Name A–Z" },
21
- { value: "-productTitle", label: "Name Z–A" },
22
- { value: "price", label: "Price: Low–High" },
23
- { value: "-price", label: "Price: High–Low" },
24
- ];
9
+ import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../../admin/hooks/useAdminListingData";
10
+ import { DataListingView } from "../../admin/components/DataListingView";
25
11
  const COLUMNS = [
26
- {
27
- key: "title",
28
- header: "Bundle",
29
- render: (row) => _jsx(Text, { className: "text-sm font-medium", children: row.title }),
30
- },
31
- {
32
- key: "price",
33
- header: "Price",
34
- render: (row) => _jsx(Text, { className: "text-sm tabular-nums", children: row.price }),
35
- },
12
+ { key: "title", header: "Bundle", render: (row) => _jsx(Text, { className: "text-sm font-medium", children: row.title }) },
13
+ { key: "price", header: "Price", render: (row) => _jsx(Text, { className: "text-sm tabular-nums", children: row.price }) },
36
14
  {
37
15
  key: "itemCount",
38
16
  header: "Items",
@@ -48,13 +26,10 @@ const COLUMNS = [
48
26
  {
49
27
  key: "createdAt",
50
28
  header: "Created",
51
- render: (row) => _jsx(Text, { className: "text-sm text-[var(--appkit-color-text-muted)]", children: row.createdAt }),
29
+ render: (row) => (_jsx(Text, { className: "text-sm text-[var(--appkit-color-text-muted)]", children: row.createdAt })),
52
30
  },
53
31
  ];
54
32
  export function SellerBundlesView({ onCreateClick, onEditClick, onDelete, onBulkDelete, }) {
55
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
56
- const [searchInput, setSearchInput] = useState(table.get(TABLE_KEYS.QUERY) || "");
57
- const [view, setView] = useState("table");
58
33
  const [deleteTargetId, setDeleteTargetId] = useState(null);
59
34
  const { deletingId, handleDelete: performDelete } = useEntityDelete({
60
35
  endpoint: (id) => `/api/store/products/${id}`,
@@ -62,46 +37,6 @@ export function SellerBundlesView({ onCreateClick, onEditClick, onDelete, onBulk
62
37
  successMessage: "Bundle deleted.",
63
38
  fetchOptions: { credentials: "include" },
64
39
  });
65
- const commitSearch = useCallback(() => {
66
- table.set(TABLE_KEYS.QUERY, searchInput.trim());
67
- }, [searchInput, table]);
68
- const resetAll = useCallback(() => {
69
- table.setMany({ [TABLE_KEYS.QUERY]: "", [TABLE_KEYS.SORT]: "" });
70
- setSearchInput("");
71
- }, [table]);
72
- const hasActiveState = !!table.get(TABLE_KEYS.QUERY) || table.get(TABLE_KEYS.SORT) !== DEFAULT_SORT;
73
- const { rows, total, isLoading, errorMessage } = useSellerListingData({
74
- queryKey: ["seller", "bundles"],
75
- endpoint: SELLER_ENDPOINTS.PRODUCTS,
76
- page: table.getNumber(TABLE_KEYS.PAGE, 1),
77
- pageSize: PAGE_SIZE,
78
- sorts: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT,
79
- filters: "listingType==bundle",
80
- q: table.get(TABLE_KEYS.QUERY) || undefined,
81
- mapRows: (response) => toRecordArray(response.products).map((item, index) => ({
82
- id: toStringValue(item.id, `bundle-${index}`),
83
- raw: item,
84
- title: toStringValue(item.productTitle ?? item.title, "Untitled bundle"),
85
- price: toRupees(item.price),
86
- itemCount: Array.isArray(item.bundleProductIds)
87
- ? item.bundleProductIds.length
88
- : Number(item.bundleItemCount ?? 0),
89
- status: toStringValue(item.status, "draft"),
90
- createdAt: toRelativeDate(item.createdAt),
91
- })),
92
- getTotal: (response, mappedRows) => typeof response.meta?.total === "number" ? response.meta.total : mappedRows.length,
93
- });
94
- const currentPage = table.getNumber(TABLE_KEYS.PAGE, 1);
95
- const totalPages = Math.ceil(total / PAGE_SIZE);
96
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
97
- const bulkActions = onBulkDelete
98
- ? [{
99
- id: "bulk-delete",
100
- label: ACTIONS.STORE["delete-listing"].label,
101
- variant: "danger",
102
- onClick: async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); },
103
- }]
104
- : [];
105
40
  const handleDelete = useCallback(async (id) => {
106
41
  await performDelete(id);
107
42
  setDeleteTargetId(null);
@@ -113,24 +48,64 @@ export function SellerBundlesView({ onCreateClick, onEditClick, onDelete, onBulk
113
48
  window.location.href = String(ROUTES.STORE.PRODUCTS_EDIT(id));
114
49
  }, [onEditClick]);
115
50
  const handleCreate = useCallback(() => {
116
- if (onCreateClick) {
51
+ if (onCreateClick)
117
52
  onCreateClick();
118
- }
119
- else {
53
+ else
120
54
  window.location.href = String(ROUTES.STORE.PRODUCTS_NEW);
121
- }
122
55
  }, [onCreateClick]);
123
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
124
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: 0, searchValue: searchInput, searchPlaceholder: "Search bundles...", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set(TABLE_KEYS.SORT, v); }, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState, extra: _jsxs(Button, { size: "sm", onClick: handleCreate, className: "flex items-center gap-1.5", children: [_jsx(Plus, { className: "h-4 w-4" }), _jsx("span", { children: "New Bundle" })] }) }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), selection.selectedCount > 0 && bulkActions.length > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx(Div, { className: "mb-4 rounded-xl border border-red-200 bg-error-surface dark:border-red-900/60 px-4 py-3 text-sm text-error", children: errorMessage })), isLoading ? (_jsx(Div, { className: "space-y-2", children: Array.from({ length: 5 }).map((_, i) => (_jsx(Div, { className: "h-14 animate-pulse rounded-xl border border-zinc-100 dark:border-slate-700 bg-zinc-50 dark:bg-slate-800" }, i))) })) : rows.length === 0 ? (_jsx(Div, { className: "py-16 text-center", children: _jsx(Text, { className: "text-zinc-400 dark:text-zinc-400", children: "No bundles yet \u2014 create a bundle to group multiple products together" }) })) : (_jsx(DataTable, { columns: COLUMNS, data: rows, keyExtractor: (r) => r.id, selectable: bulkActions.length > 0, selectedIds: selection.selectedIds, onSelectionChange: (ids) => selection.setSelectedIds(ids), actions: (row) => (_jsx(RowActionMenu, { actions: [
125
- {
126
- label: ACTIONS.STORE["edit-listing"].label,
127
- onClick: () => handleEdit(row.id),
128
- },
129
- {
130
- label: ACTIONS.STORE["delete-listing"].label,
131
- destructive: true,
132
- onClick: () => setDeleteTargetId(row.id),
133
- disabled: deletingId === row.id,
134
- },
135
- ] })) }))] }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Bundle", message: "Are you sure you want to delete this bundle? This cannot be undone.", onConfirm: () => handleDelete(deleteTargetId), onClose: () => setDeleteTargetId(null), isDeleting: deletingId === deleteTargetId }))] }));
56
+ const config = {
57
+ portal: "seller",
58
+ title: "Bundles",
59
+ searchPlaceholder: "Search bundles...",
60
+ emptyLabel: "No bundles yet — create a bundle to group multiple products together",
61
+ filterKeys: [],
62
+ defaultSort: "-createdAt",
63
+ queryKey: ["seller", "bundles"],
64
+ endpoint: SELLER_ENDPOINTS.PRODUCTS,
65
+ sortOptions: [
66
+ { value: "-createdAt", label: "Newest" },
67
+ { value: "createdAt", label: "Oldest" },
68
+ { value: "productTitle", label: "Name A–Z" },
69
+ { value: "-productTitle", label: "Name Z–A" },
70
+ { value: "price", label: "Price: Low–High" },
71
+ { value: "-price", label: "Price: High–Low" },
72
+ ],
73
+ columns: COLUMNS,
74
+ mapRows: (response) => toRecordArray(response.products).map((item, index) => ({
75
+ id: toStringValue(item.id, `bundle-${index}`),
76
+ title: toStringValue(item.productTitle ?? item.title, "Untitled bundle"),
77
+ price: toRupees(item.price),
78
+ itemCount: Array.isArray(item.bundleProductIds)
79
+ ? item.bundleProductIds.length
80
+ : Number(item.bundleItemCount ?? 0),
81
+ status: toStringValue(item.status, "draft"),
82
+ createdAt: toRelativeDate(item.createdAt),
83
+ })),
84
+ getTotal: (response, mappedRows) => typeof response.meta?.total === "number" ? response.meta.total : mappedRows.length,
85
+ buildFilters: () => "listingType==bundle",
86
+ primaryAction: { label: "New Bundle", onClick: () => handleCreate() },
87
+ buildBulkActions: onBulkDelete
88
+ ? (selection) => [
89
+ {
90
+ id: "bulk-delete",
91
+ label: ACTIONS.STORE["delete-listing"].label,
92
+ variant: "danger",
93
+ onClick: async () => {
94
+ await onBulkDelete(selection.selectedIds);
95
+ selection.clearSelection();
96
+ },
97
+ },
98
+ ]
99
+ : undefined,
100
+ renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
101
+ { label: ACTIONS.STORE["edit-listing"].label, onClick: () => handleEdit(row.id) },
102
+ {
103
+ label: ACTIONS.STORE["delete-listing"].label,
104
+ destructive: true,
105
+ onClick: () => setDeleteTargetId(row.id),
106
+ disabled: deletingId === row.id,
107
+ },
108
+ ] })),
109
+ };
110
+ return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Bundle", message: "Are you sure you want to delete this bundle? This cannot be undone.", onConfirm: () => handleDelete(deleteTargetId), onClose: () => setDeleteTargetId(null), isDeleting: deletingId === deleteTargetId }))] }));
136
111
  }
@@ -1,37 +1,16 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useCallback } from "react";
4
4
  import { useEntityDelete } from "../../../react/hooks/useEntityDelete";
5
- import { Plus } from "lucide-react";
6
- import { useUrlTable } from "../../../react/hooks/useUrlTable";
7
- import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
8
- import { BulkActionBar, Button, ConfirmDeleteModal, DataTable, Div, ListingToolbar, Pagination, RowActionMenu, Text, } from "../../../ui";
9
- import { useBottomActions } from "../../layout";
5
+ import { ConfirmDeleteModal, RowActionMenu, Text } from "../../../ui";
10
6
  import { SELLER_ENDPOINTS } from "../../../constants/api-endpoints";
11
7
  import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
12
8
  import { ROUTES } from "../../..";
13
- import { toRecordArray, toRelativeDate, toRupees, toStringValue, useSellerListingData, } from "../hooks/useSellerListingData";
14
- import { TABLE_KEYS } from "../../../constants/table-keys";
15
- const PAGE_SIZE = 25;
16
- const DEFAULT_SORT = "-createdAt";
17
- const SORT_OPTIONS = [
18
- { value: "-createdAt", label: "Newest" },
19
- { value: "createdAt", label: "Oldest" },
20
- { value: "productTitle", label: "Name A–Z" },
21
- { value: "price", label: "Price: Low–High" },
22
- { value: "-price", label: "Price: High–Low" },
23
- ];
9
+ import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../../admin/hooks/useAdminListingData";
10
+ import { DataListingView } from "../../admin/components/DataListingView";
24
11
  const COLUMNS = [
25
- {
26
- key: "title",
27
- header: "Listing",
28
- render: (row) => _jsx(Text, { className: "text-sm font-medium", children: row.title }),
29
- },
30
- {
31
- key: "price",
32
- header: "Price",
33
- render: (row) => _jsx(Text, { className: "text-sm tabular-nums", children: row.price }),
34
- },
12
+ { key: "title", header: "Listing", render: (row) => _jsx(Text, { className: "text-sm font-medium", children: row.title }) },
13
+ { key: "price", header: "Price", render: (row) => _jsx(Text, { className: "text-sm tabular-nums", children: row.price }) },
35
14
  {
36
15
  key: "city",
37
16
  header: "Location",
@@ -54,13 +33,10 @@ const COLUMNS = [
54
33
  {
55
34
  key: "createdAt",
56
35
  header: "Created",
57
- render: (row) => _jsx(Text, { className: "text-sm text-[var(--appkit-color-text-muted)]", children: row.createdAt }),
36
+ render: (row) => (_jsx(Text, { className: "text-sm text-[var(--appkit-color-text-muted)]", children: row.createdAt })),
58
37
  },
59
38
  ];
60
39
  export function SellerClassifiedView({ onCreateClick, onEditClick, onDelete, onBulkDelete, }) {
61
- const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
62
- const [searchInput, setSearchInput] = useState(table.get(TABLE_KEYS.QUERY) || "");
63
- const [view] = useState("table");
64
40
  const [deleteTargetId, setDeleteTargetId] = useState(null);
65
41
  const { deletingId, handleDelete: performDelete } = useEntityDelete({
66
42
  endpoint: (id) => `/api/store/products/${id}`,
@@ -68,28 +44,44 @@ export function SellerClassifiedView({ onCreateClick, onEditClick, onDelete, onB
68
44
  successMessage: "Listing deleted.",
69
45
  fetchOptions: { credentials: "include" },
70
46
  });
71
- const commitSearch = useCallback(() => {
72
- table.set(TABLE_KEYS.QUERY, searchInput.trim());
73
- }, [searchInput, table]);
74
- const resetAll = useCallback(() => {
75
- table.setMany({ [TABLE_KEYS.QUERY]: "", [TABLE_KEYS.SORT]: "" });
76
- setSearchInput("");
77
- }, [table]);
78
- const hasActiveState = !!table.get(TABLE_KEYS.QUERY) || table.get(TABLE_KEYS.SORT) !== DEFAULT_SORT;
79
- const { rows, total, isLoading, errorMessage } = useSellerListingData({
47
+ const handleDelete = useCallback(async (id) => {
48
+ await performDelete(id);
49
+ setDeleteTargetId(null);
50
+ }, [performDelete]);
51
+ const handleEdit = useCallback((id) => {
52
+ if (onEditClick)
53
+ onEditClick(id);
54
+ else
55
+ window.location.href = String(ROUTES.STORE.CLASSIFIED_EDIT(id));
56
+ }, [onEditClick]);
57
+ const handleCreate = useCallback(() => {
58
+ if (onCreateClick)
59
+ onCreateClick();
60
+ else
61
+ window.location.href = String(ROUTES.STORE.CLASSIFIED_NEW);
62
+ }, [onCreateClick]);
63
+ const config = {
64
+ portal: "seller",
65
+ title: "Classified",
66
+ searchPlaceholder: "Search classified listings...",
67
+ emptyLabel: "No classified listings yet — post your first buy/sell/trade ad",
68
+ filterKeys: [],
69
+ defaultSort: "-createdAt",
80
70
  queryKey: ["seller", "classified"],
81
71
  endpoint: SELLER_ENDPOINTS.PRODUCTS,
82
- page: table.getNumber(TABLE_KEYS.PAGE, 1),
83
- pageSize: PAGE_SIZE,
84
- sorts: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT,
85
- filters: "listingType==classified",
86
- q: table.get(TABLE_KEYS.QUERY) || undefined,
72
+ sortOptions: [
73
+ { value: "-createdAt", label: "Newest" },
74
+ { value: "createdAt", label: "Oldest" },
75
+ { value: "productTitle", label: "Name A–Z" },
76
+ { value: "price", label: "Price: Low–High" },
77
+ { value: "-price", label: "Price: High–Low" },
78
+ ],
79
+ columns: COLUMNS,
87
80
  mapRows: (response) => toRecordArray(response.products).map((item, index) => {
88
81
  const classified = (item.classified ?? {});
89
82
  const meetupArea = (classified.meetupArea ?? {});
90
83
  return {
91
84
  id: toStringValue(item.id, `classified-${index}`),
92
- raw: item,
93
85
  title: toStringValue(item.productTitle ?? item.title, "Untitled"),
94
86
  price: toRupees(item.price),
95
87
  city: toStringValue(meetupArea.city ?? classified.city, ""),
@@ -98,48 +90,33 @@ export function SellerClassifiedView({ onCreateClick, onEditClick, onDelete, onB
98
90
  createdAt: toRelativeDate(item.createdAt),
99
91
  };
100
92
  }),
101
- getTotal: (response, mappedRows) => typeof response.meta?.total === "number" ? response.meta.total : mappedRows.length,
102
- });
103
- const currentPage = table.getNumber(TABLE_KEYS.PAGE, 1);
104
- const totalPages = Math.ceil(total / PAGE_SIZE);
105
- const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
106
- const bulkActions = onBulkDelete
107
- ? [{
108
- id: "bulk-delete",
109
- label: ACTIONS.STORE["delete-listing"].label,
110
- variant: "danger",
111
- onClick: async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); },
112
- }]
113
- : [];
114
- const handleDelete = useCallback(async (id) => {
115
- await performDelete(id);
116
- setDeleteTargetId(null);
117
- }, [performDelete]);
118
- const handleEdit = useCallback((id) => {
119
- if (onEditClick)
120
- onEditClick(id);
121
- else
122
- window.location.href = String(ROUTES.STORE.CLASSIFIED_EDIT(id));
123
- }, [onEditClick]);
124
- const handleCreate = useCallback(() => {
125
- if (onCreateClick) {
126
- onCreateClick();
127
- }
128
- else {
129
- window.location.href = String(ROUTES.STORE.CLASSIFIED_NEW);
130
- }
131
- }, [onCreateClick]);
132
- useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
133
- return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: 0, searchValue: searchInput, searchPlaceholder: "Search classified listings...", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set(TABLE_KEYS.SORT, v); }, showTableView: true, view: view, onViewChange: () => { }, onResetAll: resetAll, hasActiveState: hasActiveState, extra: _jsxs(Button, { size: "sm", onClick: handleCreate, className: "flex items-center gap-1.5", children: [_jsx(Plus, { className: "h-4 w-4" }), _jsx("span", { children: "New Classified" })] }) }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), selection.selectedCount > 0 && bulkActions.length > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx(Div, { className: "mb-4 rounded-xl border border-red-200 bg-error-surface dark:border-red-900/60 px-4 py-3 text-sm text-error", children: errorMessage })), isLoading ? (_jsx(Div, { className: "space-y-2", children: Array.from({ length: 5 }).map((_, i) => (_jsx(Div, { className: "h-14 animate-pulse rounded-xl border border-zinc-100 dark:border-slate-700 bg-zinc-50 dark:bg-slate-800" }, i))) })) : rows.length === 0 ? (_jsx(Div, { className: "py-16 text-center", children: _jsx(Text, { className: "text-zinc-400 dark:text-zinc-400", children: "No classified listings yet \u2014 post your first buy/sell/trade ad" }) })) : (_jsx(DataTable, { columns: COLUMNS, data: rows, keyExtractor: (r) => r.id, selectable: bulkActions.length > 0, selectedIds: selection.selectedIds, onSelectionChange: (ids) => selection.setSelectedIds(ids), actions: (row) => (_jsx(RowActionMenu, { actions: [
134
- {
135
- label: ACTIONS.STORE["edit-listing"].label,
136
- onClick: () => handleEdit(row.id),
137
- },
138
- {
139
- label: ACTIONS.STORE["delete-listing"].label,
140
- destructive: true,
141
- onClick: () => setDeleteTargetId(row.id),
142
- disabled: deletingId === row.id,
143
- },
144
- ] })) }))] }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Classified Listing", message: "Are you sure you want to delete this classified listing? This cannot be undone.", onConfirm: () => handleDelete(deleteTargetId), onClose: () => setDeleteTargetId(null), isDeleting: deletingId === deleteTargetId }))] }));
93
+ getTotal: (response, mappedRows) => typeof response.meta?.total === "number"
94
+ ? response.meta.total
95
+ : mappedRows.length,
96
+ buildFilters: () => "listingType==classified",
97
+ primaryAction: { label: "New Classified", onClick: () => handleCreate() },
98
+ buildBulkActions: onBulkDelete
99
+ ? (selection) => [
100
+ {
101
+ id: "bulk-delete",
102
+ label: ACTIONS.STORE["delete-listing"].label,
103
+ variant: "danger",
104
+ onClick: async () => {
105
+ await onBulkDelete(selection.selectedIds);
106
+ selection.clearSelection();
107
+ },
108
+ },
109
+ ]
110
+ : undefined,
111
+ renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
112
+ { label: ACTIONS.STORE["edit-listing"].label, onClick: () => handleEdit(row.id) },
113
+ {
114
+ label: ACTIONS.STORE["delete-listing"].label,
115
+ destructive: true,
116
+ onClick: () => setDeleteTargetId(row.id),
117
+ disabled: deletingId === row.id,
118
+ },
119
+ ] })),
120
+ };
121
+ return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Classified Listing", message: "Are you sure you want to delete this classified listing? This cannot be undone.", onConfirm: () => handleDelete(deleteTargetId), onClose: () => setDeleteTargetId(null), isDeleting: deletingId === deleteTargetId }))] }));
145
122
  }