@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,105 +1,106 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import React
|
|
4
|
-
import {
|
|
5
|
-
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
6
|
-
import { usePanelUrlSync } from "../../../react/hooks/use-panel-url-sync";
|
|
7
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
8
|
-
import { BulkActionBar, Button, Heading, ListingToolbar, ListingViewShell, Pagination, SideDrawer, Text } from "../../../ui";
|
|
9
|
-
import { AdminViewCards } from "./AdminViewCards";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Heading, ListingLayout, Span, Text } from "../../../ui";
|
|
10
5
|
import { CATEGORY_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
11
6
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
12
|
-
import { toRecordArray, toRelativeDate, toStringValue,
|
|
13
|
-
import {
|
|
7
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
8
|
+
import { DataListingView } from "./DataListingView";
|
|
14
9
|
import { AdminCategoryEditorView } from "./AdminCategoryEditorView";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
10
|
+
const COLUMNS = [
|
|
11
|
+
{
|
|
12
|
+
key: "primary",
|
|
13
|
+
header: "Category",
|
|
14
|
+
sortable: true,
|
|
15
|
+
render: (row) => (_jsxs("div", { className: "space-y-1", children: [_jsx(Text, { className: "font-semibold text-zinc-900 dark:text-zinc-100", children: row.primary }), _jsx(Text, { className: "text-xs text-zinc-500 dark:text-zinc-400", children: row.secondary })] })),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
key: "status",
|
|
19
|
+
header: "Status",
|
|
20
|
+
className: "w-32",
|
|
21
|
+
render: (row) => (_jsx(Span, { className: "inline-flex rounded-full bg-primary-50 px-2.5 py-1 text-xs font-medium text-primary-800 dark:bg-secondary-900/30 dark:text-secondary-300", children: row.status })),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: "updatedAt",
|
|
25
|
+
header: "Updated",
|
|
26
|
+
className: "w-32",
|
|
27
|
+
render: (row) => (_jsx(Text, { className: "text-sm text-zinc-500 dark:text-zinc-400", children: row.updatedAt })),
|
|
28
|
+
},
|
|
23
29
|
];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
q: table.get("q") || undefined,
|
|
79
|
-
mapRows: (response) => {
|
|
80
|
-
const sourceItems = Array.isArray(response.data) ? response.data : response.items;
|
|
81
|
-
return toRecordArray(sourceItems).map((item, index) => ({
|
|
82
|
-
id: toStringValue(item.id, `category-${index}`),
|
|
83
|
-
primary: toStringValue(item.name, "Untitled category"),
|
|
84
|
-
secondary: `Slug: ${toStringValue(item.slug, "no-slug")} · Tier: ${typeof item.tier === "number" ? String(item.tier) : "-"} · Parent: ${toStringValue(item.parentId, "root")}`,
|
|
85
|
-
status: typeof item.isActive === "boolean" ? (item.isActive ? "Active" : "Inactive") : toStringValue(item.status, "Active"),
|
|
86
|
-
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
87
|
-
}));
|
|
30
|
+
const ADMIN_CATEGORIES_CONFIG = {
|
|
31
|
+
portal: "admin",
|
|
32
|
+
title: "Categories",
|
|
33
|
+
searchPlaceholder: "Search categories, slugs, or parent category",
|
|
34
|
+
emptyLabel: "No categories found",
|
|
35
|
+
filterKeys: ["isActive", "isFeatured"],
|
|
36
|
+
defaultSort: "name",
|
|
37
|
+
pageSize: 50,
|
|
38
|
+
queryKey: ["admin", "categories", "listing"],
|
|
39
|
+
endpoint: `${CATEGORY_ENDPOINTS.LIST}?flat=true`,
|
|
40
|
+
sortOptions: [
|
|
41
|
+
{ value: "name", label: "Name A–Z" },
|
|
42
|
+
{ value: "-name", label: "Name Z–A" },
|
|
43
|
+
{ value: "-createdAt", label: "Newest" },
|
|
44
|
+
],
|
|
45
|
+
columns: COLUMNS,
|
|
46
|
+
mapRows: (response) => {
|
|
47
|
+
const sourceItems = Array.isArray(response.data) ? response.data : response.items;
|
|
48
|
+
return toRecordArray(sourceItems).map((item, index) => ({
|
|
49
|
+
id: toStringValue(item.id, `category-${index}`),
|
|
50
|
+
primary: toStringValue(item.name, "Untitled category"),
|
|
51
|
+
secondary: `Slug: ${toStringValue(item.slug, "no-slug")} · Tier: ${typeof item.tier === "number" ? String(item.tier) : "-"} · Parent: ${toStringValue(item.parentId, "root")}`,
|
|
52
|
+
status: typeof item.isActive === "boolean"
|
|
53
|
+
? item.isActive
|
|
54
|
+
? "Active"
|
|
55
|
+
: "Inactive"
|
|
56
|
+
: toStringValue(item.status, "Active"),
|
|
57
|
+
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
58
|
+
}));
|
|
59
|
+
},
|
|
60
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
61
|
+
buildFilters: (state) => {
|
|
62
|
+
const parts = [];
|
|
63
|
+
if (state.isActive)
|
|
64
|
+
parts.push(`isActive==${state.isActive}`);
|
|
65
|
+
if (state.isFeatured === "true")
|
|
66
|
+
parts.push("isFeatured==true");
|
|
67
|
+
return parts.join(",") || undefined;
|
|
68
|
+
},
|
|
69
|
+
primaryAction: {
|
|
70
|
+
label: "Add Category",
|
|
71
|
+
onClick: ({ openCreatePanel }) => openCreatePanel(),
|
|
72
|
+
},
|
|
73
|
+
buildBulkActions: (selection) => [
|
|
74
|
+
{
|
|
75
|
+
id: "edit",
|
|
76
|
+
label: ACTIONS.ADMIN["edit-category"].label,
|
|
77
|
+
variant: "primary",
|
|
78
|
+
onClick: () => {
|
|
79
|
+
const id = selection.selectedIds[0];
|
|
80
|
+
if (id)
|
|
81
|
+
selection.openEditPanel(id);
|
|
82
|
+
selection.clearSelection();
|
|
83
|
+
},
|
|
88
84
|
},
|
|
89
|
-
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
],
|
|
86
|
+
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: "Active" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
|
|
87
|
+
{ label: "All", value: "" },
|
|
88
|
+
{ label: "Active", value: "true" },
|
|
89
|
+
{ label: "Inactive", value: "false" },
|
|
90
|
+
].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
|
|
91
|
+
? "bg-primary text-white border-primary"
|
|
92
|
+
: "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: "Featured" }), _jsx("div", { className: "flex flex-wrap gap-2", children: [
|
|
93
|
+
{ label: "All", value: "" },
|
|
94
|
+
{ label: "Featured only", value: "true" },
|
|
95
|
+
].map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, isFeatured: opt.value })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.isFeatured || "") === opt.value
|
|
96
|
+
? "bg-primary text-white border-primary"
|
|
97
|
+
: "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))) })] })] })),
|
|
98
|
+
renderEditor: ({ editId, closePanel }) => (_jsx(AdminCategoryEditorView, { categoryId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })),
|
|
99
|
+
resolveEditorTitle: ({ isCreate }) => (isCreate ? "Add Category" : "Edit Category"),
|
|
100
|
+
};
|
|
101
|
+
export function AdminCategoriesView({ children, getRowHref: _getRowHref, ...props }) {
|
|
102
|
+
if (React.Children.count(children) > 0) {
|
|
103
|
+
return (_jsxs(ListingLayout, { portal: "admin", ...props, children: [_jsx(Heading, { level: 1, className: "sr-only", children: "Categories" }), children] }));
|
|
96
104
|
}
|
|
97
|
-
|
|
98
|
-
{ id: "edit", label: ACTIONS.ADMIN["edit-category"].label, variant: "primary", onClick: () => { const id = selection.selectedIds[0]; if (id)
|
|
99
|
-
openEditPanel(id); selection.clearSelection(); } },
|
|
100
|
-
] } } : {});
|
|
101
|
-
return (_jsxs("div", { className: "min-h-screen", children: [_jsx(Heading, { level: 1, className: "sr-only", children: "Categories" }), _jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search categories, slugs, or parent category", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set("sort", v); }, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState, extra: _jsxs(Button, { size: "sm", onClick: openCreatePanel, className: "flex items-center gap-1.5", children: [_jsx(Plus, { className: "h-4 w-4" }), "Add Category"] }) }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
|
|
102
|
-
{ id: "edit", label: ACTIONS.ADMIN["edit-category"].label, variant: "primary", onClick: () => { const id = selection.selectedIds[0]; if (id)
|
|
103
|
-
openEditPanel(id); selection.clearSelection(); } },
|
|
104
|
-
] }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-error-surface px-4 py-3 text-sm text-error dark:border-red-900/60", children: errorMessage })), view === "table" ? (_jsx(DataTable, { rows: rows, isLoading: isLoading, emptyLabel: "No categories found", selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: (next) => next ? selection.setSelectedIds(rows.map(r => r.id)) : selection.clearSelection(), onRowClick: (row) => openEditPanel(row.id) })) : (_jsx(AdminViewCards, { rows: rows, view: view, isLoading: isLoading, emptyLabel: "No categories found", onRowClick: (row) => openEditPanel(row.id), selectedIdSet: selection.selectedIdSet, onToggleSelect: selection.toggle }))] }), _jsx(CategoriesFilterDrawer, { filterOpen: filterOpen, setFilterOpen: setFilterOpen, activeFilterCount: activeFilterCount, clearFilters: clearFilters, pendingFilters: pendingFilters, setPendingFilters: setPendingFilters, applyFilters: applyFilters }), _jsx(SideDrawer, { isOpen: isCreateOpen || isEditOpen, onClose: closePanel, title: isCreateOpen ? "Add Category" : "Edit Category", mode: isCreateOpen ? "create" : "edit", children: (isCreateOpen || isEditOpen) && (_jsx(AdminCategoryEditorView, { categoryId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })) })] }));
|
|
105
|
+
return (_jsxs(_Fragment, { children: [_jsx(Heading, { level: 1, className: "sr-only", children: "Categories" }), _jsx(DataListingView, { config: ADMIN_CATEGORIES_CONFIG })] }));
|
|
105
106
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
5
|
-
import { Button, Card, CardBody, ConfirmDeleteModal, Form,
|
|
5
|
+
import { Button, Card, CardBody, ConfirmDeleteModal, Form, PaginatedSelect, Input, StackedViewShell, Text, Toggle, useToast } from "../../../ui";
|
|
6
6
|
import { apiClient } from "../../../http";
|
|
7
7
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
8
8
|
import { CategoryQuickCreateForm } from "./CategoryQuickCreateForm";
|
|
@@ -114,11 +114,7 @@ export function AdminCategoryEditorView({ categoryId, onSaved, onDeleted, embedd
|
|
|
114
114
|
}, className: "space-y-6", children: [_jsxs(Card, { variant: "outlined", padding: "lg", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400 mb-4", children: "Identity" }), _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "grid sm:grid-cols-2 gap-4", children: [_jsx(FieldInput, { name: "name", label: "Category name", value: name, onChange: (v) => handleNameChange(v), required: true, placeholder: "e.g. Toys & Games" }), _jsx(Input, { label: "Slug", value: slug, onChange: (e) => {
|
|
115
115
|
setSlug(e.target.value);
|
|
116
116
|
setSlugManual(true);
|
|
117
|
-
}, placeholder: "toys-and-games", helperText: "Auto-generated from name. Used in URLs." })] }), _jsx(Input, { label: "Description", value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Brief description of the category" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Text, { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Parent category" }), _jsx(
|
|
118
|
-
if (confirm("Delete this category? Products in this category will become uncategorized.")) {
|
|
119
|
-
deleteMutation.mutate();
|
|
120
|
-
}
|
|
121
|
-
}, children: "Delete category" }))] })] }, "cat-form") }));
|
|
117
|
+
}, placeholder: "toys-and-games", helperText: "Auto-generated from name. Used in URLs." })] }), _jsx(Input, { label: "Description", value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Brief description of the category" }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Text, { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Parent category" }), _jsx(PaginatedSelect, { value: parentId || null, onChange: (v) => setParentId(v ?? ""), loadOptions: loadCategoryOptions, placeholder: "Search categories\u2026 (leave empty for root)", searchPlaceholder: "Type category name\u2026", noResultsText: "No categories found", ariaLabel: "Parent category", createLabel: "Category", renderCreateForm: ({ onCreated, onCancel }) => (_jsx(CategoryQuickCreateForm, { onSaved: (id, n) => { setParentId(id); onCreated({ value: id, label: n }); }, onCancel: onCancel })) }), _jsx(Text, { className: "text-xs text-neutral-500 dark:text-neutral-400", children: "Leave empty to create a root category." })] })] })] }), _jsxs(Card, { variant: "outlined", padding: "lg", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400 mb-4", children: "Display" }), _jsxs("div", { className: "space-y-4", children: [_jsx(Input, { label: "Display order", value: order, onChange: (e) => setOrder(e.target.value), type: "number", min: 0, placeholder: "0" }), _jsx(Toggle, { label: "Active", checked: isActive, onChange: setIsActive }), _jsx(Toggle, { label: "Show in menu", checked: showInMenu, onChange: setShowInMenu })] })] }), _jsxs("div", { className: "flex gap-3 lg:hidden", children: [_jsx(Button, { type: "submit", isLoading: isSubmitting, disabled: !name || isSubmitting, children: isEdit ? "Save changes" : "Create category" }), isEdit && (_jsx(Button, { type: "button", variant: "danger", isLoading: deleteMutation.isPending, onClick: () => setDeleteOpen(true), children: "Delete category" }))] })] }, "cat-form") }));
|
|
122
118
|
if (embedded) {
|
|
123
119
|
return _jsx("div", { className: "overflow-y-auto p-4", children: formContent });
|
|
124
120
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* AdminClassifiedView — admin browse of classified listings (W1-29).
|
|
5
|
+
* Read-only summary with edit-handoff to the seller-portal edit route.
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { ListingLayout } from "../../../ui";
|
|
9
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
10
|
+
import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../hooks/useAdminListingData";
|
|
11
|
+
import { DataListingView } from "./DataListingView";
|
|
12
|
+
const ADMIN_CLASSIFIED_CONFIG = {
|
|
13
|
+
portal: "admin",
|
|
14
|
+
title: "Classified",
|
|
15
|
+
searchPlaceholder: "Search classified by name or seller",
|
|
16
|
+
emptyLabel: "No classified listings",
|
|
17
|
+
filterKeys: [],
|
|
18
|
+
defaultSort: "-createdAt",
|
|
19
|
+
queryKey: ["admin", "classified", "listing"],
|
|
20
|
+
endpoint: ADMIN_ENDPOINTS.PRODUCTS,
|
|
21
|
+
sortOptions: [
|
|
22
|
+
{ value: "-createdAt", label: "Newest" },
|
|
23
|
+
{ value: "createdAt", label: "Oldest" },
|
|
24
|
+
{ value: "title", label: "Title A–Z" },
|
|
25
|
+
],
|
|
26
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
27
|
+
id: toStringValue(item.id, `classified-${index}`),
|
|
28
|
+
primary: toStringValue(item.title ?? item.productTitle, "Untitled classified"),
|
|
29
|
+
secondary: [
|
|
30
|
+
toStringValue(item.sellerName, "Unknown seller"),
|
|
31
|
+
toRupees(item.price),
|
|
32
|
+
].join(" · "),
|
|
33
|
+
status: toStringValue(item.status, "draft"),
|
|
34
|
+
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
35
|
+
})),
|
|
36
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
37
|
+
buildFilters: () => "listingType==classified",
|
|
38
|
+
};
|
|
39
|
+
export function AdminClassifiedView({ children, ...props }) {
|
|
40
|
+
if (React.Children.count(children) > 0) {
|
|
41
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
42
|
+
}
|
|
43
|
+
return _jsx(DataListingView, { config: ADMIN_CLASSIFIED_CONFIG });
|
|
44
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface AdminContactViewProps extends
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export interface AdminContactViewProps extends ListingLayoutProps {
|
|
3
3
|
onBulkMarkRead?: (ids: string[]) => Promise<void>;
|
|
4
4
|
onBulkArchive?: (ids: string[]) => Promise<void>;
|
|
5
5
|
onBulkDelete?: (ids: string[]) => Promise<void>;
|
|
@@ -1,100 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import React, { useState
|
|
4
|
-
import { X } from "lucide-react";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState } from "react";
|
|
5
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
|
-
import {
|
|
7
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
8
|
-
import { BulkActionBar, ConfirmDeleteModal, FilterChipGroup, ListingToolbar, ListingViewShell, Pagination, RowActionMenu, useToast, } from "../../../ui";
|
|
9
|
-
import { useBottomActions } from "../../layout";
|
|
5
|
+
import { ConfirmDeleteModal, FilterChipGroup, ListingLayout, RowActionMenu, useToast } from "../../../ui";
|
|
10
6
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
11
7
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
8
|
+
import { buildBulkAction } from "../../../_internal/shared/actions/bulk-helpers";
|
|
12
9
|
import { ROW_ACTION_META, ROW_ACTION_ID } from "../../../features/products/constants/action-defs";
|
|
13
10
|
import { ADMIN_CONTACT_STATUS_TABS } from "../constants/filter-tabs";
|
|
14
|
-
import { toRecordArray, toRelativeDate, toStringValue,
|
|
15
|
-
import {
|
|
11
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
12
|
+
import { DataListingView } from "./DataListingView";
|
|
16
13
|
import { AdminContactEditorView } from "./AdminContactEditorView";
|
|
17
14
|
import { apiClient } from "../../../http";
|
|
18
|
-
const PAGE_SIZE = 25;
|
|
19
|
-
const FILTER_KEYS = ["status"];
|
|
20
|
-
const DEFAULT_SORT = "-createdAt";
|
|
21
|
-
const SORT_OPTIONS = [
|
|
22
|
-
{ value: "-createdAt", label: "Newest" },
|
|
23
|
-
{ value: "createdAt", label: "Oldest" },
|
|
24
|
-
];
|
|
25
|
-
const STATUS_OPTIONS = ADMIN_CONTACT_STATUS_TABS;
|
|
26
|
-
function ContactFilterDrawer({ filterOpen, setFilterOpen, activeFilterCount, clearFilters, pendingFilters, setPendingFilters, applyFilters, }) {
|
|
27
|
-
if (!filterOpen)
|
|
28
|
-
return null;
|
|
29
|
-
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: _jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }) }), _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})` : ""] }) })] })] }));
|
|
30
|
-
}
|
|
31
15
|
export function AdminContactView({ children, onBulkMarkRead, onBulkArchive, onBulkDelete, ...props }) {
|
|
32
|
-
const hasChildren = React.Children.count(children) > 0;
|
|
33
|
-
const [view, setView] = useState("table");
|
|
34
16
|
const queryClient = useQueryClient();
|
|
35
17
|
const { showToast } = useToast();
|
|
36
18
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
37
19
|
const [selectedRow, setSelectedRow] = useState(null);
|
|
38
20
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
39
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
40
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
41
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
42
|
-
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
43
|
-
const openFilters = useCallback(() => {
|
|
44
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
45
|
-
setFilterOpen(true);
|
|
46
|
-
}, [table]);
|
|
47
|
-
const applyFilters = useCallback(() => {
|
|
48
|
-
const updates = { page: "1" };
|
|
49
|
-
for (const k of FILTER_KEYS)
|
|
50
|
-
updates[k] = pendingFilters[k] ?? "";
|
|
51
|
-
table.setMany(updates);
|
|
52
|
-
setFilterOpen(false);
|
|
53
|
-
}, [pendingFilters, table]);
|
|
54
|
-
const clearFilters = useCallback(() => {
|
|
55
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
56
|
-
}, []);
|
|
57
|
-
const resetAll = useCallback(() => {
|
|
58
|
-
const updates = { q: "", sort: "" };
|
|
59
|
-
for (const k of FILTER_KEYS)
|
|
60
|
-
updates[k] = "";
|
|
61
|
-
table.setMany(updates);
|
|
62
|
-
setSearchInput("");
|
|
63
|
-
}, [table]);
|
|
64
|
-
const commitSearch = useCallback(() => {
|
|
65
|
-
table.set("q", searchInput.trim());
|
|
66
|
-
}, [searchInput, table]);
|
|
67
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
68
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
69
|
-
const statusRaw = table.get("status");
|
|
70
|
-
const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
|
|
71
|
-
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
72
|
-
queryKey: ["admin", "contact", "listing"],
|
|
73
|
-
endpoint: ADMIN_ENDPOINTS.CONTACT_SUBMISSIONS,
|
|
74
|
-
page: table.getNumber("page", 1),
|
|
75
|
-
pageSize: PAGE_SIZE,
|
|
76
|
-
sorts: table.get("sort") || DEFAULT_SORT,
|
|
77
|
-
filters,
|
|
78
|
-
q: table.get("q") || undefined,
|
|
79
|
-
mapRows: (response) => toRecordArray(response.submissions).map((item, index) => ({
|
|
80
|
-
id: toStringValue(item.id, `msg-${index}`),
|
|
81
|
-
primary: toStringValue(item.subject, "No subject"),
|
|
82
|
-
secondary: [
|
|
83
|
-
toStringValue(item.name, "Unknown"),
|
|
84
|
-
toStringValue(item.email, ""),
|
|
85
|
-
].filter(Boolean).join(" · ") || "—",
|
|
86
|
-
status: toStringValue(item.status, "new"),
|
|
87
|
-
updatedAt: toRelativeDate(item.createdAt),
|
|
88
|
-
_raw: item,
|
|
89
|
-
})),
|
|
90
|
-
getTotal: (response, mappedRows) => {
|
|
91
|
-
if (typeof response.meta?.filteredTotal === "number")
|
|
92
|
-
return response.meta.filteredTotal;
|
|
93
|
-
if (typeof response.meta?.total === "number")
|
|
94
|
-
return response.meta.total;
|
|
95
|
-
return mappedRows.length;
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
21
|
const actionMutation = useMutation({
|
|
99
22
|
mutationFn: async ({ id, action }) => {
|
|
100
23
|
await apiClient.patch(ADMIN_ENDPOINTS.CONTACT_SUBMISSION_BY_ID(id), { action });
|
|
@@ -121,52 +44,104 @@ export function AdminContactView({ children, onBulkMarkRead, onBulkArchive, onBu
|
|
|
121
44
|
showToast(err?.message ?? "Failed to delete.", "error");
|
|
122
45
|
},
|
|
123
46
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
|
|
127
|
-
const bulkActions = [
|
|
128
|
-
...(onBulkMarkRead ? [{
|
|
129
|
-
id: "bulk-mark-read",
|
|
130
|
-
label: ACTIONS.ADMIN["mark-contact-read"].label,
|
|
131
|
-
onClick: async () => { await onBulkMarkRead(selection.selectedIds); selection.clearSelection(); },
|
|
132
|
-
}] : []),
|
|
133
|
-
...(onBulkArchive ? [{
|
|
134
|
-
id: "bulk-archive",
|
|
135
|
-
label: ACTIONS.ADMIN["archive-contact"].label,
|
|
136
|
-
onClick: async () => { await onBulkArchive(selection.selectedIds); selection.clearSelection(); },
|
|
137
|
-
}] : []),
|
|
138
|
-
...(onBulkDelete ? [{
|
|
139
|
-
id: "bulk-delete",
|
|
140
|
-
label: ACTIONS.ADMIN["delete-contact"].label,
|
|
141
|
-
variant: "danger",
|
|
142
|
-
onClick: async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); },
|
|
143
|
-
}] : []),
|
|
144
|
-
];
|
|
145
|
-
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
|
|
146
|
-
if (hasChildren) {
|
|
147
|
-
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
47
|
+
if (React.Children.count(children) > 0) {
|
|
48
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
148
49
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
50
|
+
const config = {
|
|
51
|
+
portal: "admin",
|
|
52
|
+
title: "Contact Submissions",
|
|
53
|
+
searchPlaceholder: "Search by subject, name, or email",
|
|
54
|
+
emptyLabel: "No contact submissions found",
|
|
55
|
+
filterKeys: ["status"],
|
|
56
|
+
defaultSort: "-createdAt",
|
|
57
|
+
queryKey: ["admin", "contact", "listing"],
|
|
58
|
+
endpoint: ADMIN_ENDPOINTS.CONTACT_SUBMISSIONS,
|
|
59
|
+
sortOptions: [
|
|
60
|
+
{ value: "-createdAt", label: "Newest" },
|
|
61
|
+
{ value: "createdAt", label: "Oldest" },
|
|
62
|
+
],
|
|
63
|
+
mapRows: (response) => toRecordArray(response.submissions).map((item, index) => ({
|
|
64
|
+
id: toStringValue(item.id, `msg-${index}`),
|
|
65
|
+
primary: toStringValue(item.subject, "No subject"),
|
|
66
|
+
secondary: [toStringValue(item.name, "Unknown"), toStringValue(item.email, "")]
|
|
67
|
+
.filter(Boolean)
|
|
68
|
+
.join(" · ") || "—",
|
|
69
|
+
status: toStringValue(item.status, "new"),
|
|
70
|
+
updatedAt: toRelativeDate(item.createdAt),
|
|
71
|
+
_raw: item,
|
|
72
|
+
})),
|
|
73
|
+
getTotal: (response, mappedRows) => {
|
|
74
|
+
if (typeof response.meta?.filteredTotal === "number")
|
|
75
|
+
return response.meta.filteredTotal;
|
|
76
|
+
if (typeof response.meta?.total === "number")
|
|
77
|
+
return response.meta.total;
|
|
78
|
+
return mappedRows.length;
|
|
79
|
+
},
|
|
80
|
+
buildFilters: (f) => (f.status && f.status !== "All" ? `status==${f.status}` : undefined),
|
|
81
|
+
buildBulkActions: (selection) => [
|
|
82
|
+
...(onBulkMarkRead
|
|
83
|
+
? [
|
|
84
|
+
buildBulkAction(ACTIONS.ADMIN["mark-contact-read"], async () => {
|
|
85
|
+
await onBulkMarkRead(selection.selectedIds);
|
|
86
|
+
selection.clearSelection();
|
|
87
|
+
}),
|
|
88
|
+
]
|
|
89
|
+
: []),
|
|
90
|
+
...(onBulkArchive
|
|
91
|
+
? [
|
|
92
|
+
buildBulkAction(ACTIONS.ADMIN["archive-contact"], async () => {
|
|
93
|
+
await onBulkArchive(selection.selectedIds);
|
|
94
|
+
selection.clearSelection();
|
|
95
|
+
}),
|
|
96
|
+
]
|
|
97
|
+
: []),
|
|
98
|
+
...(onBulkDelete
|
|
99
|
+
? [
|
|
100
|
+
buildBulkAction(ACTIONS.ADMIN["delete-contact"], async () => {
|
|
101
|
+
await onBulkDelete(selection.selectedIds);
|
|
102
|
+
selection.clearSelection();
|
|
103
|
+
}),
|
|
104
|
+
]
|
|
105
|
+
: []),
|
|
106
|
+
],
|
|
107
|
+
renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
|
|
108
|
+
{
|
|
109
|
+
label: ROW_ACTION_META[ROW_ACTION_ID.VIEW].label,
|
|
110
|
+
onClick: () => {
|
|
111
|
+
setSelectedRow(row);
|
|
112
|
+
setDrawerOpen(true);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: ACTIONS.ADMIN["mark-contact-read"].label,
|
|
117
|
+
disabled: row.status === "read" || row.status === "resolved",
|
|
118
|
+
onClick: () => actionMutation.mutate({ id: row.id, action: "read" }),
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
label: ACTIONS.ADMIN["archive-contact"].label,
|
|
122
|
+
disabled: row.status === "resolved",
|
|
123
|
+
onClick: () => actionMutation.mutate({ id: row.id, action: "resolved" }),
|
|
124
|
+
},
|
|
125
|
+
{ separator: true, label: "", onClick: () => { } },
|
|
126
|
+
{
|
|
127
|
+
label: ACTIONS.ADMIN["delete-contact"].label,
|
|
128
|
+
destructive: true,
|
|
129
|
+
onClick: () => {
|
|
130
|
+
setSelectedRow(row);
|
|
131
|
+
setDeleteOpen(true);
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
] })),
|
|
135
|
+
renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_CONTACT_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
|
|
136
|
+
};
|
|
137
|
+
return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), _jsx(AdminContactEditorView, { open: drawerOpen, onClose: () => {
|
|
138
|
+
setDrawerOpen(false);
|
|
139
|
+
setSelectedRow(null);
|
|
140
|
+
}, submissionId: selectedRow?.id, subject: toStringValue(selectedRow?._raw?.subject, "No subject"), name: toStringValue(selectedRow?._raw?.name, ""), email: toStringValue(selectedRow?._raw?.email, ""), message: toStringValue(selectedRow?._raw?.message ?? selectedRow?._raw?.body, ""), currentStatus: selectedRow?.status }), _jsx(ConfirmDeleteModal, { isOpen: deleteOpen, onClose: () => {
|
|
141
|
+
setDeleteOpen(false);
|
|
142
|
+
setSelectedRow(null);
|
|
143
|
+
}, onConfirm: () => {
|
|
144
|
+
if (selectedRow)
|
|
145
|
+
deleteMutation.mutate(selectedRow.id);
|
|
146
|
+
}, isDeleting: deleteMutation.isPending, title: "Delete submission?", message: "This contact submission will be permanently removed.", confirmText: "Delete", variant: "danger" })] }));
|
|
172
147
|
}
|