@mohasinac/appkit 2.7.27 → 2.7.31

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 (397) hide show
  1. package/dist/_internal/client/features/filters/filter-load-options.d.ts +29 -0
  2. package/dist/_internal/client/features/filters/filter-load-options.js +98 -0
  3. package/dist/_internal/client/features/layout/DashboardLayoutClient.js +1 -1
  4. package/dist/_internal/server/features/checkout/actions.js +42 -35
  5. package/dist/_internal/server/features/classified/adapters.d.ts +21 -0
  6. package/dist/_internal/server/features/classified/adapters.js +24 -0
  7. package/dist/_internal/server/features/classified/index.d.ts +3 -0
  8. package/dist/_internal/server/features/classified/index.js +3 -0
  9. package/dist/_internal/server/features/classified/metadata.d.ts +8 -0
  10. package/dist/_internal/server/features/classified/metadata.js +43 -0
  11. package/dist/_internal/server/features/classified/og.d.ts +30 -0
  12. package/dist/_internal/server/features/classified/og.js +76 -0
  13. package/dist/_internal/server/features/digital-code/adapters.d.ts +21 -0
  14. package/dist/_internal/server/features/digital-code/adapters.js +29 -0
  15. package/dist/_internal/server/features/digital-code/index.d.ts +3 -0
  16. package/dist/_internal/server/features/digital-code/index.js +3 -0
  17. package/dist/_internal/server/features/digital-code/metadata.d.ts +8 -0
  18. package/dist/_internal/server/features/digital-code/metadata.js +36 -0
  19. package/dist/_internal/server/features/digital-code/og.d.ts +27 -0
  20. package/dist/_internal/server/features/digital-code/og.js +77 -0
  21. package/dist/_internal/server/features/live/adapters.d.ts +21 -0
  22. package/dist/_internal/server/features/live/adapters.js +34 -0
  23. package/dist/_internal/server/features/live/index.d.ts +3 -0
  24. package/dist/_internal/server/features/live/index.js +3 -0
  25. package/dist/_internal/server/features/live/metadata.d.ts +8 -0
  26. package/dist/_internal/server/features/live/metadata.js +39 -0
  27. package/dist/_internal/server/features/live/og.d.ts +27 -0
  28. package/dist/_internal/server/features/live/og.js +72 -0
  29. package/dist/_internal/server/features/promotions/actions.js +4 -3
  30. package/dist/_internal/server/jobs/core/onOrderCreate.js +19 -16
  31. package/dist/_internal/server/jobs/core/onOrderStatusChange.js +25 -22
  32. package/dist/_internal/server/jobs/core/onProductWrite.js +48 -58
  33. package/dist/_internal/shared/actions/action-registry.js +504 -9
  34. package/dist/_internal/shared/features/blog/schema.d.ts +4 -4
  35. package/dist/_internal/shared/features/brands/schema.d.ts +5 -5
  36. package/dist/_internal/shared/features/cart/schema.d.ts +18 -18
  37. package/dist/_internal/shared/features/categories/bundle-copy.d.ts +1 -1
  38. package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +38 -38
  39. package/dist/_internal/shared/features/events/schema.d.ts +8 -8
  40. package/dist/_internal/shared/features/orders/schema.d.ts +8 -8
  41. package/dist/_internal/shared/features/products/schema.d.ts +42 -42
  42. package/dist/_internal/shared/features/promotions/schema.d.ts +4 -4
  43. package/dist/_internal/shared/features/reviews/schema.d.ts +1 -1
  44. package/dist/_internal/shared/media/limits.js +4 -3
  45. package/dist/client.d.ts +4 -0
  46. package/dist/client.js +2 -0
  47. package/dist/configs/next.js +4 -0
  48. package/dist/constants/api-endpoints.d.ts +6 -0
  49. package/dist/constants/api-endpoints.js +2 -0
  50. package/dist/constants/field-names.d.ts +1 -0
  51. package/dist/constants/field-names.js +1 -0
  52. package/dist/constants/table-keys.d.ts +6 -0
  53. package/dist/constants/table-keys.js +9 -0
  54. package/dist/core/hooks/useSyncManager.js +9 -8
  55. package/dist/features/about/components/FeesView.js +10 -7
  56. package/dist/features/about/components/HelpPageView.js +10 -1
  57. package/dist/features/about/components/HowAuctionsWorkView.js +10 -1
  58. package/dist/features/about/components/HowCheckoutWorksView.js +10 -1
  59. package/dist/features/about/components/HowOffersWorkView.js +10 -1
  60. package/dist/features/about/components/HowOrdersWorkView.js +10 -1
  61. package/dist/features/about/components/HowPayoutsWorkView.js +10 -1
  62. package/dist/features/about/components/HowPreOrdersWorkView.js +10 -1
  63. package/dist/features/about/components/HowReviewsWorkView.js +10 -1
  64. package/dist/features/about/components/PublicProfileView.js +46 -16
  65. package/dist/features/about/components/SecurityPrivacyView.js +7 -1
  66. package/dist/features/account/components/AddressesIndexListing.js +2 -2
  67. package/dist/features/account/components/NotificationBell.js +27 -16
  68. package/dist/features/account/components/NotificationPreferencesPanel.d.ts +9 -0
  69. package/dist/features/account/components/NotificationPreferencesPanel.js +91 -0
  70. package/dist/features/account/components/UserSidebar.js +4 -4
  71. package/dist/features/account/components/UserSupportView.js +16 -6
  72. package/dist/features/account/components/index.d.ts +2 -0
  73. package/dist/features/account/components/index.js +1 -0
  74. package/dist/features/account/schemas/index.d.ts +4 -4
  75. package/dist/features/account/types/index.d.ts +34 -0
  76. package/dist/features/admin/actions/admin-actions.js +4 -3
  77. package/dist/features/admin/actions/notification-actions.d.ts +24 -22
  78. package/dist/features/admin/actions/notification-actions.js +122 -22
  79. package/dist/features/admin/components/AdminAdEditorView.js +29 -15
  80. package/dist/features/admin/components/AdminAddressEditorView.d.ts +7 -0
  81. package/dist/features/admin/components/AdminAddressEditorView.js +117 -0
  82. package/dist/features/admin/components/AdminAdsView.js +22 -28
  83. package/dist/features/admin/components/AdminAllEventEntriesView.js +6 -1
  84. package/dist/features/admin/components/AdminBidsView.js +10 -3
  85. package/dist/features/admin/components/AdminBlogEditorView.js +2 -2
  86. package/dist/features/admin/components/AdminBlogView.js +8 -3
  87. package/dist/features/admin/components/AdminBrandsView.js +7 -2
  88. package/dist/features/admin/components/AdminBundleEditorView.js +5 -2
  89. package/dist/features/admin/components/AdminCarouselEditorView.js +6 -3
  90. package/dist/features/admin/components/AdminCarouselView.js +13 -7
  91. package/dist/features/admin/components/AdminCategoriesView.js +8 -3
  92. package/dist/features/admin/components/AdminCategoryEditorView.js +12 -9
  93. package/dist/features/admin/components/AdminContactView.js +6 -1
  94. package/dist/features/admin/components/AdminCouponEditorView.js +8 -2
  95. package/dist/features/admin/components/AdminCouponsView.js +6 -1
  96. package/dist/features/admin/components/AdminEmployeeEditorView.js +12 -9
  97. package/dist/features/admin/components/AdminFaqEditorView.js +2 -2
  98. package/dist/features/admin/components/AdminFaqsView.js +7 -2
  99. package/dist/features/admin/components/AdminFeatureFlagsView.js +58 -13
  100. package/dist/features/admin/components/AdminFeaturesView.js +4 -3
  101. package/dist/features/admin/components/AdminMediaView.js +9 -8
  102. package/dist/features/admin/components/AdminNavigationView.js +10 -17
  103. package/dist/features/admin/components/AdminNewsletterView.js +6 -1
  104. package/dist/features/admin/components/AdminNotificationsView.js +11 -3
  105. package/dist/features/admin/components/AdminOrdersView.js +6 -1
  106. package/dist/features/admin/components/AdminPayoutsView.js +10 -3
  107. package/dist/features/admin/components/AdminPrizeDrawsView.js +10 -3
  108. package/dist/features/admin/components/AdminProductEditorView.d.ts +3 -1
  109. package/dist/features/admin/components/AdminProductEditorView.js +12 -9
  110. package/dist/features/admin/components/AdminProductsView.js +18 -12
  111. package/dist/features/admin/components/AdminReturnRequestsView.js +5 -4
  112. package/dist/features/admin/components/AdminReviewsView.js +36 -26
  113. package/dist/features/admin/components/AdminScammerEditorView.js +3 -2
  114. package/dist/features/admin/components/AdminScammersView.js +28 -26
  115. package/dist/features/admin/components/AdminSectionsView.js +112 -99
  116. package/dist/features/admin/components/AdminSessionsView.js +10 -3
  117. package/dist/features/admin/components/AdminSidebar.js +4 -4
  118. package/dist/features/admin/components/AdminSiteSettingsView.js +45 -4
  119. package/dist/features/admin/components/AdminStoresView.js +6 -1
  120. package/dist/features/admin/components/AdminSublistingCategoriesView.js +0 -1
  121. package/dist/features/admin/components/AdminSupportTicketDetailView.js +1 -1
  122. package/dist/features/admin/components/AdminSupportTicketsView.js +32 -34
  123. package/dist/features/admin/components/AdminTeamView.js +6 -1
  124. package/dist/features/admin/components/AdminUserEditorView.js +8 -15
  125. package/dist/features/admin/components/AdminUsersView.js +6 -1
  126. package/dist/features/admin/components/AdminViewCards.js +4 -3
  127. package/dist/features/admin/components/DashboardStats.js +2 -2
  128. package/dist/features/admin/components/DataTable.js +2 -2
  129. package/dist/features/admin/components/index.d.ts +2 -0
  130. package/dist/features/admin/components/index.js +1 -0
  131. package/dist/features/admin/components/sections/adminSectionsTypes.js +4 -3
  132. package/dist/features/admin/repository/chat.repository.js +8 -8
  133. package/dist/features/admin/repository/site-settings.repository.d.ts +1 -0
  134. package/dist/features/admin/repository/site-settings.repository.js +11 -9
  135. package/dist/features/admin/schemas/firestore.d.ts +38 -0
  136. package/dist/features/admin/schemas/firestore.js +15 -0
  137. package/dist/features/auctions/components/AuctionBidsTable.d.ts +13 -0
  138. package/dist/features/auctions/components/AuctionBidsTable.js +62 -0
  139. package/dist/features/auctions/components/AuctionDetailPageView.js +15 -21
  140. package/dist/features/auctions/components/AuctionFilters.d.ts +7 -1
  141. package/dist/features/auctions/components/AuctionFilters.js +3 -2
  142. package/dist/features/auctions/components/MarketplaceAuctionCard.js +18 -9
  143. package/dist/features/auctions/components/MarketplaceAuctionGrid.js +3 -2
  144. package/dist/features/auctions/components/index.d.ts +2 -1
  145. package/dist/features/auctions/components/index.js +1 -1
  146. package/dist/features/auctions/schemas/index.d.ts +14 -14
  147. package/dist/features/auth/actions/realtime-token-actions.js +19 -4
  148. package/dist/features/auth/components/RegisterForm.js +8 -4
  149. package/dist/features/auth/consent-otp.d.ts +2 -0
  150. package/dist/features/auth/consent-otp.js +8 -0
  151. package/dist/features/auth/schemas/firestore.d.ts +2 -0
  152. package/dist/features/auth/schemas/firestore.js +18 -25
  153. package/dist/features/auth/schemas/index.d.ts +2 -2
  154. package/dist/features/before-after/api/[id]/route.js +8 -6
  155. package/dist/features/before-after/schemas/index.d.ts +2 -2
  156. package/dist/features/blog/actions/blog-actions.d.ts +3 -3
  157. package/dist/features/blog/components/BlogIndexListing.js +21 -2
  158. package/dist/features/blog/components/BlogPostForm.js +11 -5
  159. package/dist/features/blog/components/BlogPostView.js +10 -2
  160. package/dist/features/blog/schemas/index.d.ts +18 -18
  161. package/dist/features/cart/components/CartDrawer.js +3 -2
  162. package/dist/features/cart/components/CartView.js +2 -1
  163. package/dist/features/cart/components/CheckoutView.js +2 -1
  164. package/dist/features/cart/repository/cart.repository.js +4 -3
  165. package/dist/features/cart/utils/pending-ops.d.ts +1 -1
  166. package/dist/features/categories/api/[id]/route.js +4 -3
  167. package/dist/features/categories/api/route.js +4 -3
  168. package/dist/features/categories/components/BrandDetailPageView.js +2 -2
  169. package/dist/features/categories/components/BrandDetailTabs.d.ts +5 -1
  170. package/dist/features/categories/components/BrandDetailTabs.js +30 -16
  171. package/dist/features/categories/components/BundleCollage.d.ts +8 -0
  172. package/dist/features/categories/components/BundleCollage.js +50 -0
  173. package/dist/features/categories/components/BundleDetailView.js +2 -10
  174. package/dist/features/categories/components/BundleItemsPicker.js +20 -13
  175. package/dist/features/categories/components/CategoriesIndexListing.js +28 -9
  176. package/dist/features/categories/components/CategoryDetailPageView.js +2 -2
  177. package/dist/features/categories/components/CategoryDetailTabs.d.ts +5 -1
  178. package/dist/features/categories/components/CategoryDetailTabs.js +31 -16
  179. package/dist/features/categories/components/CategoryProductsListing.js +52 -13
  180. package/dist/features/categories/components/index.d.ts +2 -0
  181. package/dist/features/categories/components/index.js +1 -0
  182. package/dist/features/categories/schemas/index.d.ts +6 -6
  183. package/dist/features/checkout/actions/checkout-actions.js +4 -3
  184. package/dist/features/checkout/hooks/usePaymentCheckout.js +31 -22
  185. package/dist/features/classified/components/ClassifiedFilters.d.ts +12 -0
  186. package/dist/features/classified/components/ClassifiedFilters.js +20 -0
  187. package/dist/features/classified/components/ClassifiedIndexListing.d.ts +4 -0
  188. package/dist/features/classified/components/ClassifiedIndexListing.js +110 -0
  189. package/dist/features/classified/components/ClassifiedListView.d.ts +6 -0
  190. package/dist/features/classified/components/ClassifiedListView.js +43 -0
  191. package/dist/features/classified/components/index.d.ts +6 -0
  192. package/dist/features/classified/components/index.js +3 -0
  193. package/dist/features/collections/api/[slug]/route.js +16 -12
  194. package/dist/features/collections/schemas/index.d.ts +5 -5
  195. package/dist/features/consultation/api/[id]/route.js +12 -9
  196. package/dist/features/consultation/components/ConsultationForm.js +3 -2
  197. package/dist/features/consultation/schemas/index.d.ts +6 -6
  198. package/dist/features/contact/email.js +77 -116
  199. package/dist/features/copilot/components/AdminCopilotView.js +12 -2
  200. package/dist/features/corporate/api/[id]/route.js +12 -9
  201. package/dist/features/corporate/components/CorporateInquiryForm.js +2 -1
  202. package/dist/features/digital-codes/components/DigitalCodeFilters.d.ts +12 -0
  203. package/dist/features/digital-codes/components/DigitalCodeFilters.js +17 -0
  204. package/dist/features/digital-codes/components/DigitalCodesIndexListing.d.ts +4 -0
  205. package/dist/features/digital-codes/components/DigitalCodesIndexListing.js +107 -0
  206. package/dist/features/digital-codes/components/DigitalCodesListView.d.ts +6 -0
  207. package/dist/features/digital-codes/components/DigitalCodesListView.js +37 -0
  208. package/dist/features/digital-codes/components/index.d.ts +6 -0
  209. package/dist/features/digital-codes/components/index.js +3 -0
  210. package/dist/features/events/actions/event-actions.js +4 -3
  211. package/dist/features/events/components/AdminEventEditorView.js +3 -2
  212. package/dist/features/events/components/AdminEventsView.js +4 -2
  213. package/dist/features/events/components/EventPollWidget.js +5 -5
  214. package/dist/features/events/components/EventsIndexListing.js +2 -2
  215. package/dist/features/events/repository/event-entry.repository.d.ts +1 -0
  216. package/dist/features/events/repository/event-entry.repository.js +5 -0
  217. package/dist/features/events/schemas/index.d.ts +20 -20
  218. package/dist/features/faq/actions/faq-actions.d.ts +8 -8
  219. package/dist/features/faq/components/ContactCTA.js +3 -1
  220. package/dist/features/faq/components/FAQAccordion.js +1 -1
  221. package/dist/features/faq/schemas/index.d.ts +4 -4
  222. package/dist/features/filters/AsyncFacetSection.d.ts +18 -0
  223. package/dist/features/filters/AsyncFacetSection.js +65 -0
  224. package/dist/features/filters/index.d.ts +2 -0
  225. package/dist/features/filters/index.js +1 -0
  226. package/dist/features/forms/Checkbox.js +2 -2
  227. package/dist/features/forms/Input.js +2 -2
  228. package/dist/features/forms/Radio.js +5 -5
  229. package/dist/features/forms/Select.js +2 -2
  230. package/dist/features/forms/Slider.js +2 -2
  231. package/dist/features/forms/Textarea.js +2 -2
  232. package/dist/features/homepage/api/[id]/route.js +4 -3
  233. package/dist/features/homepage/api/sections/[id]/route.js +12 -9
  234. package/dist/features/homepage/components/AdSlot.js +2 -1
  235. package/dist/features/homepage/components/AdvertisementBanner.js +5 -3
  236. package/dist/features/homepage/components/BrandsSection.js +2 -2
  237. package/dist/features/homepage/components/CTABannerSection.js +2 -2
  238. package/dist/features/homepage/components/CharacterHotspot.d.ts +2 -2
  239. package/dist/features/homepage/components/CharacterHotspot.js +119 -157
  240. package/dist/features/homepage/components/CharacterHotspotForm.js +25 -20
  241. package/dist/features/homepage/components/CustomCardsSection.js +8 -6
  242. package/dist/features/homepage/components/FeaturedProductsSection.js +2 -2
  243. package/dist/features/homepage/components/GoogleReviewsSection.js +3 -3
  244. package/dist/features/homepage/components/HeroBanner.js +5 -4
  245. package/dist/features/homepage/components/HeroCarousel.js +13 -26
  246. package/dist/features/homepage/components/HowItWorksSection.js +4 -2
  247. package/dist/features/homepage/components/SocialFeedSection.js +2 -2
  248. package/dist/features/homepage/components/SocialPostCard.js +3 -2
  249. package/dist/features/homepage/lib/social-feed-fetcher.js +6 -3
  250. package/dist/features/layout/AppLayoutShell.d.ts +8 -2
  251. package/dist/features/layout/AppLayoutShell.js +54 -78
  252. package/dist/features/layout/BottomActions.js +43 -48
  253. package/dist/features/live/components/LiveItemFilters.d.ts +12 -0
  254. package/dist/features/live/components/LiveItemFilters.js +24 -0
  255. package/dist/features/live/components/LiveItemsIndexListing.d.ts +4 -0
  256. package/dist/features/live/components/LiveItemsIndexListing.js +108 -0
  257. package/dist/features/live/components/LiveItemsListView.d.ts +6 -0
  258. package/dist/features/live/components/LiveItemsListView.js +43 -0
  259. package/dist/features/live/components/index.d.ts +6 -0
  260. package/dist/features/live/components/index.js +3 -0
  261. package/dist/features/media/MediaLightbox.js +8 -14
  262. package/dist/features/media/types/index.d.ts +2 -2
  263. package/dist/features/media/upload/CameraCapture.js +2 -2
  264. package/dist/features/media/upload/ImageUpload.js +4 -2
  265. package/dist/features/media/upload/MediaUploadField.js +24 -8
  266. package/dist/features/media/upload/MediaUploadList.js +1 -1
  267. package/dist/features/orders/actions/order-actions.js +4 -3
  268. package/dist/features/orders/components/MarketplaceOrderCard.js +2 -1
  269. package/dist/features/orders/components/OrderFilters.js +12 -9
  270. package/dist/features/orders/schemas/index.d.ts +6 -6
  271. package/dist/features/pre-orders/api/[id]/route.js +12 -9
  272. package/dist/features/pre-orders/components/MarketplacePreorderCard.js +5 -4
  273. package/dist/features/pre-orders/components/PreOrderDetailPageView.js +29 -22
  274. package/dist/features/pre-orders/components/PreOrderFilters.d.ts +7 -1
  275. package/dist/features/pre-orders/components/PreOrderFilters.js +3 -2
  276. package/dist/features/pre-orders/components/PreOrdersIndexListing.js +17 -52
  277. package/dist/features/pre-orders/components/PreorderCard.d.ts +0 -9
  278. package/dist/features/pre-orders/components/PreorderCard.js +2 -13
  279. package/dist/features/pre-orders/components/index.d.ts +1 -1
  280. package/dist/features/pre-orders/components/index.js +1 -1
  281. package/dist/features/pre-orders/schemas/index.d.ts +10 -10
  282. package/dist/features/products/api/[id]/route.js +9 -7
  283. package/dist/features/products/api/route.js +1 -1
  284. package/dist/features/products/columns/productTableColumns.js +3 -3
  285. package/dist/features/products/components/AuctionsIndexListing.js +15 -51
  286. package/dist/features/products/components/BidHistory.js +2 -2
  287. package/dist/features/products/components/CompareOverlay.d.ts +2 -0
  288. package/dist/features/products/components/CompareOverlay.js +3 -2
  289. package/dist/features/products/components/MakeOfferButton.js +20 -14
  290. package/dist/features/products/components/MarketplacePrizeDrawCard.js +2 -1
  291. package/dist/features/products/components/PrizeDrawCollage.d.ts +1 -15
  292. package/dist/features/products/components/PrizeDrawCollage.js +54 -14
  293. package/dist/features/products/components/PrizeDrawDetailPageView.js +2 -1
  294. package/dist/features/products/components/PrizeDrawEntryActions.js +2 -1
  295. package/dist/features/products/components/PrizeDrawItemsEditor.js +9 -7
  296. package/dist/features/products/components/PrizeDrawsIndexListing.js +18 -51
  297. package/dist/features/products/components/PrizeRevealModal.js +24 -14
  298. package/dist/features/products/components/ProductDetailPageView.js +2 -1
  299. package/dist/features/products/components/ProductFilters.d.ts +7 -1
  300. package/dist/features/products/components/ProductFilters.js +11 -8
  301. package/dist/features/products/components/ProductForm.js +18 -16
  302. package/dist/features/products/components/ProductGalleryClient.js +2 -1
  303. package/dist/features/products/components/ProductGrid.js +12 -15
  304. package/dist/features/products/components/ProductsIndexListing.js +16 -52
  305. package/dist/features/products/components/ProductsIndexPageView.js +2 -2
  306. package/dist/features/products/repository/products.repository.d.ts +4 -0
  307. package/dist/features/products/repository/products.repository.js +22 -3
  308. package/dist/features/products/schemas/firestore.d.ts +7 -1
  309. package/dist/features/products/schemas/index.d.ts +56 -56
  310. package/dist/features/products/schemas/product-features.validators.d.ts +14 -14
  311. package/dist/features/products/types/index.d.ts +4 -0
  312. package/dist/features/promotions/components/CouponsIndexListing.js +1 -1
  313. package/dist/features/promotions/schemas/index.d.ts +6 -6
  314. package/dist/features/reviews/actions/review-actions.js +6 -5
  315. package/dist/features/reviews/api/[id]/route.js +4 -3
  316. package/dist/features/reviews/components/ReviewDetailPageView.js +2 -2
  317. package/dist/features/reviews/components/ReviewDetailShell.js +6 -3
  318. package/dist/features/reviews/components/ReviewsIndexListing.js +2 -2
  319. package/dist/features/reviews/schemas/index.d.ts +6 -6
  320. package/dist/features/scams/components/ScamProfileView.js +19 -10
  321. package/dist/features/scams/components/ScamRegistryView.js +2 -1
  322. package/dist/features/search/components/Search.d.ts +1 -1
  323. package/dist/features/search/components/Search.js +56 -49
  324. package/dist/features/search/schemas/index.d.ts +5 -5
  325. package/dist/features/seller/actions/offer-actions.js +11 -9
  326. package/dist/features/seller/components/SellerAddressesView.js +6 -4
  327. package/dist/features/seller/components/SellerBidsView.js +2 -2
  328. package/dist/features/seller/components/SellerCouponsView.js +1 -1
  329. package/dist/features/seller/components/SellerOffersPanel.js +6 -1
  330. package/dist/features/seller/components/SellerOrdersView.js +1 -1
  331. package/dist/features/seller/components/SellerPayoutSettingsView.js +3 -3
  332. package/dist/features/seller/components/SellerPreOrdersView.js +5 -4
  333. package/dist/features/seller/components/SellerPrizeDrawsView.js +5 -4
  334. package/dist/features/seller/components/SellerProductShell.d.ts +19 -1
  335. package/dist/features/seller/components/SellerProductShell.js +75 -9
  336. package/dist/features/seller/components/SellerProductsView.js +10 -11
  337. package/dist/features/seller/components/SellerShippingView.js +3 -3
  338. package/dist/features/seller/components/SellerSidebar.js +10 -7
  339. package/dist/features/seller/components/SellerStorefrontView.js +3 -3
  340. package/dist/features/seller/schemas/index.d.ts +4 -4
  341. package/dist/features/shell/FormShell.js +2 -1
  342. package/dist/features/shell/QuickFormDrawer.js +4 -3
  343. package/dist/features/shell/StepForm.js +4 -3
  344. package/dist/features/stores/actions/store-query-actions.js +4 -3
  345. package/dist/features/stores/components/StoreAboutView.js +2 -1
  346. package/dist/features/stores/components/StoreAuctionsListing.js +43 -64
  347. package/dist/features/stores/components/StoreDetailLayoutView.js +18 -4
  348. package/dist/features/stores/components/StorePreOrdersListing.js +33 -57
  349. package/dist/features/stores/components/StoreProductsListing.js +16 -49
  350. package/dist/features/stores/components/StoresIndexListing.js +2 -2
  351. package/dist/features/stores/schemas/index.d.ts +2 -2
  352. package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.js +8 -7
  353. package/dist/features/wishlist/hooks/useGuestWishlist.d.ts +5 -5
  354. package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +6 -6
  355. package/dist/features/wishlist/utils/guest-wishlist.d.ts +5 -5
  356. package/dist/index.d.ts +27 -3
  357. package/dist/index.js +1743 -1725
  358. package/dist/monitoring/server-logger.js +5 -9
  359. package/dist/next/api/apiHandler.js +56 -37
  360. package/dist/next/components/GlobalError.js +2 -1
  361. package/dist/next/routing/route-map.d.ts +41 -0
  362. package/dist/next/routing/route-map.js +17 -0
  363. package/dist/react/ErrorBoundary.js +2 -1
  364. package/dist/react/contexts/SessionContext.js +38 -28
  365. package/dist/react/hooks/useCamera.d.ts +1 -1
  366. package/dist/react/hooks/useCamera.js +8 -7
  367. package/dist/seed/products-auctions-seed-data.js +40 -40
  368. package/dist/seed/products-preorders-seed-data.js +16 -16
  369. package/dist/seed/products-prize-draws-seed-data.js +4 -4
  370. package/dist/seed/products-standard-seed-data.js +202 -202
  371. package/dist/seed/site-settings-seed-data.js +6 -0
  372. package/dist/server-entry.d.ts +3 -0
  373. package/dist/server-entry.js +3 -0
  374. package/dist/server.d.ts +12 -0
  375. package/dist/server.js +15 -0
  376. package/dist/tailwind-utilities.css +1 -1
  377. package/dist/ui/DataTable.js +28 -7
  378. package/dist/ui/components/Button.d.ts +8 -1
  379. package/dist/ui/components/Button.js +47 -8
  380. package/dist/ui/components/CollageLightbox.d.ts +18 -0
  381. package/dist/ui/components/CollageLightbox.js +41 -0
  382. package/dist/ui/components/Dropdown.js +7 -6
  383. package/dist/ui/components/ImageLightbox.d.ts +7 -1
  384. package/dist/ui/components/ImageLightbox.js +15 -5
  385. package/dist/ui/components/PageLoader.js +4 -3
  386. package/dist/ui/components/PaginatedMultiSelect.d.ts +28 -0
  387. package/dist/ui/components/PaginatedMultiSelect.js +141 -0
  388. package/dist/ui/components/PaginatedMultiSelect.style.css +272 -0
  389. package/dist/ui/components/Semantic.js +1 -1
  390. package/dist/ui/components/SideDrawer.js +17 -15
  391. package/dist/ui/components/index.style.css +1 -0
  392. package/dist/ui/index.d.ts +2 -0
  393. package/dist/ui/index.js +1 -0
  394. package/dist/utils/number.formatter.js +5 -13
  395. package/dist/utils/string.formatter.js +21 -18
  396. package/dist/validation/schemas.d.ts +2 -2
  397. package/package.json +1 -1
