@mohasinac/appkit 4.9.5 → 4.11.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.
- package/dist/_internal/client/features/layout/DashboardLayoutClient.d.ts +6 -1
- package/dist/_internal/client/features/layout/DashboardLayoutClient.js +4 -1
- package/dist/_internal/client/features/lottery/LotteryPullForm.d.ts +1 -1
- package/dist/_internal/client/features/lottery/LotteryPullForm.js +2 -2
- package/dist/_internal/server/features/admin/daily-digest-actions.d.ts +18 -0
- package/dist/_internal/server/features/admin/daily-digest-actions.js +37 -0
- package/dist/_internal/server/features/auctions/actions.js +3 -2
- package/dist/_internal/server/features/auctions/service.d.ts +4 -3
- package/dist/_internal/server/features/auctions/service.js +6 -6
- package/dist/_internal/server/features/audit-log/actions.d.ts +25 -0
- package/dist/_internal/server/features/audit-log/actions.js +38 -0
- package/dist/_internal/server/features/brands/actions.js +0 -2
- package/dist/_internal/server/features/brands/og.d.ts +4 -1
- package/dist/_internal/server/features/brands/og.js +1 -1
- package/dist/_internal/server/features/bundles/data.d.ts +9 -0
- package/dist/_internal/server/features/bundles/data.js +14 -0
- package/dist/_internal/server/features/bundles/index.d.ts +1 -1
- package/dist/_internal/server/features/bundles/index.js +1 -1
- package/dist/_internal/server/features/catalogue/og.d.ts +20 -0
- package/dist/_internal/server/features/catalogue/og.js +27 -0
- package/dist/_internal/server/features/grouped/data.d.ts +16 -0
- package/dist/_internal/server/features/grouped/data.js +50 -1
- package/dist/_internal/server/features/grouped/index.d.ts +1 -1
- package/dist/_internal/server/features/grouped/index.js +1 -1
- package/dist/_internal/server/features/orders/actions.js +9 -0
- package/dist/_internal/server/features/orders/adapters.js +25 -0
- package/dist/_internal/server/features/products/data.d.ts +23 -0
- package/dist/_internal/server/features/products/data.js +159 -0
- package/dist/_internal/server/features/products/index.d.ts +1 -1
- package/dist/_internal/server/features/products/index.js +1 -1
- package/dist/_internal/server/functions/scheduled.d.ts +3 -1
- package/dist/_internal/server/functions/scheduled.js +17 -1
- package/dist/_internal/server/jobs/core/dailyStatusDigest.d.ts +40 -0
- package/dist/_internal/server/jobs/core/dailyStatusDigest.js +164 -0
- package/dist/_internal/server/jobs/core/hardBanCascade.js +11 -0
- package/dist/_internal/server/jobs/core/testerSandboxCleanup.d.ts +1 -0
- package/dist/_internal/server/jobs/core/testerSandboxCleanup.js +4 -1
- package/dist/_internal/server/jobs/core/testerSandboxRefresh.d.ts +12 -0
- package/dist/_internal/server/jobs/core/testerSandboxRefresh.js +85 -0
- package/dist/_internal/server/jobs/core/whatsappNotify.js +16 -0
- package/dist/_internal/server/jobs/handlers/dailyStatusDigest.d.ts +2 -0
- package/dist/_internal/server/jobs/handlers/dailyStatusDigest.js +4 -0
- package/dist/_internal/server/jobs/handlers/index.d.ts +2 -0
- package/dist/_internal/server/jobs/handlers/index.js +3 -0
- package/dist/_internal/server/jobs/handlers/testerSandboxRefresh.d.ts +2 -0
- package/dist/_internal/server/jobs/handlers/testerSandboxRefresh.js +2 -0
- package/dist/_internal/server/notifications/channel-health.d.ts +27 -0
- package/dist/_internal/server/notifications/channel-health.js +101 -0
- package/dist/_internal/shared/features/auctions/config.d.ts +20 -0
- package/dist/_internal/shared/features/auctions/config.js +31 -1
- package/dist/_internal/shared/features/brands/schema.d.ts +0 -6
- package/dist/_internal/shared/features/brands/schema.js +0 -1
- package/dist/_internal/shared/features/categories/bundle-schemas.d.ts +7 -0
- package/dist/_internal/shared/features/categories/bundle-schemas.js +3 -0
- package/dist/_internal/shared/features/orders/schema.d.ts +8 -8
- package/dist/_internal/shared/listing-types/art/config.d.ts +1 -1
- package/dist/_internal/shared/listing-types/art/config.js +1 -1
- package/dist/_internal/shared/listing-types/classified/config.d.ts +1 -1
- package/dist/_internal/shared/listing-types/classified/config.js +1 -1
- package/dist/_internal/shared/listing-types/digital-code/config.d.ts +1 -1
- package/dist/_internal/shared/listing-types/digital-code/config.js +1 -1
- package/dist/_internal/shared/listing-types/live/config.d.ts +1 -1
- package/dist/_internal/shared/listing-types/live/config.js +1 -1
- package/dist/_internal/shared/listing-types/prize-draw/config.d.ts +1 -1
- package/dist/_internal/shared/listing-types/prize-draw/config.js +1 -1
- package/dist/_internal/shared/listing-types/stickers/config.d.ts +1 -1
- package/dist/_internal/shared/listing-types/stickers/config.js +1 -1
- package/dist/client.d.ts +21 -12
- package/dist/client.js +14 -7
- package/dist/constants/api-endpoints.d.ts +9 -9
- package/dist/constants/api-endpoints.js +3 -3
- package/dist/contracts/client-auth.d.ts +3 -7
- package/dist/contracts/email.d.ts +1 -0
- package/dist/features/account/components/AddressForm.js +24 -2
- package/dist/features/account/components/BecomeSellerView.d.ts +1 -2
- package/dist/features/account/components/BecomeSellerView.js +1 -1
- package/dist/features/account/components/NotificationBell.js +1 -1
- package/dist/features/account/components/UserBidsView.d.ts +1 -0
- package/dist/features/account/components/UserBidsView.js +47 -0
- package/dist/features/account/components/UserOrdersView.d.ts +4 -11
- package/dist/features/account/components/UserOrdersView.js +54 -4
- package/dist/features/account/components/UserReturnsView.d.ts +4 -9
- package/dist/features/account/components/UserReturnsView.js +37 -3
- package/dist/features/account/components/index.d.ts +3 -2
- package/dist/features/account/components/index.js +1 -0
- package/dist/features/admin/actions/admin-actions.js +22 -0
- package/dist/features/admin/actions/admin-coupon-actions.js +10 -0
- package/dist/features/admin/actions/notification-actions.js +4 -3
- package/dist/features/admin/components/AdminAdsView.d.ts +2 -3
- package/dist/features/admin/components/AdminAdsView.js +86 -89
- package/dist/features/admin/components/AdminAllEventEntriesView.js +18 -3
- package/dist/features/admin/components/AdminAuditLogView.d.ts +11 -0
- package/dist/features/admin/components/AdminAuditLogView.js +95 -0
- package/dist/features/admin/components/AdminBlogEditorView.js +37 -3
- package/dist/features/admin/components/AdminBrandEditorView.js +10 -6
- package/dist/features/admin/components/AdminBundleEditorView.js +18 -2
- package/dist/features/admin/components/AdminCarouselEditorView.js +2 -2
- package/dist/features/admin/components/AdminCarouselGroupEditorView.js +2 -2
- package/dist/features/admin/components/AdminCartsView.js +34 -4
- package/dist/features/admin/components/AdminCategoryEditorView.js +5 -4
- package/dist/features/admin/components/AdminCouponEditorView.js +2 -2
- package/dist/features/admin/components/AdminFaqEditorView.js +2 -2
- package/dist/features/admin/components/AdminHistoryView.js +11 -1
- package/dist/features/admin/components/AdminNotificationsView.js +27 -1
- package/dist/features/admin/components/AdminOrderEditorView.d.ts +10 -1
- package/dist/features/admin/components/AdminOrderEditorView.js +4 -3
- package/dist/features/admin/components/AdminOrdersView.js +92 -24
- package/dist/features/admin/components/AdminPayoutMarkPaidModal.d.ts +7 -0
- package/dist/features/admin/components/AdminPayoutMarkPaidModal.js +47 -0
- package/dist/features/admin/components/AdminPayoutsView.js +15 -31
- package/dist/features/admin/components/AdminProductEditorView.js +26 -3
- package/dist/features/admin/components/AdminSiteSettingsView.js +31 -4
- package/dist/features/admin/components/AdminStoreAddressesView.js +22 -2
- package/dist/features/admin/components/AdminStoresView.js +7 -0
- package/dist/features/admin/components/AdminSublistingCategoryEditorView.js +2 -2
- package/dist/features/admin/components/AdminTesterChecklistItemEditorView.js +2 -2
- package/dist/features/admin/components/AdminUserEditorView.d.ts +2 -2
- package/dist/features/admin/components/AdminUserEditorView.js +4 -2
- package/dist/features/admin/components/AdminUsersView.js +1 -1
- package/dist/features/admin/components/AdminWishlistsView.js +14 -1
- package/dist/features/admin/components/DataListingView.d.ts +2 -2
- package/dist/features/admin/components/ViewAuditLogEntryModal.d.ts +19 -0
- package/dist/features/admin/components/ViewAuditLogEntryModal.js +22 -0
- package/dist/features/admin/components/ViewNotificationModal.d.ts +21 -0
- package/dist/features/admin/components/ViewNotificationModal.js +15 -0
- package/dist/features/admin/components/analytics/AdminPageViewsReportView.d.ts +4 -7
- package/dist/features/admin/components/analytics/AdminPageViewsReportView.js +56 -36
- package/dist/features/admin/components/index.d.ts +8 -1
- package/dist/features/admin/components/index.js +4 -0
- package/dist/features/admin/constants/filter-tabs.d.ts +49 -0
- package/dist/features/admin/constants/filter-tabs.js +27 -0
- package/dist/features/admin/hooks/useAdminListing.d.ts +6 -0
- package/dist/features/admin/hooks/useAdminListing.js +3 -1
- package/dist/features/admin/hooks/useAdminListingData.d.ts +9 -1
- package/dist/features/admin/hooks/useAdminListingData.js +9 -2
- package/dist/features/admin/repository/site-settings.repository.d.ts +5 -0
- package/dist/features/admin/schemas/firestore.d.ts +21 -0
- package/dist/features/admin/schemas/firestore.js +6 -0
- package/dist/features/analytics/types.d.ts +1 -1
- package/dist/features/analytics/types.js +8 -0
- package/dist/features/auctions/actions/bid-actions.js +4 -1
- package/dist/features/auctions/components/AuctionBottomActions.d.ts +2 -1
- package/dist/features/auctions/components/AuctionBottomActions.js +14 -1
- package/dist/features/auctions/components/AuctionDetailPageView.js +21 -9
- package/dist/features/auctions/components/LiveMinIncrement.d.ts +18 -0
- package/dist/features/auctions/components/LiveMinIncrement.js +17 -0
- package/dist/features/auctions/components/PlaceBidFormClient.d.ts +5 -2
- package/dist/features/auctions/components/PlaceBidFormClient.js +7 -3
- package/dist/features/auctions/schemas/index.d.ts +5 -0
- package/dist/features/audit-log/repository/audit-log.repository.d.ts +45 -0
- package/dist/features/audit-log/repository/audit-log.repository.js +30 -0
- package/dist/features/audit-log/schemas/firestore.d.ts +59 -0
- package/dist/features/audit-log/schemas/firestore.js +35 -0
- package/dist/features/auth/actions/index.d.ts +0 -1
- package/dist/features/auth/actions/index.js +0 -1
- package/dist/features/auth/hooks/useAuth.d.ts +8 -35
- package/dist/features/auth/hooks/useAuth.js +21 -37
- package/dist/features/auth/permissions/constants.d.ts +1 -1
- package/dist/features/auth/permissions/constants.js +2 -0
- package/dist/features/blog/schemas/index.d.ts +32 -0
- package/dist/features/catalogue/components/AdminCatalogueApprovalsView.js +31 -3
- package/dist/features/catalogue/components/CatalogueItemEditorView.js +2 -1
- package/dist/features/catalogue/components/PublicCatalogueItemDetailView.d.ts +11 -0
- package/dist/features/catalogue/components/PublicCatalogueItemDetailView.js +33 -0
- package/dist/features/catalogue/components/PublicCatalogueView.js +2 -1
- package/dist/features/catalogue/index.d.ts +2 -0
- package/dist/features/catalogue/index.js +1 -0
- package/dist/features/categories/components/BrandDetailPageView.js +14 -12
- package/dist/features/categories/components/BundleDetailView.d.ts +3 -1
- package/dist/features/categories/components/BundleDetailView.js +3 -2
- package/dist/features/categories/components/CategoryDetailPageView.js +7 -3
- package/dist/features/categories/components/CategoryHighlightsAndFaqSection.d.ts +14 -0
- package/dist/features/categories/components/CategoryHighlightsAndFaqSection.js +22 -0
- package/dist/features/categories/components/CategoryProductsView.d.ts +1 -5
- package/dist/features/categories/components/CategoryProductsView.js +1 -1
- package/dist/features/categories/components/CategorySelectorCreate.js +16 -2
- package/dist/features/categories/schemas/firestore.d.ts +19 -2
- package/dist/features/categories/schemas/index.d.ts +24 -3
- package/dist/features/categories/schemas/index.js +3 -1
- package/dist/features/categories/types/index.d.ts +7 -0
- package/dist/features/checkout/actions/checkout-value-otp-actions.d.ts +17 -3
- package/dist/features/checkout/actions/checkout-value-otp-actions.js +101 -22
- package/dist/features/classified/components/ClassifiedContactSellerPanel.d.ts +12 -0
- package/dist/features/classified/components/ClassifiedContactSellerPanel.js +49 -0
- package/dist/features/classified/components/ClassifiedDetailPageView.d.ts +7 -0
- package/dist/features/classified/components/ClassifiedDetailPageView.js +69 -0
- package/dist/features/contact/components/ContactForm.js +17 -4
- package/dist/features/contact/components/ContactPageView.js +8 -2
- package/dist/features/contact/email.d.ts +1 -0
- package/dist/features/contact/email.js +3 -0
- package/dist/features/digital-codes/components/DigitalCodeDetailPageView.d.ts +19 -0
- package/dist/features/digital-codes/components/DigitalCodeDetailPageView.js +79 -0
- package/dist/features/events/components/AdminEventEditorView.js +54 -2
- package/dist/features/events/components/AdminEventEntriesView.d.ts +2 -16
- package/dist/features/events/components/AdminEventEntriesView.js +56 -89
- package/dist/features/events/components/EventFormDrawer.js +5 -1
- package/dist/features/events/components/EventRaffleEntryForm.d.ts +1 -3
- package/dist/features/events/components/EventRaffleEntryForm.js +1 -1
- package/dist/features/events/schemas/index.d.ts +22 -0
- package/dist/features/grouped/components/GroupedListingsCarousel.d.ts +13 -0
- package/dist/features/grouped/components/GroupedListingsCarousel.js +31 -0
- package/dist/features/grouped/repository/grouped-listings.repository.d.ts +12 -0
- package/dist/features/grouped/repository/grouped-listings.repository.js +34 -0
- package/dist/features/homepage/components/CharacterHotspotForm.js +202 -187
- package/dist/features/homepage/components/SectionCarousel.d.ts +1 -7
- package/dist/features/homepage/components/SectionCarousel.js +1 -1
- package/dist/features/layout/BottomActions.js +4 -3
- package/dist/features/layout/BottomActionsContext.d.ts +10 -0
- package/dist/features/layout/BottomActionsContext.js +5 -1
- package/dist/features/layout/TitleBarLayout.d.ts +1 -1
- package/dist/features/layout/TitleBarLayout.js +3 -3
- package/dist/features/layout/hooks/useBottomActions.d.ts +2 -0
- package/dist/features/layout/hooks/useBottomActions.js +4 -1
- package/dist/features/live/components/LiveItemDetailPageView.d.ts +9 -0
- package/dist/features/live/components/LiveItemDetailPageView.js +74 -0
- package/dist/features/media/MediaImage.js +39 -3
- package/dist/features/media/MediaVideo.js +17 -1
- package/dist/features/media/types/index.d.ts +10 -0
- package/dist/features/media/types/index.js +1 -0
- package/dist/features/media/upload/MediaUploadField.d.ts +7 -1
- package/dist/features/media/upload/MediaUploadField.js +11 -7
- package/dist/features/media/upload/video-poster.d.ts +2 -0
- package/dist/features/media/upload/video-poster.js +16 -1
- package/dist/features/media/upload/video-poster.test.js +1 -1
- package/dist/features/orders/components/OrderStatusTimeline.d.ts +12 -0
- package/dist/features/orders/components/OrderStatusTimeline.js +55 -0
- package/dist/features/orders/components/index.d.ts +2 -0
- package/dist/features/orders/components/index.js +1 -0
- package/dist/features/orders/constants/payment-window.d.ts +25 -0
- package/dist/features/orders/constants/payment-window.js +25 -0
- package/dist/features/orders/repository/orders.repository.d.ts +32 -0
- package/dist/features/orders/repository/orders.repository.js +56 -0
- package/dist/features/orders/schemas/index.d.ts +24 -24
- package/dist/features/orders/types/index.d.ts +33 -0
- package/dist/features/pre-orders/components/PreOrderDetailPageView.js +9 -1
- package/dist/features/pre-orders/schemas/index.d.ts +5 -0
- package/dist/features/products/components/BidHistory.js +9 -1
- package/dist/features/products/components/GroupSettingsPanel.js +25 -3
- package/dist/features/products/components/PrizeDrawDetailPageView.js +11 -1
- package/dist/features/products/components/PrizeDrawEntryActions.d.ts +1 -4
- package/dist/features/products/components/PrizeDrawEntryActions.js +1 -1
- package/dist/features/products/components/ProductDetailActions.d.ts +1 -2
- package/dist/features/products/components/ProductDetailActions.js +1 -1
- package/dist/features/products/components/ProductDetailPageView.js +11 -116
- package/dist/features/products/components/ProductGrid.js +15 -1
- package/dist/features/products/components/RelatedItemsSection.d.ts +16 -0
- package/dist/features/products/components/RelatedItemsSection.js +17 -0
- package/dist/features/products/constants/action-defs.d.ts +1 -0
- package/dist/features/products/constants/action-defs.js +1 -0
- package/dist/features/products/schemas/index.d.ts +5 -0
- package/dist/features/promotions/components/CouponsIndexListing.d.ts +1 -3
- package/dist/features/promotions/components/CouponsIndexListing.js +1 -1
- package/dist/features/search/components/SearchView.d.ts +1 -3
- package/dist/features/search/components/SearchView.js +1 -1
- package/dist/features/seller/components/QuickProductForm.js +2 -1
- package/dist/features/seller/components/SellerBidsView.js +66 -107
- package/dist/features/seller/components/SellerGoogleReviewsView.js +17 -1
- package/dist/features/seller/components/SellerOrdersView.d.ts +15 -3
- package/dist/features/seller/components/SellerOrdersView.js +134 -163
- package/dist/features/seller/components/SellerPayoutMethodsView.js +60 -48
- package/dist/features/seller/components/SellerPayoutSettingsView.js +69 -4
- package/dist/features/seller/components/SellerPayoutsView.d.ts +12 -0
- package/dist/features/seller/components/SellerPayoutsView.js +25 -5
- package/dist/features/seller/components/SellerProductShell.d.ts +10 -3
- package/dist/features/seller/components/SellerProductShell.js +90 -37
- package/dist/features/seller/components/SellerProductsFilterDrawer.d.ts +2 -7
- package/dist/features/seller/components/SellerProductsFilterDrawer.js +4 -4
- package/dist/features/seller/components/SellerProductsView.d.ts +2 -4
- package/dist/features/seller/components/SellerProductsView.js +131 -189
- package/dist/features/seller/components/SellerReviewsView.js +95 -133
- package/dist/features/seller/components/SellerShippingConfigsView.js +47 -67
- package/dist/features/seller/components/SellerShippingView.js +41 -4
- package/dist/features/seller/components/SellerStoreCategoriesView.js +51 -59
- package/dist/features/seller/components/SellerStorefrontView.d.ts +6 -1
- package/dist/features/seller/components/SellerStorefrontView.js +42 -5
- package/dist/features/seller/components/index.d.ts +2 -2
- package/dist/features/seller/components/index.js +2 -2
- package/dist/features/shell/FormShell.d.ts +24 -4
- package/dist/features/shell/FormShell.js +12 -6
- package/dist/features/shell/QuickFormDrawer.js +67 -12
- package/dist/features/shell/StepForm.d.ts +30 -1
- package/dist/features/shell/StepForm.js +47 -4
- package/dist/features/shell/index.d.ts +1 -1
- package/dist/features/shell/index.js +1 -1
- package/dist/features/shipments/components/AdminShipmentEditorView.js +2 -2
- package/dist/features/shipments/schemas/validation.d.ts +14 -4
- package/dist/features/tester/components/AdminTesterFeedbackListView.js +23 -2
- package/dist/features/tester/components/TesterChecklistStepRow.js +1 -1
- package/dist/features/tester/components/TesterHubView.js +3 -2
- package/dist/features/tester/seed-data/orders-tester-seed-data.js +9 -1
- package/dist/features/tester/seed-data/products-tester-seed-data.js +43 -32
- package/dist/features/tester/seed-data/tester-checklist-seed-data.js +487 -18
- package/dist/index.d.ts +17 -3
- package/dist/index.js +23 -5
- package/dist/next/routing/route-map.d.ts +13 -0
- package/dist/next/routing/route-map.js +12 -0
- package/dist/providers/email-resend/provider.js +1 -0
- package/dist/providers/firebase-client/auth.d.ts +1 -0
- package/dist/providers/firebase-client/auth.js +7 -1
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.js +1 -0
- package/dist/schemas/registry.d.ts +61 -25
- package/dist/security/pii-mask.js +1 -1
- package/dist/seed/bids-seed-data.js +48 -3
- package/dist/seed/categories-seed-data.js +69 -0
- package/dist/seed/grouped-listings-seed-data.js +167 -0
- package/dist/seed/payouts-seed-data.js +4 -4
- package/dist/seed/products-art-seed-data.js +188 -5
- package/dist/seed/products-auctions-seed-data.js +226 -6
- package/dist/seed/products-classifieds-seed-data.js +255 -8
- package/dist/seed/products-digital-codes-seed-data.js +258 -19
- package/dist/seed/products-live-items-seed-data.js +143 -10
- package/dist/seed/products-preorders-seed-data.js +213 -8
- package/dist/seed/products-prize-draws-seed-data.js +198 -0
- package/dist/seed/products-standard-seed-data.js +234 -4
- package/dist/seed/products-stickers-seed-data.js +178 -5
- package/dist/seed/site-settings-seed-data.js +23 -30
- package/dist/seed/store-extensions-seed-data.js +2 -2
- package/dist/server-entry.d.ts +6 -2
- package/dist/server-entry.js +24 -3
- package/dist/server.d.ts +10 -3
- package/dist/server.js +11 -4
- package/dist/styles.css +29 -1
- package/dist/tailwind-utilities.css +1 -1
- package/dist/ui/components/Form.d.ts +11 -2
- package/dist/ui/components/Form.js +4 -3
- package/dist/ui/components/FormField.d.ts +3 -1
- package/dist/ui/components/FormField.js +22 -4
- package/dist/ui/components/ImageLightbox.js +37 -3
- package/dist/ui/components/ImageLightbox.style.css +28 -0
- package/dist/ui/components/ListingLayout.d.ts +1 -2
- package/dist/ui/components/ListingLayout.js +1 -1
- package/dist/ui/components/RecordDetailModal.d.ts +68 -0
- package/dist/ui/components/RecordDetailModal.js +8 -0
- package/dist/ui/components/SlottedListingView.js +9 -1
- package/dist/ui/forms/FormErrorSummary.d.ts +25 -0
- package/dist/ui/forms/FormErrorSummary.js +37 -0
- package/dist/ui/forms/FormShell.d.ts +37 -2
- package/dist/ui/forms/FormShell.js +37 -7
- package/dist/ui/forms/FormShell.style.css +17 -0
- package/dist/ui/forms/index.d.ts +2 -0
- package/dist/ui/forms/index.js +1 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +5 -0
- package/dist/utils/media-url.d.ts +12 -1
- package/dist/utils/media-url.js +59 -1
- package/dist/validation/schemas.d.ts +4 -4
- package/package.json +1 -1
- package/dist/_internal/client/features/classified/ClassifiedDetailView.d.ts +0 -9
- package/dist/_internal/client/features/classified/ClassifiedDetailView.js +0 -55
- package/dist/_internal/client/features/digital-code/DigitalCodeDetailView.d.ts +0 -18
- package/dist/_internal/client/features/digital-code/DigitalCodeDetailView.js +0 -21
- package/dist/_internal/client/features/live/LiveItemDetailView.d.ts +0 -9
- package/dist/_internal/client/features/live/LiveItemDetailView.js +0 -25
- package/dist/_internal/server/jobs/core/prizeRevealClose.d.ts +0 -2
- package/dist/_internal/server/jobs/core/prizeRevealClose.js +0 -28
- package/dist/_internal/server/jobs/core/prizeRevealExpiry.d.ts +0 -2
- package/dist/_internal/server/jobs/core/prizeRevealExpiry.js +0 -61
- package/dist/_internal/server/jobs/core/prizeRevealOpen.d.ts +0 -2
- package/dist/_internal/server/jobs/core/prizeRevealOpen.js +0 -68
- package/dist/_internal/server/jobs/core/prizeRevealReminder.d.ts +0 -2
- package/dist/_internal/server/jobs/core/prizeRevealReminder.js +0 -49
- package/dist/_internal/server/jobs/handlers/prizeRevealClose.d.ts +0 -2
- package/dist/_internal/server/jobs/handlers/prizeRevealClose.js +0 -2
- package/dist/_internal/server/jobs/handlers/prizeRevealExpiry.d.ts +0 -2
- package/dist/_internal/server/jobs/handlers/prizeRevealExpiry.js +0 -2
- package/dist/_internal/server/jobs/handlers/prizeRevealOpen.d.ts +0 -2
- package/dist/_internal/server/jobs/handlers/prizeRevealOpen.js +0 -2
- package/dist/_internal/server/jobs/handlers/prizeRevealReminder.d.ts +0 -2
- package/dist/_internal/server/jobs/handlers/prizeRevealReminder.js +0 -2
- package/dist/features/auth/consent-otp.d.ts +0 -57
- package/dist/features/auth/consent-otp.js +0 -127
- package/dist/features/cart/components/CheckoutOtpModal.d.ts +0 -15
- package/dist/features/cart/components/CheckoutOtpModal.js +0 -12
- package/dist/features/checkout/actions/checkout-actions.d.ts +0 -31
- package/dist/features/checkout/actions/checkout-actions.js +0 -124
- package/dist/features/classified/components/ClassifiedIndexListing.d.ts +0 -5
- package/dist/features/classified/components/ClassifiedIndexListing.js +0 -123
- package/dist/features/classified/components/ClassifiedListView.d.ts +0 -6
- package/dist/features/classified/components/ClassifiedListView.js +0 -44
- package/dist/features/digital-codes/components/DigitalCodesIndexListing.d.ts +0 -5
- package/dist/features/digital-codes/components/DigitalCodesIndexListing.js +0 -114
- package/dist/features/digital-codes/components/DigitalCodesListView.d.ts +0 -6
- package/dist/features/digital-codes/components/DigitalCodesListView.js +0 -38
- package/dist/features/live/components/LiveItemsIndexListing.d.ts +0 -5
- package/dist/features/live/components/LiveItemsIndexListing.js +0 -115
- package/dist/features/live/components/LiveItemsListView.d.ts +0 -6
- package/dist/features/live/components/LiveItemsListView.js +0 -44
- package/dist/features/seller/components/SellerTemplatesView.d.ts +0 -12
- package/dist/features/seller/components/SellerTemplatesView.js +0 -276
- package/dist/react/hooks/useVisibleItems.d.ts +0 -37
- package/dist/react/hooks/useVisibleItems.js +0 -59
- package/dist/ui/components/TabStrip.d.ts +0 -34
- package/dist/ui/components/TabStrip.js +0 -56
- package/dist/ui/components/TabStrip.style.css +0 -97
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useCallback } from "react";
|
|
4
|
-
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
5
|
-
import { useProducts } from "../../products/hooks/useProducts";
|
|
6
|
-
import { BulkActionBar, Div, FilterDrawer, ListingToolbar, LoginRequiredModal, Pagination, Row, Stack, Text, useToast, StickyToolbar } from "../../../ui";
|
|
7
|
-
import { usePendingTable } from "../../../react/hooks/usePendingTable";
|
|
8
|
-
import { useAuthGate } from "../../../react/hooks/useAuthGate";
|
|
9
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
10
|
-
import { useGuestWishlist } from "../../wishlist/hooks/useGuestWishlist";
|
|
11
|
-
import { pushWishlistOp } from "../../cart/utils/pending-ops";
|
|
12
|
-
import { useCategoryTree, categoriesToFacetOptions } from "../../categories/hooks/useCategoryTree";
|
|
13
|
-
import { TABLE_KEYS, VIEW_MODE } from "../../../constants/table-keys";
|
|
14
|
-
import { sortBy } from "../../../constants/sort";
|
|
15
|
-
import { PRODUCT_FIELDS } from "../../../constants/field-names";
|
|
16
|
-
import { ROUTES } from "../../../next";
|
|
17
|
-
import { InteractiveProductCard } from "../../products/components/InteractiveProductCard";
|
|
18
|
-
import { DigitalCodeFilters } from "./DigitalCodeFilters";
|
|
19
|
-
import { ACTION_ID } from "../../products/constants/action-defs";
|
|
20
|
-
import { useBottomActions } from "../../layout";
|
|
21
|
-
const __P = {
|
|
22
|
-
p3: "p-[var(--appkit-space-3)]",
|
|
23
|
-
};
|
|
24
|
-
const __O = {
|
|
25
|
-
hidden: "overflow-hidden",
|
|
26
|
-
};
|
|
27
|
-
const DEFAULT_SORT = sortBy(PRODUCT_FIELDS.CREATED_AT);
|
|
28
|
-
const SORT_OPTIONS = [
|
|
29
|
-
{ value: sortBy(PRODUCT_FIELDS.CREATED_AT), label: "Newest First" },
|
|
30
|
-
{ value: sortBy(PRODUCT_FIELDS.CREATED_AT, "ASC"), label: "Oldest First" },
|
|
31
|
-
{ value: sortBy(PRODUCT_FIELDS.PRICE, "ASC"), label: "Price: Low to High" },
|
|
32
|
-
{ value: sortBy(PRODUCT_FIELDS.PRICE), label: "Price: High to Low" },
|
|
33
|
-
];
|
|
34
|
-
const FILTER_KEYS = [
|
|
35
|
-
TABLE_KEYS.CATEGORY,
|
|
36
|
-
TABLE_KEYS.DELIVERY_METHOD,
|
|
37
|
-
TABLE_KEYS.MIN_PRICE,
|
|
38
|
-
TABLE_KEYS.MAX_PRICE,
|
|
39
|
-
];
|
|
40
|
-
export function DigitalCodesIndexListing({ initialData }) {
|
|
41
|
-
const table = useUrlTable({ defaults: { pageSize: "24", sort: DEFAULT_SORT } });
|
|
42
|
-
const { showToast } = useToast();
|
|
43
|
-
const { requireAuth, modalOpen, modalMessage, closeModal } = useAuthGate();
|
|
44
|
-
const [searchInput, setSearchInput] = useState(table.get(TABLE_KEYS.QUERY) || "");
|
|
45
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
46
|
-
const [view, setView] = useState(table.get(TABLE_KEYS.VIEW) || VIEW_MODE.GRID);
|
|
47
|
-
const localWishlist = useGuestWishlist();
|
|
48
|
-
const { categories } = useCategoryTree();
|
|
49
|
-
const categoryOptions = categoriesToFacetOptions(categories);
|
|
50
|
-
const wishlistedIds = new Set(localWishlist.items.filter((i) => i.type === "digital-code").map((i) => i.itemId));
|
|
51
|
-
const { pendingTable, filterActiveCount, onFilterApply, onFilterClear, onResetAll, onFilterReset } = usePendingTable(table, FILTER_KEYS);
|
|
52
|
-
const openFilters = useCallback(() => {
|
|
53
|
-
onFilterReset();
|
|
54
|
-
setFilterOpen(true);
|
|
55
|
-
}, [onFilterReset]);
|
|
56
|
-
const applyFilters = useCallback(() => {
|
|
57
|
-
onFilterApply();
|
|
58
|
-
setFilterOpen(false);
|
|
59
|
-
}, [onFilterApply]);
|
|
60
|
-
const resetAll = useCallback(() => {
|
|
61
|
-
onResetAll({ [TABLE_KEYS.QUERY]: "", [TABLE_KEYS.SORT]: "" });
|
|
62
|
-
setSearchInput("");
|
|
63
|
-
}, [onResetAll]);
|
|
64
|
-
const hasActiveState = !!table.get(TABLE_KEYS.QUERY) ||
|
|
65
|
-
table.get(TABLE_KEYS.SORT) !== DEFAULT_SORT ||
|
|
66
|
-
filterActiveCount > 0;
|
|
67
|
-
const params = {
|
|
68
|
-
q: table.get(TABLE_KEYS.QUERY) || undefined,
|
|
69
|
-
category: table.get(TABLE_KEYS.CATEGORY) || undefined,
|
|
70
|
-
minPrice: table.get(TABLE_KEYS.MIN_PRICE) ? Number(table.get(TABLE_KEYS.MIN_PRICE)) : undefined,
|
|
71
|
-
maxPrice: table.get(TABLE_KEYS.MAX_PRICE) ? Number(table.get(TABLE_KEYS.MAX_PRICE)) : undefined,
|
|
72
|
-
sort: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT,
|
|
73
|
-
page: table.getNumber(TABLE_KEYS.PAGE, 1),
|
|
74
|
-
perPage: table.getNumber(TABLE_KEYS.PAGE_SIZE, 24),
|
|
75
|
-
listingType: "digital-code",
|
|
76
|
-
};
|
|
77
|
-
const { products, totalPages, page, isLoading } = useProducts(params, { initialData });
|
|
78
|
-
const commitSearch = useCallback(() => {
|
|
79
|
-
table.set(TABLE_KEYS.QUERY, searchInput.trim());
|
|
80
|
-
}, [searchInput, table]);
|
|
81
|
-
const selection = useBulkSelection({ items: products, keyExtractor: (p) => p.id });
|
|
82
|
-
const gridClass = "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-[var(--appkit-space-4)]";
|
|
83
|
-
const wishlistActions = {
|
|
84
|
-
addToWishlist: (productId) => {
|
|
85
|
-
requireAuth(ACTION_ID.ADD_TO_WISHLIST, () => {
|
|
86
|
-
localWishlist.add(productId, "digital-code");
|
|
87
|
-
pushWishlistOp({ op: "add", itemId: productId, type: "digital-code" });
|
|
88
|
-
showToast("Added to wishlist", "success");
|
|
89
|
-
});
|
|
90
|
-
return Promise.resolve();
|
|
91
|
-
},
|
|
92
|
-
removeFromWishlist: (productId) => {
|
|
93
|
-
requireAuth(ACTION_ID.REMOVE_FROM_WISHLIST, () => {
|
|
94
|
-
localWishlist.remove(productId, "digital-code");
|
|
95
|
-
pushWishlistOp({ op: "remove", itemId: productId, type: "digital-code" });
|
|
96
|
-
showToast("Removed from wishlist", "info");
|
|
97
|
-
});
|
|
98
|
-
return Promise.resolve();
|
|
99
|
-
},
|
|
100
|
-
isWishlisted: (productId) => wishlistedIds.has(productId),
|
|
101
|
-
};
|
|
102
|
-
function handleToggleWishlist(id) {
|
|
103
|
-
if (wishlistActions.isWishlisted(id)) {
|
|
104
|
-
wishlistActions.removeFromWishlist(id);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
wishlistActions.addToWishlist(id);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [] } } : {});
|
|
111
|
-
return (_jsxs(Div, { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: filterActiveCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search digital codes\u2026", onSearchChange: setSearchInput, onSearchCommit: commitSearch, onSearchKeyDown: (e) => { if (e.key === "Enter")
|
|
112
|
-
commitSearch(); }, sortValue: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set(TABLE_KEYS.SORT, v); }, view: view, onViewChange: (v) => { if (v !== "table")
|
|
113
|
-
setView(v); }, onResetAll: resetAll, hasActiveState: hasActiveState, bulkMode: selection.isSelecting, bulkSelectedCount: selection.selectedCount, bulkTotalCount: products.length, onBulkSelectAll: selection.toggleAll, onBulkClear: selection.clearSelection }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [] }), totalPages > 1 && (_jsx(StickyToolbar, { offset: "header+pagination", tone: "translucent", border: true, padding: "toolbar", children: _jsx(Row, { justify: "center", children: _jsx(Pagination, { currentPage: page, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) }) })), _jsx(Div, { padding: "y-lg", children: isLoading ? (_jsx(Div, { className: gridClass, children: Array.from({ length: 10 }).map((_, i) => (_jsxs(Div, { className: `${__O.hidden} animate-pulse`, border: "subtle", rounded: "xl", children: [_jsx(Div, { className: "aspect-square", surface: "subtle" }), _jsxs(Stack, { className: `${__P.p3}`, gap: "sm", children: [_jsx(Div, { className: "h-3 w-3/4", surface: "subtle", rounded: "default" }), _jsx(Div, { className: "h-4 w-1/3", surface: "subtle", rounded: "default" })] })] }, i))) })) : products.length === 0 ? (_jsx(Text, { paddingY: "3xl", color: "muted", size: "sm", align: "start", children: "No digital code listings found." })) : (_jsx(Div, { className: view === "list" ? "flex flex-col divide-y divide-zinc-100 divide-[var(--appkit-color-border-subtle)] rounded-xl border border-[var(--appkit-color-border-subtle)]" : gridClass, children: products.map((product) => (_jsx(InteractiveProductCard, { product: product, href: String(ROUTES.PUBLIC.DIGITAL_CODE_DETAIL(product.id)), variant: view === "list" ? "list" : "grid", isWishlisted: wishlistActions.isWishlisted(product.id), onToggleWishlist: handleToggleWishlist, selectable: selection.isSelecting, isSelected: selection.isSelected(product.id), onSelect: (id) => selection.toggle(id) }, product.id))) })) }), _jsx(FilterDrawer, { open: filterOpen, onOpen: openFilters, onClose: () => setFilterOpen(false), onApply: applyFilters, onReset: onFilterClear, activeCount: filterActiveCount, hideTrigger: true, children: _jsx(DigitalCodeFilters, { table: pendingTable, categoryOptions: categoryOptions }) }), _jsx(LoginRequiredModal, { isOpen: modalOpen, onClose: closeModal, message: modalMessage })] }));
|
|
114
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
type SearchParams = Record<string, string | string[]>;
|
|
2
|
-
export interface DigitalCodesListViewProps {
|
|
3
|
-
searchParams?: SearchParams;
|
|
4
|
-
}
|
|
5
|
-
export declare function DigitalCodesListView({ searchParams }: DigitalCodesListViewProps): Promise<import("react").JSX.Element>;
|
|
6
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { sieveFilter, SIEVE_OP } from "@mohasinac/appkit";
|
|
3
|
-
import { productRepository } from "../../../repositories";
|
|
4
|
-
import { Container, Heading, Main, Section } from "../../../ui";
|
|
5
|
-
import { AdSlot } from "../../homepage/components/AdSlot";
|
|
6
|
-
import { parseListingSearchParams } from "../../../utils/listing-params";
|
|
7
|
-
import { DigitalCodesIndexListing } from "./DigitalCodesIndexListing";
|
|
8
|
-
const DEFAULT_PAGE = 1;
|
|
9
|
-
const DEFAULT_PAGE_SIZE = 24;
|
|
10
|
-
const DEFAULT_SORT = "-createdAt";
|
|
11
|
-
function sp(params, key) {
|
|
12
|
-
const v = params[key];
|
|
13
|
-
return Array.isArray(v) ? v[0] ?? "" : v ?? "";
|
|
14
|
-
}
|
|
15
|
-
function buildDigitalCodeFilters(params) {
|
|
16
|
-
const parts = ["status==published", "listingType==digital-code"];
|
|
17
|
-
const minPrice = sp(params, "minPrice");
|
|
18
|
-
const maxPrice = sp(params, "maxPrice");
|
|
19
|
-
if (minPrice)
|
|
20
|
-
parts.push(sieveFilter("price", SIEVE_OP.GTE, minPrice));
|
|
21
|
-
if (maxPrice)
|
|
22
|
-
parts.push(sieveFilter("price", SIEVE_OP.LTE, maxPrice));
|
|
23
|
-
const deliveryMethod = sp(params, "deliveryMethod");
|
|
24
|
-
if (deliveryMethod)
|
|
25
|
-
parts.push(sieveFilter("digitalCodeDelivery", SIEVE_OP.EQ, deliveryMethod));
|
|
26
|
-
return parts.join(",");
|
|
27
|
-
}
|
|
28
|
-
export async function DigitalCodesListView({ searchParams = {} }) {
|
|
29
|
-
const std = parseListingSearchParams(searchParams);
|
|
30
|
-
const sort = std.sorts ?? DEFAULT_SORT;
|
|
31
|
-
const page = std.page ?? DEFAULT_PAGE;
|
|
32
|
-
const pageSize = std.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
33
|
-
const filters = buildDigitalCodeFilters(searchParams);
|
|
34
|
-
const result = await productRepository
|
|
35
|
-
.list({ filters, sorts: sort, page, pageSize })
|
|
36
|
-
.catch(() => null);
|
|
37
|
-
return (_jsx(Main, { children: _jsx(Section, { padding: "y-2xl", children: _jsxs(Container, { size: "xl", children: [_jsx(Heading, { level: 1, className: "mb-8", color: "primary", size: "3xl", weight: "semibold", children: "Digital Codes" }), _jsx(AdSlot, { id: "listing-sidebar-top", className: "mb-6" }), _jsx(DigitalCodesIndexListing, { initialData: result ?? undefined }), _jsx(AdSlot, { id: "listing-sidebar-bottom", className: "mt-8" })] }) }) }));
|
|
38
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useCallback } from "react";
|
|
4
|
-
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
5
|
-
import { useProducts } from "../../products/hooks/useProducts";
|
|
6
|
-
import { BulkActionBar, Div, FilterDrawer, ListingToolbar, LoginRequiredModal, Pagination, Row, Stack, Text, useToast, StickyToolbar } from "../../../ui";
|
|
7
|
-
import { usePendingTable } from "../../../react/hooks/usePendingTable";
|
|
8
|
-
import { useAuthGate } from "../../../react/hooks/useAuthGate";
|
|
9
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
10
|
-
import { useGuestWishlist } from "../../wishlist/hooks/useGuestWishlist";
|
|
11
|
-
import { pushWishlistOp } from "../../cart/utils/pending-ops";
|
|
12
|
-
import { useCategoryTree, categoriesToFacetOptions } from "../../categories/hooks/useCategoryTree";
|
|
13
|
-
import { TABLE_KEYS, VIEW_MODE } from "../../../constants/table-keys";
|
|
14
|
-
import { sortBy } from "../../../constants/sort";
|
|
15
|
-
import { PRODUCT_FIELDS } from "../../../constants/field-names";
|
|
16
|
-
import { ROUTES } from "../../../next";
|
|
17
|
-
import { InteractiveProductCard } from "../../products/components/InteractiveProductCard";
|
|
18
|
-
import { LiveItemFilters } from "./LiveItemFilters";
|
|
19
|
-
import { ACTION_ID } from "../../products/constants/action-defs";
|
|
20
|
-
import { useBottomActions } from "../../layout";
|
|
21
|
-
const __P = {
|
|
22
|
-
p3: "p-[var(--appkit-space-3)]",
|
|
23
|
-
};
|
|
24
|
-
const __O = {
|
|
25
|
-
hidden: "overflow-hidden",
|
|
26
|
-
};
|
|
27
|
-
const DEFAULT_SORT = sortBy(PRODUCT_FIELDS.CREATED_AT);
|
|
28
|
-
const SORT_OPTIONS = [
|
|
29
|
-
{ value: sortBy(PRODUCT_FIELDS.CREATED_AT), label: "Newest First" },
|
|
30
|
-
{ value: sortBy(PRODUCT_FIELDS.CREATED_AT, "ASC"), label: "Oldest First" },
|
|
31
|
-
{ value: sortBy(PRODUCT_FIELDS.PRICE, "ASC"), label: "Price: Low to High" },
|
|
32
|
-
{ value: sortBy(PRODUCT_FIELDS.PRICE), label: "Price: High to Low" },
|
|
33
|
-
];
|
|
34
|
-
const FILTER_KEYS = [
|
|
35
|
-
TABLE_KEYS.CATEGORY,
|
|
36
|
-
TABLE_KEYS.SPECIES,
|
|
37
|
-
TABLE_KEYS.JURISDICTION,
|
|
38
|
-
TABLE_KEYS.MIN_PRICE,
|
|
39
|
-
TABLE_KEYS.MAX_PRICE,
|
|
40
|
-
];
|
|
41
|
-
export function LiveItemsIndexListing({ initialData }) {
|
|
42
|
-
const table = useUrlTable({ defaults: { pageSize: "24", sort: DEFAULT_SORT } });
|
|
43
|
-
const { showToast } = useToast();
|
|
44
|
-
const { requireAuth, modalOpen, modalMessage, closeModal } = useAuthGate();
|
|
45
|
-
const [searchInput, setSearchInput] = useState(table.get(TABLE_KEYS.QUERY) || "");
|
|
46
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
47
|
-
const [view, setView] = useState(table.get(TABLE_KEYS.VIEW) || VIEW_MODE.GRID);
|
|
48
|
-
const localWishlist = useGuestWishlist();
|
|
49
|
-
const { categories } = useCategoryTree();
|
|
50
|
-
const categoryOptions = categoriesToFacetOptions(categories);
|
|
51
|
-
const wishlistedIds = new Set(localWishlist.items.filter((i) => i.type === "live").map((i) => i.itemId));
|
|
52
|
-
const { pendingTable, filterActiveCount, onFilterApply, onFilterClear, onResetAll, onFilterReset } = usePendingTable(table, FILTER_KEYS);
|
|
53
|
-
const openFilters = useCallback(() => {
|
|
54
|
-
onFilterReset();
|
|
55
|
-
setFilterOpen(true);
|
|
56
|
-
}, [onFilterReset]);
|
|
57
|
-
const applyFilters = useCallback(() => {
|
|
58
|
-
onFilterApply();
|
|
59
|
-
setFilterOpen(false);
|
|
60
|
-
}, [onFilterApply]);
|
|
61
|
-
const resetAll = useCallback(() => {
|
|
62
|
-
onResetAll({ [TABLE_KEYS.QUERY]: "", [TABLE_KEYS.SORT]: "" });
|
|
63
|
-
setSearchInput("");
|
|
64
|
-
}, [onResetAll]);
|
|
65
|
-
const hasActiveState = !!table.get(TABLE_KEYS.QUERY) ||
|
|
66
|
-
table.get(TABLE_KEYS.SORT) !== DEFAULT_SORT ||
|
|
67
|
-
filterActiveCount > 0;
|
|
68
|
-
const params = {
|
|
69
|
-
q: table.get(TABLE_KEYS.QUERY) || undefined,
|
|
70
|
-
category: table.get(TABLE_KEYS.CATEGORY) || undefined,
|
|
71
|
-
minPrice: table.get(TABLE_KEYS.MIN_PRICE) ? Number(table.get(TABLE_KEYS.MIN_PRICE)) : undefined,
|
|
72
|
-
maxPrice: table.get(TABLE_KEYS.MAX_PRICE) ? Number(table.get(TABLE_KEYS.MAX_PRICE)) : undefined,
|
|
73
|
-
sort: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT,
|
|
74
|
-
page: table.getNumber(TABLE_KEYS.PAGE, 1),
|
|
75
|
-
perPage: table.getNumber(TABLE_KEYS.PAGE_SIZE, 24),
|
|
76
|
-
listingType: "live",
|
|
77
|
-
};
|
|
78
|
-
const { products, totalPages, page, isLoading } = useProducts(params, { initialData });
|
|
79
|
-
const commitSearch = useCallback(() => {
|
|
80
|
-
table.set(TABLE_KEYS.QUERY, searchInput.trim());
|
|
81
|
-
}, [searchInput, table]);
|
|
82
|
-
const selection = useBulkSelection({ items: products, keyExtractor: (p) => p.id });
|
|
83
|
-
const gridClass = "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-[var(--appkit-space-4)]";
|
|
84
|
-
const wishlistActions = {
|
|
85
|
-
addToWishlist: (productId) => {
|
|
86
|
-
requireAuth(ACTION_ID.ADD_TO_WISHLIST, () => {
|
|
87
|
-
localWishlist.add(productId, "live");
|
|
88
|
-
pushWishlistOp({ op: "add", itemId: productId, type: "live" });
|
|
89
|
-
showToast("Added to wishlist", "success");
|
|
90
|
-
});
|
|
91
|
-
return Promise.resolve();
|
|
92
|
-
},
|
|
93
|
-
removeFromWishlist: (productId) => {
|
|
94
|
-
requireAuth(ACTION_ID.REMOVE_FROM_WISHLIST, () => {
|
|
95
|
-
localWishlist.remove(productId, "live");
|
|
96
|
-
pushWishlistOp({ op: "remove", itemId: productId, type: "live" });
|
|
97
|
-
showToast("Removed from wishlist", "info");
|
|
98
|
-
});
|
|
99
|
-
return Promise.resolve();
|
|
100
|
-
},
|
|
101
|
-
isWishlisted: (productId) => wishlistedIds.has(productId),
|
|
102
|
-
};
|
|
103
|
-
function handleToggleWishlist(id) {
|
|
104
|
-
if (wishlistActions.isWishlisted(id)) {
|
|
105
|
-
wishlistActions.removeFromWishlist(id);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
wishlistActions.addToWishlist(id);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [] } } : {});
|
|
112
|
-
return (_jsxs(Div, { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: filterActiveCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search live items\u2026", onSearchChange: setSearchInput, onSearchCommit: commitSearch, onSearchKeyDown: (e) => { if (e.key === "Enter")
|
|
113
|
-
commitSearch(); }, sortValue: table.get(TABLE_KEYS.SORT) || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set(TABLE_KEYS.SORT, v); }, view: view, onViewChange: (v) => { if (v !== "table")
|
|
114
|
-
setView(v); }, onResetAll: resetAll, hasActiveState: hasActiveState, bulkMode: selection.isSelecting, bulkSelectedCount: selection.selectedCount, bulkTotalCount: products.length, onBulkSelectAll: selection.toggleAll, onBulkClear: selection.clearSelection }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [] }), totalPages > 1 && (_jsx(StickyToolbar, { offset: "header+pagination", tone: "translucent", border: true, padding: "toolbar", children: _jsx(Row, { justify: "center", children: _jsx(Pagination, { currentPage: page, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) }) })), _jsx(Div, { padding: "y-lg", children: isLoading ? (_jsx(Div, { className: gridClass, children: Array.from({ length: 10 }).map((_, i) => (_jsxs(Div, { className: `${__O.hidden} animate-pulse`, border: "subtle", rounded: "xl", children: [_jsx(Div, { className: "aspect-square", surface: "subtle" }), _jsxs(Stack, { className: `${__P.p3}`, gap: "sm", children: [_jsx(Div, { className: "h-3 w-3/4", surface: "subtle", rounded: "default" }), _jsx(Div, { className: "h-4 w-1/3", surface: "subtle", rounded: "default" })] })] }, i))) })) : products.length === 0 ? (_jsx(Text, { paddingY: "3xl", color: "muted", size: "sm", align: "start", children: "No live item listings found." })) : (_jsx(Div, { className: view === "list" ? "flex flex-col divide-y divide-zinc-100 divide-[var(--appkit-color-border-subtle)] rounded-xl border border-[var(--appkit-color-border-subtle)]" : gridClass, children: products.map((product) => (_jsx(InteractiveProductCard, { product: product, href: String(ROUTES.PUBLIC.LIVE_DETAIL(product.id)), variant: view === "list" ? "list" : "grid", isWishlisted: wishlistActions.isWishlisted(product.id), onToggleWishlist: handleToggleWishlist, selectable: selection.isSelecting, isSelected: selection.isSelected(product.id), onSelect: (id) => selection.toggle(id) }, product.id))) })) }), _jsx(FilterDrawer, { open: filterOpen, onOpen: openFilters, onClose: () => setFilterOpen(false), onApply: applyFilters, onReset: onFilterClear, activeCount: filterActiveCount, hideTrigger: true, children: _jsx(LiveItemFilters, { table: pendingTable, categoryOptions: categoryOptions }) }), _jsx(LoginRequiredModal, { isOpen: modalOpen, onClose: closeModal, message: modalMessage })] }));
|
|
115
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
type SearchParams = Record<string, string | string[]>;
|
|
2
|
-
export interface LiveItemsListViewProps {
|
|
3
|
-
searchParams?: SearchParams;
|
|
4
|
-
}
|
|
5
|
-
export declare function LiveItemsListView({ searchParams }: LiveItemsListViewProps): Promise<import("react").JSX.Element>;
|
|
6
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { sieveFilter, SIEVE_OP } from "@mohasinac/appkit";
|
|
3
|
-
import { productRepository } from "../../../repositories";
|
|
4
|
-
import { Container, Heading, Main, Section } from "../../../ui";
|
|
5
|
-
import { AdSlot } from "../../homepage/components/AdSlot";
|
|
6
|
-
import { parseListingSearchParams } from "../../../utils/listing-params";
|
|
7
|
-
import { LiveItemsIndexListing } from "./LiveItemsIndexListing";
|
|
8
|
-
const DEFAULT_PAGE = 1;
|
|
9
|
-
const DEFAULT_PAGE_SIZE = 24;
|
|
10
|
-
const DEFAULT_SORT = "-createdAt";
|
|
11
|
-
function sp(params, key) {
|
|
12
|
-
const v = params[key];
|
|
13
|
-
return Array.isArray(v) ? v[0] ?? "" : v ?? "";
|
|
14
|
-
}
|
|
15
|
-
function buildLiveFilters(params) {
|
|
16
|
-
const parts = ["status==published", "listingType==live"];
|
|
17
|
-
const minPrice = sp(params, "minPrice");
|
|
18
|
-
const maxPrice = sp(params, "maxPrice");
|
|
19
|
-
if (minPrice)
|
|
20
|
-
parts.push(sieveFilter("price", SIEVE_OP.GTE, minPrice));
|
|
21
|
-
if (maxPrice)
|
|
22
|
-
parts.push(sieveFilter("price", SIEVE_OP.LTE, maxPrice));
|
|
23
|
-
const species = sp(params, "species");
|
|
24
|
-
if (species)
|
|
25
|
-
parts.push(sieveFilter("liveSpecies", SIEVE_OP.EQ, species));
|
|
26
|
-
const liveSex = sp(params, "liveSex");
|
|
27
|
-
if (liveSex)
|
|
28
|
-
parts.push(sieveFilter("liveSex", SIEVE_OP.EQ, liveSex));
|
|
29
|
-
const transport = sp(params, "liveTransportMethod");
|
|
30
|
-
if (transport)
|
|
31
|
-
parts.push(sieveFilter("liveTransportMethod", SIEVE_OP.EQ, transport));
|
|
32
|
-
return parts.join(",");
|
|
33
|
-
}
|
|
34
|
-
export async function LiveItemsListView({ searchParams = {} }) {
|
|
35
|
-
const std = parseListingSearchParams(searchParams);
|
|
36
|
-
const sort = std.sorts ?? DEFAULT_SORT;
|
|
37
|
-
const page = std.page ?? DEFAULT_PAGE;
|
|
38
|
-
const pageSize = std.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
39
|
-
const filters = buildLiveFilters(searchParams);
|
|
40
|
-
const result = await productRepository
|
|
41
|
-
.list({ filters, sorts: sort, page, pageSize })
|
|
42
|
-
.catch(() => null);
|
|
43
|
-
return (_jsx(Main, { children: _jsx(Section, { padding: "y-2xl", children: _jsxs(Container, { size: "xl", children: [_jsx(Heading, { level: 1, className: "mb-8", color: "primary", size: "3xl", weight: "semibold", children: "Live Items" }), _jsx(AdSlot, { id: "listing-sidebar-top", className: "mb-6" }), _jsx(LiveItemsIndexListing, { initialData: result ?? undefined }), _jsx(AdSlot, { id: "listing-sidebar-bottom", className: "mt-8" })] }) }) }));
|
|
44
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { JsonValue } from "@mohasinac/appkit";
|
|
2
|
-
import React from "react";
|
|
3
|
-
export interface SellerTemplatesViewProps {
|
|
4
|
-
onDelete?: (id: string) => Promise<void>;
|
|
5
|
-
onBulkDelete?: (ids: string[]) => Promise<void>;
|
|
6
|
-
onDuplicate?: (row: {
|
|
7
|
-
id: string;
|
|
8
|
-
name: string;
|
|
9
|
-
raw: Record<string, JsonValue>;
|
|
10
|
-
}) => Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export declare function SellerTemplatesView({ onDelete, onBulkDelete, onDuplicate, }: SellerTemplatesViewProps): React.JSX.Element;
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { normalizeError } from "../../../errors/normalize";
|
|
4
|
-
import { Row, sortBy } from "@mohasinac/appkit";
|
|
5
|
-
import { useState, useCallback, useMemo } from "react";
|
|
6
|
-
import { useEntityDelete } from "../../../react/hooks/useEntityDelete";
|
|
7
|
-
import { Plus } from "lucide-react";
|
|
8
|
-
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
9
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
10
|
-
import { BulkActionBar, Button, ConfirmDeleteModal, DataTable, Div, FilterDrawer, Input, Label, ListingToolbar, Pagination, RowActionMenu, Select, SideDrawer, Span, Stack, Text, useToast, StickyToolbar, } from "../../../ui";
|
|
11
|
-
import { useBottomActions } from "../../layout";
|
|
12
|
-
import { SELLER_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
13
|
-
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
14
|
-
import { buildBulkAction } from "../../../_internal/shared/actions/bulk-helpers";
|
|
15
|
-
import { toRecordArray, toStringValue, useSellerListingData, } from "../hooks/useSellerListingData";
|
|
16
|
-
import { TABLE_KEYS } from "../../../constants/table-keys";
|
|
17
|
-
const __P = {
|
|
18
|
-
p4: "p-[var(--appkit-space-4)]",
|
|
19
|
-
};
|
|
20
|
-
const PAGE_SIZE = 25;
|
|
21
|
-
const DEFAULT_SORT = "name";
|
|
22
|
-
const SORT_OPTIONS = [
|
|
23
|
-
{ value: sortBy("name", "ASC"), label: "Name A–Z" },
|
|
24
|
-
{ value: sortBy("name", "DESC"), label: "Name Z–A" },
|
|
25
|
-
{ value: sortBy("createdAt", "DESC"), label: "Newest" },
|
|
26
|
-
];
|
|
27
|
-
const CONDITION_OPTIONS = [
|
|
28
|
-
{ value: "", label: "Any condition" },
|
|
29
|
-
{ value: "new", label: "New" },
|
|
30
|
-
{ value: "like_new", label: "Like New" },
|
|
31
|
-
{ value: "good", label: "Good" },
|
|
32
|
-
{ value: "fair", label: "Fair" },
|
|
33
|
-
{ value: "used", label: "Used" },
|
|
34
|
-
];
|
|
35
|
-
const EMPTY_DRAFT = {
|
|
36
|
-
name: "",
|
|
37
|
-
description: "",
|
|
38
|
-
category: "",
|
|
39
|
-
brand: "",
|
|
40
|
-
condition: "",
|
|
41
|
-
};
|
|
42
|
-
const COLUMNS = [
|
|
43
|
-
{
|
|
44
|
-
key: "name",
|
|
45
|
-
header: "Name",
|
|
46
|
-
render: (row) => _jsx(Text, { size: "sm", weight: "medium", children: row.name }),
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
key: "category",
|
|
50
|
-
header: "Category",
|
|
51
|
-
render: (row) => (_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: row.category || "—" })),
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
key: "brand",
|
|
55
|
-
header: "Brand",
|
|
56
|
-
render: (row) => (_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: row.brand || "—" })),
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
key: "condition",
|
|
60
|
-
header: "Condition",
|
|
61
|
-
render: (row) => row.condition ? (_jsx(Span, { layout: "inline-flex", size: "xs", weight: "medium", rounded: "full", padding: "pill-xs", surface: "subtle", color: "muted", transform: "capitalize", children: row.condition.replace(/_/g, " ") })) : (_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "\u2014" })),
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
export function SellerTemplatesView({ onDelete, onBulkDelete, onDuplicate, }) {
|
|
65
|
-
const table = useUrlTable({ defaults: { sort: DEFAULT_SORT } });
|
|
66
|
-
const [searchInput, setSearchInput] = useState(table.get(TABLE_KEYS.QUERY) || "");
|
|
67
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
68
|
-
const [pendingCondition, setPendingCondition] = useState(table.get(TABLE_KEYS.CONDITION) || "");
|
|
69
|
-
// Drawer state
|
|
70
|
-
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
71
|
-
const [drawerMode, setDrawerMode] = useState("create");
|
|
72
|
-
const [editingId, setEditingId] = useState(null);
|
|
73
|
-
const [draft, setDraft] = useState(EMPTY_DRAFT);
|
|
74
|
-
const [saving, setSaving] = useState(false);
|
|
75
|
-
const [savingError, setSavingError] = useState(null);
|
|
76
|
-
// Delete state
|
|
77
|
-
const [deleteTargetId, setDeleteTargetId] = useState(null);
|
|
78
|
-
const { deletingId, handleDelete: performDelete } = useEntityDelete({
|
|
79
|
-
endpoint: SELLER_ENDPOINTS.TEMPLATE_BY_ID,
|
|
80
|
-
deleteFn: onDelete,
|
|
81
|
-
successMessage: "Template deleted.",
|
|
82
|
-
onSuccess: () => { refetch?.(); },
|
|
83
|
-
fetchOptions: { credentials: "include" },
|
|
84
|
-
});
|
|
85
|
-
const [duplicatingId, setDuplicatingId] = useState(null);
|
|
86
|
-
const { showToast } = useToast();
|
|
87
|
-
const commitSearch = useCallback(() => {
|
|
88
|
-
table.set(TABLE_KEYS.QUERY, searchInput.trim());
|
|
89
|
-
}, [searchInput, table]);
|
|
90
|
-
const openFilters = useCallback(() => {
|
|
91
|
-
setPendingCondition(table.get(TABLE_KEYS.CONDITION) || "");
|
|
92
|
-
setFilterOpen(true);
|
|
93
|
-
}, [table]);
|
|
94
|
-
const applyFilters = useCallback(() => {
|
|
95
|
-
table.setMany({ [TABLE_KEYS.CONDITION]: pendingCondition });
|
|
96
|
-
setFilterOpen(false);
|
|
97
|
-
}, [pendingCondition, table]);
|
|
98
|
-
const resetAll = useCallback(() => {
|
|
99
|
-
table.setMany({ [TABLE_KEYS.QUERY]: "", [TABLE_KEYS.SORT]: "", [TABLE_KEYS.CONDITION]: "" });
|
|
100
|
-
setSearchInput("");
|
|
101
|
-
}, [table]);
|
|
102
|
-
const q = table.get(TABLE_KEYS.QUERY) || "";
|
|
103
|
-
const conditionFilter = table.get(TABLE_KEYS.CONDITION) || "";
|
|
104
|
-
const sort = table.get(TABLE_KEYS.SORT) || DEFAULT_SORT;
|
|
105
|
-
const currentPage = table.getNumber(TABLE_KEYS.PAGE, 1);
|
|
106
|
-
const hasActiveState = !!q || sort !== DEFAULT_SORT || !!conditionFilter;
|
|
107
|
-
const filterActiveCount = conditionFilter ? 1 : 0;
|
|
108
|
-
// Fetch all templates (server doesn't paginate this endpoint)
|
|
109
|
-
const { rows: allRows, isLoading, errorMessage, refetch } = useSellerListingData({
|
|
110
|
-
queryKey: ["seller", "templates"],
|
|
111
|
-
endpoint: SELLER_ENDPOINTS.TEMPLATES,
|
|
112
|
-
page: 1,
|
|
113
|
-
pageSize: 1000,
|
|
114
|
-
mapRows: (response) => toRecordArray(response.templates).map((item, index) => ({
|
|
115
|
-
id: toStringValue(item.id, `tpl-${index}`),
|
|
116
|
-
raw: item,
|
|
117
|
-
name: String(item.name ?? ""),
|
|
118
|
-
category: String(item.category ?? ""),
|
|
119
|
-
brand: String(item.brand ?? ""),
|
|
120
|
-
condition: String(item.condition ?? ""),
|
|
121
|
-
})),
|
|
122
|
-
});
|
|
123
|
-
// Client-side filter + sort
|
|
124
|
-
const filteredRows = useMemo(() => {
|
|
125
|
-
let result = allRows;
|
|
126
|
-
if (q)
|
|
127
|
-
result = result.filter((r) => r.name.toLowerCase().includes(q.toLowerCase()));
|
|
128
|
-
if (conditionFilter)
|
|
129
|
-
result = result.filter((r) => r.condition === conditionFilter);
|
|
130
|
-
return [...result].sort((a, b) => sort === "-name" ? b.name.localeCompare(a.name) : a.name.localeCompare(b.name));
|
|
131
|
-
}, [allRows, q, conditionFilter, sort]);
|
|
132
|
-
const totalPages = Math.max(1, Math.ceil(filteredRows.length / PAGE_SIZE));
|
|
133
|
-
const safePage = Math.min(Math.max(1, currentPage), totalPages);
|
|
134
|
-
const pageRows = filteredRows.slice((safePage - 1) * PAGE_SIZE, safePage * PAGE_SIZE);
|
|
135
|
-
const selection = useBulkSelection({ items: filteredRows, keyExtractor: (r) => r.id });
|
|
136
|
-
// Drawer helpers
|
|
137
|
-
const openCreate = useCallback(() => {
|
|
138
|
-
setDraft(EMPTY_DRAFT);
|
|
139
|
-
setEditingId(null);
|
|
140
|
-
setDrawerMode("create");
|
|
141
|
-
setSavingError(null);
|
|
142
|
-
setDrawerOpen(true);
|
|
143
|
-
}, []);
|
|
144
|
-
const openEdit = useCallback((row) => {
|
|
145
|
-
setDraft({
|
|
146
|
-
name: row.name,
|
|
147
|
-
description: String(row.raw.description ?? ""),
|
|
148
|
-
category: row.category,
|
|
149
|
-
brand: row.brand,
|
|
150
|
-
condition: row.condition,
|
|
151
|
-
});
|
|
152
|
-
setEditingId(row.id);
|
|
153
|
-
setDrawerMode("edit");
|
|
154
|
-
setSavingError(null);
|
|
155
|
-
setDrawerOpen(true);
|
|
156
|
-
}, []);
|
|
157
|
-
const closeDrawer = useCallback(() => {
|
|
158
|
-
setDrawerOpen(false);
|
|
159
|
-
setEditingId(null);
|
|
160
|
-
setSavingError(null);
|
|
161
|
-
}, []);
|
|
162
|
-
const handleSave = useCallback(async () => {
|
|
163
|
-
if (!draft.name.trim()) {
|
|
164
|
-
setSavingError("Template name is required.");
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
setSaving(true);
|
|
168
|
-
setSavingError(null);
|
|
169
|
-
try {
|
|
170
|
-
const body = {
|
|
171
|
-
name: draft.name.trim(),
|
|
172
|
-
description: draft.description.trim() || undefined,
|
|
173
|
-
category: draft.category.trim() || undefined,
|
|
174
|
-
brand: draft.brand.trim() || undefined,
|
|
175
|
-
condition: draft.condition || undefined,
|
|
176
|
-
};
|
|
177
|
-
const url = drawerMode === "edit" && editingId
|
|
178
|
-
? SELLER_ENDPOINTS.TEMPLATE_BY_ID(editingId)
|
|
179
|
-
: SELLER_ENDPOINTS.TEMPLATES;
|
|
180
|
-
const method = drawerMode === "edit" ? "PUT" : "POST";
|
|
181
|
-
await fetch(url, {
|
|
182
|
-
method,
|
|
183
|
-
headers: { "Content-Type": "application/json" },
|
|
184
|
-
credentials: "include",
|
|
185
|
-
body: JSON.stringify(body),
|
|
186
|
-
});
|
|
187
|
-
closeDrawer();
|
|
188
|
-
refetch?.();
|
|
189
|
-
showToast("Template saved.", "success");
|
|
190
|
-
}
|
|
191
|
-
catch (err) {
|
|
192
|
-
void normalizeError(err);
|
|
193
|
-
setSavingError("Failed to save template. Please try again.");
|
|
194
|
-
showToast(err instanceof Error ? err.message : "Failed to save template.", "error");
|
|
195
|
-
}
|
|
196
|
-
finally {
|
|
197
|
-
setSaving(false);
|
|
198
|
-
}
|
|
199
|
-
}, [draft, drawerMode, editingId, closeDrawer, refetch, showToast]);
|
|
200
|
-
const handleDelete = useCallback(async (id) => {
|
|
201
|
-
try {
|
|
202
|
-
await performDelete(id);
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
void normalizeError(err);
|
|
206
|
-
showToast(err instanceof Error ? err.message : "Failed to delete template", "error");
|
|
207
|
-
}
|
|
208
|
-
setDeleteTargetId(null);
|
|
209
|
-
}, [performDelete, showToast]);
|
|
210
|
-
const handleDuplicate = useCallback(async (row) => {
|
|
211
|
-
setDuplicatingId(row.id);
|
|
212
|
-
try {
|
|
213
|
-
if (onDuplicate) {
|
|
214
|
-
await onDuplicate(row);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
await fetch(SELLER_ENDPOINTS.TEMPLATES, {
|
|
218
|
-
method: "POST",
|
|
219
|
-
headers: { "Content-Type": "application/json" },
|
|
220
|
-
credentials: "include",
|
|
221
|
-
body: JSON.stringify({
|
|
222
|
-
name: `Copy of ${row.name}`,
|
|
223
|
-
description: String(row.raw.description ?? "") || undefined,
|
|
224
|
-
category: row.category || undefined,
|
|
225
|
-
brand: row.brand || undefined,
|
|
226
|
-
condition: row.condition || undefined,
|
|
227
|
-
}),
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
refetch?.();
|
|
231
|
-
showToast("Template duplicated.", "success");
|
|
232
|
-
}
|
|
233
|
-
catch (err) {
|
|
234
|
-
void normalizeError(err);
|
|
235
|
-
showToast(err instanceof Error ? err.message : "Failed to duplicate template.", "error");
|
|
236
|
-
}
|
|
237
|
-
finally {
|
|
238
|
-
setDuplicatingId(null);
|
|
239
|
-
}
|
|
240
|
-
}, [onDuplicate, refetch, showToast]);
|
|
241
|
-
const bulkActions = [
|
|
242
|
-
buildBulkAction(ACTIONS.STORE["delete-template"], async () => {
|
|
243
|
-
if (onBulkDelete) {
|
|
244
|
-
await onBulkDelete(selection.selectedIds);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
await Promise.all(selection.selectedIds.map((id) => fetch(SELLER_ENDPOINTS.TEMPLATE_BY_ID(id), {
|
|
248
|
-
method: "DELETE",
|
|
249
|
-
credentials: "include",
|
|
250
|
-
})));
|
|
251
|
-
}
|
|
252
|
-
selection.clearSelection();
|
|
253
|
-
refetch?.();
|
|
254
|
-
}),
|
|
255
|
-
];
|
|
256
|
-
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
|
|
257
|
-
return (_jsxs(Div, { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: filterActiveCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search templates by name...", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: sort, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set(TABLE_KEYS.SORT, v); }, showTableView: true, view: "table", onViewChange: () => { }, onResetAll: resetAll, hasActiveState: hasActiveState, extra: _jsxs(Button, { gap: "sm", size: "sm", onClick: openCreate, children: [_jsx(Plus, { className: "h-4 w-4" }), _jsx(Span, { children: "New Template" })] }) }), totalPages > 1 && (_jsx(StickyToolbar, { offset: "header+pagination", tone: "translucent", border: true, padding: "toolbar", children: _jsx(Row, { justify: "center", children: _jsx(Pagination, { currentPage: safePage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) }) })), selection.selectedCount > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs(Div, { paddingX: "x-sm-md", padding: "y-md", children: [errorMessage && (_jsx(Div, { textSize: "sm", className: "mb-4 border border-error/20", color: "error", surface: "danger-surface", padding: "inline", rounded: "xl", children: errorMessage })), isLoading ? (_jsx(Stack, { gap: "sm", children: Array.from({ length: 5 }).map((_, i) => (_jsx(Div, { className: "h-14 animate-pulse", border: "subtle", surface: "muted", rounded: "xl" }, i))) })) : pageRows.length === 0 ? (_jsx(Div, { className: "text-center", padding: "y-4xl", children: _jsx(Text, { color: "faint", children: q || conditionFilter
|
|
258
|
-
? "No templates match your search or filters"
|
|
259
|
-
: "No templates yet — add your first product template" }) })) : (_jsx(DataTable, { columns: COLUMNS, data: pageRows, keyExtractor: (r) => r.id, selectable: bulkActions.length > 0, selectedIds: selection.selectedIds, onSelectionChange: (ids) => selection.setSelectedIds(ids), actions: (row) => (_jsx(RowActionMenu, { actions: [
|
|
260
|
-
{
|
|
261
|
-
label: ACTIONS.STORE["edit-template"].label,
|
|
262
|
-
onClick: () => openEdit(row),
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
label: "Clone",
|
|
266
|
-
disabled: duplicatingId === row.id,
|
|
267
|
-
onClick: () => handleDuplicate(row),
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
label: ACTIONS.STORE["delete-template"].label,
|
|
271
|
-
destructive: true,
|
|
272
|
-
onClick: () => setDeleteTargetId(row.id),
|
|
273
|
-
disabled: deletingId === row.id,
|
|
274
|
-
},
|
|
275
|
-
] })) }))] }), _jsx(FilterDrawer, { open: filterOpen, onOpen: openFilters, onClose: () => setFilterOpen(false), onApply: applyFilters, onReset: () => setPendingCondition(""), activeCount: filterActiveCount, hideTrigger: true, children: _jsx(Stack, { className: `${__P.p4}`, gap: "md", children: _jsxs(Div, { children: [_jsx(Label, { className: "mb-1.5 block", color: "primary", size: "sm", weight: "medium", children: "Condition" }), _jsx(Select, { value: pendingCondition, onValueChange: setPendingCondition, options: CONDITION_OPTIONS })] }) }) }), _jsx(SideDrawer, { isOpen: drawerOpen, onClose: closeDrawer, title: drawerMode === "create" ? "New Template" : "Edit Template", mode: drawerMode, isDirty: draft.name !== "" || draft.category !== "" || draft.brand !== "", footer: _jsxs(Row, { align: "center", justify: "end", gap: "sm", children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: closeDrawer, disabled: saving, children: "Cancel" }), _jsx(Button, { size: "sm", isLoading: saving, onClick: handleSave, children: drawerMode === "create" ? "Create Template" : "Save Changes" })] }), children: _jsxs(Stack, { gap: "md", children: [savingError && (_jsx(Div, { textSize: "sm", className: "border border-error/20", color: "error", surface: "danger-surface", padding: "inlineSm", rounded: "lg", children: savingError })), _jsx(Input, { id: "tpl-name", label: "Template Name", value: draft.name, onChange: (e) => setDraft((d) => ({ ...d, name: e.target.value })), placeholder: "e.g. Pok\u00E9mon Card Standard", required: true, autoComplete: "off" }), _jsx(Input, { id: "tpl-description", label: "Description (optional)", value: draft.description, onChange: (e) => setDraft((d) => ({ ...d, description: e.target.value })), placeholder: "Short note about when to use this template", autoComplete: "off" }), _jsx(Input, { id: "tpl-category", label: "Category (optional)", value: draft.category, onChange: (e) => setDraft((d) => ({ ...d, category: e.target.value })), placeholder: "e.g. trading-cards", autoComplete: "off" }), _jsx(Input, { id: "tpl-brand", label: "Brand (optional)", value: draft.brand, onChange: (e) => setDraft((d) => ({ ...d, brand: e.target.value })), placeholder: "e.g. Pok\u00E9mon Company", autoComplete: "off" }), _jsx(Select, { label: "Condition (optional)", name: "tpl-condition", value: draft.condition, onValueChange: (v) => setDraft((d) => ({ ...d, condition: v })), options: CONDITION_OPTIONS })] }) }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Template", message: "Are you sure you want to delete this template? This cannot be undone.", onConfirm: () => handleDelete(deleteTargetId), onClose: () => setDeleteTargetId(null), isDeleting: deletingId === deleteTargetId }))] }));
|
|
276
|
-
}
|