@mohasinac/appkit 2.7.59 → 2.8.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/_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/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/client.d.ts +10 -6
- package/dist/client.js +7 -3
- 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/about/components/PublicProfileView.js +8 -8
- package/dist/features/account/components/UserOffersPanel.js +1 -1
- 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 -83
- package/dist/features/admin/components/AdminBidsView.d.ts +2 -3
- package/dist/features/admin/components/AdminBidsView.js +64 -98
- package/dist/features/admin/components/AdminBlogView.d.ts +3 -7
- package/dist/features/admin/components/AdminBlogView.js +53 -83
- package/dist/features/admin/components/AdminBrandsView.d.ts +2 -3
- package/dist/features/admin/components/AdminBrandsView.js +84 -83
- package/dist/features/admin/components/AdminBundlesView.js +82 -125
- package/dist/features/admin/components/AdminCarouselView.d.ts +2 -2
- package/dist/features/admin/components/AdminCarouselView.js +17 -52
- package/dist/features/admin/components/AdminCartsView.d.ts +2 -3
- package/dist/features/admin/components/AdminCartsView.js +39 -88
- package/dist/features/admin/components/AdminCategoriesView.d.ts +3 -3
- package/dist/features/admin/components/AdminCategoriesView.js +98 -92
- package/dist/features/admin/components/AdminCategoryEditorView.js +2 -2
- 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 +104 -111
- package/dist/features/admin/components/AdminCouponsView.d.ts +3 -6
- package/dist/features/admin/components/AdminCouponsView.js +66 -86
- package/dist/features/admin/components/AdminDigitalCodesView.d.ts +3 -0
- package/dist/features/admin/components/AdminDigitalCodesView.js +51 -0
- package/dist/features/admin/components/AdminFaqsView.d.ts +4 -4
- package/dist/features/admin/components/AdminFaqsView.js +77 -33
- 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 +67 -97
- package/dist/features/admin/components/AdminNotificationsView.d.ts +2 -3
- package/dist/features/admin/components/AdminNotificationsView.js +67 -93
- 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 -107
- package/dist/features/admin/components/AdminPayoutsView.d.ts +2 -3
- package/dist/features/admin/components/AdminPayoutsView.js +51 -91
- package/dist/features/admin/components/AdminPrizeDrawsView.d.ts +2 -3
- package/dist/features/admin/components/AdminPrizeDrawsView.js +39 -76
- package/dist/features/admin/components/AdminProductEditorView.js +3 -3
- package/dist/features/admin/components/AdminProductsView.d.ts +4 -4
- package/dist/features/admin/components/AdminProductsView.js +167 -163
- 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 -110
- package/dist/features/admin/components/AdminScammersView.d.ts +2 -3
- package/dist/features/admin/components/AdminScammersView.js +53 -97
- 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 -89
- package/dist/features/admin/components/AdminSiteSettingsView.js +4 -5
- 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 -99
- package/dist/features/admin/components/AdminSublistingCategoriesView.d.ts +1 -1
- package/dist/features/admin/components/AdminSublistingCategoriesView.js +28 -44
- 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 -96
- package/dist/features/admin/components/AdminTeamView.d.ts +2 -2
- package/dist/features/admin/components/AdminTeamView.js +40 -74
- package/dist/features/admin/components/AdminUserEditorView.d.ts +11 -1
- package/dist/features/admin/components/AdminUserEditorView.js +77 -7
- package/dist/features/admin/components/AdminUsersView.d.ts +2 -3
- package/dist/features/admin/components/AdminUsersView.js +108 -100
- package/dist/features/admin/components/AdminViewCards.d.ts +1 -1
- package/dist/features/admin/components/AdminViewCards.js +15 -15
- 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 +1 -0
- package/dist/features/admin/hooks/useAdminListing.js +1 -1
- 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/blog/components/BlogFeaturedCard.js +1 -0
- package/dist/features/cart/repository/cart.repository.d.ts +4 -1
- package/dist/features/cart/repository/cart.repository.js +12 -0
- package/dist/features/checkout/hooks/useCheckoutApi.d.ts +0 -2
- package/dist/features/checkout/index.d.ts +1 -1
- package/dist/features/events/components/AdminEventEditorView.js +10 -13
- package/dist/features/events/components/AdminEventsView.d.ts +3 -3
- package/dist/features/events/components/AdminEventsView.js +50 -86
- package/dist/features/events/components/EventCard.js +1 -0
- 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/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/faq/components/FAQPageContent.js +1 -0
- package/dist/features/filters/AsyncFacetSection.d.ts +1 -1
- package/dist/features/homepage/components/AdvertisementBanner.js +6 -6
- package/dist/features/homepage/components/FAQSection.d.ts +0 -5
- package/dist/features/homepage/components/HomepageSkeleton.js +2 -2
- package/dist/features/homepage/components/WelcomeSection.js +3 -3
- package/dist/features/homepage/lib/live-stats.js +1 -1
- package/dist/features/homepage/schemas/firestore.d.ts +0 -2
- package/dist/features/layout/TitleBar.js +1 -0
- package/dist/features/layout/index.d.ts +0 -2
- package/dist/features/layout/index.js +0 -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 +2 -2
- 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 +15 -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/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/types/index.d.ts +4 -0
- package/dist/features/promotions/components/CouponsIndexListing.js +4 -4
- package/dist/features/promotions/server.d.ts +0 -1
- package/dist/features/promotions/server.js +0 -1
- package/dist/features/reviews/components/ReviewDetailShell.js +3 -3
- 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 +4 -5
- package/dist/features/seller/components/SellerAuctionsView.d.ts +3 -3
- package/dist/features/seller/components/SellerAuctionsView.js +60 -90
- package/dist/features/seller/components/SellerBidsView.js +1 -1
- package/dist/features/seller/components/SellerBundlesView.js +64 -89
- package/dist/features/seller/components/SellerClassifiedView.js +67 -90
- 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 +45 -84
- package/dist/features/seller/components/SellerDigitalCodesView.js +63 -88
- package/dist/features/seller/components/SellerGroupedListingsView.js +33 -49
- package/dist/features/seller/components/SellerLiveView.js +63 -84
- 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 -69
- package/dist/features/seller/components/SellerOrdersView.d.ts +2 -2
- package/dist/features/seller/components/SellerOrdersView.js +4 -4
- package/dist/features/seller/components/SellerPayoutMethodsView.js +1 -1
- package/dist/features/seller/components/SellerPayoutsView.d.ts +2 -2
- package/dist/features/seller/components/SellerPayoutsView.js +34 -68
- package/dist/features/seller/components/SellerPreOrdersView.d.ts +2 -2
- package/dist/features/seller/components/SellerPreOrdersView.js +49 -82
- package/dist/features/seller/components/SellerPrizeDrawsView.d.ts +2 -2
- package/dist/features/seller/components/SellerPrizeDrawsView.js +49 -82
- package/dist/features/seller/components/SellerProductShell.d.ts +1 -1
- package/dist/features/seller/components/SellerProductsView.d.ts +2 -2
- package/dist/features/seller/components/SellerProductsView.js +15 -10
- package/dist/features/seller/components/SellerShippingConfigsView.js +1 -1
- 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 +1 -1
- package/dist/features/seller/components/SellerTemplatesView.js +2 -2
- 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 +7 -4
- 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/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/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 +9 -27
- package/dist/index.js +14 -50
- package/dist/next/routing/route-map.d.ts +8 -0
- package/dist/next/routing/route-map.js +4 -0
- package/dist/react/hooks/useListingTypeFlags.d.ts +32 -0
- package/dist/react/hooks/useListingTypeFlags.js +19 -0
- 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/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 +12 -14
- package/dist/ui/index.js +6 -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,95 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import React, { useState
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
-
import {
|
|
6
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
7
|
-
import { BulkActionBar, ConfirmDeleteModal, FilterChipGroup, ListingToolbar, ListingViewShell, Pagination, RowActionMenu, useToast, ListingFilterDrawer } from "../../../ui";
|
|
8
|
-
import { useBottomActions } from "../../layout";
|
|
5
|
+
import { ConfirmDeleteModal, FilterChipGroup, ListingLayout, RowActionMenu, useToast } from "../../../ui";
|
|
9
6
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
10
7
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
11
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
15
|
export function AdminContactView({ children, onBulkMarkRead, onBulkArchive, onBulkDelete, ...props }) {
|
|
27
|
-
const hasChildren = React.Children.count(children) > 0;
|
|
28
|
-
const [view, setView] = useState("table");
|
|
29
16
|
const queryClient = useQueryClient();
|
|
30
17
|
const { showToast } = useToast();
|
|
31
18
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
32
19
|
const [selectedRow, setSelectedRow] = useState(null);
|
|
33
20
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
34
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
35
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
36
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
37
|
-
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
38
|
-
const openFilters = useCallback(() => {
|
|
39
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
40
|
-
setFilterOpen(true);
|
|
41
|
-
}, [table]);
|
|
42
|
-
const applyFilters = useCallback(() => {
|
|
43
|
-
const updates = { page: "1" };
|
|
44
|
-
for (const k of FILTER_KEYS)
|
|
45
|
-
updates[k] = pendingFilters[k] ?? "";
|
|
46
|
-
table.setMany(updates);
|
|
47
|
-
setFilterOpen(false);
|
|
48
|
-
}, [pendingFilters, table]);
|
|
49
|
-
const clearFilters = useCallback(() => {
|
|
50
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
51
|
-
}, []);
|
|
52
|
-
const resetAll = useCallback(() => {
|
|
53
|
-
const updates = { q: "", sort: "" };
|
|
54
|
-
for (const k of FILTER_KEYS)
|
|
55
|
-
updates[k] = "";
|
|
56
|
-
table.setMany(updates);
|
|
57
|
-
setSearchInput("");
|
|
58
|
-
}, [table]);
|
|
59
|
-
const commitSearch = useCallback(() => {
|
|
60
|
-
table.set("q", searchInput.trim());
|
|
61
|
-
}, [searchInput, table]);
|
|
62
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
63
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
64
|
-
const statusRaw = table.get("status");
|
|
65
|
-
const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
|
|
66
|
-
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
67
|
-
queryKey: ["admin", "contact", "listing"],
|
|
68
|
-
endpoint: ADMIN_ENDPOINTS.CONTACT_SUBMISSIONS,
|
|
69
|
-
page: table.getNumber("page", 1),
|
|
70
|
-
pageSize: PAGE_SIZE,
|
|
71
|
-
sorts: table.get("sort") || DEFAULT_SORT,
|
|
72
|
-
filters,
|
|
73
|
-
q: table.get("q") || undefined,
|
|
74
|
-
mapRows: (response) => toRecordArray(response.submissions).map((item, index) => ({
|
|
75
|
-
id: toStringValue(item.id, `msg-${index}`),
|
|
76
|
-
primary: toStringValue(item.subject, "No subject"),
|
|
77
|
-
secondary: [
|
|
78
|
-
toStringValue(item.name, "Unknown"),
|
|
79
|
-
toStringValue(item.email, ""),
|
|
80
|
-
].filter(Boolean).join(" · ") || "—",
|
|
81
|
-
status: toStringValue(item.status, "new"),
|
|
82
|
-
updatedAt: toRelativeDate(item.createdAt),
|
|
83
|
-
_raw: item,
|
|
84
|
-
})),
|
|
85
|
-
getTotal: (response, mappedRows) => {
|
|
86
|
-
if (typeof response.meta?.filteredTotal === "number")
|
|
87
|
-
return response.meta.filteredTotal;
|
|
88
|
-
if (typeof response.meta?.total === "number")
|
|
89
|
-
return response.meta.total;
|
|
90
|
-
return mappedRows.length;
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
21
|
const actionMutation = useMutation({
|
|
94
22
|
mutationFn: async ({ id, action }) => {
|
|
95
23
|
await apiClient.patch(ADMIN_ENDPOINTS.CONTACT_SUBMISSION_BY_ID(id), { action });
|
|
@@ -116,39 +44,104 @@ export function AdminContactView({ children, onBulkMarkRead, onBulkArchive, onBu
|
|
|
116
44
|
showToast(err?.message ?? "Failed to delete.", "error");
|
|
117
45
|
},
|
|
118
46
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
|
|
122
|
-
const bulkActions = [
|
|
123
|
-
...(onBulkMarkRead ? [buildBulkAction(ACTIONS.ADMIN["mark-contact-read"], async () => { await onBulkMarkRead(selection.selectedIds); selection.clearSelection(); })] : []),
|
|
124
|
-
...(onBulkArchive ? [buildBulkAction(ACTIONS.ADMIN["archive-contact"], async () => { await onBulkArchive(selection.selectedIds); selection.clearSelection(); })] : []),
|
|
125
|
-
...(onBulkDelete ? [buildBulkAction(ACTIONS.ADMIN["delete-contact"], async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); })] : []),
|
|
126
|
-
];
|
|
127
|
-
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
|
|
128
|
-
if (hasChildren) {
|
|
129
|
-
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
47
|
+
if (React.Children.count(children) > 0) {
|
|
48
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
130
49
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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" })] }));
|
|
154
147
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export interface AdminCouponsViewProps extends ListingViewShellProps {
|
|
4
|
-
actionHref?: string;
|
|
5
|
-
getRowHref?: (row: AdminListingScaffoldRow) => string;
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export interface AdminCouponsViewProps extends ListingLayoutProps {
|
|
6
3
|
onBulkArchive?: (ids: string[]) => Promise<void>;
|
|
7
4
|
onBulkDelete?: (ids: string[]) => Promise<void>;
|
|
8
5
|
}
|
|
9
|
-
export declare function AdminCouponsView({ children,
|
|
6
|
+
export declare function AdminCouponsView({ children, onBulkArchive, onBulkDelete, ...props }: AdminCouponsViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,117 +1,97 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import React, {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
7
|
-
import { usePanelUrlSync } from "../../../react/hooks/use-panel-url-sync";
|
|
8
|
-
import { BulkActionBar, Button, Div, FilterChipGroup, ListingToolbar, Pagination, ListingViewShell, SideDrawer, Text, useToast, ListingFilterDrawer } from "../../../ui";
|
|
9
|
-
import { useBottomActions } from "../../layout";
|
|
3
|
+
import React, { useCallback } from "react";
|
|
4
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { Div, FilterChipGroup, ListingLayout, Text, useToast } from "../../../ui";
|
|
10
6
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
11
7
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
12
8
|
import { buildBulkAction } from "../../../_internal/shared/actions/bulk-helpers";
|
|
13
9
|
import { ROW_ACTION_META, ROW_ACTION_ID } from "../../products/constants/action-defs";
|
|
14
10
|
import { ADMIN_COUPON_TYPE_TABS } from "../constants/filter-tabs";
|
|
15
11
|
import { apiClient } from "../../../http";
|
|
16
|
-
import { toRecordArray, toStringValue,
|
|
12
|
+
import { toRecordArray, toStringValue, } from "../hooks/useAdminListingData";
|
|
13
|
+
import { DataListingView } from "./DataListingView";
|
|
17
14
|
import { AdminCouponEditorView } from "./AdminCouponEditorView";
|
|
18
15
|
import { CouponCard } from "../../promotions/components/CouponCard";
|
|
19
|
-
|
|
20
|
-
const FILTER_KEYS = ["type"];
|
|
21
|
-
const DEFAULT_SORT = "-createdAt";
|
|
22
|
-
const SORT_OPTIONS = [
|
|
23
|
-
{ value: "-createdAt", label: "Newest" },
|
|
24
|
-
{ value: "createdAt", label: "Oldest" },
|
|
25
|
-
{ value: "code", label: "Code A–Z" },
|
|
26
|
-
];
|
|
27
|
-
const TYPE_OPTIONS = ADMIN_COUPON_TYPE_TABS;
|
|
28
|
-
export function AdminCouponsView({ children, getRowHref, onBulkArchive, onBulkDelete, ...props }) {
|
|
29
|
-
const hasChildren = React.Children.count(children) > 0;
|
|
30
|
-
const [view, setView] = useState("table");
|
|
31
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
32
|
-
const { openCreatePanel, openEditPanel, closePanel, isCreateOpen, isEditOpen, editId } = usePanelUrlSync();
|
|
33
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
34
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
35
|
-
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
36
|
-
const openFilters = useCallback(() => {
|
|
37
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
38
|
-
setFilterOpen(true);
|
|
39
|
-
}, [table]);
|
|
40
|
-
const applyFilters = useCallback(() => {
|
|
41
|
-
const updates = { page: "1" };
|
|
42
|
-
for (const k of FILTER_KEYS)
|
|
43
|
-
updates[k] = pendingFilters[k] ?? "";
|
|
44
|
-
table.setMany(updates);
|
|
45
|
-
setFilterOpen(false);
|
|
46
|
-
}, [pendingFilters, table]);
|
|
47
|
-
const clearFilters = useCallback(() => {
|
|
48
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
49
|
-
}, []);
|
|
50
|
-
const resetAll = useCallback(() => {
|
|
51
|
-
const updates = { q: "", sort: "" };
|
|
52
|
-
for (const k of FILTER_KEYS)
|
|
53
|
-
updates[k] = "";
|
|
54
|
-
table.setMany(updates);
|
|
55
|
-
setSearchInput("");
|
|
56
|
-
}, [table]);
|
|
57
|
-
const commitSearch = useCallback(() => {
|
|
58
|
-
table.set("q", searchInput.trim());
|
|
59
|
-
}, [searchInput, table]);
|
|
60
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
61
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
62
|
-
const typeRaw = table.get("type");
|
|
63
|
-
const filters = typeRaw && typeRaw !== "All" ? `type==${typeRaw}` : undefined;
|
|
64
|
-
const { rows, total, isLoading, errorMessage, refetch } = useAdminListingData({
|
|
65
|
-
queryKey: ["admin", "coupons", "listing"],
|
|
66
|
-
endpoint: ADMIN_ENDPOINTS.COUPONS,
|
|
67
|
-
page: table.getNumber("page", 1),
|
|
68
|
-
pageSize: PAGE_SIZE,
|
|
69
|
-
sorts: table.get("sort") || DEFAULT_SORT,
|
|
70
|
-
filters,
|
|
71
|
-
q: table.get("q") || undefined,
|
|
72
|
-
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
73
|
-
id: toStringValue(item.id, `coupon-${index}`),
|
|
74
|
-
raw: item,
|
|
75
|
-
})),
|
|
76
|
-
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
77
|
-
});
|
|
16
|
+
export function AdminCouponsView({ children, onBulkArchive, onBulkDelete, ...props }) {
|
|
78
17
|
const { showToast } = useToast();
|
|
18
|
+
const queryClient = useQueryClient();
|
|
79
19
|
const handleToggle = useCallback(async (id, currentlyActive) => {
|
|
80
20
|
try {
|
|
81
21
|
await apiClient.patch(ADMIN_ENDPOINTS.COUPON_BY_ID(id), {
|
|
82
22
|
validity: { isActive: !currentlyActive },
|
|
83
23
|
});
|
|
84
24
|
showToast(currentlyActive ? "Coupon deactivated." : "Coupon activated.", "success");
|
|
85
|
-
|
|
25
|
+
queryClient.invalidateQueries({ queryKey: ["admin", "coupons"] });
|
|
86
26
|
}
|
|
87
27
|
catch {
|
|
88
28
|
showToast("Could not update coupon status.", "error");
|
|
89
29
|
}
|
|
90
|
-
}, [showToast,
|
|
30
|
+
}, [showToast, queryClient]);
|
|
91
31
|
const handleDelete = useCallback(async (id) => {
|
|
92
32
|
try {
|
|
93
33
|
await apiClient.delete(ADMIN_ENDPOINTS.COUPON_BY_ID(id));
|
|
94
34
|
showToast("Coupon deleted.", "success");
|
|
95
|
-
|
|
35
|
+
queryClient.invalidateQueries({ queryKey: ["admin", "coupons"] });
|
|
96
36
|
}
|
|
97
37
|
catch {
|
|
98
38
|
showToast("Could not delete coupon.", "error");
|
|
99
39
|
}
|
|
100
|
-
}, [showToast,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
|
|
104
|
-
const bulkActions = [
|
|
105
|
-
...(onBulkArchive ? [{
|
|
106
|
-
id: "bulk-archive",
|
|
107
|
-
label: ROW_ACTION_META[ROW_ACTION_ID.ARCHIVE].label,
|
|
108
|
-
onClick: async () => { await onBulkArchive(selection.selectedIds); selection.clearSelection(); },
|
|
109
|
-
}] : []),
|
|
110
|
-
...(onBulkDelete ? [buildBulkAction(ACTIONS.ADMIN["delete-coupon"], async () => { await onBulkDelete(selection.selectedIds); selection.clearSelection(); })] : []),
|
|
111
|
-
];
|
|
112
|
-
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
|
|
113
|
-
if (hasChildren) {
|
|
114
|
-
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
40
|
+
}, [showToast, queryClient]);
|
|
41
|
+
if (React.Children.count(children) > 0) {
|
|
42
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
115
43
|
}
|
|
116
|
-
|
|
44
|
+
const config = {
|
|
45
|
+
portal: "admin",
|
|
46
|
+
title: "Coupons",
|
|
47
|
+
searchPlaceholder: "Search codes, campaigns, or seller scopes",
|
|
48
|
+
emptyLabel: "No coupons found",
|
|
49
|
+
filterKeys: ["type"],
|
|
50
|
+
defaultSort: "-createdAt",
|
|
51
|
+
queryKey: ["admin", "coupons", "listing"],
|
|
52
|
+
endpoint: ADMIN_ENDPOINTS.COUPONS,
|
|
53
|
+
sortOptions: [
|
|
54
|
+
{ value: "-createdAt", label: "Newest" },
|
|
55
|
+
{ value: "createdAt", label: "Oldest" },
|
|
56
|
+
{ value: "code", label: "Code A–Z" },
|
|
57
|
+
],
|
|
58
|
+
hideTableView: true,
|
|
59
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
60
|
+
id: toStringValue(item.id, `coupon-${index}`),
|
|
61
|
+
raw: item,
|
|
62
|
+
})),
|
|
63
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
64
|
+
buildFilters: (state) => state.type && state.type !== "All" ? `type==${state.type}` : undefined,
|
|
65
|
+
primaryAction: {
|
|
66
|
+
label: "Add Coupon",
|
|
67
|
+
onClick: ({ openCreatePanel }) => openCreatePanel(),
|
|
68
|
+
},
|
|
69
|
+
buildBulkActions: (selection) => [
|
|
70
|
+
...(onBulkArchive
|
|
71
|
+
? [
|
|
72
|
+
{
|
|
73
|
+
id: "bulk-archive",
|
|
74
|
+
label: ROW_ACTION_META[ROW_ACTION_ID.ARCHIVE].label,
|
|
75
|
+
onClick: async () => {
|
|
76
|
+
await onBulkArchive(selection.selectedIds);
|
|
77
|
+
selection.clearSelection();
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
: []),
|
|
82
|
+
...(onBulkDelete
|
|
83
|
+
? [
|
|
84
|
+
buildBulkAction(ACTIONS.ADMIN["delete-coupon"], async () => {
|
|
85
|
+
await onBulkDelete(selection.selectedIds);
|
|
86
|
+
selection.clearSelection();
|
|
87
|
+
}),
|
|
88
|
+
]
|
|
89
|
+
: []),
|
|
90
|
+
],
|
|
91
|
+
renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Type", tabs: ADMIN_COUPON_TYPE_TABS, value: pendingFilters.type ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, type: id })) })),
|
|
92
|
+
renderCards: (rows, _view, selectionCtx, isLoading) => isLoading ? (_jsx(Div, { className: "fluid-grid-card gap-3", children: Array.from({ length: 6 }).map((_, i) => (_jsxs(Div, { className: "rounded-xl border-2 border-zinc-100 dark:border-slate-700 p-4 animate-pulse space-y-3", children: [_jsx(Div, { className: "h-6 bg-zinc-200 dark:bg-slate-700 rounded w-2/3" }), _jsx(Div, { className: "h-4 bg-zinc-200 dark:bg-slate-700 rounded w-full" }), _jsx(Div, { className: "h-3 bg-zinc-200 dark:bg-slate-700 rounded w-1/2" })] }, i))) })) : rows.length === 0 ? (_jsx(Div, { className: "py-16 text-center", children: _jsx(Text, { className: "text-zinc-400 dark:text-zinc-400", children: "No coupons found" }) })) : (_jsx(Div, { className: "fluid-grid-card gap-3", children: rows.map((row) => (_jsx(CouponCard, { coupon: row.raw, onEdit: selectionCtx.openEditPanel, onToggleActive: handleToggle, onDelete: handleDelete }, row.id))) })),
|
|
93
|
+
renderEditor: ({ editId, closePanel }) => (_jsx(AdminCouponEditorView, { couponId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })),
|
|
94
|
+
resolveEditorTitle: ({ isCreate }) => (isCreate ? "Add Coupon" : "Edit Coupon"),
|
|
95
|
+
};
|
|
96
|
+
return _jsx(DataListingView, { config: config });
|
|
117
97
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* AdminDigitalCodesView — admin browse of digital-code listings (W1-29).
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { ListingLayout } from "../../../ui";
|
|
8
|
+
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
9
|
+
import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../hooks/useAdminListingData";
|
|
10
|
+
import { DataListingView } from "./DataListingView";
|
|
11
|
+
const ADMIN_DIGITAL_CODES_CONFIG = {
|
|
12
|
+
portal: "admin",
|
|
13
|
+
title: "Digital Codes",
|
|
14
|
+
searchPlaceholder: "Search digital code listings",
|
|
15
|
+
emptyLabel: "No digital code listings",
|
|
16
|
+
filterKeys: [],
|
|
17
|
+
defaultSort: "-createdAt",
|
|
18
|
+
queryKey: ["admin", "digital-codes", "listing"],
|
|
19
|
+
endpoint: ADMIN_ENDPOINTS.PRODUCTS,
|
|
20
|
+
sortOptions: [
|
|
21
|
+
{ value: "-createdAt", label: "Newest" },
|
|
22
|
+
{ value: "createdAt", label: "Oldest" },
|
|
23
|
+
{ value: "title", label: "Title A–Z" },
|
|
24
|
+
],
|
|
25
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => {
|
|
26
|
+
const dc = (item.digitalCode ?? {});
|
|
27
|
+
return {
|
|
28
|
+
id: toStringValue(item.id, `dc-${index}`),
|
|
29
|
+
primary: toStringValue(item.title ?? item.productTitle, "Untitled digital code"),
|
|
30
|
+
secondary: [
|
|
31
|
+
toStringValue(item.sellerName, "Unknown seller"),
|
|
32
|
+
toRupees(item.price),
|
|
33
|
+
typeof dc.codesAvailable === "number"
|
|
34
|
+
? `${dc.codesAvailable} avail`
|
|
35
|
+
: null,
|
|
36
|
+
]
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.join(" · "),
|
|
39
|
+
status: toStringValue(item.status, "draft"),
|
|
40
|
+
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
41
|
+
};
|
|
42
|
+
}),
|
|
43
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
44
|
+
buildFilters: () => "listingType==digital-code",
|
|
45
|
+
};
|
|
46
|
+
export function AdminDigitalCodesView({ children, ...props }) {
|
|
47
|
+
if (React.Children.count(children) > 0) {
|
|
48
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
49
|
+
}
|
|
50
|
+
return _jsx(DataListingView, { config: ADMIN_DIGITAL_CODES_CONFIG });
|
|
51
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AdminListingScaffoldRow } from "./
|
|
3
|
-
export interface AdminFaqsViewProps extends
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
import type { AdminListingScaffoldRow } from "./DataListingView";
|
|
3
|
+
export interface AdminFaqsViewProps extends ListingLayoutProps {
|
|
4
4
|
actionHref?: string;
|
|
5
5
|
getRowHref?: (row: AdminListingScaffoldRow) => string;
|
|
6
6
|
onBulkArchive?: (ids: string[]) => Promise<void>;
|
|
7
7
|
onBulkDelete?: (ids: string[]) => Promise<void>;
|
|
8
8
|
}
|
|
9
|
-
export declare function AdminFaqsView({ children,
|
|
9
|
+
export declare function AdminFaqsView({ children, onBulkArchive, onBulkDelete, ...props }: AdminFaqsViewProps): import("react/jsx-runtime").JSX.Element;
|