@@ -16,15 +16,11 @@ import { AppError } from "../errors";
16
16
  // Using require() calls inside functions keeps the imports out of the static
17
17
  // analysis graph and prevents Edge Runtime warnings.
18
18
  /* eslint-disable @typescript-eslint/no-require-imports */
19
- function nodeFsPromises() {
20
- return require("fs/promises");
21
- }
22
- function nodeFs() {
23
- return require("fs");
24
- }
25
- function nodePath() {
26
- return require("path");
27
- }
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ function nodeRequire(id) { return require(id); }
21
+ function nodeFsPromises() { return nodeRequire("fs/promises"); }
22
+ function nodeFs() { return nodeRequire("fs"); }
23
+ function nodePath() { return nodeRequire("path"); }
28
24
  // process.cwd() is a Node.js-only API. Access it through module.require so
29
25
  // Next.js Edge static analysis does not flag this file.
30
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,9 +1,56 @@
1
+ async function validateSchema(request, schema) {
2
+ if (typeof schema.safeParse === "function") {
3
+ const body = await request.json();
4
+ const result = schema.safeParse(body);
5
+ if (!result.success) {
6
+ return { validationError: true, issues: result.error.issues };
7
+ }
8
+ return { validationError: false, data: result.data };
9
+ }
10
+ try {
11
+ const data = (await request.json());
12
+ return { validationError: false, data };
13
+ }
14
+ catch {
15
+ return { validationError: false, data: undefined };
16
+ }
17
+ }
18
+ function buildRateLimitHeaders(result) {
19
+ return {
20
+ "RateLimit-Limit": String(result.limit),
21
+ "RateLimit-Remaining": String(result.remaining),
22
+ "RateLimit-Reset": String(result.reset),
23
+ };
24
+ }
25
+ function buildRateLimitExceededResponse(message, headers) {
26
+ return new Response(JSON.stringify({ success: false, error: message }), { status: 429, headers: { "Content-Type": "application/json", ...headers } });
27
+ }
28
+ function applyRateLimitHeaders(response, headers) {
29
+ for (const [key, value] of Object.entries(headers)) {
30
+ response.headers.set(key, value);
31
+ }
32
+ }
1
33
  function buildPublicCacheControl(policy) {
2
34
  const maxAge = policy?.maxAge ?? 30;
3
35
  const sMaxAge = policy?.sMaxAge ?? 300;
4
36
  const staleWhileRevalidate = policy?.staleWhileRevalidate ?? 600;
5
37
  return `public, max-age=${maxAge}, s-maxage=${sMaxAge}, stale-while-revalidate=${staleWhileRevalidate}`;
6
38
  }
