@mohasinac/appkit 2.3.2 → 2.4.1
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/client.d.ts +48 -12
- package/dist/client.js +25 -6
- package/dist/constants/api-endpoints.d.ts +380 -22
- package/dist/constants/api-endpoints.js +66 -13
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/core/hooks/useSyncManager.d.ts +1 -0
- package/dist/core/hooks/useSyncManager.js +83 -0
- package/dist/core/integration-keys.d.ts +4 -0
- package/dist/core/integration-keys.js +8 -0
- package/dist/features/about/components/FAQPageView.js +9 -11
- package/dist/features/about/components/PolicyPageView.js +32 -11
- package/dist/features/about/components/PublicProfileView.js +77 -11
- package/dist/features/account/components/AddressesIndexListing.js +63 -38
- package/dist/features/account/components/UserOffersPanel.d.ts +8 -0
- package/dist/features/account/components/UserOffersPanel.js +81 -0
- package/dist/features/account/components/UserSettingsView.d.ts +2 -1
- package/dist/features/account/components/UserSettingsView.js +2 -1
- package/dist/features/account/components/UserSidebar.d.ts +6 -1
- package/dist/features/account/components/UserSidebar.js +48 -42
- package/dist/features/account/components/index.d.ts +2 -0
- package/dist/features/account/components/index.js +1 -0
- package/dist/features/admin/actions/admin-actions.d.ts +1 -1
- package/dist/features/admin/actions/admin-actions.js +13 -3
- package/dist/features/admin/components/AdminAdEditorView.js +6 -7
- package/dist/features/admin/components/AdminAllEventEntriesView.d.ts +4 -0
- package/dist/features/admin/components/AdminAllEventEntriesView.js +102 -0
- package/dist/features/admin/components/AdminBidsView.js +94 -8
- package/dist/features/admin/components/AdminBlogEditorView.d.ts +7 -0
- package/dist/features/admin/components/AdminBlogEditorView.js +162 -0
- package/dist/features/admin/components/AdminBlogView.d.ts +4 -1
- package/dist/features/admin/components/AdminBlogView.js +61 -31
- package/dist/features/admin/components/AdminBrandEditorView.d.ts +7 -0
- package/dist/features/admin/components/AdminBrandEditorView.js +104 -0
- package/dist/features/admin/components/AdminBrandsView.d.ts +4 -0
- package/dist/features/admin/components/AdminBrandsView.js +76 -0
- package/dist/features/admin/components/AdminCarouselEditorView.d.ts +8 -0
- package/dist/features/admin/components/AdminCarouselEditorView.js +204 -0
- package/dist/features/admin/components/AdminCarouselView.js +153 -34
- package/dist/features/admin/components/AdminCartsView.d.ts +4 -0
- package/dist/features/admin/components/AdminCartsView.js +82 -0
- package/dist/features/admin/components/AdminCategoriesView.d.ts +4 -1
- package/dist/features/admin/components/AdminCategoriesView.js +66 -48
- package/dist/features/admin/components/AdminCategoryEditorView.d.ts +7 -0
- package/dist/features/admin/components/AdminCategoryEditorView.js +115 -0
- package/dist/features/admin/components/AdminContactEditorView.d.ts +11 -0
- package/dist/features/admin/components/AdminContactEditorView.js +32 -0
- package/dist/features/admin/components/AdminContactView.js +111 -20
- package/dist/features/admin/components/AdminCouponEditorView.d.ts +7 -0
- package/dist/features/admin/components/AdminCouponEditorView.js +179 -0
- package/dist/features/admin/components/AdminCouponsView.d.ts +4 -1
- package/dist/features/admin/components/AdminCouponsView.js +57 -9
- package/dist/features/admin/components/AdminDashboardView.js +3 -0
- package/dist/features/admin/components/AdminFaqEditorView.d.ts +7 -0
- package/dist/features/admin/components/AdminFaqEditorView.js +128 -0
- package/dist/features/admin/components/AdminFaqsView.d.ts +4 -1
- package/dist/features/admin/components/AdminFaqsView.js +55 -23
- package/dist/features/admin/components/AdminFeatureFlagsView.js +33 -24
- package/dist/features/admin/components/AdminListingScaffold.d.ts +7 -1
- package/dist/features/admin/components/AdminListingScaffold.js +2 -2
- package/dist/features/admin/components/AdminMediaView.js +18 -8
- package/dist/features/admin/components/AdminNavEditorView.d.ts +20 -0
- package/dist/features/admin/components/AdminNavEditorView.js +84 -0
- package/dist/features/admin/components/AdminNavigationView.d.ts +1 -7
- package/dist/features/admin/components/AdminNavigationView.js +84 -72
- package/dist/features/admin/components/AdminNewsletterView.js +102 -20
- package/dist/features/admin/components/AdminNotificationsView.d.ts +4 -0
- package/dist/features/admin/components/AdminNotificationsView.js +119 -0
- package/dist/features/admin/components/AdminOrderEditorView.d.ts +8 -0
- package/dist/features/admin/components/AdminOrderEditorView.js +74 -0
- package/dist/features/admin/components/AdminOrdersView.js +64 -8
- package/dist/features/admin/components/AdminPayoutsView.js +122 -13
- package/dist/features/admin/components/AdminProductEditorView.d.ts +7 -0
- package/dist/features/admin/components/AdminProductEditorView.js +143 -0
- package/dist/features/admin/components/AdminProductsView.d.ts +4 -1
- package/dist/features/admin/components/AdminProductsView.js +119 -30
- package/dist/features/admin/components/AdminReturnRequestsView.d.ts +5 -0
- package/dist/features/admin/components/AdminReturnRequestsView.js +101 -0
- package/dist/features/admin/components/AdminReviewsView.js +138 -28
- package/dist/features/admin/components/AdminSectionsView.js +361 -472
- package/dist/features/admin/components/AdminSessionsView.d.ts +4 -0
- package/dist/features/admin/components/AdminSessionsView.js +119 -0
- package/dist/features/admin/components/AdminSidebar.d.ts +18 -3
- package/dist/features/admin/components/AdminSidebar.js +51 -4
- package/dist/features/admin/components/AdminSiteSettingsView.d.ts +7 -0
- package/dist/features/admin/components/AdminSiteSettingsView.js +319 -0
- package/dist/features/admin/components/AdminStoreAddressesView.d.ts +5 -0
- package/dist/features/admin/components/AdminStoreAddressesView.js +52 -0
- package/dist/features/admin/components/AdminStoreEditorView.d.ts +9 -0
- package/dist/features/admin/components/AdminStoreEditorView.js +55 -0
- package/dist/features/admin/components/AdminStoresView.js +62 -20
- package/dist/features/admin/components/AdminUserEditorView.d.ts +10 -0
- package/dist/features/admin/components/AdminUserEditorView.js +72 -0
- package/dist/features/admin/components/AdminUsersView.js +70 -36
- package/dist/features/admin/components/AdminWishlistsView.d.ts +4 -0
- package/dist/features/admin/components/AdminWishlistsView.js +53 -0
- package/dist/features/admin/components/BrandQuickCreateForm.d.ts +5 -0
- package/dist/features/admin/components/BrandQuickCreateForm.js +36 -0
- package/dist/features/admin/components/CategoryQuickCreateForm.d.ts +5 -0
- package/dist/features/admin/components/CategoryQuickCreateForm.js +35 -0
- package/dist/features/admin/components/DataTable.d.ts +4 -2
- package/dist/features/admin/components/DataTable.js +26 -6
- package/dist/features/admin/components/index.d.ts +47 -1
- package/dist/features/admin/components/index.js +23 -0
- package/dist/features/admin/components/sections/adminSectionsBuildParse.d.ts +48 -0
- package/dist/features/admin/components/sections/adminSectionsBuildParse.js +653 -0
- package/dist/features/admin/components/sections/adminSectionsTypes.d.ts +298 -0
- package/dist/features/admin/components/sections/adminSectionsTypes.js +278 -0
- package/dist/features/admin/schemas/firestore.d.ts +26 -0
- package/dist/features/admin/schemas/firestore.js +1 -0
- package/dist/features/admin/types/product.types.d.ts +2 -3
- package/dist/features/auctions/actions/bid-actions.js +6 -2
- package/dist/features/auctions/components/AuctionDetailPageView.d.ts +3 -1
- package/dist/features/auctions/components/AuctionDetailPageView.js +38 -12
- package/dist/features/auctions/components/AuctionFilters.d.ts +3 -1
- package/dist/features/auctions/components/AuctionFilters.js +6 -2
- package/dist/features/auctions/components/CollapsibleBidHistory.d.ts +7 -0
- package/dist/features/auctions/components/CollapsibleBidHistory.js +8 -0
- package/dist/features/auctions/components/MarketplaceAuctionCard.d.ts +4 -0
- package/dist/features/auctions/components/MarketplaceAuctionCard.js +43 -9
- package/dist/features/auctions/components/MarketplaceAuctionGrid.js +1 -0
- package/dist/features/auctions/components/PlaceBidFormClient.d.ts +18 -0
- package/dist/features/auctions/components/PlaceBidFormClient.js +33 -0
- package/dist/features/auctions/hooks/useAuctions.d.ts +1 -0
- package/dist/features/auctions/hooks/useAuctions.js +1 -0
- package/dist/features/auctions/schemas/index.d.ts +22 -12
- package/dist/features/auth/actions/profile-actions.d.ts +5 -3
- package/dist/features/auth/actions/profile-actions.js +30 -11
- package/dist/features/auth/auth-helpers.js +1 -0
- package/dist/features/auth/components/LoginForm.js +2 -1
- package/dist/features/auth/hooks/useAuth.js +16 -4
- package/dist/features/auth/permissions/constants.d.ts +63 -0
- package/dist/features/auth/permissions/constants.js +323 -0
- package/dist/features/auth/schemas/firestore.d.ts +20 -0
- package/dist/features/auth/schemas/index.d.ts +4 -4
- package/dist/features/auth/schemas/index.js +3 -2
- package/dist/features/auth/types/index.d.ts +1 -1
- package/dist/features/before-after/schemas/index.d.ts +2 -2
- package/dist/features/blog/actions/blog-actions.d.ts +15 -15
- package/dist/features/blog/components/BlogFilters.js +1 -1
- package/dist/features/blog/components/BlogIndexListing.js +57 -5
- package/dist/features/blog/components/BlogIndexPageView.js +14 -2
- package/dist/features/blog/components/BlogPostForm.js +6 -2
- package/dist/features/blog/components/BlogPostView.js +2 -1
- package/dist/features/blog/hooks/useBlog.d.ts +2 -0
- package/dist/features/blog/hooks/useBlog.js +2 -0
- package/dist/features/blog/schemas/index.d.ts +46 -12
- package/dist/features/brands/actions/brand-actions.d.ts +2 -0
- package/dist/features/brands/actions/brand-actions.js +5 -0
- package/dist/features/brands/index.d.ts +3 -0
- package/dist/features/brands/index.js +3 -0
- package/dist/features/brands/repository/brands.repository.d.ts +13 -0
- package/dist/features/brands/repository/brands.repository.js +60 -0
- package/dist/features/brands/schemas/index.d.ts +33 -0
- package/dist/features/brands/schemas/index.js +15 -0
- package/dist/features/brands/server.d.ts +7 -0
- package/dist/features/brands/server.js +7 -0
- package/dist/features/cart/actions/cart-actions.js +2 -2
- package/dist/features/cart/components/CartDrawer.d.ts +5 -1
- package/dist/features/cart/components/CartDrawer.js +3 -3
- package/dist/features/cart/hooks/useCartCount.d.ts +3 -2
- package/dist/features/cart/hooks/useCartCount.js +4 -2
- package/dist/features/cart/hooks/useGuestCartMerge.js +1 -1
- package/dist/features/cart/index.d.ts +1 -0
- package/dist/features/cart/index.js +1 -0
- package/dist/features/cart/repository/cart.repository.d.ts +5 -1
- package/dist/features/cart/repository/cart.repository.js +36 -5
- package/dist/features/cart/schemas/firestore.d.ts +25 -6
- package/dist/features/cart/schemas/firestore.js +2 -2
- package/dist/features/cart/schemas/index.d.ts +9 -9
- package/dist/features/cart/schemas/index.js +1 -1
- package/dist/features/cart/types/index.d.ts +1 -1
- package/dist/features/cart/utils/pending-ops.d.ts +33 -0
- package/dist/features/cart/utils/pending-ops.js +102 -0
- package/dist/features/categories/components/BrandDetailPageView.d.ts +4 -0
- package/dist/features/categories/components/BrandDetailPageView.js +54 -0
- package/dist/features/categories/components/BrandDetailTabs.d.ts +10 -0
- package/dist/features/categories/components/BrandDetailTabs.js +22 -0
- package/dist/features/categories/components/CategoriesIndexListing.d.ts +3 -1
- package/dist/features/categories/components/CategoriesIndexListing.js +83 -7
- package/dist/features/categories/components/CategoryDetailPageView.js +42 -21
- package/dist/features/categories/components/CategoryDetailTabs.d.ts +7 -1
- package/dist/features/categories/components/CategoryDetailTabs.js +12 -7
- package/dist/features/categories/components/CategoryFilters.js +1 -1
- package/dist/features/categories/components/CategoryForm.js +10 -4
- package/dist/features/categories/components/CategoryProductsListing.d.ts +4 -1
- package/dist/features/categories/components/CategoryProductsListing.js +34 -5
- package/dist/features/categories/components/ConcernCard.js +1 -1
- package/dist/features/categories/hooks/useCategories.js +2 -0
- package/dist/features/categories/repository/categories.repository.js +2 -3
- package/dist/features/categories/schemas/firestore.d.ts +23 -2
- package/dist/features/categories/schemas/firestore.js +8 -0
- package/dist/features/categories/schemas/index.d.ts +8 -8
- package/dist/features/categories/types/index.d.ts +1 -0
- package/dist/features/collections/schemas/index.d.ts +2 -2
- package/dist/features/events/components/AdminEventEditorView.js +2 -2
- package/dist/features/events/components/AdminEventsView.d.ts +4 -1
- package/dist/features/events/components/AdminEventsView.js +64 -38
- package/dist/features/events/components/EventCard.js +1 -1
- package/dist/features/events/components/EventFilters.js +1 -1
- package/dist/features/events/components/EventPollWidget.d.ts +12 -0
- package/dist/features/events/components/EventPollWidget.js +62 -0
- package/dist/features/events/components/EventsIndexListing.js +57 -5
- package/dist/features/events/components/EventsListPageView.js +1 -1
- package/dist/features/events/components/index.d.ts +2 -0
- package/dist/features/events/components/index.js +1 -0
- package/dist/features/events/hooks/useEvents.d.ts +1 -0
- package/dist/features/events/hooks/useEvents.js +1 -0
- package/dist/features/events/repository/events.repository.js +3 -0
- package/dist/features/events/schemas/firestore.d.ts +1 -0
- package/dist/features/events/schemas/index.d.ts +44 -0
- package/dist/features/events/types/index.d.ts +2 -0
- package/dist/features/faq/actions/faq-actions.d.ts +16 -16
- package/dist/features/faq/hooks/useFaqList.js +1 -1
- package/dist/features/faq/schemas/firestore.d.ts +2 -2
- package/dist/features/faq/schemas/firestore.js +2 -1
- package/dist/features/faq/schemas/index.d.ts +4 -4
- package/dist/features/filters/FilterFacetSection.d.ts +1 -0
- package/dist/features/filters/FilterFacetSection.js +13 -1
- package/dist/features/filters/SwitchFilter.js +1 -1
- package/dist/features/grouped/schemas/firestore.d.ts +32 -0
- package/dist/features/grouped/schemas/firestore.js +19 -0
- package/dist/features/homepage/components/AdSlot.d.ts +1 -3
- package/dist/features/homepage/components/AdSlot.js +15 -14
- package/dist/features/homepage/components/BlogArticlesSection.d.ts +3 -1
- package/dist/features/homepage/components/BlogArticlesSection.js +2 -2
- package/dist/features/homepage/components/BrandsSection.d.ts +3 -1
- package/dist/features/homepage/components/BrandsSection.js +4 -3
- package/dist/features/homepage/components/CustomCardsSection.d.ts +3 -0
- package/dist/features/homepage/components/CustomCardsSection.js +76 -0
- package/dist/features/homepage/components/EventsSection.d.ts +3 -1
- package/dist/features/homepage/components/EventsSection.js +2 -2
- package/dist/features/homepage/components/FeaturedAuctionsSection.d.ts +4 -1
- package/dist/features/homepage/components/FeaturedAuctionsSection.js +2 -2
- package/dist/features/homepage/components/FeaturedPreOrdersSection.d.ts +4 -1
- package/dist/features/homepage/components/FeaturedPreOrdersSection.js +2 -2
- package/dist/features/homepage/components/FeaturedProductsSection.d.ts +4 -1
- package/dist/features/homepage/components/FeaturedProductsSection.js +8 -3
- package/dist/features/homepage/components/FeaturedStoresSection.d.ts +3 -1
- package/dist/features/homepage/components/FeaturedStoresSection.js +2 -2
- package/dist/features/homepage/components/GoogleReviewsSection.d.ts +3 -0
- package/dist/features/homepage/components/GoogleReviewsSection.js +65 -0
- package/dist/features/homepage/components/HeroCarousel.js +128 -84
- package/dist/features/homepage/components/MarketplaceHomepageView.d.ts +2 -20
- package/dist/features/homepage/components/MarketplaceHomepageView.js +73 -230
- package/dist/features/homepage/components/SectionCarousel.d.ts +1 -1
- package/dist/features/homepage/components/SectionCarousel.js +2 -0
- package/dist/features/homepage/components/ShopByCategorySection.d.ts +3 -1
- package/dist/features/homepage/components/ShopByCategorySection.js +8 -4
- package/dist/features/homepage/components/SocialFeedSection.d.ts +3 -0
- package/dist/features/homepage/components/SocialFeedSection.js +86 -0
- package/dist/features/homepage/components/SocialPostCard.d.ts +7 -0
- package/dist/features/homepage/components/SocialPostCard.js +39 -0
- package/dist/features/homepage/components/StatsCounterSection.js +1 -1
- package/dist/features/homepage/components/WelcomeSection.js +1 -1
- package/dist/features/homepage/components/WhatsAppCommunitySection.js +1 -1
- package/dist/features/homepage/hooks/useActiveAd.d.ts +23 -0
- package/dist/features/homepage/hooks/useActiveAd.js +20 -0
- package/dist/features/homepage/hooks/useBlogArticles.d.ts +1 -0
- package/dist/features/homepage/hooks/useBlogArticles.js +10 -0
- package/dist/features/homepage/hooks/useFeaturedAuctions.d.ts +4 -1
- package/dist/features/homepage/hooks/useFeaturedAuctions.js +8 -4
- package/dist/features/homepage/hooks/useFeaturedPreOrders.d.ts +4 -1
- package/dist/features/homepage/hooks/useFeaturedPreOrders.js +8 -4
- package/dist/features/homepage/hooks/useFeaturedProducts.d.ts +1 -0
- package/dist/features/homepage/hooks/useFeaturedProducts.js +6 -3
- package/dist/features/homepage/hooks/useFeaturedStores.d.ts +3 -1
- package/dist/features/homepage/hooks/useFeaturedStores.js +2 -1
- package/dist/features/homepage/hooks/useHomepageEvents.d.ts +3 -1
- package/dist/features/homepage/hooks/useHomepageEvents.js +2 -1
- package/dist/features/homepage/hooks/useTopBrands.d.ts +3 -1
- package/dist/features/homepage/hooks/useTopBrands.js +2 -1
- package/dist/features/homepage/index.d.ts +2 -0
- package/dist/features/homepage/index.js +1 -0
- package/dist/features/homepage/lib/google-reviews-fetcher.d.ts +14 -0
- package/dist/features/homepage/lib/google-reviews-fetcher.js +27 -0
- package/dist/features/homepage/lib/live-stats.d.ts +14 -0
- package/dist/features/homepage/lib/live-stats.js +62 -0
- package/dist/features/homepage/lib/section-defaults.d.ts +11 -0
- package/dist/features/homepage/lib/section-defaults.js +45 -0
- package/dist/features/homepage/lib/section-helpers.d.ts +5 -0
- package/dist/features/homepage/lib/section-helpers.js +25 -0
- package/dist/features/homepage/lib/section-renderer.d.ts +33 -0
- package/dist/features/homepage/lib/section-renderer.js +164 -0
- package/dist/features/homepage/lib/social-feed-fetcher.d.ts +5 -0
- package/dist/features/homepage/lib/social-feed-fetcher.js +193 -0
- package/dist/features/homepage/schemas/firestore.d.ts +180 -29
- package/dist/features/homepage/schemas/firestore.js +5 -0
- package/dist/features/homepage/types/index.d.ts +48 -19
- package/dist/features/layout/AppLayoutShell.d.ts +6 -1
- package/dist/features/layout/AppLayoutShell.js +25 -9
- package/dist/features/layout/BottomActions.js +1 -1
- package/dist/features/layout/BottomNavbar.d.ts +15 -1
- package/dist/features/layout/BottomNavbar.js +8 -2
- package/dist/features/layout/FooterLayout.d.ts +7 -1
- package/dist/features/layout/FooterLayout.js +3 -3
- package/dist/features/layout/ListingLayout.js +2 -2
- package/dist/features/layout/MainNavbar.d.ts +6 -14
- package/dist/features/layout/MainNavbar.js +4 -16
- package/dist/features/layout/NavItem.js +1 -1
- package/dist/features/layout/NavbarLayout.d.ts +3 -1
- package/dist/features/layout/NavbarLayout.js +5 -5
- package/dist/features/layout/TitleBar.d.ts +4 -2
- package/dist/features/layout/TitleBar.js +5 -3
- package/dist/features/layout/TitleBarLayout.d.ts +3 -1
- package/dist/features/layout/TitleBarLayout.js +2 -2
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/media/MediaPickerModal.d.ts +30 -0
- package/dist/features/media/MediaPickerModal.js +72 -0
- package/dist/features/media/index.d.ts +3 -1
- package/dist/features/media/index.js +1 -0
- package/dist/features/media/types/index.d.ts +12 -0
- package/dist/features/media/types/index.js +4 -2
- package/dist/features/media/upload/MediaUploadField.d.ts +5 -1
- package/dist/features/media/upload/MediaUploadField.js +56 -3
- package/dist/features/messages/schemas/firestore.d.ts +36 -0
- package/dist/features/messages/schemas/firestore.js +16 -0
- package/dist/features/orders/repository/orders.repository.d.ts +2 -2
- package/dist/features/orders/repository/orders.repository.js +2 -2
- package/dist/features/orders/schemas/firestore.d.ts +17 -4
- package/dist/features/orders/schemas/firestore.js +2 -2
- package/dist/features/orders/schemas/index.d.ts +18 -18
- package/dist/features/orders/schemas/index.js +3 -3
- package/dist/features/orders/types/index.d.ts +1 -1
- package/dist/features/orders/utils/order-splitter.d.ts +1 -1
- package/dist/features/orders/utils/order-splitter.js +2 -2
- package/dist/features/payments/repository/payout.repository.d.ts +4 -4
- package/dist/features/payments/repository/payout.repository.js +7 -7
- package/dist/features/payments/schemas/firestore.d.ts +6 -6
- package/dist/features/payments/schemas/firestore.js +6 -6
- package/dist/features/pre-orders/components/MarketplacePreorderCard.js +11 -10
- package/dist/features/pre-orders/components/PreOrderActionsClient.d.ts +11 -0
- package/dist/features/pre-orders/components/PreOrderActionsClient.js +28 -0
- package/dist/features/pre-orders/components/PreOrderDetailPageView.d.ts +2 -1
- package/dist/features/pre-orders/components/PreOrderDetailPageView.js +27 -9
- package/dist/features/pre-orders/components/PreOrderFilters.d.ts +3 -1
- package/dist/features/pre-orders/components/PreOrderFilters.js +9 -6
- package/dist/features/pre-orders/components/PreOrdersIndexListing.d.ts +3 -1
- package/dist/features/pre-orders/components/PreOrdersIndexListing.js +132 -36
- package/dist/features/pre-orders/components/PreOrdersListView.js +3 -3
- package/dist/features/pre-orders/components/PreorderCard.js +1 -1
- package/dist/features/pre-orders/schemas/index.d.ts +10 -0
- package/dist/features/products/actions/product-actions.d.ts +2 -2
- package/dist/features/products/actions/product-actions.js +5 -5
- package/dist/features/products/api/[id]/route.js +5 -2
- package/dist/features/products/api/route.js +10 -14
- package/dist/features/products/columns/productTableColumns.js +2 -2
- package/dist/features/products/components/AuctionDetailView.d.ts +2 -1
- package/dist/features/products/components/AuctionDetailView.js +2 -2
- package/dist/features/products/components/AuctionsIndexListing.d.ts +3 -1
- package/dist/features/products/components/AuctionsIndexListing.js +93 -31
- package/dist/features/products/components/BidHistory.d.ts +2 -1
- package/dist/features/products/components/BidHistory.js +18 -2
- package/dist/features/products/components/MakeOfferButton.d.ts +10 -0
- package/dist/features/products/components/MakeOfferButton.js +68 -0
- package/dist/features/products/components/ProductDetailPageView.d.ts +11 -1
- package/dist/features/products/components/ProductDetailPageView.js +27 -8
- package/dist/features/products/components/ProductFilters.d.ts +7 -1
- package/dist/features/products/components/ProductFilters.js +4 -2
- package/dist/features/products/components/ProductForm.d.ts +19 -1
- package/dist/features/products/components/ProductForm.js +24 -6
- package/dist/features/products/components/ProductGrid.d.ts +10 -2
- package/dist/features/products/components/ProductGrid.js +76 -29
- package/dist/features/products/components/ProductsIndexListing.js +131 -45
- package/dist/features/products/components/RelatedProductsCarousel.js +1 -1
- package/dist/features/products/components/ShareButton.d.ts +7 -0
- package/dist/features/products/components/ShareButton.js +22 -0
- package/dist/features/products/components/index.d.ts +2 -0
- package/dist/features/products/components/index.js +1 -0
- package/dist/features/products/hooks/useProducts.d.ts +7 -0
- package/dist/features/products/hooks/useProducts.js +6 -4
- package/dist/features/products/repository/products.repository.d.ts +4 -8
- package/dist/features/products/repository/products.repository.js +17 -50
- package/dist/features/products/schemas/firestore.d.ts +11 -9
- package/dist/features/products/schemas/firestore.js +11 -3
- package/dist/features/products/schemas/index.d.ts +51 -50
- package/dist/features/products/schemas/index.js +2 -5
- package/dist/features/products/types/index.d.ts +13 -5
- package/dist/features/promotions/actions/coupon-actions.d.ts +2 -2
- package/dist/features/promotions/actions/coupon-actions.js +1 -1
- package/dist/features/promotions/actions/seller-coupon-actions.js +11 -6
- package/dist/features/promotions/api/route.js +3 -3
- package/dist/features/promotions/components/CouponCard.js +16 -7
- package/dist/features/promotions/components/CouponsIndexListing.js +3 -9
- package/dist/features/promotions/hooks/useCouponValidate.d.ts +1 -1
- package/dist/features/promotions/hooks/usePromotions.js +2 -2
- package/dist/features/promotions/repository/coupons.repository.d.ts +21 -15
- package/dist/features/promotions/repository/coupons.repository.js +97 -125
- package/dist/features/promotions/schemas/firestore.d.ts +31 -2
- package/dist/features/promotions/schemas/firestore.js +29 -0
- package/dist/features/promotions/schemas/index.d.ts +9 -12
- package/dist/features/promotions/schemas/index.js +1 -2
- package/dist/features/promotions/types/index.d.ts +1 -2
- package/dist/features/reviews/actions/review-actions.js +3 -2
- package/dist/features/reviews/components/ReviewDetailPageView.js +5 -9
- package/dist/features/reviews/components/ReviewFilters.js +1 -1
- package/dist/features/reviews/components/ReviewsIndexListing.js +58 -7
- package/dist/features/reviews/components/ReviewsList.js +2 -2
- package/dist/features/reviews/hooks/useReviews.d.ts +1 -0
- package/dist/features/reviews/hooks/useReviews.js +2 -1
- package/dist/features/reviews/repository/reviews.repository.d.ts +9 -4
- package/dist/features/reviews/repository/reviews.repository.js +18 -7
- package/dist/features/reviews/schemas/firestore.d.ts +5 -2
- package/dist/features/reviews/schemas/firestore.js +1 -0
- package/dist/features/reviews/schemas/index.d.ts +19 -16
- package/dist/features/reviews/schemas/index.js +3 -2
- package/dist/features/reviews/types/index.d.ts +3 -2
- package/dist/features/scams/actions/scam-actions.d.ts +29 -0
- package/dist/features/scams/actions/scam-actions.js +62 -0
- package/dist/features/scams/components/ScamProfileView.d.ts +10 -0
- package/dist/features/scams/components/ScamProfileView.js +51 -0
- package/dist/features/scams/components/ScamRegistryView.d.ts +6 -0
- package/dist/features/scams/components/ScamRegistryView.js +41 -0
- package/dist/features/scams/components/index.d.ts +4 -0
- package/dist/features/scams/components/index.js +2 -0
- package/dist/features/scams/constants/scam-types.d.ts +38 -0
- package/dist/features/scams/constants/scam-types.js +443 -0
- package/dist/features/scams/repository/scammer.repository.d.ts +67 -0
- package/dist/features/scams/repository/scammer.repository.js +160 -0
- package/dist/features/scams/schemas/firestore.d.ts +362 -0
- package/dist/features/scams/schemas/firestore.js +233 -0
- package/dist/features/search/components/Search.d.ts +12 -2
- package/dist/features/search/components/Search.js +26 -7
- package/dist/features/search/components/index.d.ts +1 -1
- package/dist/features/search/hooks/useNavSuggestions.d.ts +1 -1
- package/dist/features/search/hooks/useNavSuggestions.js +2 -2
- package/dist/features/search/schemas/index.d.ts +7 -7
- package/dist/features/seller/actions/offer-actions.js +52 -36
- package/dist/features/seller/actions/seller-actions.js +19 -13
- package/dist/features/seller/api/products/route.js +9 -4
- package/dist/features/seller/components/SellerAddressesView.d.ts +3 -12
- package/dist/features/seller/components/SellerAddressesView.js +144 -4
- package/dist/features/seller/components/SellerAuctionsView.js +58 -5
- package/dist/features/seller/components/SellerBidsView.d.ts +4 -0
- package/dist/features/seller/components/SellerBidsView.js +131 -0
- package/dist/features/seller/components/SellerCouponEditorView.d.ts +19 -0
- package/dist/features/seller/components/SellerCouponEditorView.js +67 -0
- package/dist/features/seller/components/SellerCouponsView.d.ts +5 -3
- package/dist/features/seller/components/SellerCouponsView.js +135 -13
- package/dist/features/seller/components/SellerCreateProductView.d.ts +4 -10
- package/dist/features/seller/components/SellerCreateProductView.js +4 -3
- package/dist/features/seller/components/SellerEditProductView.d.ts +4 -10
- package/dist/features/seller/components/SellerEditProductView.js +4 -3
- package/dist/features/seller/components/SellerOffersPanel.d.ts +20 -0
- package/dist/features/seller/components/SellerOffersPanel.js +138 -0
- package/dist/features/seller/components/SellerOffersView.js +56 -5
- package/dist/features/seller/components/SellerOrdersView.d.ts +2 -1
- package/dist/features/seller/components/SellerOrdersView.js +185 -16
- package/dist/features/seller/components/SellerPayoutRequestView.d.ts +7 -0
- package/dist/features/seller/components/SellerPayoutRequestView.js +63 -0
- package/dist/features/seller/components/SellerPayoutSettingsView.d.ts +3 -10
- package/dist/features/seller/components/SellerPayoutSettingsView.js +89 -3
- package/dist/features/seller/components/SellerPayoutsView.js +56 -5
- package/dist/features/seller/components/SellerProductShell.d.ts +68 -0
- package/dist/features/seller/components/SellerProductShell.js +179 -0
- package/dist/features/seller/components/SellerProductsView.d.ts +2 -3
- package/dist/features/seller/components/SellerProductsView.js +194 -18
- package/dist/features/seller/components/SellerReviewsView.d.ts +5 -0
- package/dist/features/seller/components/SellerReviewsView.js +100 -0
- package/dist/features/seller/components/SellerShippingView.d.ts +3 -11
- package/dist/features/seller/components/SellerShippingView.js +87 -3
- package/dist/features/seller/components/SellerSidebar.d.ts +11 -3
- package/dist/features/seller/components/SellerSidebar.js +52 -8
- package/dist/features/seller/components/SellerStorefrontView.d.ts +26 -11
- package/dist/features/seller/components/SellerStorefrontView.js +45 -7
- package/dist/features/seller/components/index.d.ts +16 -2
- package/dist/features/seller/components/index.js +7 -0
- package/dist/features/seller/hooks/useSellerListingData.d.ts +3 -1
- package/dist/features/seller/hooks/useSellerListingData.js +6 -4
- package/dist/features/seller/repository/offer.repository.d.ts +3 -3
- package/dist/features/seller/repository/offer.repository.js +6 -6
- package/dist/features/seller/schemas/firestore.d.ts +7 -7
- package/dist/features/seller/schemas/firestore.js +4 -4
- package/dist/features/seller/schemas/index.d.ts +16 -16
- package/dist/features/shell/FormShell.d.ts +29 -0
- package/dist/features/shell/FormShell.js +103 -0
- package/dist/features/shell/QuickFormDrawer.d.ts +29 -0
- package/dist/features/shell/QuickFormDrawer.js +117 -0
- package/dist/features/shell/StepForm.d.ts +44 -0
- package/dist/features/shell/StepForm.js +81 -0
- package/dist/features/shell/index.d.ts +6 -0
- package/dist/features/shell/index.js +3 -0
- package/dist/features/stores/actions/store-query-actions.js +3 -3
- package/dist/features/stores/api/[storeSlug]/auctions/route.js +1 -1
- package/dist/features/stores/api/[storeSlug]/products/route.js +1 -1
- package/dist/features/stores/api/[storeSlug]/reviews/route.js +1 -1
- package/dist/features/stores/components/InteractiveStoreCard.d.ts +2 -2
- package/dist/features/stores/components/InteractiveStoreCard.js +21 -7
- package/dist/features/stores/components/StoreAboutView.js +1 -1
- package/dist/features/stores/components/StoreAuctionsListing.d.ts +5 -2
- package/dist/features/stores/components/StoreAuctionsListing.js +81 -8
- package/dist/features/stores/components/StoreAuctionsPageView.js +8 -7
- package/dist/features/stores/components/StoreDetailLayoutView.d.ts +1 -0
- package/dist/features/stores/components/StoreDetailLayoutView.js +29 -5
- package/dist/features/stores/components/StoreHeader.js +2 -1
- package/dist/features/stores/components/StorePreOrdersListing.d.ts +4 -2
- package/dist/features/stores/components/StorePreOrdersListing.js +59 -7
- package/dist/features/stores/components/StorePreOrdersPageView.js +8 -7
- package/dist/features/stores/components/StoreProductsListing.d.ts +5 -2
- package/dist/features/stores/components/StoreProductsListing.js +97 -8
- package/dist/features/stores/components/StoreProductsPageView.js +8 -7
- package/dist/features/stores/components/StoreReviewsListing.js +2 -2
- package/dist/features/stores/components/StoresIndexListing.js +74 -11
- package/dist/features/stores/components/StoresListView.js +1 -1
- package/dist/features/stores/hooks/useStores.d.ts +1 -0
- package/dist/features/stores/hooks/useStores.js +1 -0
- package/dist/features/stores/schemas/firestore.d.ts +34 -0
- package/dist/features/stores/schemas/index.d.ts +8 -8
- package/dist/features/sublisting/schemas/firestore.d.ts +30 -0
- package/dist/features/sublisting/schemas/firestore.js +19 -0
- package/dist/features/support/schemas/firestore.d.ts +113 -0
- package/dist/features/support/schemas/firestore.js +95 -0
- package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.d.ts +5 -0
- package/dist/features/whatsapp-bot/components/SellerWhatsAppSettingsView.js +143 -0
- package/dist/features/whatsapp-bot/components/index.d.ts +2 -0
- package/dist/features/whatsapp-bot/components/index.js +1 -0
- package/dist/features/whatsapp-bot/helpers/whatsapp.d.ts +23 -1
- package/dist/features/whatsapp-bot/helpers/whatsapp.js +104 -0
- package/dist/features/whatsapp-bot/server.d.ts +1 -0
- package/dist/features/whatsapp-bot/server.js +1 -0
- package/dist/features/whatsapp-bot/types/index.d.ts +49 -0
- package/dist/features/wishlist/components/WishlistView.d.ts +0 -10
- package/dist/features/wishlist/components/WishlistView.js +13 -6
- package/dist/features/wishlist/hooks/useWishlist.js +2 -0
- package/dist/features/wishlist/hooks/useWishlistCount.d.ts +11 -3
- package/dist/features/wishlist/hooks/useWishlistCount.js +89 -25
- package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +1 -1
- package/dist/features/wishlist/schemas/index.d.ts +2 -2
- package/dist/features/wishlist/types/index.d.ts +16 -0
- package/dist/http/api-handler.js +8 -1
- package/dist/index.d.ts +114 -16
- package/dist/index.js +136 -28
- package/dist/monitoring/server-logger.js +9 -3
- package/dist/next/routing/route-map.d.ts +120 -6
- package/dist/next/routing/route-map.js +53 -2
- package/dist/providers/db-firebase/realtime.d.ts +1 -1
- package/dist/react/contexts/SessionContext.js +17 -26
- package/dist/react/hooks/useBulkSelection.d.ts +7 -24
- package/dist/react/hooks/useBulkSelection.js +27 -34
- package/dist/react/hooks/useLongPress.d.ts +3 -16
- package/dist/react/hooks/useLongPress.js +6 -25
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +2 -0
- package/dist/repositories/index.d.ts +3 -0
- package/dist/repositories/index.js +2 -0
- package/dist/seed/actions/demo-seed-actions.d.ts +2 -2
- package/dist/seed/actions/demo-seed-actions.js +1 -1
- package/dist/seed/anime-figures-seed-data.d.ts +8 -0
- package/dist/seed/anime-figures-seed-data.js +1033 -0
- package/dist/seed/beyblade-seed-data.js +206 -24
- package/dist/seed/bids-seed-data.d.ts +4 -10
- package/dist/seed/bids-seed-data.js +365 -238
- package/dist/seed/blog-posts-seed-data.d.ts +3 -2
- package/dist/seed/blog-posts-seed-data.js +250 -511
- package/dist/seed/brands-seed-data.d.ts +7 -0
- package/dist/seed/brands-seed-data.js +410 -0
- package/dist/seed/carousel-slides-seed-data.d.ts +3 -2
- package/dist/seed/carousel-slides-seed-data.js +177 -216
- package/dist/seed/cart-seed-data.d.ts +9 -9
- package/dist/seed/cart-seed-data.js +73 -73
- package/dist/seed/categories-seed-data.d.ts +4 -2
- package/dist/seed/categories-seed-data.js +720 -879
- package/dist/seed/conversations-seed-data.d.ts +8 -0
- package/dist/seed/conversations-seed-data.js +388 -0
- package/dist/seed/cosplay-accessories-seed-data.d.ts +8 -0
- package/dist/seed/cosplay-accessories-seed-data.js +647 -0
- package/dist/seed/coupon-usage-seed-data.d.ts +25 -0
- package/dist/seed/coupon-usage-seed-data.js +69 -0
- package/dist/seed/coupons-seed-data.d.ts +6 -3
- package/dist/seed/coupons-seed-data.js +375 -3
- package/dist/seed/events-seed-data.d.ts +4 -2
- package/dist/seed/events-seed-data.js +128 -430
- package/dist/seed/factories/cart.factory.d.ts +0 -1
- package/dist/seed/factories/cart.factory.js +2 -2
- package/dist/seed/faq-seed-data.d.ts +11 -18
- package/dist/seed/faq-seed-data.js +786 -1817
- package/dist/seed/grouped-listings-seed-data.d.ts +8 -0
- package/dist/seed/grouped-listings-seed-data.js +201 -0
- package/dist/seed/homepage-sections-seed-data.d.ts +3 -13
- package/dist/seed/homepage-sections-seed-data.js +228 -252
- package/dist/seed/hot-wheels-seed-data.js +285 -38
- package/dist/seed/index.d.ts +12 -11
- package/dist/seed/index.js +10 -12
- package/dist/seed/letitrip-official-seed-data.d.ts +8 -0
- package/dist/seed/letitrip-official-seed-data.js +399 -0
- package/dist/seed/manifest.d.ts +15 -0
- package/dist/seed/manifest.js +140 -0
- package/dist/seed/notifications-seed-data.d.ts +4 -2
- package/dist/seed/notifications-seed-data.js +117 -440
- package/dist/seed/orders-seed-data.d.ts +4 -2
- package/dist/seed/orders-seed-data.js +1090 -521
- package/dist/seed/payouts-seed-data.d.ts +4 -2
- package/dist/seed/payouts-seed-data.js +522 -145
- package/dist/seed/pokemon-carousel-slides-seed-data.js +6 -1
- package/dist/seed/pokemon-categories-seed-data.js +81 -81
- package/dist/seed/pokemon-homepage-sections-seed-data.d.ts +1 -1
- package/dist/seed/pokemon-homepage-sections-seed-data.js +116 -23
- package/dist/seed/pokemon-products-seed-data.d.ts +1 -1
- package/dist/seed/pokemon-products-seed-data.js +83 -73
- package/dist/seed/pokemon-seed-bundle.d.ts +5 -1
- package/dist/seed/pokemon-seed-bundle.js +21 -2
- package/dist/seed/pokemon-stores-seed-data.js +85 -9
- package/dist/seed/pokemon-users-seed-data.js +107 -8
- package/dist/seed/products-auctions-seed-data.d.ts +10 -0
- package/dist/seed/products-auctions-seed-data.js +689 -0
- package/dist/seed/products-preorders-seed-data.d.ts +9 -0
- package/dist/seed/products-preorders-seed-data.js +483 -0
- package/dist/seed/products-seed-data.js +34 -13
- package/dist/seed/products-standard-seed-data.d.ts +8 -0
- package/dist/seed/products-standard-seed-data.js +4179 -0
- package/dist/seed/retro-gaming-seed-data.d.ts +8 -0
- package/dist/seed/retro-gaming-seed-data.js +801 -0
- package/dist/seed/reviews-seed-data.d.ts +4 -17
- package/dist/seed/reviews-seed-data.js +1043 -515
- package/dist/seed/scammers-seed-data.d.ts +17 -0
- package/dist/seed/scammers-seed-data.js +118 -0
- package/dist/seed/site-settings-seed-data.js +25 -2
- package/dist/seed/store-addresses-seed-data.js +188 -84
- package/dist/seed/stores-seed-data.d.ts +3 -9
- package/dist/seed/stores-seed-data.js +212 -102
- package/dist/seed/sublisting-categories-seed-data.d.ts +7 -0
- package/dist/seed/sublisting-categories-seed-data.js +315 -0
- package/dist/seed/transformers-seed-data.js +34 -14
- package/dist/seed/users-seed-data.d.ts +3 -2
- package/dist/seed/users-seed-data.js +531 -440
- package/dist/seed/wishlists-seed-data.js +13 -13
- package/dist/server.d.ts +9 -2
- package/dist/server.js +12 -4
- package/dist/tokens/tokens.css +76 -31
- package/dist/ui/components/Avatar.style.css +10 -12
- package/dist/ui/components/BaseListingCard.d.ts +8 -3
- package/dist/ui/components/BaseListingCard.js +17 -6
- package/dist/ui/components/BaseListingCard.style.css +3 -1
- package/dist/ui/components/BulkActionsBar.d.ts +16 -0
- package/dist/ui/components/BulkActionsBar.js +22 -0
- package/dist/ui/components/Button.style.css +23 -23
- package/dist/ui/components/Card.style.css +60 -62
- package/dist/ui/components/Checkbox.style.css +19 -21
- package/dist/ui/components/DashboardStatsCard.style.css +12 -14
- package/dist/ui/components/Drawer.style.css +18 -14
- package/dist/ui/components/Dropdown.style.css +25 -27
- package/dist/ui/components/EmptyState.style.css +2 -4
- package/dist/ui/components/HorizontalScroller.d.ts +3 -1
- package/dist/ui/components/HorizontalScroller.js +116 -21
- package/dist/ui/components/HorizontalScroller.style.css +2 -2
- package/dist/ui/components/ImageLightbox.d.ts +0 -9
- package/dist/ui/components/ImageLightbox.js +43 -9
- package/dist/ui/components/InlineCreateSelect.d.ts +38 -0
- package/dist/ui/components/InlineCreateSelect.js +70 -0
- package/dist/ui/components/ListingLayout.style.css +41 -77
- package/dist/ui/components/ListingToolbar.d.ts +54 -0
- package/dist/ui/components/ListingToolbar.js +34 -0
- package/dist/ui/components/Modal.style.css +14 -10
- package/dist/ui/components/PageLoader.d.ts +11 -0
- package/dist/ui/components/PageLoader.js +21 -0
- package/dist/ui/components/Radio.style.css +34 -36
- package/dist/ui/components/RichTextEditor.js +1 -1
- package/dist/ui/components/RowActionMenu.d.ts +1 -0
- package/dist/ui/components/RowActionMenu.js +4 -2
- package/dist/ui/components/SectionTabs.js +1 -1
- package/dist/ui/components/SectionTabs.style.css +1 -0
- package/dist/ui/components/SideModal.style.css +4 -8
- package/dist/ui/components/Slider.style.css +2 -4
- package/dist/ui/components/Tabs.style.css +8 -10
- package/dist/ui/components/Toast.style.css +22 -24
- package/dist/ui/components/Toggle.style.css +11 -13
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +5 -0
- package/dist/ui/rich-text/RichText.js +2 -1
- package/dist/ui/rich-text/RichText.style.css +292 -5
- package/dist/ui/rich-text/RichTextRenderer.d.ts +15 -0
- package/dist/ui/rich-text/RichTextRenderer.js +15 -0
- package/dist/utils/id-generators.d.ts +10 -0
- package/dist/utils/id-generators.js +12 -0
- package/dist/validation/schemas.d.ts +9 -9
- package/package.json +5 -1
- package/README.md +0 -116
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useCallback } from "react";
|
|
4
|
+
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
5
|
+
import { ListingToolbar, Pagination } from "../../../ui";
|
|
6
|
+
import { toRecordArray, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
|
|
7
|
+
import { DataTable } from "./DataTable";
|
|
8
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
9
|
+
const PAGE_SIZE = 25;
|
|
10
|
+
const DEFAULT_SORT = "storeId";
|
|
11
|
+
const SORT_OPTIONS = [
|
|
12
|
+
{ value: "storeId", label: "Store ID" },
|
|
13
|
+
{ value: "city", label: "City A–Z" },
|
|
14
|
+
];
|
|
15
|
+
export function AdminStoreAddressesView({ children: _children }) {
|
|
16
|
+
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
17
|
+
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
18
|
+
const resetAll = useCallback(() => {
|
|
19
|
+
table.setMany({ q: "", sort: "" });
|
|
20
|
+
setSearchInput("");
|
|
21
|
+
}, [table]);
|
|
22
|
+
const commitSearch = useCallback(() => {
|
|
23
|
+
table.set("q", searchInput.trim());
|
|
24
|
+
}, [searchInput, table]);
|
|
25
|
+
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT;
|
|
26
|
+
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
27
|
+
queryKey: ["admin", "store-addresses", "listing"],
|
|
28
|
+
endpoint: ADMIN_ENDPOINTS.STORE_ADDRESSES,
|
|
29
|
+
page: table.getNumber("page", 1),
|
|
30
|
+
pageSize: PAGE_SIZE,
|
|
31
|
+
sorts: table.get("sort") || DEFAULT_SORT,
|
|
32
|
+
q: table.get("q") || undefined,
|
|
33
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
34
|
+
id: toStringValue(item.id, `addr-${index}`),
|
|
35
|
+
primary: [
|
|
36
|
+
toStringValue(item.label, "Address"),
|
|
37
|
+
toStringValue(item.city, ""),
|
|
38
|
+
toStringValue(item.state, ""),
|
|
39
|
+
].filter(Boolean).join(", "),
|
|
40
|
+
secondary: [
|
|
41
|
+
toStringValue(item.storeId ?? item.storeName, "Unknown store"),
|
|
42
|
+
toStringValue(item.pincode, ""),
|
|
43
|
+
].filter(Boolean).join(" · "),
|
|
44
|
+
status: item.isPickupLocation ? "pickup" : "standard",
|
|
45
|
+
updatedAt: toStringValue(item.storeId, ""),
|
|
46
|
+
})),
|
|
47
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
48
|
+
});
|
|
49
|
+
const currentPage = table.getNumber("page", 1);
|
|
50
|
+
const totalPages = Math.ceil(total / PAGE_SIZE);
|
|
51
|
+
return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: 0, searchValue: searchInput, searchPlaceholder: "Search by label, city, or store ID", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set("sort", v); table.setPage(1); }, hideViewToggle: true, 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) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-200", children: errorMessage })), _jsx(DataTable, { rows: rows, isLoading: isLoading, emptyLabel: "No store addresses found" })] })] }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface AdminStoreEditorViewProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
storeId?: string;
|
|
5
|
+
storeName?: string;
|
|
6
|
+
currentStatus?: string;
|
|
7
|
+
currentIsVerified?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function AdminStoreEditorView({ open, onClose, storeId, storeName, currentStatus, currentIsVerified, }: AdminStoreEditorViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { Button, Form, FormActions, Select, SideDrawer, Toggle, useToast, } from "../../../ui";
|
|
6
|
+
import { apiClient } from "../../../http";
|
|
7
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
8
|
+
const STATUS_OPTIONS = [
|
|
9
|
+
{ label: "Active", value: "active" },
|
|
10
|
+
{ label: "Pending", value: "pending" },
|
|
11
|
+
{ label: "Suspended", value: "suspended" },
|
|
12
|
+
{ label: "Rejected", value: "rejected" },
|
|
13
|
+
];
|
|
14
|
+
// --- Component ---------------------------------------------------------------
|
|
15
|
+
export function AdminStoreEditorView({ open, onClose, storeId, storeName, currentStatus, currentIsVerified, }) {
|
|
16
|
+
const queryClient = useQueryClient();
|
|
17
|
+
const { showToast } = useToast();
|
|
18
|
+
const [storeStatus, setStoreStatus] = React.useState(currentStatus ?? "pending");
|
|
19
|
+
const [adminNotes, setAdminNotes] = React.useState("");
|
|
20
|
+
const [isFeatured, setIsFeatured] = React.useState(false);
|
|
21
|
+
const [isVerified, setIsVerified] = React.useState(currentIsVerified ?? false);
|
|
22
|
+
const [suspensionReason, setSuspensionReason] = React.useState("");
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
if (open) {
|
|
25
|
+
setStoreStatus(currentStatus ?? "pending");
|
|
26
|
+
setAdminNotes("");
|
|
27
|
+
setIsFeatured(false);
|
|
28
|
+
setIsVerified(currentIsVerified ?? false);
|
|
29
|
+
setSuspensionReason("");
|
|
30
|
+
}
|
|
31
|
+
}, [open, currentStatus, currentIsVerified]);
|
|
32
|
+
const saveMutation = useMutation({
|
|
33
|
+
mutationFn: async () => {
|
|
34
|
+
await apiClient.patch(ADMIN_ENDPOINTS.STORE_BY_ID(storeId), {
|
|
35
|
+
storeStatus,
|
|
36
|
+
adminNotes: adminNotes || undefined,
|
|
37
|
+
isFeatured,
|
|
38
|
+
isVerified,
|
|
39
|
+
suspensionReason: storeStatus === "suspended" ? (suspensionReason || undefined) : undefined,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
onSuccess: () => {
|
|
43
|
+
showToast("Store updated.", "success");
|
|
44
|
+
queryClient.invalidateQueries({ queryKey: ["admin", "stores"] });
|
|
45
|
+
onClose();
|
|
46
|
+
},
|
|
47
|
+
onError: (err) => {
|
|
48
|
+
showToast(err?.message ?? "Failed to update store.", "error");
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
return (_jsx(SideDrawer, { isOpen: open, onClose: onClose, title: storeName ? `Manage: ${storeName}` : "Manage Store", children: _jsxs(Form, { onSubmit: (e) => {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
saveMutation.mutate();
|
|
54
|
+
}, className: "space-y-4 p-4", children: [_jsx(Select, { label: "Store status", options: STATUS_OPTIONS, value: storeStatus, onValueChange: setStoreStatus }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Admin notes (optional)" }), _jsx("textarea", { value: adminNotes, onChange: (e) => setAdminNotes(e.target.value), rows: 3, placeholder: "e.g. Reason for suspension, approval notes\u2026", className: "w-full rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-primary-500" })] }), _jsx(Toggle, { label: "Verified store", checked: isVerified, onChange: setIsVerified }), _jsx(Toggle, { label: "Featured store", checked: isFeatured, onChange: setIsFeatured }), storeStatus === "suspended" && (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Suspension reason (optional)" }), _jsx("textarea", { value: suspensionReason, onChange: (e) => setSuspensionReason(e.target.value), rows: 2, placeholder: "e.g. Policy violation, fraudulent activity\u2026", className: "w-full rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-primary-500" })] })), _jsxs(FormActions, { align: "right", children: [_jsx(Button, { type: "button", variant: "secondary", onClick: onClose, children: "Cancel" }), _jsx(Button, { type: "submit", isLoading: saveMutation.isPending, disabled: !storeId || saveMutation.isPending, children: "Save changes" })] })] }) }));
|
|
55
|
+
}
|
|
@@ -1,23 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState, useCallback } from "react";
|
|
4
|
+
import { X } from "lucide-react";
|
|
5
|
+
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
6
|
+
import { ListingToolbar, Pagination, ListingViewShell, RowActionMenu } from "../../../ui";
|
|
5
7
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
6
8
|
import { toRecordArray, toRelativeDate, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
|
|
7
|
-
import {
|
|
9
|
+
import { DataTable } from "./DataTable";
|
|
10
|
+
import { AdminStoreEditorView } from "./AdminStoreEditorView";
|
|
11
|
+
const PAGE_SIZE = 25;
|
|
12
|
+
const FILTER_KEYS = ["status"];
|
|
13
|
+
const DEFAULT_SORT = "-createdAt";
|
|
14
|
+
const SORT_OPTIONS = [
|
|
15
|
+
{ value: "-createdAt", label: "Newest" },
|
|
16
|
+
{ value: "createdAt", label: "Oldest" },
|
|
17
|
+
{ value: "storeName", label: "Name A–Z" },
|
|
18
|
+
];
|
|
19
|
+
const STATUS_OPTIONS = ["All", "active", "pending", "suspended", "rejected"];
|
|
8
20
|
export function AdminStoresView({ children, ...props }) {
|
|
9
21
|
const hasChildren = React.Children.count(children) > 0;
|
|
10
|
-
const
|
|
11
|
-
const [
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
22
|
+
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
23
|
+
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
24
|
+
const [filterOpen, setFilterOpen] = useState(false);
|
|
25
|
+
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
26
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
27
|
+
const [selectedRow, setSelectedRow] = useState(null);
|
|
28
|
+
const openFilters = useCallback(() => {
|
|
29
|
+
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
30
|
+
setFilterOpen(true);
|
|
31
|
+
}, [table]);
|
|
32
|
+
const applyFilters = useCallback(() => {
|
|
33
|
+
const updates = { page: "1" };
|
|
34
|
+
for (const k of FILTER_KEYS)
|
|
35
|
+
updates[k] = pendingFilters[k] ?? "";
|
|
36
|
+
table.setMany(updates);
|
|
37
|
+
setFilterOpen(false);
|
|
38
|
+
}, [pendingFilters, table]);
|
|
39
|
+
const clearFilters = useCallback(() => {
|
|
40
|
+
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
41
|
+
}, []);
|
|
42
|
+
const resetAll = useCallback(() => {
|
|
43
|
+
const updates = { q: "", sort: "" };
|
|
44
|
+
for (const k of FILTER_KEYS)
|
|
45
|
+
updates[k] = "";
|
|
46
|
+
table.setMany(updates);
|
|
47
|
+
setSearchInput("");
|
|
48
|
+
}, [table]);
|
|
49
|
+
const commitSearch = useCallback(() => {
|
|
50
|
+
table.set("q", searchInput.trim());
|
|
51
|
+
}, [searchInput, table]);
|
|
52
|
+
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
53
|
+
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
54
|
+
const statusRaw = table.get("status");
|
|
55
|
+
const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
|
|
16
56
|
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
17
|
-
queryKey: ["admin", "stores", "listing"
|
|
57
|
+
queryKey: ["admin", "stores", "listing"],
|
|
18
58
|
endpoint: ADMIN_ENDPOINTS.STORES,
|
|
59
|
+
page: table.getNumber("page", 1),
|
|
60
|
+
pageSize: PAGE_SIZE,
|
|
61
|
+
sorts: table.get("sort") || DEFAULT_SORT,
|
|
19
62
|
filters,
|
|
20
|
-
q,
|
|
63
|
+
q: table.get("q") || undefined,
|
|
21
64
|
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
22
65
|
id: toStringValue(item.id, `store-${index}`),
|
|
23
66
|
primary: toStringValue(item.storeName, "Unnamed store"),
|
|
@@ -27,18 +70,17 @@ export function AdminStoresView({ children, ...props }) {
|
|
|
27
70
|
].join(" · "),
|
|
28
71
|
status: toStringValue(item.status, "Pending"),
|
|
29
72
|
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
73
|
+
_raw: item,
|
|
30
74
|
})),
|
|
31
75
|
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
32
76
|
});
|
|
77
|
+
const currentPage = table.getNumber("page", 1);
|
|
78
|
+
const totalPages = Math.ceil(total / PAGE_SIZE);
|
|
33
79
|
if (hasChildren) {
|
|
34
80
|
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
35
81
|
}
|
|
36
|
-
return (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
active: statusFilter || "All",
|
|
41
|
-
onSelect: (opt) => setStatusFilter(opt === "All" ? "" : opt),
|
|
42
|
-
},
|
|
43
|
-
] }));
|
|
82
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search stores, slugs, or owner names", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set("sort", v); table.setPage(1); }, hideViewToggle: true, 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) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-200", children: errorMessage })), _jsx(DataTable, { rows: rows, isLoading: isLoading, emptyLabel: "No stores found", renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [{
|
|
83
|
+
label: "Manage",
|
|
84
|
+
onClick: () => { setSelectedRow(row); setDrawerOpen(true); },
|
|
85
|
+
}] })) })] }), filterOpen && (_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 hover:bg-zinc-100 dark:hover:bg-slate-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("p", { 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: STATUS_OPTIONS.map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, status: opt === "All" ? "" : opt })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.status || "All") === opt ? "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 }, opt))) })] }) }), _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})` : ""] }) })] })] }))] }), _jsx(AdminStoreEditorView, { open: drawerOpen, onClose: () => setDrawerOpen(false), storeId: selectedRow?.id, storeName: selectedRow?.primary, currentStatus: selectedRow?.status?.toLowerCase(), currentIsVerified: Boolean(selectedRow?._raw?.isVerified) })] }));
|
|
44
86
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AdminUserEditorViewProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
userId?: string;
|
|
5
|
+
displayName?: string;
|
|
6
|
+
currentRole?: string;
|
|
7
|
+
currentIsDisabled?: boolean;
|
|
8
|
+
currentEmailVerified?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function AdminUserEditorView({ open, onClose, userId, displayName, currentRole, currentIsDisabled, currentEmailVerified, }: AdminUserEditorViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { Button, ConfirmDeleteModal, Form, FormActions, Select, SideDrawer, Toggle, useToast, } from "../../../ui";
|
|
6
|
+
import { apiClient } from "../../../http";
|
|
7
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
8
|
+
const ROLE_OPTIONS = [
|
|
9
|
+
{ label: "User (buyer)", value: "user" },
|
|
10
|
+
{ label: "Seller", value: "seller" },
|
|
11
|
+
{ label: "Admin", value: "admin" },
|
|
12
|
+
];
|
|
13
|
+
// --- Component ---------------------------------------------------------------
|
|
14
|
+
export function AdminUserEditorView({ open, onClose, userId, displayName, currentRole, currentIsDisabled, currentEmailVerified, }) {
|
|
15
|
+
const queryClient = useQueryClient();
|
|
16
|
+
const { showToast } = useToast();
|
|
17
|
+
const [role, setRole] = React.useState(currentRole ?? "user");
|
|
18
|
+
const [isDisabled, setIsDisabled] = React.useState(currentIsDisabled ?? false);
|
|
19
|
+
const [banReason, setBanReason] = React.useState("");
|
|
20
|
+
const [emailVerified, setEmailVerified] = React.useState(currentEmailVerified ?? false);
|
|
21
|
+
const [adminNotes, setAdminNotes] = React.useState("");
|
|
22
|
+
const [deleteOpen, setDeleteOpen] = React.useState(false);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
if (open) {
|
|
25
|
+
setRole(currentRole ?? "user");
|
|
26
|
+
setIsDisabled(currentIsDisabled ?? false);
|
|
27
|
+
setBanReason("");
|
|
28
|
+
setEmailVerified(currentEmailVerified ?? false);
|
|
29
|
+
setAdminNotes("");
|
|
30
|
+
}
|
|
31
|
+
}, [open, currentRole, currentIsDisabled, currentEmailVerified]);
|
|
32
|
+
const saveMutation = useMutation({
|
|
33
|
+
mutationFn: async () => {
|
|
34
|
+
await apiClient.patch(ADMIN_ENDPOINTS.USER_BY_ID(userId), {
|
|
35
|
+
role,
|
|
36
|
+
isDisabled,
|
|
37
|
+
emailVerified,
|
|
38
|
+
adminNotes: adminNotes || undefined,
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
onSuccess: () => {
|
|
42
|
+
showToast("User updated.", "success");
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: ["admin", "users"] });
|
|
44
|
+
onClose();
|
|
45
|
+
},
|
|
46
|
+
onError: (err) => {
|
|
47
|
+
showToast(err?.message ?? "Failed to update user.", "error");
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const deleteMutation = useMutation({
|
|
51
|
+
mutationFn: async () => {
|
|
52
|
+
await apiClient.delete(ADMIN_ENDPOINTS.USER_BY_ID(userId));
|
|
53
|
+
},
|
|
54
|
+
onSuccess: () => {
|
|
55
|
+
showToast("User deleted.", "success");
|
|
56
|
+
queryClient.invalidateQueries({ queryKey: ["admin", "users"] });
|
|
57
|
+
setDeleteOpen(false);
|
|
58
|
+
onClose();
|
|
59
|
+
},
|
|
60
|
+
onError: (err) => {
|
|
61
|
+
showToast(err?.message ?? "Failed to delete user.", "error");
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return (_jsxs(_Fragment, { children: [_jsx(SideDrawer, { isOpen: open, onClose: onClose, title: displayName ? `Manage: ${displayName}` : "Manage User", children: _jsxs(Form, { onSubmit: (e) => {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
saveMutation.mutate();
|
|
67
|
+
}, className: "space-y-4 p-4", children: [_jsx(Select, { label: "Role", options: ROLE_OPTIONS, value: role, onValueChange: setRole }), _jsx(Toggle, { label: "Account disabled (banned)", checked: isDisabled, onChange: (val) => {
|
|
68
|
+
setIsDisabled(val);
|
|
69
|
+
if (!val)
|
|
70
|
+
setBanReason("");
|
|
71
|
+
} }), isDisabled && (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Ban reason (optional)" }), _jsx("textarea", { value: banReason, onChange: (e) => setBanReason(e.target.value), rows: 2, placeholder: "e.g. Repeated policy violations, fraudulent activity\u2026", className: "w-full rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-primary-500" })] })), _jsx(Toggle, { label: "Email verified", checked: emailVerified, onChange: setEmailVerified }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Admin notes (optional)" }), _jsx("textarea", { value: adminNotes, onChange: (e) => setAdminNotes(e.target.value), rows: 3, placeholder: "Internal notes about this user\u2026", className: "w-full rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-primary-500" })] }), _jsxs(FormActions, { align: "right", children: [_jsx(Button, { type: "button", variant: "danger", onClick: () => setDeleteOpen(true), disabled: !userId, children: "Delete user" }), _jsx(Button, { type: "button", variant: "secondary", onClick: onClose, children: "Cancel" }), _jsx(Button, { type: "submit", isLoading: saveMutation.isPending, disabled: !userId || saveMutation.isPending, children: "Save changes" })] })] }) }), _jsx(ConfirmDeleteModal, { isOpen: deleteOpen, onClose: () => setDeleteOpen(false), onConfirm: () => deleteMutation.mutate(), isDeleting: deleteMutation.isPending, title: `Delete ${displayName ?? "user"}?`, message: "This action cannot be undone. The user's account and all associated data will be permanently removed.", confirmText: "Delete user", variant: "danger" })] }));
|
|
72
|
+
}
|
|
@@ -1,27 +1,74 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState, useCallback } from "react";
|
|
4
|
+
import { X } from "lucide-react";
|
|
5
|
+
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
6
|
+
import { ListingToolbar, Pagination, ListingViewShell, RowActionMenu } from "../../../ui";
|
|
5
7
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
6
8
|
import { toRecordArray, toRelativeDate, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
|
|
7
|
-
import {
|
|
9
|
+
import { DataTable } from "./DataTable";
|
|
10
|
+
import { AdminUserEditorView } from "./AdminUserEditorView";
|
|
11
|
+
const PAGE_SIZE = 25;
|
|
12
|
+
const FILTER_KEYS = ["status", "role"];
|
|
13
|
+
const DEFAULT_SORT = "-createdAt";
|
|
14
|
+
const SORT_OPTIONS = [
|
|
15
|
+
{ value: "-createdAt", label: "Newest" },
|
|
16
|
+
{ value: "createdAt", label: "Oldest" },
|
|
17
|
+
{ value: "displayName", label: "Name A–Z" },
|
|
18
|
+
];
|
|
19
|
+
const STATUS_OPTIONS = ["All", "Active", "Disabled"];
|
|
20
|
+
const ROLE_OPTIONS = ["All", "admin", "seller", "buyer", "moderator"];
|
|
8
21
|
export function AdminUsersView({ children, ...props }) {
|
|
9
22
|
const hasChildren = React.Children.count(children) > 0;
|
|
10
|
-
const
|
|
11
|
-
const [
|
|
12
|
-
const [
|
|
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 [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
27
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
28
|
+
const [selectedRow, setSelectedRow] = useState(null);
|
|
29
|
+
const openFilters = useCallback(() => {
|
|
30
|
+
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
31
|
+
setFilterOpen(true);
|
|
32
|
+
}, [table]);
|
|
33
|
+
const applyFilters = useCallback(() => {
|
|
34
|
+
const updates = { page: "1" };
|
|
35
|
+
for (const k of FILTER_KEYS)
|
|
36
|
+
updates[k] = pendingFilters[k] ?? "";
|
|
37
|
+
table.setMany(updates);
|
|
38
|
+
setFilterOpen(false);
|
|
39
|
+
}, [pendingFilters, table]);
|
|
40
|
+
const clearFilters = useCallback(() => {
|
|
41
|
+
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
42
|
+
}, []);
|
|
43
|
+
const resetAll = useCallback(() => {
|
|
44
|
+
const updates = { q: "", sort: "" };
|
|
45
|
+
for (const k of FILTER_KEYS)
|
|
46
|
+
updates[k] = "";
|
|
47
|
+
table.setMany(updates);
|
|
48
|
+
setSearchInput("");
|
|
49
|
+
}, [table]);
|
|
50
|
+
const commitSearch = useCallback(() => {
|
|
51
|
+
table.set("q", searchInput.trim());
|
|
52
|
+
}, [searchInput, table]);
|
|
53
|
+
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
54
|
+
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
13
55
|
const filterParts = [];
|
|
14
|
-
|
|
15
|
-
|
|
56
|
+
const statusRaw = table.get("status");
|
|
57
|
+
if (statusRaw && statusRaw !== "All") {
|
|
58
|
+
filterParts.push(statusRaw === "Active" ? "disabled==false" : "disabled==true");
|
|
16
59
|
}
|
|
17
|
-
|
|
18
|
-
|
|
60
|
+
const roleRaw = table.get("role");
|
|
61
|
+
if (roleRaw && roleRaw !== "All")
|
|
62
|
+
filterParts.push(`role==${roleRaw}`);
|
|
19
63
|
const filters = filterParts.join(",") || undefined;
|
|
20
64
|
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
21
|
-
queryKey: ["admin", "users", "listing"
|
|
65
|
+
queryKey: ["admin", "users", "listing"],
|
|
22
66
|
endpoint: ADMIN_ENDPOINTS.USERS,
|
|
67
|
+
page: table.getNumber("page", 1),
|
|
68
|
+
pageSize: PAGE_SIZE,
|
|
69
|
+
sorts: table.get("sort") || DEFAULT_SORT,
|
|
23
70
|
filters,
|
|
24
|
-
q,
|
|
71
|
+
q: table.get("q") || undefined,
|
|
25
72
|
mapRows: (response) => toRecordArray(response.users).map((item, index) => ({
|
|
26
73
|
id: toStringValue(item.id ?? item.uid, `user-${index}`),
|
|
27
74
|
primary: toStringValue(item.displayName, "Unnamed user"),
|
|
@@ -29,38 +76,25 @@ export function AdminUsersView({ children, ...props }) {
|
|
|
29
76
|
toStringValue(item.email, "No email"),
|
|
30
77
|
toStringValue(item.role, "Unknown role"),
|
|
31
78
|
].join(" · "),
|
|
32
|
-
status: typeof item.disabled === "boolean"
|
|
33
|
-
? item.disabled
|
|
34
|
-
? "Disabled"
|
|
35
|
-
: "Active"
|
|
36
|
-
: "Active",
|
|
79
|
+
status: typeof item.disabled === "boolean" ? (item.disabled ? "Disabled" : "Active") : "Active",
|
|
37
80
|
updatedAt: toRelativeDate(item.lastLoginAt ?? item.createdAt),
|
|
81
|
+
_raw: item,
|
|
38
82
|
})),
|
|
39
83
|
getTotal: (response, mappedRows) => {
|
|
40
|
-
if (typeof response.meta?.total === "number")
|
|
84
|
+
if (typeof response.meta?.total === "number")
|
|
41
85
|
return response.meta.total;
|
|
42
|
-
|
|
43
|
-
if (typeof response.total === "number") {
|
|
86
|
+
if (typeof response.total === "number")
|
|
44
87
|
return response.total;
|
|
45
|
-
}
|
|
46
88
|
return mappedRows.length;
|
|
47
89
|
},
|
|
48
90
|
});
|
|
91
|
+
const currentPage = table.getNumber("page", 1);
|
|
92
|
+
const totalPages = Math.ceil(total / PAGE_SIZE);
|
|
49
93
|
if (hasChildren) {
|
|
50
94
|
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
51
95
|
}
|
|
52
|
-
return (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
active: statusFilter || "All",
|
|
57
|
-
onSelect: (opt) => setStatusFilter(opt === "All" ? "" : opt),
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
title: "Role",
|
|
61
|
-
options: ["All", "admin", "seller", "buyer", "moderator"],
|
|
62
|
-
active: roleFilter || "All",
|
|
63
|
-
onSelect: (opt) => setRoleFilter(opt === "All" ? "" : opt),
|
|
64
|
-
},
|
|
65
|
-
] }));
|
|
96
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search users, email, or seller handles", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set("sort", v); table.setPage(1); }, hideViewToggle: true, 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) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-200", children: errorMessage })), _jsx(DataTable, { rows: rows, isLoading: isLoading, emptyLabel: "No users found", renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [{
|
|
97
|
+
label: "Manage",
|
|
98
|
+
onClick: () => { setSelectedRow(row); setDrawerOpen(true); },
|
|
99
|
+
}] })) })] }), filterOpen && (_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 hover:bg-zinc-100 dark:hover:bg-slate-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("p", { 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: STATUS_OPTIONS.map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, status: opt === "All" ? "" : opt })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.status || "All") === opt ? "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 }, opt))) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Role" }), _jsx("div", { className: "flex flex-wrap gap-2", children: ROLE_OPTIONS.map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, role: opt === "All" ? "" : opt })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.role || "All") === opt ? "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 }, opt))) })] })] }), _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})` : ""] }) })] })] }))] }), _jsx(AdminUserEditorView, { open: drawerOpen, onClose: () => setDrawerOpen(false), userId: selectedRow?.id, displayName: selectedRow?.primary, currentRole: toStringValue(selectedRow?._raw?.role, "user"), currentIsDisabled: selectedRow?.status === "Disabled", currentEmailVerified: Boolean(selectedRow?._raw?.emailVerified) })] }));
|
|
66
100
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState, useCallback } from "react";
|
|
4
|
+
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
5
|
+
import { ListingToolbar, Pagination, ListingViewShell } from "../../../ui";
|
|
6
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
7
|
+
import { toRecordArray, toRelativeDate, toRupees, toStringValue, useAdminListingData, } from "../hooks/useAdminListingData";
|
|
8
|
+
import { DataTable } from "./DataTable";
|
|
9
|
+
const PAGE_SIZE = 25;
|
|
10
|
+
const FILTER_KEYS = [];
|
|
11
|
+
const DEFAULT_SORT = "-addedAt";
|
|
12
|
+
const SORT_OPTIONS = [
|
|
13
|
+
{ value: "-addedAt", label: "Newest" },
|
|
14
|
+
{ value: "addedAt", label: "Oldest" },
|
|
15
|
+
];
|
|
16
|
+
export function AdminWishlistsView({ children, ...props }) {
|
|
17
|
+
const hasChildren = React.Children.count(children) > 0;
|
|
18
|
+
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
19
|
+
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
20
|
+
const resetAll = useCallback(() => {
|
|
21
|
+
table.setMany({ q: "", sort: "" });
|
|
22
|
+
setSearchInput("");
|
|
23
|
+
}, [table]);
|
|
24
|
+
const commitSearch = useCallback(() => {
|
|
25
|
+
table.set("q", searchInput.trim());
|
|
26
|
+
}, [searchInput, table]);
|
|
27
|
+
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT;
|
|
28
|
+
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
29
|
+
queryKey: ["admin", "wishlists", "listing"],
|
|
30
|
+
endpoint: ADMIN_ENDPOINTS.ADMIN_WISHLISTS,
|
|
31
|
+
page: table.getNumber("page", 1),
|
|
32
|
+
pageSize: PAGE_SIZE,
|
|
33
|
+
sorts: table.get("sort") || DEFAULT_SORT,
|
|
34
|
+
q: table.get("q") || undefined,
|
|
35
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
36
|
+
id: toStringValue(item.id, `wish-${index}`),
|
|
37
|
+
primary: toStringValue(item.productTitle ?? item.productId, "Unknown product"),
|
|
38
|
+
secondary: [
|
|
39
|
+
toStringValue(item.userId, ""),
|
|
40
|
+
toRupees(item.priceAtAdd),
|
|
41
|
+
].filter(Boolean).join(" · "),
|
|
42
|
+
status: "—",
|
|
43
|
+
updatedAt: toRelativeDate(item.addedAt ?? item.createdAt),
|
|
44
|
+
})),
|
|
45
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
46
|
+
});
|
|
47
|
+
const currentPage = table.getNumber("page", 1);
|
|
48
|
+
const totalPages = Math.ceil(total / PAGE_SIZE);
|
|
49
|
+
if (hasChildren) {
|
|
50
|
+
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
51
|
+
}
|
|
52
|
+
return (_jsxs("div", { className: "min-h-screen", children: [_jsx(ListingToolbar, { filterCount: 0, searchValue: searchInput, searchPlaceholder: "Search by product or user ID", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set("sort", v); table.setPage(1); }, hideViewToggle: true, 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) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-200", children: errorMessage })), _jsx(DataTable, { rows: rows, isLoading: isLoading, emptyLabel: "No wishlist items found" })] })] }));
|
|
53
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useMutation } from "@tanstack/react-query";
|
|
5
|
+
import { Button, Form, Input, Toggle, useToast } from "../../../ui";
|
|
6
|
+
import { apiClient } from "../../../http";
|
|
7
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
8
|
+
function toBrandSlug(str) {
|
|
9
|
+
const base = str.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10
|
+
return base.startsWith("brand-") ? base : `brand-${base}`;
|
|
11
|
+
}
|
|
12
|
+
export function BrandQuickCreateForm({ onSaved, onCancel }) {
|
|
13
|
+
const [name, setName] = React.useState("");
|
|
14
|
+
const [description, setDescription] = React.useState("");
|
|
15
|
+
const [isActive, setIsActive] = React.useState(true);
|
|
16
|
+
const { showToast } = useToast();
|
|
17
|
+
const mutation = useMutation({
|
|
18
|
+
mutationFn: async () => apiClient.post(ADMIN_ENDPOINTS.BRANDS, {
|
|
19
|
+
name,
|
|
20
|
+
slug: toBrandSlug(name),
|
|
21
|
+
description: description || undefined,
|
|
22
|
+
isActive,
|
|
23
|
+
}),
|
|
24
|
+
onSuccess: (res) => {
|
|
25
|
+
const id = res?.data?.id ?? res?.id ?? "";
|
|
26
|
+
onSaved(id, name);
|
|
27
|
+
},
|
|
28
|
+
onError: (err) => {
|
|
29
|
+
showToast(err?.message ?? "Failed to create brand.", "error");
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return (_jsxs(Form, { onSubmit: (e) => {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
mutation.mutate();
|
|
35
|
+
}, className: "space-y-4", children: [_jsx(Input, { label: "Brand name", value: name, onChange: (e) => setName(e.target.value), required: true, placeholder: "e.g. Hot Wheels", autoFocus: true }), _jsx(Input, { label: "Description", value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Optional brief description" }), _jsx(Toggle, { label: "Active", checked: isActive, onChange: setIsActive }), _jsxs("div", { className: "flex gap-3 pt-2", children: [_jsx(Button, { type: "submit", isLoading: mutation.isPending, disabled: !name || mutation.isPending, children: "Create brand" }), _jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, children: "Cancel" })] })] }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { useMutation } from "@tanstack/react-query";
|
|
5
|
+
import { Button, Form, Input, Toggle, useToast } from "../../../ui";
|
|
6
|
+
import { apiClient } from "../../../http";
|
|
7
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
8
|
+
function toCategorySlug(str) {
|
|
9
|
+
return str.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
10
|
+
}
|
|
11
|
+
export function CategoryQuickCreateForm({ onSaved, onCancel }) {
|
|
12
|
+
const [name, setName] = React.useState("");
|
|
13
|
+
const [description, setDescription] = React.useState("");
|
|
14
|
+
const [isActive, setIsActive] = React.useState(true);
|
|
15
|
+
const { showToast } = useToast();
|
|
16
|
+
const mutation = useMutation({
|
|
17
|
+
mutationFn: async () => apiClient.post(ADMIN_ENDPOINTS.CATEGORIES, {
|
|
18
|
+
name,
|
|
19
|
+
slug: toCategorySlug(name),
|
|
20
|
+
description: description || undefined,
|
|
21
|
+
isActive,
|
|
22
|
+
}),
|
|
23
|
+
onSuccess: (res) => {
|
|
24
|
+
const id = res?.data?.id ?? res?.id ?? "";
|
|
25
|
+
onSaved(id, name);
|
|
26
|
+
},
|
|
27
|
+
onError: (err) => {
|
|
28
|
+
showToast(err?.message ?? "Failed to create category.", "error");
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return (_jsxs(Form, { onSubmit: (e) => {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
mutation.mutate();
|
|
34
|
+
}, className: "space-y-4", children: [_jsx(Input, { label: "Category name", value: name, onChange: (e) => setName(e.target.value), required: true, placeholder: "e.g. Trading Cards", autoFocus: true }), _jsx(Input, { label: "Description", value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Optional brief description" }), _jsx(Toggle, { label: "Active", checked: isActive, onChange: setIsActive }), _jsxs("div", { className: "flex gap-3 pt-2", children: [_jsx(Button, { type: "submit", isLoading: mutation.isPending, disabled: !name || mutation.isPending, children: "Create category" }), _jsx(Button, { type: "button", variant: "ghost", onClick: onCancel, children: "Cancel" })] })] }));
|
|
35
|
+
}
|