@mohasinac/appkit 2.7.59 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/client/features/filters/filter-load-options.d.ts +4 -5
- package/dist/_internal/server/features/auctions/og.js +8 -32
- package/dist/_internal/server/features/blog/og.js +10 -49
- package/dist/_internal/server/features/checkout/actions.js +6 -0
- package/dist/_internal/server/features/classified/og.js +9 -51
- package/dist/_internal/server/features/digital-code/actions.d.ts +11 -0
- package/dist/_internal/server/features/digital-code/actions.js +30 -0
- package/dist/_internal/server/features/digital-code/index.d.ts +1 -0
- package/dist/_internal/server/features/digital-code/index.js +1 -0
- package/dist/_internal/server/features/digital-code/og.js +9 -51
- package/dist/_internal/server/features/events/og.js +10 -49
- package/dist/_internal/server/features/item-requests/data.d.ts +17 -0
- package/dist/_internal/server/features/item-requests/data.js +20 -0
- package/dist/_internal/server/features/item-requests/index.d.ts +2 -0
- package/dist/_internal/server/features/item-requests/index.js +2 -0
- package/dist/_internal/server/features/item-requests/og.d.ts +40 -0
- package/dist/_internal/server/features/item-requests/og.js +136 -0
- package/dist/_internal/server/features/live/actions.d.ts +5 -0
- package/dist/_internal/server/features/live/actions.js +24 -0
- package/dist/_internal/server/features/live/index.d.ts +1 -0
- package/dist/_internal/server/features/live/index.js +1 -0
- package/dist/_internal/server/features/live/og.js +9 -51
- package/dist/_internal/server/features/media/contextGuards.js +19 -8
- package/dist/_internal/server/features/pre-orders/og.js +8 -32
- package/dist/_internal/server/features/prize-draws/data.d.ts +17 -0
- package/dist/_internal/server/features/prize-draws/data.js +20 -0
- package/dist/_internal/server/features/prize-draws/index.d.ts +2 -0
- package/dist/_internal/server/features/prize-draws/index.js +2 -0
- package/dist/_internal/server/features/prize-draws/og.d.ts +30 -0
- package/dist/_internal/server/features/prize-draws/og.js +50 -0
- package/dist/_internal/server/features/products/og.js +8 -33
- package/dist/_internal/server/features/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/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/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 +80 -6
- 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/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/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/AdminEventsView.d.ts +3 -3
- package/dist/features/events/components/AdminEventsView.js +50 -86
- package/dist/features/events/components/EventOfferCard.d.ts +19 -0
- package/dist/features/events/components/EventOfferCard.js +29 -0
- package/dist/features/events/components/EventRaffleEntryForm.d.ts +25 -0
- package/dist/features/events/components/EventRaffleEntryForm.js +37 -0
- package/dist/features/events/components/EventRafflesSection.d.ts +1 -4
- package/dist/features/events/components/EventRafflesSection.js +17 -6
- package/dist/features/events/components/EventSaleBanner.d.ts +21 -0
- package/dist/features/events/components/EventSaleBanner.js +18 -0
- package/dist/features/events/components/index.d.ts +6 -0
- package/dist/features/events/components/index.js +4 -0
- package/dist/features/events/repository/event-entry.repository.d.ts +5 -0
- package/dist/features/events/repository/event-entry.repository.js +7 -0
- package/dist/features/filters/AsyncFacetSection.d.ts +1 -1
- package/dist/features/homepage/components/FAQSection.d.ts +0 -5
- package/dist/features/homepage/lib/live-stats.js +1 -1
- package/dist/features/homepage/schemas/firestore.d.ts +0 -2
- package/dist/features/layout/index.d.ts +0 -2
- package/dist/features/layout/index.js +0 -1
- package/dist/features/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 +14 -2
- package/dist/features/products/components/ProductTabsShell.d.ts +5 -1
- package/dist/features/products/components/ProductTabsShell.js +6 -1
- package/dist/features/products/components/index.d.ts +4 -0
- package/dist/features/products/components/index.js +3 -0
- package/dist/features/products/constants/action-defs.d.ts +5 -0
- package/dist/features/products/constants/action-defs.js +52 -32
- package/dist/features/products/constants/sieve.d.ts +24 -4
- package/dist/features/products/constants/sieve.js +20 -11
- package/dist/features/products/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/server.d.ts +0 -1
- package/dist/features/promotions/server.js +0 -1
- package/dist/features/search/api/route.js +44 -1
- package/dist/features/search/components/Search.js +2 -0
- package/dist/features/search/hooks/useNavSuggestions.d.ts +5 -1
- package/dist/features/search/hooks/useNavSuggestions.js +31 -4
- package/dist/features/seller/components/BrandInlineSelect.js +2 -2
- package/dist/features/seller/components/CategoryInlineSelect.js +2 -2
- package/dist/features/seller/components/SellerAddressesView.js +1 -1
- 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 +4 -1
- package/dist/features/shell/field-groups/ImageFieldGroup.d.ts +18 -0
- package/dist/features/shell/field-groups/ImageFieldGroup.js +15 -0
- package/dist/features/shell/field-groups/SeoFieldGroup.d.ts +22 -0
- package/dist/features/shell/field-groups/SeoFieldGroup.js +16 -0
- package/dist/features/shell/field-groups/StatusFieldGroup.d.ts +35 -0
- package/dist/features/shell/field-groups/StatusFieldGroup.js +16 -0
- package/dist/features/shell/field-groups/TitleDescriptionGroup.d.ts +40 -0
- package/dist/features/shell/field-groups/TitleDescriptionGroup.js +16 -0
- package/dist/features/shell/field-groups/index.d.ts +13 -0
- package/dist/features/shell/field-groups/index.js +9 -0
- package/dist/features/shell/index.d.ts +2 -0
- package/dist/features/shell/index.js +1 -0
- package/dist/features/stores/components/StoreCapabilitiesGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoreFinanceGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoreHeader.js +2 -1
- package/dist/features/stores/components/StoreListingsGuideView.d.ts +1 -2
- package/dist/features/stores/components/StoreOrdersGuideView.d.ts +1 -2
- package/dist/features/stores/components/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,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AdminListingScaffoldRow } from "./
|
|
3
|
-
export interface AdminProductsViewProps extends
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
import type { AdminListingScaffoldRow } from "./DataListingView";
|
|
3
|
+
export interface AdminProductsViewProps extends ListingLayoutProps {
|
|
4
4
|
actionHref?: string;
|
|
5
5
|
getRowHref?: (row: AdminListingScaffoldRow) => string;
|
|
6
6
|
}
|
|
7
|
-
export declare function AdminProductsView({ children,
|
|
7
|
+
export declare function AdminProductsView({ children, ...props }: AdminProductsViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import React, { useState, useCallback } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { useUrlTable } from "../../../react/hooks/useUrlTable";
|
|
6
|
-
import { usePanelUrlSync } from "../../../react/hooks/use-panel-url-sync";
|
|
7
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
8
|
-
import { useBottomActions } from "../../layout";
|
|
9
|
-
import { BulkActionBar, Button, FilterChipGroup, Heading, ListingFilterDrawer, ListingToolbar, ListingViewShell, Pagination, SideDrawer, Text, Toggle, useToast } from "../../../ui";
|
|
4
|
+
import { ListingLayout, Text, Toggle, useToast } from "../../../ui";
|
|
10
5
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
11
6
|
import { ADMIN_PRODUCT_STATUS_TABS, ADMIN_PRODUCT_LISTING_TYPE_TABS, } from "../constants/filter-tabs";
|
|
12
|
-
import { toRecordArray, toRelativeDate, toStringValue,
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
7
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
8
|
+
import { DataListingView } from "./DataListingView";
|
|
9
|
+
import { FilterChipGroup } from "../../../ui";
|
|
15
10
|
import { apiClient } from "../../../http";
|
|
16
11
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
17
12
|
import { AdminProductEditorView } from "./AdminProductEditorView";
|
|
18
13
|
import { QuickEditMenu } from "./QuickEditMenu";
|
|
19
|
-
const PAGE_SIZE = 25;
|
|
20
|
-
const FILTER_KEYS = ["status", "type"];
|
|
21
|
-
const DEFAULT_SORT = "-createdAt";
|
|
22
|
-
const SORT_OPTIONS = [
|
|
23
|
-
{ value: "-createdAt", label: "Newest" },
|
|
24
|
-
{ value: "createdAt", label: "Oldest" },
|
|
25
|
-
{ value: "title", label: "Title A–Z" },
|
|
26
|
-
{ value: "-price", label: "Highest price" },
|
|
27
|
-
];
|
|
28
|
-
const STATUS_OPTIONS = ADMIN_PRODUCT_STATUS_TABS;
|
|
29
|
-
const TYPE_OPTIONS = ADMIN_PRODUCT_LISTING_TYPE_TABS;
|
|
30
14
|
const FLAG_DEFS = [
|
|
31
15
|
{ key: "featured", label: "Featured" },
|
|
32
16
|
{ key: "isPromoted", label: "Promoted" },
|
|
33
17
|
{ key: "isOnSale", label: "On Sale" },
|
|
34
18
|
{ key: "isSold", label: "Sold" },
|
|
35
19
|
];
|
|
20
|
+
const TYPE_FILTER_MAP = {
|
|
21
|
+
Auctions: "listingType==auction",
|
|
22
|
+
"Pre-orders": "listingType==pre-order",
|
|
23
|
+
"Prize Draws": "listingType==prize-draw",
|
|
24
|
+
Products: "listingType==standard",
|
|
25
|
+
Classifieds: "listingType==classified",
|
|
26
|
+
"Digital Codes": "listingType==digital-code",
|
|
27
|
+
"Live Items": "listingType==live",
|
|
28
|
+
};
|
|
36
29
|
function buildBaseColumns() {
|
|
37
30
|
return [
|
|
38
31
|
{
|
|
@@ -57,93 +50,11 @@ function buildBaseColumns() {
|
|
|
57
50
|
},
|
|
58
51
|
];
|
|
59
52
|
}
|
|
60
|
-
export function AdminProductsView({ children,
|
|
61
|
-
const hasChildren = React.Children.count(children) > 0;
|
|
53
|
+
export function AdminProductsView({ children, ...props }) {
|
|
62
54
|
const [overrides, setOverrides] = useState({});
|
|
63
55
|
const { showToast } = useToast();
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const { openCreatePanel, openEditPanel, closePanel, isCreateOpen, isEditOpen, editId } = usePanelUrlSync();
|
|
67
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
68
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
69
|
-
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
70
|
-
const openFilters = useCallback(() => {
|
|
71
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
72
|
-
setFilterOpen(true);
|
|
73
|
-
}, [table]);
|
|
74
|
-
const applyFilters = useCallback(() => {
|
|
75
|
-
const updates = { page: "1" };
|
|
76
|
-
for (const k of FILTER_KEYS)
|
|
77
|
-
updates[k] = pendingFilters[k] ?? "";
|
|
78
|
-
table.setMany(updates);
|
|
79
|
-
setFilterOpen(false);
|
|
80
|
-
}, [pendingFilters, table]);
|
|
81
|
-
const clearFilters = useCallback(() => {
|
|
82
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
83
|
-
}, []);
|
|
84
|
-
const resetAll = useCallback(() => {
|
|
85
|
-
const updates = { q: "", sort: "", showSold: "" };
|
|
86
|
-
for (const k of FILTER_KEYS)
|
|
87
|
-
updates[k] = "";
|
|
88
|
-
table.setMany(updates);
|
|
89
|
-
setSearchInput("");
|
|
90
|
-
}, [table]);
|
|
91
|
-
const commitSearch = useCallback(() => {
|
|
92
|
-
table.set("q", searchInput.trim());
|
|
93
|
-
}, [searchInput, table]);
|
|
94
|
-
const showSold = table.get("showSold") === "true";
|
|
95
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
96
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0 || showSold;
|
|
97
|
-
const filterParts = [];
|
|
98
|
-
if (!showSold)
|
|
99
|
-
filterParts.push("isSold==false");
|
|
100
|
-
const statusRaw = table.get("status");
|
|
101
|
-
if (statusRaw && statusRaw !== "All")
|
|
102
|
-
filterParts.push(`status==${statusRaw}`);
|
|
103
|
-
const typeRaw = table.get("type");
|
|
104
|
-
if (typeRaw && typeRaw !== "All") {
|
|
105
|
-
const TYPE_FILTER = {
|
|
106
|
-
Auctions: "listingType==auction",
|
|
107
|
-
"Pre-orders": "listingType==pre-order",
|
|
108
|
-
"Prize Draws": "listingType==prize-draw",
|
|
109
|
-
Products: "listingType==standard",
|
|
110
|
-
Classifieds: "listingType==classified",
|
|
111
|
-
"Digital Codes": "listingType==digital-code",
|
|
112
|
-
"Live Items": "listingType==live",
|
|
113
|
-
};
|
|
114
|
-
const typeFilter = TYPE_FILTER[typeRaw];
|
|
115
|
-
if (typeFilter)
|
|
116
|
-
filterParts.push(typeFilter);
|
|
117
|
-
}
|
|
118
|
-
const filters = filterParts.join(",") || undefined;
|
|
119
|
-
const { rows: fetchedRows, total, isLoading, errorMessage } = useAdminListingData({
|
|
120
|
-
queryKey: ["admin", "products", "listing"],
|
|
121
|
-
endpoint: ADMIN_ENDPOINTS.PRODUCTS,
|
|
122
|
-
page: table.getNumber("page", 1),
|
|
123
|
-
pageSize: PAGE_SIZE,
|
|
124
|
-
sorts: table.get("sort") || DEFAULT_SORT,
|
|
125
|
-
filters,
|
|
126
|
-
q: table.get("q") || undefined,
|
|
127
|
-
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
128
|
-
id: toStringValue(item.id, `product-${index}`),
|
|
129
|
-
primary: toStringValue(item.title ?? item.name, "Untitled product"),
|
|
130
|
-
secondary: [
|
|
131
|
-
toStringValue(item.sellerName, "Unknown seller"),
|
|
132
|
-
toStringValue(item.sku, "No SKU"),
|
|
133
|
-
].join(" · "),
|
|
134
|
-
status: toStringValue(item.status, "Unknown"),
|
|
135
|
-
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
136
|
-
featured: Boolean(item.featured),
|
|
137
|
-
isPromoted: Boolean(item.isPromoted),
|
|
138
|
-
isOnSale: Boolean(item.isOnSale),
|
|
139
|
-
isSold: Boolean(item.isSold),
|
|
140
|
-
})),
|
|
141
|
-
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
142
|
-
});
|
|
143
|
-
const rows = fetchedRows.map((r) => overrides[r.id] ? { ...r, ...overrides[r.id] } : r);
|
|
144
|
-
const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
|
|
145
|
-
const handleToggle = async (id, field, value) => {
|
|
146
|
-
const prev = fetchedRows.find((r) => r.id === id)?.[field];
|
|
56
|
+
const handleToggle = useCallback(async (id, field, value) => {
|
|
57
|
+
const prev = overrides[id]?.[field];
|
|
147
58
|
setOverrides((o) => ({ ...o, [id]: { ...o[id], [field]: value } }));
|
|
148
59
|
try {
|
|
149
60
|
await apiClient.patch(ADMIN_ENDPOINTS.PRODUCT_BY_ID(id), { [field]: value });
|
|
@@ -152,9 +63,9 @@ export function AdminProductsView({ children, actionHref, getRowHref, ...props }
|
|
|
152
63
|
setOverrides((o) => ({ ...o, [id]: { ...o[id], [field]: prev } }));
|
|
153
64
|
showToast(err?.message ?? "Failed to update product.", "error");
|
|
154
65
|
}
|
|
155
|
-
};
|
|
66
|
+
}, [showToast, overrides]);
|
|
156
67
|
const handleQuickEdit = useCallback(async (id, values) => {
|
|
157
|
-
const prev =
|
|
68
|
+
const prev = overrides[id];
|
|
158
69
|
setOverrides((o) => ({ ...o, [id]: { ...o[id], ...values } }));
|
|
159
70
|
try {
|
|
160
71
|
await apiClient.patch(ADMIN_ENDPOINTS.PRODUCT_BY_ID(id), values);
|
|
@@ -166,65 +77,158 @@ export function AdminProductsView({ children, actionHref, getRowHref, ...props }
|
|
|
166
77
|
showToast(err?.message ?? "Failed to update product.", "error");
|
|
167
78
|
throw err;
|
|
168
79
|
}
|
|
169
|
-
}, [
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (hasChildren) {
|
|
173
|
-
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
80
|
+
}, [showToast, overrides]);
|
|
81
|
+
if (React.Children.count(children) > 0) {
|
|
82
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
174
83
|
}
|
|
175
84
|
const flagColumn = {
|
|
176
85
|
key: "flags",
|
|
177
86
|
header: "Flags",
|
|
178
87
|
className: "w-56",
|
|
179
|
-
render: (row) => (_jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), role: "presentation", children: FLAG_DEFS.map(({ key, label }) => (_jsx(Toggle, { size: "sm", label: label, checked: !!row[key], onChange: (v) => {
|
|
88
|
+
render: (row) => (_jsx("div", { className: "flex flex-wrap gap-x-3 gap-y-1", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), role: "presentation", children: FLAG_DEFS.map(({ key, label }) => (_jsx(Toggle, { size: "sm", label: label, checked: !!row[key], onChange: (v) => {
|
|
89
|
+
void handleToggle(row.id, key, v);
|
|
90
|
+
} }, key))) })),
|
|
91
|
+
};
|
|
92
|
+
// We need showSold state to be derived from URL — read it via a small inner component
|
|
93
|
+
// that uses the listing's own table state. To keep things simple, use a ref into the
|
|
94
|
+
// config's render-prop chain via `renderAboveContent` which has no useUrlTable.
|
|
95
|
+
// Simplest: use buildFilters which gets the full filterState, and add showSold to filterKeys.
|
|
96
|
+
const config = {
|
|
97
|
+
portal: "admin",
|
|
98
|
+
title: "Products",
|
|
99
|
+
searchPlaceholder: "Search products, SKUs, or seller names",
|
|
100
|
+
emptyLabel: "No products found",
|
|
101
|
+
filterKeys: ["status", "type", "showSold"],
|
|
102
|
+
defaultSort: "-createdAt",
|
|
103
|
+
queryKey: ["admin", "products", "listing"],
|
|
104
|
+
endpoint: ADMIN_ENDPOINTS.PRODUCTS,
|
|
105
|
+
sortOptions: [
|
|
106
|
+
{ value: "-createdAt", label: "Newest" },
|
|
107
|
+
{ value: "createdAt", label: "Oldest" },
|
|
108
|
+
{ value: "title", label: "Title A–Z" },
|
|
109
|
+
{ value: "-price", label: "Highest price" },
|
|
110
|
+
],
|
|
111
|
+
columns: [...buildBaseColumns(), flagColumn],
|
|
112
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => {
|
|
113
|
+
const id = toStringValue(item.id, `product-${index}`);
|
|
114
|
+
const base = {
|
|
115
|
+
id,
|
|
116
|
+
primary: toStringValue(item.title ?? item.name, "Untitled product"),
|
|
117
|
+
secondary: [
|
|
118
|
+
toStringValue(item.sellerName, "Unknown seller"),
|
|
119
|
+
toStringValue(item.sku, "No SKU"),
|
|
120
|
+
].join(" · "),
|
|
121
|
+
status: toStringValue(item.status, "Unknown"),
|
|
122
|
+
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
123
|
+
featured: Boolean(item.featured),
|
|
124
|
+
isPromoted: Boolean(item.isPromoted),
|
|
125
|
+
isOnSale: Boolean(item.isOnSale),
|
|
126
|
+
isSold: Boolean(item.isSold),
|
|
127
|
+
};
|
|
128
|
+
return overrides[id] ? { ...base, ...overrides[id] } : base;
|
|
129
|
+
}),
|
|
130
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
131
|
+
buildFilters: (state) => {
|
|
132
|
+
const parts = [];
|
|
133
|
+
if (state.showSold !== "true")
|
|
134
|
+
parts.push("isSold==false");
|
|
135
|
+
if (state.status && state.status !== "All")
|
|
136
|
+
parts.push(`status==${state.status}`);
|
|
137
|
+
const typeFilter = TYPE_FILTER_MAP[state.type];
|
|
138
|
+
if (typeFilter)
|
|
139
|
+
parts.push(typeFilter);
|
|
140
|
+
return parts.join(",") || undefined;
|
|
141
|
+
},
|
|
142
|
+
primaryAction: {
|
|
143
|
+
label: "Add Product",
|
|
144
|
+
onClick: ({ openCreatePanel }) => openCreatePanel(),
|
|
145
|
+
},
|
|
146
|
+
buildBulkActions: (selection) => [
|
|
147
|
+
{
|
|
148
|
+
id: "feature",
|
|
149
|
+
label: ACTIONS.ADMIN["toggle-featured"].label,
|
|
150
|
+
variant: "secondary",
|
|
151
|
+
onClick: () => {
|
|
152
|
+
for (const id of selection.selectedIds) {
|
|
153
|
+
const row = selection.rows.find((r) => r.id === id);
|
|
154
|
+
if (row)
|
|
155
|
+
void handleToggle(id, "featured", !row.featured);
|
|
156
|
+
}
|
|
157
|
+
selection.clearSelection();
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: "promote",
|
|
162
|
+
label: ACTIONS.ADMIN["toggle-promoted"].label,
|
|
163
|
+
variant: "secondary",
|
|
164
|
+
onClick: () => {
|
|
165
|
+
for (const id of selection.selectedIds) {
|
|
166
|
+
const row = selection.rows.find((r) => r.id === id);
|
|
167
|
+
if (row)
|
|
168
|
+
void handleToggle(id, "isPromoted", !row.isPromoted);
|
|
169
|
+
}
|
|
170
|
+
selection.clearSelection();
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: "sale",
|
|
175
|
+
label: ACTIONS.ADMIN["toggle-on-sale"].label,
|
|
176
|
+
variant: "secondary",
|
|
177
|
+
onClick: () => {
|
|
178
|
+
for (const id of selection.selectedIds) {
|
|
179
|
+
const row = selection.rows.find((r) => r.id === id);
|
|
180
|
+
if (row)
|
|
181
|
+
void handleToggle(id, "isOnSale", !row.isOnSale);
|
|
182
|
+
}
|
|
183
|
+
selection.clearSelection();
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
renderRowActions: (row) => (_jsx(QuickEditMenu, { actions: [
|
|
188
|
+
{
|
|
189
|
+
label: ACTIONS.ADMIN["approve-product"].label,
|
|
190
|
+
onClick: () => handleQuickEdit(row.id, { status: "published" }),
|
|
191
|
+
disabled: row.status === "published",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
label: ACTIONS.ADMIN["reject-product"].label,
|
|
195
|
+
destructive: true,
|
|
196
|
+
onClick: () => handleQuickEdit(row.id, { status: "rejected" }),
|
|
197
|
+
disabled: row.status === "rejected",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
label: "Quick edit",
|
|
201
|
+
separator: true,
|
|
202
|
+
formTitle: "Quick Edit Product",
|
|
203
|
+
fields: [
|
|
204
|
+
{
|
|
205
|
+
name: "status",
|
|
206
|
+
label: "Status",
|
|
207
|
+
type: "select",
|
|
208
|
+
required: true,
|
|
209
|
+
options: ADMIN_PRODUCT_STATUS_TABS.filter((t) => t.id !== "All").map((t) => ({
|
|
210
|
+
value: t.id,
|
|
211
|
+
label: t.label,
|
|
212
|
+
})),
|
|
213
|
+
},
|
|
214
|
+
{ name: "featured", label: "Featured", type: "toggle" },
|
|
215
|
+
{ name: "isPromoted", label: "Promoted", type: "toggle" },
|
|
216
|
+
],
|
|
217
|
+
defaultValues: {
|
|
218
|
+
status: row.status,
|
|
219
|
+
featured: row.featured,
|
|
220
|
+
isPromoted: row.isPromoted,
|
|
221
|
+
},
|
|
222
|
+
onSubmit: (vals) => handleQuickEdit(row.id, vals),
|
|
223
|
+
submitLabel: "Save",
|
|
224
|
+
},
|
|
225
|
+
] })),
|
|
226
|
+
renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsxs(_Fragment, { children: [_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_PRODUCT_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }), _jsx(FilterChipGroup, { label: "Type", tabs: ADMIN_PRODUCT_LISTING_TYPE_TABS, value: pendingFilters.type ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, type: id })) }), _jsx(FilterChipGroup, { label: "Sold", tabs: [
|
|
227
|
+
{ id: "", label: "Hide sold" },
|
|
228
|
+
{ id: "true", label: "Show sold" },
|
|
229
|
+
], value: pendingFilters.showSold ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, showSold: id })), allId: "" })] })),
|
|
230
|
+
renderEditor: ({ editId, closePanel }) => (_jsx(AdminProductEditorView, { productId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })),
|
|
231
|
+
resolveEditorTitle: ({ isCreate }) => (isCreate ? "Add Product" : "Edit Product"),
|
|
180
232
|
};
|
|
181
|
-
|
|
182
|
-
{ id: "feature", label: ACTIONS.ADMIN["toggle-featured"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
|
|
183
|
-
void handleToggle(id, "featured", !rows.find(r => r.id === id)?.featured); selection.clearSelection(); } },
|
|
184
|
-
{ id: "promote", label: ACTIONS.ADMIN["toggle-promoted"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
|
|
185
|
-
void handleToggle(id, "isPromoted", !rows.find(r => r.id === id)?.isPromoted); selection.clearSelection(); } },
|
|
186
|
-
{ id: "sale", label: ACTIONS.ADMIN["toggle-on-sale"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
|
|
187
|
-
void handleToggle(id, "isOnSale", !rows.find(r => r.id === id)?.isOnSale); selection.clearSelection(); } },
|
|
188
|
-
] } } : {});
|
|
189
|
-
return (_jsxs("div", { className: "min-h-screen", children: [_jsx(Heading, { level: 1, className: "sr-only", children: "Products" }), _jsx(ListingToolbar, { filterCount: activeFilterCount, onFiltersClick: openFilters, searchValue: searchInput, searchPlaceholder: "Search products, SKUs, or seller names", onSearchChange: setSearchInput, onSearchCommit: commitSearch, sortValue: table.get("sort") || DEFAULT_SORT, sortOptions: SORT_OPTIONS, onSortChange: (v) => { table.set("sort", v); }, showTableView: true, view: view, onViewChange: (v) => setView(v), onResetAll: resetAll, hasActiveState: hasActiveState, toggles: [
|
|
190
|
-
{ label: "Show sold", active: showSold, onChange: (next) => table.set("showSold", next ? "true" : "") },
|
|
191
|
-
], extra: _jsxs(Button, { size: "sm", onClick: openCreatePanel, className: "flex items-center gap-1.5", children: [_jsx(Plus, { className: "h-4 w-4" }), "Add Product"] }) }), _jsx(BulkActionBar, { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: [
|
|
192
|
-
{ id: "feature", label: ACTIONS.ADMIN["toggle-featured"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
|
|
193
|
-
void handleToggle(id, "featured", !rows.find(r => r.id === id)?.featured); selection.clearSelection(); } },
|
|
194
|
-
{ id: "promote", label: ACTIONS.ADMIN["toggle-promoted"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
|
|
195
|
-
void handleToggle(id, "isPromoted", !rows.find(r => r.id === id)?.isPromoted); selection.clearSelection(); } },
|
|
196
|
-
{ id: "sale", label: ACTIONS.ADMIN["toggle-on-sale"].label, variant: "secondary", onClick: () => { for (const id of selection.selectedIds)
|
|
197
|
-
void handleToggle(id, "isOnSale", !rows.find(r => r.id === id)?.isOnSale); selection.clearSelection(); } },
|
|
198
|
-
] }), totalPages > 1 && (_jsx("div", { className: "sticky top-[calc(var(--header-height,0px)+44px)] z-10 flex justify-center bg-white/95 dark:bg-slate-900/95 backdrop-blur-sm border-b border-zinc-200 dark:border-slate-700 px-3 py-1.5", children: _jsx(Pagination, { currentPage: currentPage, totalPages: totalPages, onPageChange: (p) => table.setPage(p) }) })), _jsxs("div", { className: "py-4 px-3 sm:px-4", children: [errorMessage && (_jsx("div", { className: "mb-4 rounded-xl border border-red-200 bg-error-surface px-4 py-3 text-sm text-error dark:border-red-900/60", children: errorMessage })), view === "table" ? (_jsx(DataTable, { rows: rows, columns: [...buildBaseColumns(), flagColumn], isLoading: isLoading, emptyLabel: "No products found", onRowClick: (row) => openEditPanel(row.id), selectedIds: selection.selectedIdSet, onToggleSelect: selection.toggle, onToggleSelectAll: (next) => next ? selection.setSelectedIds(rows.map(r => r.id)) : selection.clearSelection(), renderRowActions: (row) => (_jsx(QuickEditMenu, { actions: [
|
|
199
|
-
{
|
|
200
|
-
label: ACTIONS.ADMIN["approve-product"].label,
|
|
201
|
-
onClick: () => handleQuickEdit(row.id, { status: "published" }),
|
|
202
|
-
disabled: row.status === "published",
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
label: ACTIONS.ADMIN["reject-product"].label,
|
|
206
|
-
destructive: true,
|
|
207
|
-
onClick: () => handleQuickEdit(row.id, { status: "rejected" }),
|
|
208
|
-
disabled: row.status === "rejected",
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
label: "Quick edit",
|
|
212
|
-
separator: true,
|
|
213
|
-
formTitle: "Quick Edit Product",
|
|
214
|
-
fields: [
|
|
215
|
-
{ name: "status", label: "Status", type: "select", required: true,
|
|
216
|
-
options: STATUS_OPTIONS.filter((t) => t.id !== "All").map((t) => ({ value: t.id, label: t.label })) },
|
|
217
|
-
{ name: "featured", label: "Featured", type: "toggle" },
|
|
218
|
-
{ name: "isPromoted", label: "Promoted", type: "toggle" },
|
|
219
|
-
],
|
|
220
|
-
defaultValues: { status: row.status, featured: row.featured, isPromoted: row.isPromoted },
|
|
221
|
-
onSubmit: (vals) => handleQuickEdit(row.id, vals),
|
|
222
|
-
submitLabel: "Save",
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
label: "Open full editor",
|
|
226
|
-
separator: true,
|
|
227
|
-
onClick: () => openEditPanel(row.id),
|
|
228
|
-
},
|
|
229
|
-
] })) })) : (_jsx(AdminViewCards, { rows: rows, view: view, isLoading: isLoading, emptyLabel: "No products found", onRowClick: (row) => openEditPanel(row.id), selectedIdSet: selection.selectedIdSet, onToggleSelect: selection.toggle }))] }), _jsxs(ListingFilterDrawer, { open: filterOpen, onClose: () => setFilterOpen(false), onApply: applyFilters, onClear: clearFilters, activeCount: activeFilterCount, children: [_jsx(FilterChipGroup, { label: "Status", tabs: STATUS_OPTIONS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) }), _jsx(FilterChipGroup, { label: "Type", tabs: TYPE_OPTIONS, value: pendingFilters.type ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, type: id })) })] }), _jsx(SideDrawer, { isOpen: isCreateOpen || isEditOpen, onClose: closePanel, title: isCreateOpen ? "Add Product" : "Edit Product", mode: isCreateOpen ? "create" : "edit", children: (isCreateOpen || isEditOpen) && (_jsx(AdminProductEditorView, { productId: editId ?? undefined, onSaved: closePanel, onDeleted: closePanel, embedded: true })) })] }));
|
|
233
|
+
return _jsx(DataListingView, { config: config });
|
|
230
234
|
}
|
|
@@ -2,4 +2,4 @@ import React from "react";
|
|
|
2
2
|
export interface AdminReturnRequestsViewProps {
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
}
|
|
5
|
-
export declare function AdminReturnRequestsView(
|
|
5
|
+
export declare function AdminReturnRequestsView(_props: AdminReturnRequestsViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,61 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import { useState
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
-
import {
|
|
6
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
7
|
-
import { ListingToolbar, Pagination, ConfirmDeleteModal, RowActionMenu, useToast } from "../../../ui";
|
|
5
|
+
import { ConfirmDeleteModal, RowActionMenu, useToast } from "../../../ui";
|
|
8
6
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
9
7
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
10
|
-
import { toRecordArray, toRelativeDate, toRupees, toStringValue,
|
|
11
|
-
import {
|
|
8
|
+
import { toRecordArray, toRelativeDate, toRupees, toStringValue, } from "../hooks/useAdminListingData";
|
|
9
|
+
import { DataListingView } from "./DataListingView";
|
|
12
10
|
import { apiClient } from "../../../http";
|
|
13
|
-
|
|
14
|
-
const DEFAULT_SORT = "-createdAt";
|
|
15
|
-
const SORT_OPTIONS = [
|
|
16
|
-
{ value: "-createdAt", label: "Newest" },
|
|
17
|
-
{ value: "createdAt", label: "Oldest" },
|
|
18
|
-
];
|
|
19
|
-
export function AdminReturnRequestsView({ children: _children }) {
|
|
11
|
+
export function AdminReturnRequestsView(_props) {
|
|
20
12
|
const queryClient = useQueryClient();
|
|
21
13
|
const { showToast } = useToast();
|
|
22
14
|
const [approveOpen, setApproveOpen] = useState(false);
|
|
23
15
|
const [rejectOpen, setRejectOpen] = useState(false);
|
|
24
16
|
const [selectedRow, setSelectedRow] = useState(null);
|
|
25
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
26
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
27
|
-
const [view, setView] = useState("table");
|
|
28
|
-
const resetAll = useCallback(() => {
|
|
29
|
-
table.setMany({ q: "", sort: "" });
|
|
30
|
-
setSearchInput("");
|
|
31
|
-
}, [table]);
|
|
32
|
-
const commitSearch = useCallback(() => {
|
|
33
|
-
table.set("q", searchInput.trim());
|
|
34
|
-
}, [searchInput, table]);
|
|
35
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT;
|
|
36
|
-
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
37
|
-
queryKey: ["admin", "return-requests", "listing"],
|
|
38
|
-
endpoint: `${ADMIN_ENDPOINTS.ORDERS}?status=RETURN_REQUESTED`,
|
|
39
|
-
page: table.getNumber("page", 1),
|
|
40
|
-
pageSize: PAGE_SIZE,
|
|
41
|
-
sorts: table.get("sort") || DEFAULT_SORT,
|
|
42
|
-
q: table.get("q") || undefined,
|
|
43
|
-
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
44
|
-
id: toStringValue(item.id, `order-${index}`),
|
|
45
|
-
primary: toStringValue(item.id, "Unknown order"),
|
|
46
|
-
secondary: [
|
|
47
|
-
toStringValue(item.buyerName ?? item.buyerId, "Unknown buyer"),
|
|
48
|
-
toRupees(item.totalAmount),
|
|
49
|
-
].join(" · "),
|
|
50
|
-
status: toStringValue(item.status, "RETURN_REQUESTED"),
|
|
51
|
-
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
52
|
-
_raw: item,
|
|
53
|
-
})),
|
|
54
|
-
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
55
|
-
});
|
|
56
17
|
const approveMutation = useMutation({
|
|
57
18
|
mutationFn: async (orderId) => {
|
|
58
|
-
await apiClient.patch(ADMIN_ENDPOINTS.ORDER_BY_ID(orderId), { status: "
|
|
19
|
+
await apiClient.patch(ADMIN_ENDPOINTS.ORDER_BY_ID(orderId), { status: "refunded" });
|
|
59
20
|
},
|
|
60
21
|
onSuccess: () => {
|
|
61
22
|
showToast("Return approved — order marked as Refunded.", "success");
|
|
@@ -70,7 +31,7 @@ export function AdminReturnRequestsView({ children: _children }) {
|
|
|
70
31
|
});
|
|
71
32
|
const rejectMutation = useMutation({
|
|
72
33
|
mutationFn: async (orderId) => {
|
|
73
|
-
await apiClient.patch(ADMIN_ENDPOINTS.ORDER_BY_ID(orderId), { status: "
|
|
34
|
+
await apiClient.patch(ADMIN_ENDPOINTS.ORDER_BY_ID(orderId), { status: "delivered" });
|
|
74
35
|
},
|
|
75
36
|
onSuccess: () => {
|
|
76
37
|
showToast("Return rejected — order reverted to Delivered.", "success");
|
|
@@ -83,23 +44,60 @@ export function AdminReturnRequestsView({ children: _children }) {
|
|
|
83
44
|
showToast(err?.message ?? "Failed to reject return.", "error");
|
|
84
45
|
},
|
|
85
46
|
});
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
47
|
+
const config = {
|
|
48
|
+
portal: "admin",
|
|
49
|
+
title: "Return Requests",
|
|
50
|
+
searchPlaceholder: "Search by order ID or buyer",
|
|
51
|
+
emptyLabel: "No return requests",
|
|
52
|
+
filterKeys: [],
|
|
53
|
+
defaultSort: "-createdAt",
|
|
54
|
+
queryKey: ["admin", "return-requests", "listing"],
|
|
55
|
+
endpoint: `${ADMIN_ENDPOINTS.ORDERS}?status=return_requested`,
|
|
56
|
+
sortOptions: [
|
|
57
|
+
{ value: "-createdAt", label: "Newest" },
|
|
58
|
+
{ value: "createdAt", label: "Oldest" },
|
|
59
|
+
],
|
|
60
|
+
mapRows: (response) => toRecordArray(response.items).map((item, index) => ({
|
|
61
|
+
id: toStringValue(item.id, `order-${index}`),
|
|
62
|
+
primary: toStringValue(item.id, "Unknown order"),
|
|
63
|
+
secondary: [
|
|
64
|
+
toStringValue(item.buyerName ?? item.buyerId, "Unknown buyer"),
|
|
65
|
+
toRupees(item.totalAmount),
|
|
66
|
+
].join(" · "),
|
|
67
|
+
status: toStringValue(item.status, "return_requested"),
|
|
68
|
+
updatedAt: toRelativeDate(item.updatedAt ?? item.createdAt),
|
|
69
|
+
})),
|
|
70
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
71
|
+
buildFilters: () => undefined,
|
|
72
|
+
renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
|
|
73
|
+
{
|
|
74
|
+
label: ACTIONS.ADMIN["approve-return"].label,
|
|
75
|
+
onClick: () => {
|
|
76
|
+
setSelectedRow(row);
|
|
77
|
+
setApproveOpen(true);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
label: ACTIONS.ADMIN["reject-return"].label,
|
|
82
|
+
destructive: true,
|
|
83
|
+
onClick: () => {
|
|
84
|
+
setSelectedRow(row);
|
|
85
|
+
setRejectOpen(true);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
] })),
|
|
89
|
+
};
|
|
90
|
+
return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), _jsx(ConfirmDeleteModal, { isOpen: approveOpen, onClose: () => {
|
|
91
|
+
setApproveOpen(false);
|
|
92
|
+
setSelectedRow(null);
|
|
93
|
+
}, onConfirm: () => {
|
|
94
|
+
if (selectedRow)
|
|
95
|
+
approveMutation.mutate(selectedRow.id);
|
|
96
|
+
}, isDeleting: approveMutation.isPending, title: ACTIONS.ADMIN["approve-return"].confirmation.title, message: "The order status will be updated to Refunded. The buyer will be notified and the refund process will begin.", confirmText: ACTIONS.ADMIN["approve-return"].confirmation.confirmLabel, variant: "primary" }), _jsx(ConfirmDeleteModal, { isOpen: rejectOpen, onClose: () => {
|
|
97
|
+
setRejectOpen(false);
|
|
98
|
+
setSelectedRow(null);
|
|
99
|
+
}, onConfirm: () => {
|
|
100
|
+
if (selectedRow)
|
|
101
|
+
rejectMutation.mutate(selectedRow.id);
|
|
102
|
+
}, isDeleting: rejectMutation.isPending, title: ACTIONS.ADMIN["reject-return"].confirmation.title, message: "The order status will be reverted to Delivered. The buyer's return request will be declined.", confirmText: ACTIONS.ADMIN["reject-return"].confirmation.confirmLabel, variant: "danger" })] }));
|
|
105
103
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
/** @deprecated Use `detailView` instead. */
|
|
5
|
-
renderDetailView?: () => React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare function AdminReviewsView({ renderDetailView, children, ...props }: AdminReviewsViewProps): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export type AdminReviewsViewProps = ListingLayoutProps;
|
|
3
|
+
export declare function AdminReviewsView({ children, ...props }: AdminReviewsViewProps): import("react/jsx-runtime").JSX.Element;
|