39
+ async function applyRateLimitCheck(request, config, applyRateLimit, getRateLimitExceededMessage) {
40
+ const result = await applyRateLimit(request, config);
41
+ const headers = buildRateLimitHeaders(result);
42
+ if (!result.success) {
43
+ return { blocked: true, response: buildRateLimitExceededResponse(getRateLimitExceededMessage(), headers) };
44
+ }
45
+ return { blocked: false, headers };
46
+ }
47
+ async function applySchemaValidation(request, schema, errorResponse) {
48
+ const schemaResult = await validateSchema(request, schema);
49
+ if (schemaResult.validationError) {
50
+ return { invalid: true, response: errorResponse("Validation failed", 400, schemaResult.issues) };
51
+ }
52
+ return { invalid: false, data: schemaResult.data };
53
+ }
7
54
  export function createApiHandlerFactory(deps) {
8
55
  return function createApiHandler(options) {
9
56
  return async (request, context) => {
@@ -11,24 +58,10 @@ export function createApiHandlerFactory(deps) {
11
58
  try {
12
59
  let rateLimitHeaders;
13
60
  if (options.rateLimit) {
14
- const rateLimitResult = await deps.applyRateLimit(request, options.rateLimit);
15
- rateLimitHeaders = {
16
- "RateLimit-Limit": String(rateLimitResult.limit),
17
- "RateLimit-Remaining": String(rateLimitResult.remaining),
18
- "RateLimit-Reset": String(rateLimitResult.reset),
19
- };
20
- if (!rateLimitResult.success) {
21
- return new Response(JSON.stringify({
22
- success: false,
23
- error: deps.getRateLimitExceededMessage(),
24
- }), {
25
- status: 429,
26
- headers: {
27
- "Content-Type": "application/json",
28
- ...rateLimitHeaders,
29
- },
30
- });
31
- }
61
+ const rlCheck = await applyRateLimitCheck(request, options.rateLimit, deps.applyRateLimit, deps.getRateLimitExceededMessage);
62
+ if (rlCheck.blocked)
63
+ return rlCheck.response;
64
+ rateLimitHeaders = rlCheck.headers;
32
65
  }
33
66
  let user;
34
67
  if (options.roles && options.roles.length > 0) {
@@ -39,22 +72,10 @@ export function createApiHandlerFactory(deps) {
39
72
  }
40
73
  let validatedBody;
41
74
  if (options.schema) {
42
- if (typeof options.schema.safeParse === "function") {
43
- const body = await request.json();
44
- const result = options.schema.safeParse(body);
45
- if (!result.success) {
46
- return deps.errorResponse("Validation failed", 400, result.error.issues);
47
- }
48
- validatedBody = result.data;
49
- }
50
- else {
51
- try {
52
- validatedBody = (await request.json());
53
- }
54
- catch {
55
- validatedBody = undefined;
56
- }
57
- }
75
+ const schemaCheck = await applySchemaValidation(request, options.schema, deps.errorResponse);
76
+ if (schemaCheck.invalid)
77
+ return schemaCheck.response;
78
+ validatedBody = schemaCheck.data;
58
79
  }
59
80
  const resolvedParams = context?.params
60
81
  ? await context.params
@@ -67,9 +88,7 @@ export function createApiHandlerFactory(deps) {
67
88
  });
68
89
  response.headers.set("Access-Control-Max-Age", "86400");
69
90
  if (rateLimitHeaders) {
70
- for (const [key, value] of Object.entries(rateLimitHeaders)) {
71
- response.headers.set(key, value);
72
- }
91
+ applyRateLimitHeaders(response, rateLimitHeaders);
73
92
  }
74
93
  const hasCredentialHeaders = !!request.headers.get("authorization") || !!request.headers.get("cookie");
75
94
  const hasRoleGuards = !!options.roles && options.roles.length > 0;
@@ -12,6 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  * export { GlobalError as default } from "@mohasinac/appkit/next";
13
13
  */
14
14
  import { useEffect } from "react";
15
+ import { Heading, Text } from "../../ui";
15
16
  import { trackError, ErrorCategory, ErrorSeverity, } from "../../monitoring/error-tracking";
16
17
  export function GlobalError({ error, reset }) {
17
18
  useEffect(() => {
@@ -30,7 +31,7 @@ export function GlobalError({ error, reset }) {
30
31
  fontFamily: "system-ui, sans-serif",
31
32
  padding: "2rem",
32
33
  textAlign: "center",
33
- }, children: [_jsx("h1", { style: { fontSize: "2rem", marginBottom: "0.5rem" }, children: "Something went wrong" }), _jsx("p", { style: { opacity: 0.7, marginBottom: "1.5rem" }, children: "A critical error occurred. We're working on it." }), process.env.NODE_ENV === "development" && (_jsxs("pre", { style: {
34
+ }, children: [_jsx(Heading, { level: 1, style: { fontSize: "2rem", marginBottom: "0.5rem" }, children: "Something went wrong" }), _jsx(Text, { style: { opacity: 0.7, marginBottom: "1.5rem" }, children: "A critical error occurred. We're working on it." }), process.env.NODE_ENV === "development" && (_jsxs("pre", { style: {
34
35
  fontSize: "0.75rem",
35
36
  padding: "1rem",
36
37
  background: "#f3f4f6",
@@ -126,6 +126,10 @@ export declare const DEFAULT_ROUTE_MAP: {
126
126
  readonly RETURNS: "/user/returns";
127
127
  readonly SUPPORT: "/user/support";
128
128
  readonly SUPPORT_TICKET: (id: string) => string;
129
+ readonly PRE_ORDERS: "/user/pre-orders";
130
+ readonly DIGITAL_CODES: "/user/digital-codes";
131
+ readonly PRIZE_DRAWS: "/user/prize-draws";
132
+ readonly EVENTS: "/user/events";
129
133
  };
130
134
  readonly STORE: {
131
135
  readonly DASHBOARD: "/store";
@@ -170,6 +174,15 @@ export declare const DEFAULT_ROUTE_MAP: {
170
174
  readonly PRIZE_DRAWS_NEW: "/store/prize-draws/new";
171
175
  readonly PRIZE_DRAWS_EDIT: (id: string) => string;
172
176
  readonly PRODUCT_CODES: (id: string) => string;
177
+ readonly CLASSIFIED: "/store/classified";
178
+ readonly CLASSIFIED_NEW: "/store/classified/new";
179
+ readonly CLASSIFIED_EDIT: (id: string) => string;
180
+ readonly DIGITAL_CODES: "/store/digital-codes";
181
+ readonly DIGITAL_CODES_NEW: "/store/digital-codes/new";
182
+ readonly DIGITAL_CODES_EDIT: (id: string) => string;
183
+ readonly LIVE_ITEMS: "/store/live";
184
+ readonly LIVE_ITEMS_NEW: "/store/live/new";
185
+ readonly LIVE_ITEMS_EDIT: (id: string) => string;
173
186
  };
174
187
  readonly ADMIN: {
175
188
  readonly DASHBOARD: "/admin/dashboard";
@@ -229,6 +242,9 @@ export declare const DEFAULT_ROUTE_MAP: {
229
242
  readonly HISTORY: "/admin/history";
230
243
  readonly RETURN_REQUESTS: "/admin/return-requests";
231
244
  readonly STORE_ADDRESSES: "/admin/store-addresses";
245
+ readonly ADDRESSES: "/admin/addresses";
246
+ readonly ADDRESSES_NEW: "/admin/addresses/new";
247
+ readonly ADDRESSES_EDIT: (id: string) => string;
232
248
  readonly SUBLISTING_CATEGORIES: "/admin/sublisting-categories";
233
249
  readonly SUBLISTING_CATEGORIES_NEW: "/admin/sublisting-categories/new";
234
250
  readonly SUBLISTING_CATEGORIES_EDIT: (id: string) => string;
@@ -372,6 +388,10 @@ export declare const ROUTES: {
372
388
  readonly RETURNS: "/user/returns";
373
389
  readonly SUPPORT: "/user/support";
374
390
  readonly SUPPORT_TICKET: (id: string) => string;
391
+ readonly PRE_ORDERS: "/user/pre-orders";
392
+ readonly DIGITAL_CODES: "/user/digital-codes";
393
+ readonly PRIZE_DRAWS: "/user/prize-draws";
394
+ readonly EVENTS: "/user/events";
375
395
  };
376
396
  readonly STORE: {
377
397
  readonly DASHBOARD: "/store";
@@ -416,6 +436,15 @@ export declare const ROUTES: {
416
436
  readonly PRIZE_DRAWS_NEW: "/store/prize-draws/new";
417
437
  readonly PRIZE_DRAWS_EDIT: (id: string) => string;
418
438
  readonly PRODUCT_CODES: (id: string) => string;
439
+ readonly CLASSIFIED: "/store/classified";
440
+ readonly CLASSIFIED_NEW: "/store/classified/new";
441
+ readonly CLASSIFIED_EDIT: (id: string) => string;
442
+ readonly DIGITAL_CODES: "/store/digital-codes";
443
+ readonly DIGITAL_CODES_NEW: "/store/digital-codes/new";
444
+ readonly DIGITAL_CODES_EDIT: (id: string) => string;
445
+ readonly LIVE_ITEMS: "/store/live";
446
+ readonly LIVE_ITEMS_NEW: "/store/live/new";
447
+ readonly LIVE_ITEMS_EDIT: (id: string) => string;
419
448
  };
420
449
  readonly ADMIN: {
421
450
  readonly DASHBOARD: "/admin/dashboard";
@@ -475,6 +504,9 @@ export declare const ROUTES: {
475
504
  readonly HISTORY: "/admin/history";
476
505
  readonly RETURN_REQUESTS: "/admin/return-requests";
477
506
  readonly STORE_ADDRESSES: "/admin/store-addresses";
507
+ readonly ADDRESSES: "/admin/addresses";
508
+ readonly ADDRESSES_NEW: "/admin/addresses/new";
509
+ readonly ADDRESSES_EDIT: (id: string) => string;
478
510
  readonly SUBLISTING_CATEGORIES: "/admin/sublisting-categories";
479
511
  readonly SUBLISTING_CATEGORIES_NEW: "/admin/sublisting-categories/new";
480
512
  readonly SUBLISTING_CATEGORIES_EDIT: (id: string) => string;
@@ -546,6 +578,15 @@ export declare const SELLER_ROUTES: {
546
578
  readonly PRIZE_DRAWS_NEW: "/store/prize-draws/new";
547
579
  readonly PRIZE_DRAWS_EDIT: (id: string) => string;
548
580
  readonly PRODUCT_CODES: (id: string) => string;
581
+ readonly CLASSIFIED: "/store/classified";
582
+ readonly CLASSIFIED_NEW: "/store/classified/new";
583
+ readonly CLASSIFIED_EDIT: (id: string) => string;
584
+ readonly DIGITAL_CODES: "/store/digital-codes";
585
+ readonly DIGITAL_CODES_NEW: "/store/digital-codes/new";
586
+ readonly DIGITAL_CODES_EDIT: (id: string) => string;
587
+ readonly LIVE_ITEMS: "/store/live";
588
+ readonly LIVE_ITEMS_NEW: "/store/live/new";
589
+ readonly LIVE_ITEMS_EDIT: (id: string) => string;
549
590
  };
550
591
  export declare const PUBLIC_ROUTES: readonly ["/", string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, "/unauthorized", "/auth/login", "/auth/register", "/auth/forgot-password", "/auth/reset-password", "/auth/verify-email"];
551
592
  export declare const PROTECTED_ROUTES: readonly [string, string, string, string, string, string, string];
@@ -114,6 +114,10 @@ export const DEFAULT_ROUTE_MAP = {
114
114
  RETURNS: "/user/returns",
115
115
  SUPPORT: "/user/support",
116
116
  SUPPORT_TICKET: (id) => `/user/support/${id}`,
117
+ PRE_ORDERS: "/user/pre-orders",
118
+ DIGITAL_CODES: "/user/digital-codes",
119
+ PRIZE_DRAWS: "/user/prize-draws",
120
+ EVENTS: "/user/events",
117
121
  },
118
122
  STORE: {
119
123
  DASHBOARD: "/store",
@@ -159,6 +163,16 @@ export const DEFAULT_ROUTE_MAP = {
159
163
  PRIZE_DRAWS_NEW: "/store/prize-draws/new",
160
164
  PRIZE_DRAWS_EDIT: (id) => `/store/prize-draws/${id}/edit`,
161
165
  PRODUCT_CODES: (id) => `/store/products/${id}/codes`,
166
+ // SB-UNI-R — classified / digital-code / live
167
+ CLASSIFIED: "/store/classified",
168
+ CLASSIFIED_NEW: "/store/classified/new",
169
+ CLASSIFIED_EDIT: (id) => `/store/classified/${id}/edit`,
170
+ DIGITAL_CODES: "/store/digital-codes",
171
+ DIGITAL_CODES_NEW: "/store/digital-codes/new",
172
+ DIGITAL_CODES_EDIT: (id) => `/store/digital-codes/${id}/edit`,
173
+ LIVE_ITEMS: "/store/live",
174
+ LIVE_ITEMS_NEW: "/store/live/new",
175
+ LIVE_ITEMS_EDIT: (id) => `/store/live/${id}/edit`,
162
176
  },
163
177
  ADMIN: {
164
178
  DASHBOARD: "/admin/dashboard",
@@ -218,6 +232,9 @@ export const DEFAULT_ROUTE_MAP = {
218
232
  HISTORY: "/admin/history",
219
233
  RETURN_REQUESTS: "/admin/return-requests",
220
234
  STORE_ADDRESSES: "/admin/store-addresses",
235
+ ADDRESSES: "/admin/addresses",
236
+ ADDRESSES_NEW: "/admin/addresses/new",
237
+ ADDRESSES_EDIT: (id) => `/admin/addresses/${id}/edit`,
221
238
  SUBLISTING_CATEGORIES: "/admin/sublisting-categories",
222
239
  SUBLISTING_CATEGORIES_NEW: "/admin/sublisting-categories/new",
223
240
  SUBLISTING_CATEGORIES_EDIT: (id) => `/admin/sublisting-categories/${id}/edit`,
@@ -10,6 +10,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
10
  */
11
11
  import { Component } from "react";
12
12
  import { Logger } from "../core/Logger";
13
+ import { Heading, Text } from "../ui";
13
14
  import { trackError, ErrorCategory, ErrorSeverity, } from "../monitoring/error-tracking";
14
15
  function DefaultFallback({ error, onReset, }) {
15
16
  return (_jsxs("div", { role: "alert", style: {
@@ -20,7 +21,7 @@ function DefaultFallback({ error, onReset, }) {
20
21
  minHeight: "100vh",
21
22
  padding: "2rem",
22
23
  textAlign: "center",
23
- }, "data-section": "errorboundary-div-446", children: [_jsx("h1", { style: { fontSize: "1.5rem", marginBottom: "0.5rem" }, children: "Something went wrong" }), _jsx("p", { style: { marginBottom: "1.5rem", opacity: 0.7 }, children: "An unexpected error occurred. Please try again." }), process.env.NODE_ENV === "development" && error && (_jsx("pre", { style: {
24
+ }, "data-section": "errorboundary-div-446", children: [_jsx(Heading, { level: 1, style: { fontSize: "1.5rem", marginBottom: "0.5rem" }, children: "Something went wrong" }), _jsx(Text, { style: { marginBottom: "1.5rem", opacity: 0.7 }, children: "An unexpected error occurred. Please try again." }), process.env.NODE_ENV === "development" && error && (_jsx("pre", { style: {
24
25
  fontSize: "0.75rem",
25
26
  padding: "1rem",
26
27
  background: "#f3f4f6",
@@ -230,24 +230,46 @@ export function SessionProvider({ children, initialUser, endpoints: endpointOver
230
230
  useEffect(() => {
231
231
  const adapter = getClientSessionAdapter();
232
232
  let authVersion = 0;
233
+ async function tryCreateSession(authUser, version, getVersion) {
234
+ try {
235
+ const idToken = await authUser.getIdToken(true);
236
+ if (version !== getVersion())
237
+ return;
238
+ const data = await apiClient.post(ep.createSession, { idToken });
239
+ if (version !== getVersion())
240
+ return;
241
+ if (data?.sessionId)
242
+ setSessionId(data.sessionId);
243
+ }
244
+ catch (error) {
245
+ logger.error("Session creation failed", { error });
246
+ }
247
+ }
248
+ async function handleNoAuthUser(version, getVersion) {
249
+ if (!hasSessionCookie())
250
+ return false;
251
+ const serverUser = await fetchUserProfileFromServer();
252
+ if (version !== getVersion())
253
+ return true;
254
+ if (serverUser) {
255
+ setUser(serverUser);
256
+ const sid = getSessionIdFromCookie();
257
+ if (sid)
258
+ setSessionId(sid);
259
+ setLoading(false);
260
+ return true;
261
+ }
262
+ deleteCookie(SESSION_COOKIE);
263
+ deleteCookie(SESSION_ID_COOKIE);
264
+ return false;
265
+ }
233
266
  const unsubscribe = adapter.onAuthStateChanged(async (authUser) => {
234
267
  const thisVersion = ++authVersion;
268
+ const getVersion = () => authVersion;
235
269
  if (authUser) {
236
270
  const hasSession = hasSessionCookie();
237
271
  if (!hasSession) {
238
- try {
239
- const idToken = await authUser.getIdToken(true);
240
- if (thisVersion !== authVersion)
241
- return;
242
- const data = await apiClient.post(ep.createSession, { idToken });
243
- if (thisVersion !== authVersion)
244
- return;
245
- if (data?.sessionId)
246
- setSessionId(data.sessionId);
247
- }
248
- catch (error) {
249
- logger.error("Session creation failed", { error });
250
- }
272
+ await tryCreateSession(authUser, thisVersion, getVersion);
251
273
  }
252
274
  if (thisVersion !== authVersion)
253
275
  return;
@@ -276,21 +298,9 @@ export function SessionProvider({ children, initialUser, endpoints: endpointOver
276
298
  }
277
299
  else {
278
300
  // No auth user — try server-session fallback (OAuth flows)
279
- if (hasSessionCookie()) {
280
- const serverUser = await fetchUserProfileFromServer();
281
- if (thisVersion !== authVersion)
282
- return;
283
- if (serverUser) {
284
- setUser(serverUser);
285
- const sid = getSessionIdFromCookie();
286
- if (sid)
287
- setSessionId(sid);
288
- setLoading(false);
289
- return;
290
- }
291
- deleteCookie(SESSION_COOKIE);
292
- deleteCookie(SESSION_ID_COOKIE);
293
- }
301
+ const handled = await handleNoAuthUser(thisVersion, getVersion);
302
+ if (handled)
303
+ return;
294
304
  setUser(null);
295
305
  setSessionId(null);
296
306
  if (activityUpdateRef.current) {
@@ -12,7 +12,7 @@ export interface UseCameraReturn {
12
12
  videoRef: React.RefObject<HTMLVideoElement | null>;
13
13
  startCamera: (options?: UseCameraOptions) => Promise<void>;
14
14
  stopCamera: () => void;
15
- takePhoto: () => Blob | null;
15
+ takePhoto: () => Promise<Blob | null>;
16
16
  startRecording: () => void;
17
17
  stopRecording: () => Promise<Blob>;
18
18
  switchCamera: () => Promise<void>;
@@ -73,22 +73,23 @@ export function useCamera() {
73
73
  setError(message);
74
74
  }
75
75
  }, [isSupported, stopCamera]);
76
+ // canvas.toBlob() is async — must return a Promise so the blob is available
77
+ // to the caller after the encoding completes (a synchronous return always
78
+ // gives null because the callback hasn't fired yet).
76
79
  const takePhoto = useCallback(() => {
77
80
  const video = videoRef.current;
78
81
  if (!video || !isActive)
79
- return null;
82
+ return Promise.resolve(null);
80
83
  const canvas = document.createElement("canvas");
81
84
  canvas.width = video.videoWidth;
82
85
  canvas.height = video.videoHeight;
83
86
  const ctx = canvas.getContext("2d");
84
87
  if (!ctx)
85
- return null;
88
+ return Promise.resolve(null);
86
89
  ctx.drawImage(video, 0, 0);
87
- let result = null;
88
- canvas.toBlob((blob) => {
89
- result = blob;
90
- }, "image/webp", 0.92);
91
- return result;
90
+ return new Promise((resolve) => {
91
+ canvas.toBlob((blob) => resolve(blob), "image/webp", 0.92);
92
+ });
92
93
  }, [isActive]);
93
94
  const startRecording = useCallback(() => {
94
95
  if (!streamRef.current || !isActive)