@mohasinac/appkit 2.7.58 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/client/features/filters/filter-load-options.d.ts +4 -5
- package/dist/_internal/server/features/auctions/og.js +8 -32
- package/dist/_internal/server/features/blog/og.js +10 -49
- package/dist/_internal/server/features/checkout/actions.js +6 -0
- package/dist/_internal/server/features/classified/og.js +9 -51
- package/dist/_internal/server/features/digital-code/actions.d.ts +11 -0
- package/dist/_internal/server/features/digital-code/actions.js +30 -0
- package/dist/_internal/server/features/digital-code/index.d.ts +1 -0
- package/dist/_internal/server/features/digital-code/index.js +1 -0
- package/dist/_internal/server/features/digital-code/og.js +9 -51
- package/dist/_internal/server/features/events/og.js +10 -49
- package/dist/_internal/server/features/item-requests/data.d.ts +17 -0
- package/dist/_internal/server/features/item-requests/data.js +20 -0
- package/dist/_internal/server/features/item-requests/index.d.ts +2 -0
- package/dist/_internal/server/features/item-requests/index.js +2 -0
- package/dist/_internal/server/features/item-requests/og.d.ts +40 -0
- package/dist/_internal/server/features/item-requests/og.js +136 -0
- package/dist/_internal/server/features/live/actions.d.ts +5 -0
- package/dist/_internal/server/features/live/actions.js +24 -0
- package/dist/_internal/server/features/live/index.d.ts +1 -0
- package/dist/_internal/server/features/live/index.js +1 -0
- package/dist/_internal/server/features/live/og.js +9 -51
- package/dist/_internal/server/features/media/contextGuards.js +19 -8
- package/dist/_internal/server/features/pre-orders/og.js +8 -32
- package/dist/_internal/server/features/prize-draws/data.d.ts +17 -0
- package/dist/_internal/server/features/prize-draws/data.js +20 -0
- package/dist/_internal/server/features/prize-draws/index.d.ts +2 -0
- package/dist/_internal/server/features/prize-draws/index.js +2 -0
- package/dist/_internal/server/features/prize-draws/og.d.ts +30 -0
- package/dist/_internal/server/features/prize-draws/og.js +50 -0
- package/dist/_internal/server/features/products/og.js +8 -33
- package/dist/_internal/server/features/scams/og.js +1 -1
- package/dist/_internal/server/features/seo/og-layout.d.ts +42 -0
- package/dist/_internal/server/features/seo/og-layout.js +69 -0
- package/dist/_internal/server/features/stores/og.js +8 -41
- package/dist/_internal/server/features/sublisting-categories/og.js +11 -42
- package/dist/_internal/shared/actions/bulk-helpers.d.ts +3 -0
- package/dist/_internal/shared/actions/bulk-helpers.js +19 -0
- package/dist/_internal/shared/config/schema.d.ts +4 -4
- package/dist/client.d.ts +13 -6
- package/dist/client.js +9 -3
- package/dist/configs/next.js +11 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/notification-types.d.ts +20 -0
- package/dist/constants/notification-types.js +37 -0
- package/dist/constants/pagination-presets.d.ts +39 -0
- package/dist/constants/pagination-presets.js +38 -0
- package/dist/errors/messages.d.ts +0 -4
- package/dist/errors/messages.js +0 -4
- package/dist/features/account/components/AddressesIndexListing.js +3 -4
- package/dist/features/account/components/UserOffersPanel.js +1 -1
- package/dist/features/account/components/UserSidebar.js +14 -10
- package/dist/features/account/components/UserSupportView.d.ts +1 -2
- package/dist/features/account/components/UserSupportView.js +9 -1
- package/dist/features/admin/actions/admin-actions.js +16 -1
- package/dist/features/admin/components/AdminAllEventEntriesView.d.ts +2 -3
- package/dist/features/admin/components/AdminAllEventEntriesView.js +50 -89
- package/dist/features/admin/components/AdminBidsView.d.ts +2 -3
- package/dist/features/admin/components/AdminBidsView.js +64 -104
- package/dist/features/admin/components/AdminBlogView.d.ts +3 -7
- package/dist/features/admin/components/AdminBlogView.js +53 -88
- package/dist/features/admin/components/AdminBrandEditorView.js +14 -17
- package/dist/features/admin/components/AdminBrandsView.d.ts +2 -3
- package/dist/features/admin/components/AdminBrandsView.js +85 -89
- package/dist/features/admin/components/AdminBundlesView.js +68 -130
- package/dist/features/admin/components/AdminCarouselView.d.ts +2 -2
- package/dist/features/admin/components/AdminCarouselView.js +22 -70
- package/dist/features/admin/components/AdminCartsView.d.ts +2 -3
- package/dist/features/admin/components/AdminCartsView.js +39 -89
- package/dist/features/admin/components/AdminCategoriesView.d.ts +3 -3
- package/dist/features/admin/components/AdminCategoriesView.js +97 -96
- package/dist/features/admin/components/AdminCategoryEditorView.js +2 -6
- package/dist/features/admin/components/AdminClassifiedView.d.ts +3 -0
- package/dist/features/admin/components/AdminClassifiedView.js +44 -0
- package/dist/features/admin/components/AdminContactView.d.ts +2 -2
- package/dist/features/admin/components/AdminContactView.js +105 -130
- package/dist/features/admin/components/AdminCouponEditorView.js +14 -17
- package/dist/features/admin/components/AdminCouponsView.d.ts +3 -6
- package/dist/features/admin/components/AdminCouponsView.js +69 -97
- package/dist/features/admin/components/AdminDigitalCodesView.d.ts +3 -0
- package/dist/features/admin/components/AdminDigitalCodesView.js +51 -0
- package/dist/features/admin/components/AdminFaqEditorView.js +14 -17
- package/dist/features/admin/components/AdminFaqsView.d.ts +4 -4
- package/dist/features/admin/components/AdminFaqsView.js +79 -86
- package/dist/features/admin/components/AdminFeatureEditorView.js +7 -9
- package/dist/features/admin/components/AdminFeaturesView.d.ts +2 -3
- package/dist/features/admin/components/AdminFeaturesView.js +57 -70
- package/dist/features/admin/components/AdminGroupedListingsView.d.ts +3 -0
- package/dist/features/admin/components/AdminGroupedListingsView.js +43 -0
- package/dist/features/admin/components/AdminHistoryView.d.ts +2 -3
- package/dist/features/admin/components/AdminHistoryView.js +35 -52
- package/dist/features/admin/components/AdminListingScaffold.d.ts +2 -2
- package/dist/features/admin/components/AdminListingScaffold.js +3 -3
- package/dist/features/admin/components/AdminLiveView.d.ts +3 -0
- package/dist/features/admin/components/AdminLiveView.js +50 -0
- package/dist/features/admin/components/AdminNewsletterView.d.ts +2 -2
- package/dist/features/admin/components/AdminNewsletterView.js +68 -108
- package/dist/features/admin/components/AdminNotificationsView.d.ts +2 -3
- package/dist/features/admin/components/AdminNotificationsView.js +67 -99
- package/dist/features/admin/components/AdminOrderEditorView.js +10 -10
- package/dist/features/admin/components/AdminOrdersView.d.ts +2 -3
- package/dist/features/admin/components/AdminOrdersView.js +93 -113
- package/dist/features/admin/components/AdminPayoutsView.d.ts +2 -3
- package/dist/features/admin/components/AdminPayoutsView.js +51 -97
- package/dist/features/admin/components/AdminPrizeDrawsView.d.ts +2 -3
- package/dist/features/admin/components/AdminPrizeDrawsView.js +41 -83
- package/dist/features/admin/components/AdminProductEditorView.js +3 -7
- package/dist/features/admin/components/AdminProductsView.d.ts +4 -4
- package/dist/features/admin/components/AdminProductsView.js +166 -167
- package/dist/features/admin/components/AdminReturnRequestsView.d.ts +1 -1
- package/dist/features/admin/components/AdminReturnRequestsView.js +64 -66
- package/dist/features/admin/components/AdminReviewsView.d.ts +3 -7
- package/dist/features/admin/components/AdminReviewsView.js +94 -116
- package/dist/features/admin/components/AdminScammersView.d.ts +2 -3
- package/dist/features/admin/components/AdminScammersView.js +53 -103
- package/dist/features/admin/components/AdminSectionsView.js +1 -1
- package/dist/features/admin/components/AdminSessionsView.d.ts +2 -3
- package/dist/features/admin/components/AdminSessionsView.js +62 -95
- package/dist/features/admin/components/AdminStoreAddressesView.d.ts +1 -1
- package/dist/features/admin/components/AdminStoreAddressesView.js +39 -53
- package/dist/features/admin/components/AdminStoreEditorView.js +21 -8
- package/dist/features/admin/components/AdminStoresView.d.ts +2 -3
- package/dist/features/admin/components/AdminStoresView.js +67 -105
- package/dist/features/admin/components/AdminSublistingCategoriesView.d.ts +1 -1
- package/dist/features/admin/components/AdminSublistingCategoriesView.js +29 -49
- package/dist/features/admin/components/AdminSublistingCategoryEditorView.js +17 -20
- package/dist/features/admin/components/AdminSupportTicketDetailView.d.ts +10 -1
- package/dist/features/admin/components/AdminSupportTicketDetailView.js +191 -5
- package/dist/features/admin/components/AdminSupportTicketsView.d.ts +2 -3
- package/dist/features/admin/components/AdminSupportTicketsView.js +65 -102
- package/dist/features/admin/components/AdminTeamView.d.ts +2 -2
- package/dist/features/admin/components/AdminTeamView.js +42 -85
- package/dist/features/admin/components/AdminUserEditorView.d.ts +11 -1
- package/dist/features/admin/components/AdminUserEditorView.js +80 -6
- package/dist/features/admin/components/AdminUsersView.d.ts +2 -3
- package/dist/features/admin/components/AdminUsersView.js +108 -106
- package/dist/features/admin/components/AdminViewCards.d.ts +1 -1
- package/dist/features/admin/components/AdminWishlistsView.d.ts +2 -3
- package/dist/features/admin/components/AdminWishlistsView.js +36 -62
- package/dist/features/admin/components/DataListingView.d.ts +122 -0
- package/dist/features/admin/components/DataListingView.js +66 -0
- package/dist/features/admin/components/index.d.ts +10 -4
- package/dist/features/admin/components/index.js +6 -2
- package/dist/features/admin/constants/filter-tabs.d.ts +23 -17
- package/dist/features/admin/constants/filter-tabs.js +21 -17
- package/dist/features/admin/hooks/useAdminListing.d.ts +59 -0
- package/dist/features/admin/hooks/useAdminListing.js +71 -0
- package/dist/features/admin/schemas/firestore.js +6 -7
- package/dist/features/auctions/server.d.ts +0 -1
- package/dist/features/auctions/server.js +0 -1
- package/dist/features/auth/actions/realtime-token-actions.js +1 -1
- package/dist/features/auth/repository/user.repository.js +1 -1
- package/dist/features/auth/schemas/firestore.d.ts +1 -0
- package/dist/features/blog/components/BlogIndexListing.js +3 -6
- package/dist/features/cart/repository/cart.repository.d.ts +4 -1
- package/dist/features/cart/repository/cart.repository.js +12 -0
- package/dist/features/categories/components/CategoriesIndexListing.js +3 -6
- package/dist/features/checkout/hooks/useCheckoutApi.d.ts +0 -2
- package/dist/features/checkout/index.d.ts +1 -1
- package/dist/features/events/components/AdminEventsView.d.ts +3 -3
- package/dist/features/events/components/AdminEventsView.js +50 -86
- package/dist/features/events/components/EventOfferCard.d.ts +19 -0
- package/dist/features/events/components/EventOfferCard.js +29 -0
- package/dist/features/events/components/EventRaffleEntryForm.d.ts +25 -0
- package/dist/features/events/components/EventRaffleEntryForm.js +37 -0
- package/dist/features/events/components/EventRafflesSection.d.ts +1 -4
- package/dist/features/events/components/EventRafflesSection.js +17 -6
- package/dist/features/events/components/EventSaleBanner.d.ts +21 -0
- package/dist/features/events/components/EventSaleBanner.js +18 -0
- package/dist/features/events/components/EventsIndexListing.js +3 -4
- package/dist/features/events/components/index.d.ts +6 -0
- package/dist/features/events/components/index.js +4 -0
- package/dist/features/events/repository/event-entry.repository.d.ts +5 -0
- package/dist/features/events/repository/event-entry.repository.js +7 -0
- package/dist/features/filters/AsyncFacetSection.d.ts +1 -1
- package/dist/features/homepage/components/AnnouncementBar.d.ts +4 -1
- package/dist/features/homepage/components/AnnouncementBar.js +51 -4
- package/dist/features/homepage/components/FAQSection.d.ts +0 -5
- package/dist/features/homepage/components/MarketplaceHomepageView.d.ts +3 -1
- package/dist/features/homepage/components/MarketplaceHomepageView.js +2 -2
- package/dist/features/homepage/components/index.d.ts +1 -1
- package/dist/features/homepage/components/index.js +1 -1
- package/dist/features/homepage/lib/live-stats.js +1 -1
- package/dist/features/homepage/lib/section-renderer.d.ts +2 -2
- package/dist/features/homepage/lib/section-renderer.js +2 -2
- package/dist/features/homepage/schemas/firestore.d.ts +0 -2
- package/dist/features/layout/index.d.ts +0 -2
- package/dist/features/layout/index.js +0 -1
- package/dist/features/orders/repository/orders.repository.d.ts +0 -1
- package/dist/features/orders/repository/orders.repository.js +0 -1
- package/dist/features/orders/server.d.ts +1 -1
- package/dist/features/orders/server.js +1 -1
- package/dist/features/pre-orders/server.d.ts +0 -1
- package/dist/features/pre-orders/server.js +0 -1
- package/dist/features/products/components/GroupSettingsPanel.js +65 -49
- package/dist/features/products/components/PrizeDrawItemsEditor.js +2 -2
- package/dist/features/products/components/PrizeDrawsSection.d.ts +1 -4
- package/dist/features/products/components/PrizeDrawsSection.js +17 -6
- package/dist/features/products/components/PrizeRevealModal.js +1 -1
- package/dist/features/products/components/ProductCardMetadataSection.d.ts +11 -0
- package/dist/features/products/components/ProductCardMetadataSection.js +25 -0
- package/dist/features/products/components/ProductDetailPageView.js +3 -1
- package/dist/features/products/components/ProductFeaturesSelector.js +1 -1
- package/dist/features/products/components/ProductGradingTab.d.ts +13 -0
- package/dist/features/products/components/ProductGradingTab.js +25 -0
- package/dist/features/products/components/ProductGrid.js +14 -2
- package/dist/features/products/components/ProductTabsShell.d.ts +5 -1
- package/dist/features/products/components/ProductTabsShell.js +6 -1
- package/dist/features/products/components/index.d.ts +4 -0
- package/dist/features/products/components/index.js +3 -0
- package/dist/features/products/constants/action-defs.d.ts +5 -0
- package/dist/features/products/constants/action-defs.js +52 -32
- package/dist/features/products/constants/sieve.d.ts +24 -4
- package/dist/features/products/constants/sieve.js +20 -11
- package/dist/features/products/repository/products.repository.d.ts +0 -2
- package/dist/features/products/repository/products.repository.js +0 -2
- package/dist/features/products/schemas/firestore.d.ts +17 -0
- package/dist/features/products/schemas/product-features.validators.d.ts +2 -2
- package/dist/features/products/schemas/product-templates.d.ts +2 -4
- package/dist/features/products/server.d.ts +1 -1
- package/dist/features/products/server.js +1 -1
- package/dist/features/products/types/index.d.ts +4 -0
- package/dist/features/promotions/components/CouponCard.js +5 -5
- package/dist/features/promotions/components/CouponsIndexListing.js +3 -2
- package/dist/features/promotions/server.d.ts +0 -1
- package/dist/features/promotions/server.js +0 -1
- package/dist/features/reviews/components/ReviewsIndexListing.js +3 -4
- package/dist/features/reviews/repository/reviews.repository.d.ts +0 -1
- package/dist/features/reviews/repository/reviews.repository.js +0 -1
- package/dist/features/reviews/server.d.ts +1 -1
- package/dist/features/reviews/server.js +1 -1
- package/dist/features/search/api/route.js +44 -1
- package/dist/features/search/components/Search.js +2 -0
- package/dist/features/search/hooks/useNavSuggestions.d.ts +5 -1
- package/dist/features/search/hooks/useNavSuggestions.js +31 -4
- package/dist/features/seller/components/BrandInlineSelect.js +2 -2
- package/dist/features/seller/components/CategoryInlineSelect.js +2 -2
- package/dist/features/seller/components/SellerAddressesView.js +10 -20
- package/dist/features/seller/components/SellerAuctionsView.d.ts +3 -3
- package/dist/features/seller/components/SellerAuctionsView.js +67 -106
- package/dist/features/seller/components/SellerBidsView.js +6 -6
- package/dist/features/seller/components/SellerBundlesView.js +72 -105
- package/dist/features/seller/components/SellerClassifiedView.js +74 -105
- package/dist/features/seller/components/SellerCouponEditorView.js +1 -1
- package/dist/features/seller/components/SellerCouponsView.d.ts +2 -2
- package/dist/features/seller/components/SellerCouponsView.js +51 -96
- package/dist/features/seller/components/SellerDigitalCodesView.js +70 -103
- package/dist/features/seller/components/SellerGroupedListingsView.js +34 -54
- package/dist/features/seller/components/SellerLiveView.js +70 -99
- package/dist/features/seller/components/SellerOffersPanel.js +1 -1
- package/dist/features/seller/components/SellerOffersView.d.ts +2 -2
- package/dist/features/seller/components/SellerOffersView.js +37 -70
- package/dist/features/seller/components/SellerOrdersView.d.ts +2 -2
- package/dist/features/seller/components/SellerOrdersView.js +10 -24
- package/dist/features/seller/components/SellerPayoutMethodsView.js +12 -24
- package/dist/features/seller/components/SellerPayoutsView.d.ts +2 -2
- package/dist/features/seller/components/SellerPayoutsView.js +34 -69
- package/dist/features/seller/components/SellerPreOrdersView.d.ts +2 -2
- package/dist/features/seller/components/SellerPreOrdersView.js +55 -97
- package/dist/features/seller/components/SellerPrizeDrawsView.d.ts +2 -2
- package/dist/features/seller/components/SellerPrizeDrawsView.js +55 -97
- package/dist/features/seller/components/SellerProductShell.d.ts +1 -1
- package/dist/features/seller/components/SellerProductsFilterDrawer.d.ts +1 -1
- package/dist/features/seller/components/SellerProductsFilterDrawer.js +3 -6
- package/dist/features/seller/components/SellerProductsView.d.ts +2 -2
- package/dist/features/seller/components/SellerProductsView.js +24 -32
- package/dist/features/seller/components/SellerShippingConfigsView.js +12 -24
- package/dist/features/seller/components/SellerSidebar.d.ts +0 -4
- package/dist/features/seller/components/SellerSidebar.js +0 -2
- package/dist/features/seller/components/SellerStoreCategoriesView.js +15 -34
- package/dist/features/seller/components/SellerTemplatesView.js +27 -43
- package/dist/features/seller/components/SellersListView.d.ts +1 -2
- package/dist/features/seller/components/analytics/SellerAnalyticsStats.d.ts +5 -0
- package/dist/features/seller/components/analytics/SellerAnalyticsStats.js +2 -8
- package/dist/features/seller/components/index.d.ts +0 -3
- package/dist/features/seller/components/index.js +0 -2
- package/dist/features/seller/server.d.ts +0 -1
- package/dist/features/seller/server.js +0 -1
- package/dist/features/shell/FormShell.d.ts +1 -1
- package/dist/features/shell/FormShell.js +4 -1
- package/dist/features/shell/field-groups/ImageFieldGroup.d.ts +18 -0
- package/dist/features/shell/field-groups/ImageFieldGroup.js +15 -0
- package/dist/features/shell/field-groups/SeoFieldGroup.d.ts +22 -0
- package/dist/features/shell/field-groups/SeoFieldGroup.js +16 -0
- package/dist/features/shell/field-groups/StatusFieldGroup.d.ts +35 -0
- package/dist/features/shell/field-groups/StatusFieldGroup.js +16 -0
- package/dist/features/shell/field-groups/TitleDescriptionGroup.d.ts +40 -0
- package/dist/features/shell/field-groups/TitleDescriptionGroup.js +16 -0
- package/dist/features/shell/field-groups/index.d.ts +13 -0
- package/dist/features/shell/field-groups/index.js +9 -0
- package/dist/features/shell/index.d.ts +2 -0
- package/dist/features/shell/index.js +1 -0
- package/dist/features/stores/components/StoreCapabilitiesGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoreFinanceGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoreHeader.js +2 -1
- package/dist/features/stores/components/StoreListingsGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoreOrdersGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoreReviewsListing.js +3 -4
- package/dist/features/stores/components/StoreScopedSearch.d.ts +16 -0
- package/dist/features/stores/components/StoreScopedSearch.js +27 -0
- package/dist/features/stores/components/StoreSettingsGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoresIndexListing.js +3 -4
- package/dist/features/stores/server.d.ts +0 -1
- package/dist/features/stores/server.js +0 -1
- package/dist/features/support/schemas/firestore.d.ts +22 -1
- package/dist/features/support/schemas/firestore.js +10 -0
- package/dist/features/wishlist/server.d.ts +0 -1
- package/dist/features/wishlist/server.js +0 -1
- package/dist/index.d.ts +11 -33
- package/dist/index.js +17 -62
- package/dist/next/routing/route-map.d.ts +8 -0
- package/dist/next/routing/route-map.js +4 -0
- package/dist/react/contexts/SessionContext.d.ts +2 -0
- package/dist/react/contexts/SessionContext.js +2 -0
- package/dist/react/hooks/useEntityDelete.d.ts +15 -0
- package/dist/react/hooks/useEntityDelete.js +39 -0
- package/dist/react/hooks/useListingTypeFlags.d.ts +32 -0
- package/dist/react/hooks/useListingTypeFlags.js +19 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/repositories/index.d.ts +3 -3
- package/dist/repositories/index.js +3 -3
- package/dist/security/index.d.ts +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/pii-redact.d.ts +8 -0
- package/dist/security/pii-redact.js +10 -1
- package/dist/seed/grouped-listings-seed-data.d.ts +4 -0
- package/dist/seed/products-preorders-seed-data.d.ts +4 -0
- package/dist/seed/products-prize-draws-seed-data.js +3 -0
- package/dist/seed/site-settings-seed-data.js +5 -5
- package/dist/seed/sub-listings-seed-data.d.ts +4 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +4 -0
- package/dist/styles.css +54 -395
- package/dist/tailwind-utilities.css +1 -1
- package/dist/ui/components/BaseListingCard.d.ts +10 -0
- package/dist/ui/components/BaseListingCard.js +17 -1
- package/dist/ui/components/DetailPageGallery.d.ts +32 -0
- package/dist/ui/components/DetailPageGallery.js +47 -0
- package/dist/ui/components/DetailPageHero.d.ts +30 -0
- package/dist/ui/components/DetailPageHero.js +22 -0
- package/dist/ui/components/DetailPageTabs.d.ts +34 -0
- package/dist/ui/components/DetailPageTabs.js +38 -0
- package/dist/ui/components/HorizontalScroller.style.css +15 -2
- package/dist/ui/components/ListingFilterDrawer.d.ts +10 -0
- package/dist/ui/components/ListingFilterDrawer.js +8 -0
- package/dist/ui/components/ListingLayout.d.ts +11 -2
- package/dist/ui/components/ListingLayout.js +12 -6
- package/dist/ui/components/PaginatedSelect.d.ts +66 -0
- package/dist/ui/components/PaginatedSelect.js +201 -0
- package/dist/ui/components/PaginatedSelect.style.css +254 -0
- package/dist/ui/components/Semantic.d.ts +0 -4
- package/dist/ui/components/Semantic.js +0 -2
- package/dist/ui/components/SettingsSection.d.ts +47 -0
- package/dist/ui/components/SettingsSection.js +38 -0
- package/dist/ui/components/index.style.css +1 -4
- package/dist/ui/index.d.ts +14 -14
- package/dist/ui/index.js +7 -7
- package/dist/utils/id-generators.d.ts +1 -18
- package/dist/utils/id-generators.js +51 -18
- package/dist/validation/schemas.d.ts +25 -0
- package/dist/validation/schemas.js +28 -0
- package/package.json +1 -1
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
6
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
7
|
-
import { Badge, BulkActionBar, Button, Heading, ListingToolbar, Pagination, Stack, Text, useToast, } from "../../../ui";
|
|
4
|
+
import { Badge, Button, Stack, Text, useToast } from "../../../ui";
|
|
8
5
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
9
|
-
import { toRecordArray, toRelativeDate, toStringValue,
|
|
10
|
-
import {
|
|
6
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
7
|
+
import { DataListingView } from "./DataListingView";
|
|
11
8
|
import { BUNDLE_COPY, BUNDLE_STOCK_VARIANT, } from "../../../_internal/shared/features/categories/bundle-copy";
|
|
12
9
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
13
|
-
import {
|
|
14
|
-
const PAGE_SIZE = 25;
|
|
15
|
-
const FILTER_KEYS = ["isActive", "bundleStockStatus"];
|
|
16
|
-
const DEFAULT_SORT = "name";
|
|
17
|
-
const SORT_OPTIONS = [
|
|
18
|
-
{ value: "name", label: "Name A–Z" },
|
|
19
|
-
{ value: "-name", label: "Name Z–A" },
|
|
20
|
-
{ value: "-bundlePriceInPaise", label: "Price high→low" },
|
|
21
|
-
{ value: "bundlePriceInPaise", label: "Price low→high" },
|
|
22
|
-
{ value: "-createdAt", label: "Newest" },
|
|
23
|
-
{ value: "createdAt", label: "Oldest" },
|
|
24
|
-
];
|
|
10
|
+
import { buildBulkAction } from "../../../_internal/shared/actions/bulk-helpers";
|
|
25
11
|
function formatPrice(paise) {
|
|
26
12
|
if (typeof paise !== "number" || paise <= 0)
|
|
27
13
|
return "—";
|
|
@@ -51,71 +37,42 @@ const COLUMNS = [
|
|
|
51
37
|
},
|
|
52
38
|
{ key: "updatedAt", header: "Updated", className: "w-28" },
|
|
53
39
|
];
|
|
54
|
-
function BundlesFilterDrawer({ filterOpen, setFilterOpen, activeFilterCount, clearFilters, pendingFilters, setPendingFilters, applyFilters, }) {
|
|
55
|
-
if (!filterOpen)
|
|
56
|
-
return null;
|
|
57
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40 bg-black/40", "aria-hidden": "true", onClick: () => setFilterOpen(false) }), _jsxs("div", { className: "fixed inset-y-0 left-0 z-50 flex w-80 flex-col bg-white dark:bg-slate-900 shadow-2xl", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: [_jsx("span", { className: "text-base font-semibold text-zinc-900 dark:text-zinc-100", children: "Filters" }), _jsxs("div", { className: "flex items-center gap-2", children: [activeFilterCount > 0 && (_jsx("button", { type: "button", onClick: clearFilters, className: "text-xs text-zinc-500 hover:text-rose-500 dark:text-zinc-400 transition-colors", children: "Clear all" })), _jsx("button", { type: "button", onClick: () => setFilterOpen(false), "aria-label": "Close", className: "rounded-lg p-1.5 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors", children: _jsx(X, { className: "h-5 w-5" }) })] })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
|
|
58
|
-
{ label: "All", value: "" },
|
|
59
|
-
{ label: "Active", value: "true" },
|
|
60
|
-
{ label: "Inactive", value: "false" },
|
|
61
|
-
].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, isActive: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.isActive || "") === opt.value
|
|
62
|
-
? "bg-primary text-white border-primary"
|
|
63
|
-
: "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Stock" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
|
|
64
|
-
{ label: "All", value: "" },
|
|
65
|
-
{ label: "Sold out", value: "out_of_stock" },
|
|
66
|
-
].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, bundleStockStatus: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.bundleStockStatus || "") === opt.value
|
|
67
|
-
? "bg-primary text-white border-primary"
|
|
68
|
-
: "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] })] }), _jsx("div", { className: "border-t border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: _jsxs("button", { type: "button", onClick: applyFilters, className: "w-full rounded-lg bg-primary py-2.5 text-sm font-semibold text-white hover:bg-primary-600 transition-colors active:scale-[0.98]", children: ["Apply Filters", activeFilterCount > 0 ? ` (${activeFilterCount})` : ""] }) })] })] }));
|
|
69
|
-
}
|
|
70
40
|
export function AdminBundlesView({ getEditHref, newHref }) {
|
|
71
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
72
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
73
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
74
|
-
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
75
41
|
const [rebuildingId, setRebuildingId] = useState(null);
|
|
76
42
|
const toast = useToast();
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
table.set("q", searchInput.trim());
|
|
100
|
-
}, [searchInput, table]);
|
|
101
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
102
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
103
|
-
const filterParts = [];
|
|
104
|
-
const isActiveRaw = table.get("isActive");
|
|
105
|
-
if (isActiveRaw)
|
|
106
|
-
filterParts.push(`isActive==${isActiveRaw}`);
|
|
107
|
-
const stockStatusRaw = table.get("bundleStockStatus");
|
|
108
|
-
if (stockStatusRaw)
|
|
109
|
-
filterParts.push(`bundleStockStatus==${stockStatusRaw}`);
|
|
110
|
-
const filters = filterParts.join(",") || undefined;
|
|
111
|
-
const { rows, total, isLoading, errorMessage, refetch } = useAdminListingData({
|
|
43
|
+
const handleRebuild = useCallback(async (bundleId) => {
|
|
44
|
+
setRebuildingId(bundleId);
|
|
45
|
+
try {
|
|
46
|
+
const res = await fetch(ADMIN_ENDPOINTS.BUNDLE_REBUILD(bundleId), { method: "POST" });
|
|
47
|
+
if (!res.ok)
|
|
48
|
+
throw new Error("Rebuild failed");
|
|
49
|
+
toast.showToast("Bundle stock rebuilt.", "success");
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
toast.showToast("Failed to rebuild bundle stock.", "error");
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
setRebuildingId(null);
|
|
56
|
+
}
|
|
57
|
+
}, [toast]);
|
|
58
|
+
const config = {
|
|
59
|
+
portal: "admin",
|
|
60
|
+
title: "Bundles",
|
|
61
|
+
searchPlaceholder: "Search bundles by name or slug…",
|
|
62
|
+
emptyLabel: BUNDLE_COPY.adminList.empty,
|
|
63
|
+
filterKeys: ["isActive", "bundleStockStatus"],
|
|
64
|
+
defaultSort: "name",
|
|
112
65
|
queryKey: ["admin", "bundles", "listing"],
|
|
113
66
|
endpoint: ADMIN_ENDPOINTS.BUNDLES,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
67
|
+
sortOptions: [
|
|
68
|
+
{ value: "name", label: "Name A–Z" },
|
|
69
|
+
{ value: "-name", label: "Name Z–A" },
|
|
70
|
+
{ value: "-bundlePriceInPaise", label: "Price high→low" },
|
|
71
|
+
{ value: "bundlePriceInPaise", label: "Price low→high" },
|
|
72
|
+
{ value: "-createdAt", label: "Newest" },
|
|
73
|
+
{ value: "createdAt", label: "Oldest" },
|
|
74
|
+
],
|
|
75
|
+
columns: COLUMNS,
|
|
119
76
|
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
120
77
|
id: toStringValue(item.id, `bundle-${index}`),
|
|
121
78
|
primary: toStringValue(item.name, "Untitled bundle"),
|
|
@@ -130,70 +87,51 @@ export function AdminBundlesView({ getEditHref, newHref }) {
|
|
|
130
87
|
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
131
88
|
})),
|
|
132
89
|
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
catch {
|
|
146
|
-
toast.showToast("Failed to rebuild bundle stock.", "error");
|
|
147
|
-
}
|
|
148
|
-
finally {
|
|
149
|
-
setRebuildingId(null);
|
|
150
|
-
refetch();
|
|
151
|
-
}
|
|
152
|
-
}, [refetch, toast]);
|
|
153
|
-
const bulkActions = [
|
|
154
|
-
{
|
|
155
|
-
id: "activate",
|
|
156
|
-
label: ACTIONS.ADMIN["activate-bundle"].label,
|
|
157
|
-
variant: "primary",
|
|
158
|
-
onClick: async () => {
|
|
90
|
+
buildFilters: (filterState) => {
|
|
91
|
+
const parts = [];
|
|
92
|
+
if (filterState.isActive)
|
|
93
|
+
parts.push(`isActive==${filterState.isActive}`);
|
|
94
|
+
if (filterState.bundleStockStatus)
|
|
95
|
+
parts.push(`bundleStockStatus==${filterState.bundleStockStatus}`);
|
|
96
|
+
return parts.join(",") || undefined;
|
|
97
|
+
},
|
|
98
|
+
getRowHref: getEditHref,
|
|
99
|
+
toolbarExtra: (_jsx(Button, { asChild: true, size: "sm", variant: "primary", children: _jsxs("a", { href: newHref, className: "flex items-center gap-1.5", children: ["+ ", BUNDLE_COPY.adminList.newButton] }) })),
|
|
100
|
+
buildBulkActions: (selection) => [
|
|
101
|
+
buildBulkAction(ACTIONS.ADMIN["activate-bundle"], async () => {
|
|
159
102
|
await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), {
|
|
160
103
|
method: "PUT",
|
|
161
104
|
headers: { "Content-Type": "application/json" },
|
|
162
105
|
body: JSON.stringify({ isActive: true }),
|
|
163
106
|
})));
|
|
164
107
|
selection.clearSelection();
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
id: "deactivate",
|
|
170
|
-
label: ACTIONS.ADMIN["deactivate-bundle"].label,
|
|
171
|
-
variant: "secondary",
|
|
172
|
-
onClick: async () => {
|
|
108
|
+
}),
|
|
109
|
+
buildBulkAction(ACTIONS.ADMIN["deactivate-bundle"], async () => {
|
|
173
110
|
await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), {
|
|
174
111
|
method: "PUT",
|
|
175
112
|
headers: { "Content-Type": "application/json" },
|
|
176
113
|
body: JSON.stringify({ isActive: false }),
|
|
177
114
|
})));
|
|
178
115
|
selection.clearSelection();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
id: "delete",
|
|
184
|
-
label: ACTIONS.ADMIN["delete-bundle"].label,
|
|
185
|
-
variant: "danger",
|
|
186
|
-
onClick: async () => {
|
|
116
|
+
}),
|
|
117
|
+
buildBulkAction(ACTIONS.ADMIN["delete-bundle"], async () => {
|
|
187
118
|
await Promise.all(selection.selectedIds.map((id) => fetch(ADMIN_ENDPOINTS.BUNDLE_BY_ID(id), { method: "DELETE" })));
|
|
188
119
|
selection.clearSelection();
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
120
|
+
}),
|
|
121
|
+
],
|
|
122
|
+
renderRowActions: (row) => (_jsx(Button, { variant: "ghost", size: "sm", isLoading: rebuildingId === row.id, disabled: rebuildingId === row.id, onClick: () => void handleRebuild(row.id), children: ACTIONS.ADMIN["rebuild-bundle"].label })),
|
|
123
|
+
renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
|
|
124
|
+
{ label: "All", value: "" },
|
|
125
|
+
{ label: "Active", value: "true" },
|
|
126
|
+
{ label: "Inactive", value: "false" },
|
|
127
|
+
].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, isActive: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.isActive || "") === opt.value
|
|
128
|
+
? "bg-primary text-white border-primary"
|
|
129
|
+
: "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Stock" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
|
|
130
|
+
{ label: "All", value: "" },
|
|
131
|
+
{ label: "Sold out", value: "out_of_stock" },
|
|
132
|
+
].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, bundleStockStatus: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.bundleStockStatus || "") === opt.value
|
|
133
|
+
? "bg-primary text-white border-primary"
|
|
134
|
+
: "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] })] })),
|
|
135
|
+
};
|
|
136
|
+
return _jsx(DataListingView, { config: config });
|
|
199
137
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface AdminCarouselViewProps extends
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export interface AdminCarouselViewProps extends ListingLayoutProps {
|
|
3
3
|
onBulkDelete?: (ids: string[]) => Promise<void>;
|
|
4
4
|
}
|
|
5
5
|
export declare function AdminCarouselView({ children, onBulkDelete, ...props }: AdminCarouselViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,76 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import React, { useState, useCallback } from "react";
|
|
4
|
-
import { X } from "lucide-react";
|
|
5
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
|
-
import {
|
|
7
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
8
|
-
import { BulkActionBar, ListingToolbar, ListingViewShell, Pagination, Text } from "../../../ui";
|
|
5
|
+
import { BulkActionBar, ConfirmDeleteModal, ListingFilterDrawer, ListingToolbar, ListingLayout, Pagination, Text } from "../../../ui";
|
|
9
6
|
import { useBottomActions } from "../../layout";
|
|
10
7
|
import { ADMIN_ENDPOINTS, HOMEPAGE_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
11
8
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
12
|
-
import {
|
|
9
|
+
import { buildBulkAction } from "../../../_internal/shared/actions/bulk-helpers";
|
|
10
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
11
|
+
import { useAdminListing } from "../hooks/useAdminListing";
|
|
13
12
|
import { DataTable } from "./DataTable";
|
|
14
13
|
import { RowActionMenu } from "../../../ui/components/RowActionMenu";
|
|
15
14
|
import { apiClient } from "../../../http";
|
|
16
15
|
const PAGE_SIZE = 50;
|
|
17
16
|
const FILTER_KEYS = ["active"];
|
|
18
17
|
const DEFAULT_SORT = "order";
|
|
19
|
-
function CarouselFilterDrawer({ filterOpen, setFilterOpen, activeFilterCount, clearFilters, pendingFilters, setPendingFilters, applyFilters, }) {
|
|
20
|
-
if (!filterOpen)
|
|
21
|
-
return null;
|
|
22
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40 bg-black/40", "aria-hidden": "true", onClick: () => setFilterOpen(false) }), _jsxs("div", { className: "fixed inset-y-0 left-0 z-50 flex w-80 flex-col bg-white dark:bg-slate-900 shadow-2xl", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: [_jsx("span", { className: "text-base font-semibold text-zinc-900 dark:text-zinc-100", children: "Filters" }), _jsxs("div", { className: "flex items-center gap-2", children: [activeFilterCount > 0 && (_jsx("button", { type: "button", onClick: clearFilters, className: "text-xs text-zinc-500 hover:text-rose-500 dark:text-zinc-400 transition-colors", children: "Clear all" })), _jsx("button", { type: "button", onClick: () => setFilterOpen(false), "aria-label": "Close", className: "rounded-lg p-1.5 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors", children: _jsx(X, { className: "h-5 w-5" }) })] })] }), _jsx("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5", children: _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [{ label: "All", value: "" }, { label: "Active", value: "true" }, { label: "Inactive", value: "false" }].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, active: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.active || "") === opt.value ? "bg-primary text-white border-primary" : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }) }), _jsx("div", { className: "border-t border-zinc-200 dark:border-slate-700 px-4 py-3.5", children: _jsxs("button", { type: "button", onClick: applyFilters, className: "w-full rounded-lg bg-primary py-2.5 text-sm font-semibold text-white hover:bg-primary-600 transition-colors active:scale-[0.98]", children: ["Apply Filters", activeFilterCount > 0 ? ` (${activeFilterCount})` : ""] }) })] })] }));
|
|
23
|
-
}
|
|
24
18
|
export function AdminCarouselView({ children, onBulkDelete, ...props }) {
|
|
25
19
|
const hasChildren = React.Children.count(children) > 0;
|
|
26
|
-
const [view, setView] = useState("table");
|
|
27
20
|
const [draggingId, setDraggingId] = useState(null);
|
|
21
|
+
const [deleteTargetId, setDeleteTargetId] = useState(null);
|
|
28
22
|
const [localRows, setLocalRows] = useState([]);
|
|
29
23
|
const queryClient = useQueryClient();
|
|
30
|
-
const table
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const openFilters = useCallback(() => {
|
|
35
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
36
|
-
setFilterOpen(true);
|
|
37
|
-
}, [table]);
|
|
38
|
-
const applyFilters = useCallback(() => {
|
|
39
|
-
const updates = { page: "1" };
|
|
40
|
-
for (const k of FILTER_KEYS)
|
|
41
|
-
updates[k] = pendingFilters[k] ?? "";
|
|
42
|
-
table.setMany(updates);
|
|
43
|
-
setFilterOpen(false);
|
|
44
|
-
}, [pendingFilters, table]);
|
|
45
|
-
const clearFilters = useCallback(() => {
|
|
46
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
47
|
-
}, []);
|
|
48
|
-
const resetAll = useCallback(() => {
|
|
49
|
-
const updates = { q: "", sort: "" };
|
|
50
|
-
for (const k of FILTER_KEYS)
|
|
51
|
-
updates[k] = "";
|
|
52
|
-
table.setMany(updates);
|
|
53
|
-
setSearchInput("");
|
|
54
|
-
}, [table]);
|
|
55
|
-
const commitSearch = useCallback(() => {
|
|
56
|
-
table.set("q", searchInput.trim());
|
|
57
|
-
}, [searchInput, table]);
|
|
58
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
59
|
-
const hasActiveState = !!table.get("q") || activeFilterCount > 0;
|
|
60
|
-
const activeRaw = table.get("active");
|
|
61
|
-
const filterParts = [];
|
|
62
|
-
if (activeRaw === "true")
|
|
63
|
-
filterParts.push("active==true");
|
|
64
|
-
else if (activeRaw === "false")
|
|
65
|
-
filterParts.push("active==false");
|
|
66
|
-
const filters = filterParts.join(",") || undefined;
|
|
67
|
-
const { rows: fetchedRows, total, isLoading, errorMessage } = useAdminListingData({
|
|
24
|
+
const { view, setView, table, searchInput, setSearchInput, commitSearch, filterOpen, setFilterOpen, openFilters, applyFilters, clearFilters, pendingFilters, setPendingFilters, activeFilterCount, hasActiveState, resetAll, rows: fetchedRows, total, isLoading, errorMessage, currentPage, totalPages, selection, } = useAdminListing({
|
|
25
|
+
filterKeys: FILTER_KEYS,
|
|
26
|
+
defaultSort: DEFAULT_SORT,
|
|
27
|
+
pageSize: PAGE_SIZE,
|
|
68
28
|
queryKey: ["admin", "carousel", "listing"],
|
|
69
29
|
endpoint: `${HOMEPAGE_ENDPOINTS.CAROUSEL}?includeInactive=true`,
|
|
70
|
-
page: table.getNumber("page", 1),
|
|
71
|
-
pageSize: PAGE_SIZE,
|
|
72
|
-
filters,
|
|
73
|
-
q: table.get("q") || undefined,
|
|
74
30
|
mapRows: (response) => {
|
|
75
31
|
const sourceItems = Array.isArray(response.data) ? response.data : response.items;
|
|
76
32
|
return toRecordArray(sourceItems)
|
|
@@ -93,6 +49,14 @@ export function AdminCarouselView({ children, onBulkDelete, ...props }) {
|
|
|
93
49
|
});
|
|
94
50
|
},
|
|
95
51
|
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
52
|
+
buildFilters: (filterState) => {
|
|
53
|
+
const activeRaw = filterState.active;
|
|
54
|
+
if (activeRaw === "true")
|
|
55
|
+
return "active==true";
|
|
56
|
+
if (activeRaw === "false")
|
|
57
|
+
return "active==false";
|
|
58
|
+
return undefined;
|
|
59
|
+
},
|
|
96
60
|
});
|
|
97
61
|
React.useEffect(() => {
|
|
98
62
|
setLocalRows(fetchedRows);
|
|
@@ -109,11 +73,7 @@ export function AdminCarouselView({ children, onBulkDelete, ...props }) {
|
|
|
109
73
|
queryClient.invalidateQueries({ queryKey: ["admin", "carousel", "listing"] });
|
|
110
74
|
},
|
|
111
75
|
});
|
|
112
|
-
const handleDeleteSlide = useCallback((id) =>
|
|
113
|
-
if (confirm("Delete this carousel slide? This cannot be undone.")) {
|
|
114
|
-
deleteMutation.mutate(id);
|
|
115
|
-
}
|
|
116
|
-
}, [deleteMutation]);
|
|
76
|
+
const handleDeleteSlide = useCallback((id) => setDeleteTargetId(id), []);
|
|
117
77
|
const handleDragStart = (id) => setDraggingId(id);
|
|
118
78
|
const handleDrop = (targetId) => {
|
|
119
79
|
if (!draggingId || draggingId === targetId) {
|
|
@@ -133,20 +93,12 @@ export function AdminCarouselView({ children, onBulkDelete, ...props }) {
|
|
|
133
93
|
setDraggingId(null);
|
|
134
94
|
reorderMutation.mutate(next.map((r) => r.id));
|
|
135
95
|
};
|
|
136
|
-
const currentPage = table.getNumber("page", 1);
|
|
137
|
-
const totalPages = Math.ceil(total / PAGE_SIZE);
|
|
138
|
-
const selection = useBulkSelection({ items: fetchedRows, keyExtractor: (r) => r.id });
|
|
139
96
|
const bulkActions = [
|
|
140
|
-
...(onBulkDelete ? [{
|
|
141
|
-
id: "bulk-delete",
|
|
142
|
-
label: ACTIONS.ADMIN["delete-carousel"].label,
|
|
143
|
-
variant: "danger",
|
|
144
|
-
onClick: async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); },
|
|
145
|
-
}] : []),
|
|
97
|
+
...(onBulkDelete ? [buildBulkAction(ACTIONS.ADMIN["delete-carousel"], async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); })] : []),
|
|
146
98
|
];
|
|
147
99
|
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
|
|
148
100
|
if (hasChildren) {
|
|
149
|
-
return _jsx(
|
|
101
|
+
return _jsx(ListingLayout, { portal: "admin", ...props, children: children });
|
|
150
102
|
}
|
|
151
103
|
const displayRows = (localRows.length > 0 ? localRows : fetchedRows).map((row) => ({
|
|
152
104
|
...row,
|
|
@@ -191,5 +143,5 @@ export function AdminCarouselView({ children, onBulkDelete, ...props }) {
|
|
|
191
143
|
] })),
|
|
192
144
|
},
|
|
193
145
|
];
|
|
194
|
-
return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search slide titles", onSearchChange: setSearchInput, onSearchCommit: commitSearch, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), selection.selectedCount > 0 && bulkActions.length > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-
|
|
146
|
+
return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search slide titles", onSearchChange: setSearchInput, onSearchCommit: commitSearch, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), selection.selectedCount > 0 && bulkActions.length > 0 && (_jsx(BulkActionBar, { selectedCount: selection.selectedCount, actions: bulkActions, onClearSelection: selection.clearSelection })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-error/20 bg-error-surface px-4 py-3 text-sm text-error", children: errorMessage })), _jsx(DataTable, { rows: displayRows, columns: columns, isLoading: isLoading, emptyLabel: "No carousel slides \u2014 use 'New slide' to add one", getRowHref: (row) => `/admin/carousel/${row.id}/edit` })] }), _jsx(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: _jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Status" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [{ label: "All", value: "" }, { label: "Active", value: "true" }, { label: "Inactive", value: "false" }].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, active: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.active || "") === opt.value ? "bg-primary text-white border-primary" : "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt.label }, opt.label))) })] }) }), deleteTargetId && (_jsx(ConfirmDeleteModal, { isOpen: true, title: "Delete Carousel Slide", message: "Delete this carousel slide? This cannot be undone.", onConfirm: () => { deleteMutation.mutate(deleteTargetId); setDeleteTargetId(null); }, onClose: () => setDeleteTargetId(null), isDeleting: deleteMutation.isPending }))] }));
|
|
195
147
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
}
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export type AdminCartsViewProps = ListingLayoutProps;
|
|
4
3
|
export declare function AdminCartsView({ children, ...props }: AdminCartsViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,95 +1,45 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import React
|
|
4
|
-
import {
|
|
5
|
-
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
6
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
7
|
-
import { FilterChipGroup, ListingToolbar, Pagination, ListingViewShell } from "../../../ui";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { FilterChipGroup, ListingLayout } from "../../../ui";
|
|
8
5
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
9
6
|
import { ADMIN_CART_OWNERSHIP_TABS } from "../constants/filter-tabs";
|
|
10
|
-
import { toRecordArray, toRelativeDate, toStringValue,
|
|
11
|
-
import {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
8
|
+
import { DataListingView } from "./DataListingView";
|
|
9
|
+
const ADMIN_CARTS_CONFIG = {
|
|
10
|
+
portal: "admin",
|
|
11
|
+
title: "Carts",
|
|
12
|
+
searchPlaceholder: "Search by user ID or session",
|
|
13
|
+
emptyLabel: "No carts found",
|
|
14
|
+
filterKeys: ["type"],
|
|
15
|
+
defaultSort: "-updatedAt",
|
|
16
|
+
queryKey: ["admin", "carts", "listing"],
|
|
17
|
+
endpoint: ADMIN_ENDPOINTS.ADMIN_CARTS,
|
|
18
|
+
sortOptions: [
|
|
19
|
+
{ value: "-updatedAt", label: "Recently updated" },
|
|
20
|
+
{ value: "updatedAt", label: "Oldest" },
|
|
21
|
+
],
|
|
22
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => {
|
|
23
|
+
const isGuest = !item.userId;
|
|
24
|
+
const itemCount = Array.isArray(item.items) ? item.items.length : 0;
|
|
25
|
+
const sessionShort = toStringValue(item.sessionId, "").slice(0, 8);
|
|
26
|
+
return {
|
|
27
|
+
id: toStringValue(item.id, `cart-${index}`),
|
|
28
|
+
primary: isGuest
|
|
29
|
+
? `Guest · ${sessionShort || "—"}`
|
|
30
|
+
: toStringValue(item.userId, `user-${index}`),
|
|
31
|
+
secondary: `${itemCount} item${itemCount !== 1 ? "s" : ""}`,
|
|
32
|
+
status: isGuest ? "Guest" : "Authenticated",
|
|
33
|
+
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
37
|
+
buildFilters: (state) => state.type && state.type !== "All" ? `type==${state.type}` : undefined,
|
|
38
|
+
renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Type", tabs: ADMIN_CART_OWNERSHIP_TABS, value: pendingFilters.type ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, type: id })) })),
|
|
39
|
+
};
|
|
20
40
|
export function AdminCartsView({ children, ...props }) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
24
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
25
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
26
|
-
const [selectedIds, setSelectedIds] = useState(new Set());
|
|
27
|
-
const toggleSelect = (id, next) => setSelectedIds((prev) => {
|
|
28
|
-
const s = new Set(prev);
|
|
29
|
-
if (next)
|
|
30
|
-
s.add(id);
|
|
31
|
-
else
|
|
32
|
-
s.delete(id);
|
|
33
|
-
return s;
|
|
34
|
-
});
|
|
35
|
-
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
36
|
-
const openFilters = useCallback(() => {
|
|
37
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
38
|
-
setFilterOpen(true);
|
|
39
|
-
}, [table]);
|
|
40
|
-
const applyFilters = useCallback(() => {
|
|
41
|
-
const updates = { page: "1" };
|
|
42
|
-
for (const k of FILTER_KEYS)
|
|
43
|
-
updates[k] = pendingFilters[k] ?? "";
|
|
44
|
-
table.setMany(updates);
|
|
45
|
-
setFilterOpen(false);
|
|
46
|
-
}, [pendingFilters, table]);
|
|
47
|
-
const clearFilters = useCallback(() => {
|
|
48
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
49
|
-
}, []);
|
|
50
|
-
const resetAll = useCallback(() => {
|
|
51
|
-
const updates = { q: "", sort: "" };
|
|
52
|
-
for (const k of FILTER_KEYS)
|
|
53
|
-
updates[k] = "";
|
|
54
|
-
table.setMany(updates);
|
|
55
|
-
setSearchInput("");
|
|
56
|
-
}, [table]);
|
|
57
|
-
const commitSearch = useCallback(() => {
|
|
58
|
-
table.set("q", searchInput.trim());
|
|
59
|
-
}, [searchInput, table]);
|
|
60
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
61
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
62
|
-
const typeRaw = table.get("type");
|
|
63
|
-
const filters = typeRaw && typeRaw !== "All" ? `type==${typeRaw}` : undefined;
|
|
64
|
-
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
65
|
-
queryKey: ["admin", "carts", "listing"],
|
|
66
|
-
endpoint: ADMIN_ENDPOINTS.ADMIN_CARTS,
|
|
67
|
-
page: table.getNumber("page", 1),
|
|
68
|
-
pageSize: PAGE_SIZE,
|
|
69
|
-
sorts: table.get("sort") || DEFAULT_SORT,
|
|
70
|
-
filters,
|
|
71
|
-
q: table.get("q") || undefined,
|
|
72
|
-
mapRows: (response) => toRecordArray(response.items).map((item, index) => {
|
|
73
|
-
const isGuest = !item.userId;
|
|
74
|
-
const itemCount = Array.isArray(item.items) ? item.items.length : 0;
|
|
75
|
-
const sessionShort = toStringValue(item.sessionId, "").slice(0, 8);
|
|
76
|
-
return {
|
|
77
|
-
id: toStringValue(item.id, `cart-${index}`),
|
|
78
|
-
primary: isGuest
|
|
79
|
-
? `Guest · ${sessionShort || "—"}`
|
|
80
|
-
: toStringValue(item.userId, `user-${index}`),
|
|
81
|
-
secondary: `${itemCount} item${itemCount !== 1 ? "s" : ""}`,
|
|
82
|
-
status: isGuest ? "Guest" : "Authenticated",
|
|
83
|
-
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
84
|
-
};
|
|
85
|
-
}),
|
|
86
|
-
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
87
|
-
});
|
|
88
|
-
const currentPage = table.getNumber("page", 1);
|
|
89
|
-
const totalPages = Math.ceil(total / PAGE_SIZE);
|
|
90
|
-
const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
|
|
91
|
-
if (hasChildren) {
|
|
92
|
-
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
41
|
+
if (React.Children.count(children) > 0) {
|
|
42
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
93
43
|
}
|
|
94
|
-
return
|
|
44
|
+
return _jsx(DataListingView, { config: ADMIN_CARTS_CONFIG });
|
|
95
45
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface AdminCategoriesViewProps extends
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export interface AdminCategoriesViewProps extends ListingLayoutProps {
|
|
3
3
|
getRowHref?: (row: {
|
|
4
4
|
id: string;
|
|
5
5
|
}) => string;
|
|
6
6
|
}
|
|
7
|
-
export declare function AdminCategoriesView({ children, getRowHref, ...props }: AdminCategoriesViewProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function AdminCategoriesView({ children, getRowHref: _getRowHref, ...props }: AdminCategoriesViewProps): import("react/jsx-runtime").JSX.Element;
|