@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,91 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import React, {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useCallback, useState } from "react";
|
|
4
4
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
-
import {
|
|
6
|
-
import { useBulkSelection } from "../../../react/hooks/useBulkSelection";
|
|
7
|
-
import { BulkActionBar, Button, ConfirmDeleteModal, FilterChipGroup, ListingToolbar, ListingViewShell, Pagination, RowActionMenu, useToast, ListingFilterDrawer } from "../../../ui";
|
|
8
|
-
import { useBottomActions } from "../../layout";
|
|
5
|
+
import { Button, 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 { ADMIN_NEWSLETTER_STATUS_TABS } from "../constants/filter-tabs";
|
|
13
|
-
import { toRecordArray, toRelativeDate, toStringValue,
|
|
14
|
-
import {
|
|
10
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
11
|
+
import { DataListingView } from "./DataListingView";
|
|
15
12
|
import { apiClient } from "../../../http";
|
|
16
|
-
const PAGE_SIZE = 25;
|
|
17
|
-
const FILTER_KEYS = ["status"];
|
|
18
|
-
const DEFAULT_SORT = "-subscribedAt";
|
|
19
|
-
const SORT_OPTIONS = [
|
|
20
|
-
{ value: "-subscribedAt", label: "Newest" },
|
|
21
|
-
{ value: "subscribedAt", label: "Oldest" },
|
|
22
|
-
];
|
|
23
|
-
const STATUS_OPTIONS = ADMIN_NEWSLETTER_STATUS_TABS;
|
|
24
13
|
export function AdminNewsletterView({ children, onBulkUnsubscribe, ...props }) {
|
|
25
|
-
const hasChildren = React.Children.count(children) > 0;
|
|
26
|
-
const [view, setView] = useState("table");
|
|
27
14
|
const queryClient = useQueryClient();
|
|
28
15
|
const { showToast } = useToast();
|
|
29
16
|
const [unsubscribeOpen, setUnsubscribeOpen] = useState(false);
|
|
30
17
|
const [selectedRow, setSelectedRow] = useState(null);
|
|
31
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
32
|
-
const [searchInput, setSearchInput] = useState(table.get("q") || "");
|
|
33
|
-
const [filterOpen, setFilterOpen] = useState(false);
|
|
34
|
-
const [pendingFilters, setPendingFilters] = useState(() => Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
35
|
-
const openFilters = useCallback(() => {
|
|
36
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, table.get(k)])));
|
|
37
|
-
setFilterOpen(true);
|
|
38
|
-
}, [table]);
|
|
39
|
-
const applyFilters = useCallback(() => {
|
|
40
|
-
const updates = { page: "1" };
|
|
41
|
-
for (const k of FILTER_KEYS)
|
|
42
|
-
updates[k] = pendingFilters[k] ?? "";
|
|
43
|
-
table.setMany(updates);
|
|
44
|
-
setFilterOpen(false);
|
|
45
|
-
}, [pendingFilters, table]);
|
|
46
|
-
const clearFilters = useCallback(() => {
|
|
47
|
-
setPendingFilters(Object.fromEntries(FILTER_KEYS.map((k) => [k, ""])));
|
|
48
|
-
}, []);
|
|
49
|
-
const resetAll = useCallback(() => {
|
|
50
|
-
const updates = { q: "", sort: "" };
|
|
51
|
-
for (const k of FILTER_KEYS)
|
|
52
|
-
updates[k] = "";
|
|
53
|
-
table.setMany(updates);
|
|
54
|
-
setSearchInput("");
|
|
55
|
-
}, [table]);
|
|
56
|
-
const commitSearch = useCallback(() => {
|
|
57
|
-
table.set("q", searchInput.trim());
|
|
58
|
-
}, [searchInput, table]);
|
|
59
|
-
const activeFilterCount = FILTER_KEYS.filter((k) => !!table.get(k)).length;
|
|
60
|
-
const hasActiveState = !!table.get("q") || table.get("sort") !== DEFAULT_SORT || activeFilterCount > 0;
|
|
61
|
-
const statusRaw = table.get("status");
|
|
62
|
-
const filters = statusRaw && statusRaw !== "All" ? `status==${statusRaw}` : undefined;
|
|
63
|
-
const { rows, total, isLoading, errorMessage } = useAdminListingData({
|
|
64
|
-
queryKey: ["admin", "newsletter", "listing"],
|
|
65
|
-
endpoint: ADMIN_ENDPOINTS.NEWSLETTER,
|
|
66
|
-
page: table.getNumber("page", 1),
|
|
67
|
-
pageSize: PAGE_SIZE,
|
|
68
|
-
sorts: table.get("sort") || DEFAULT_SORT,
|
|
69
|
-
filters,
|
|
70
|
-
q: table.get("q") || undefined,
|
|
71
|
-
mapRows: (response) => toRecordArray(response.subscribers).map((item, index) => ({
|
|
72
|
-
id: toStringValue(item.id, `sub-${index}`),
|
|
73
|
-
primary: toStringValue(item.email, "Unknown email"),
|
|
74
|
-
secondary: [
|
|
75
|
-
toStringValue(item.source, ""),
|
|
76
|
-
item.ipAddress ? "IP logged" : "",
|
|
77
|
-
].filter(Boolean).join(" · ") || "—",
|
|
78
|
-
status: toStringValue(item.status, "unknown"),
|
|
79
|
-
updatedAt: toRelativeDate(item.subscribedAt ?? item.createdAt),
|
|
80
|
-
})),
|
|
81
|
-
getTotal: (response, mappedRows) => {
|
|
82
|
-
if (typeof response.meta?.filteredTotal === "number")
|
|
83
|
-
return response.meta.filteredTotal;
|
|
84
|
-
if (typeof response.meta?.total === "number")
|
|
85
|
-
return response.meta.total;
|
|
86
|
-
return mappedRows.length;
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
18
|
const unsubscribeMutation = useMutation({
|
|
90
19
|
mutationFn: async (id) => {
|
|
91
20
|
await apiClient.delete(ADMIN_ENDPOINTS.NEWSLETTER_BY_ID(id));
|
|
@@ -117,26 +46,67 @@ export function AdminNewsletterView({ children, onBulkUnsubscribe, ...props }) {
|
|
|
117
46
|
showToast("Failed to export CSV.", "error");
|
|
118
47
|
}
|
|
119
48
|
}, [showToast]);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
|
|
123
|
-
const bulkActions = [
|
|
124
|
-
...(onBulkUnsubscribe ? [buildBulkAction(ACTIONS.ADMIN["unsubscribe-newsletter"], async () => { await onBulkUnsubscribe(selection.selectedIds); selection.clearSelection(); })] : []),
|
|
125
|
-
];
|
|
126
|
-
useBottomActions(selection.selectedCount > 0 ? { bulk: { selectedCount: selection.selectedCount, onClearSelection: selection.clearSelection, actions: bulkActions } } : {});
|
|
127
|
-
if (hasChildren) {
|
|
128
|
-
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
49
|
+
if (React.Children.count(children) > 0) {
|
|
50
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
129
51
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
52
|
+
const config = {
|
|
53
|
+
portal: "admin",
|
|
54
|
+
title: "Newsletter",
|
|
55
|
+
searchPlaceholder: "Search by email or source",
|
|
56
|
+
emptyLabel: "No subscribers found",
|
|
57
|
+
filterKeys: ["status"],
|
|
58
|
+
defaultSort: "-subscribedAt",
|
|
59
|
+
queryKey: ["admin", "newsletter", "listing"],
|
|
60
|
+
endpoint: ADMIN_ENDPOINTS.NEWSLETTER,
|
|
61
|
+
sortOptions: [
|
|
62
|
+
{ value: "-subscribedAt", label: "Newest" },
|
|
63
|
+
{ value: "subscribedAt", label: "Oldest" },
|
|
64
|
+
],
|
|
65
|
+
mapRows: (response) => toRecordArray(response.subscribers).map((item, index) => ({
|
|
66
|
+
id: toStringValue(item.id, `sub-${index}`),
|
|
67
|
+
primary: toStringValue(item.email, "Unknown email"),
|
|
68
|
+
secondary: [toStringValue(item.source, ""), item.ipAddress ? "IP logged" : ""]
|
|
69
|
+
.filter(Boolean)
|
|
70
|
+
.join(" · ") || "—",
|
|
71
|
+
status: toStringValue(item.status, "unknown"),
|
|
72
|
+
updatedAt: toRelativeDate(item.subscribedAt ??
|
|
73
|
+
item.createdAt),
|
|
74
|
+
})),
|
|
75
|
+
getTotal: (response, mappedRows) => {
|
|
76
|
+
if (typeof response.meta?.filteredTotal === "number")
|
|
77
|
+
return response.meta.filteredTotal;
|
|
78
|
+
if (typeof response.meta?.total === "number")
|
|
79
|
+
return response.meta.total;
|
|
80
|
+
return mappedRows.length;
|
|
81
|
+
},
|
|
82
|
+
buildFilters: (state) => state.status && state.status !== "All" ? `status==${state.status}` : undefined,
|
|
83
|
+
toolbarExtra: (_jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: handleExportCsv, children: ACTIONS.ADMIN["export-csv"].label })),
|
|
84
|
+
buildBulkActions: onBulkUnsubscribe
|
|
85
|
+
? (selection) => [
|
|
86
|
+
buildBulkAction(ACTIONS.ADMIN["unsubscribe-newsletter"], async () => {
|
|
87
|
+
await onBulkUnsubscribe(selection.selectedIds);
|
|
88
|
+
selection.clearSelection();
|
|
89
|
+
}),
|
|
90
|
+
]
|
|
91
|
+
: undefined,
|
|
92
|
+
renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
|
|
93
|
+
{
|
|
94
|
+
label: ACTIONS.ADMIN["unsubscribe-newsletter"].label,
|
|
95
|
+
destructive: true,
|
|
96
|
+
disabled: row.status === "unsubscribed",
|
|
97
|
+
onClick: () => {
|
|
98
|
+
setSelectedRow(row);
|
|
99
|
+
setUnsubscribeOpen(true);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
] })),
|
|
103
|
+
renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsx(FilterChipGroup, { label: "Status", tabs: ADMIN_NEWSLETTER_STATUS_TABS, value: pendingFilters.status ?? "", onChange: (id) => setPendingFilters((p) => ({ ...p, status: id })) })),
|
|
104
|
+
};
|
|
105
|
+
return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), _jsx(ConfirmDeleteModal, { isOpen: unsubscribeOpen, onClose: () => {
|
|
106
|
+
setUnsubscribeOpen(false);
|
|
107
|
+
setSelectedRow(null);
|
|
108
|
+
}, onConfirm: () => {
|
|
109
|
+
if (selectedRow)
|
|
110
|
+
unsubscribeMutation.mutate(selectedRow.id);
|
|
111
|
+
}, isDeleting: unsubscribeMutation.isPending, title: `Unsubscribe ${selectedRow?.primary ?? "subscriber"}?`, message: "The subscriber will be marked as unsubscribed and will no longer receive newsletter emails.", confirmText: "Unsubscribe", variant: "warning" })] }));
|
|
142
112
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
}
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export type AdminNotificationsViewProps = ListingLayoutProps;
|
|
4
3
|
export declare function AdminNotificationsView({ children, ...props }: AdminNotificationsViewProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,87 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import React, { useState
|
|
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, ListingToolbar, ListingViewShell, Pagination, RowActionMenu, Text, useToast, ListingFilterDrawer } from "../../../ui";
|
|
5
|
+
import { ConfirmDeleteModal, ListingLayout, RowActionMenu, Text, useToast } from "../../../ui";
|
|
8
6
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
9
7
|
import { ACTIONS } from "../../../_internal/shared/actions/action-registry";
|
|
10
8
|
import { ROW_ACTION_META, ROW_ACTION_ID } from "../../products/constants/action-defs";
|
|
11
|
-
import { toRecordArray, toRelativeDate, toStringValue,
|
|
12
|
-
import {
|
|
9
|
+
import { toRecordArray, toRelativeDate, toStringValue, } from "../hooks/useAdminListingData";
|
|
10
|
+
import { DataListingView } from "./DataListingView";
|
|
13
11
|
import { apiClient } from "../../../http";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const DEFAULT_SORT = "-createdAt";
|
|
18
|
-
const SORT_OPTIONS = [
|
|
19
|
-
{ value: "-createdAt", label: "Newest" },
|
|
20
|
-
{ value: "createdAt", label: "Oldest" },
|
|
21
|
-
];
|
|
22
|
-
const NOTIF_TYPES = [
|
|
23
|
-
"All", "order_placed", "order_shipped", "order_delivered", "order_cancelled",
|
|
24
|
-
"bid_placed", "bid_outbid", "bid_won", "review_posted", "payout_processed",
|
|
25
|
-
];
|
|
12
|
+
import { NOTIFICATION_TYPES } from "../../../constants/notification-types";
|
|
13
|
+
// W1-33 — sourced from shared NOTIFICATION_TYPES registry, prefixed with "All".
|
|
14
|
+
const NOTIF_TYPES = ["All", ...NOTIFICATION_TYPES];
|
|
26
15
|
export function AdminNotificationsView({ children, ...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 [deleteTarget, setDeleteTarget] = useState(null);
|
|
32
|
-
const table = useUrlTable({ defaults: { pageSize: String(PAGE_SIZE), sort: DEFAULT_SORT } });
|
|
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 } = useAdminListingData({
|
|
65
|
-
queryKey: ["admin", "notifications", "listing"],
|
|
66
|
-
endpoint: ADMIN_ENDPOINTS.ADMIN_NOTIFICATIONS,
|
|
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, `notif-${index}`),
|
|
74
|
-
primary: toStringValue(item.title, "Notification"),
|
|
75
|
-
secondary: [
|
|
76
|
-
toStringValue(item.userId, ""),
|
|
77
|
-
toStringValue(item.type, ""),
|
|
78
|
-
].filter(Boolean).join(" · "),
|
|
79
|
-
status: Boolean(item.isRead) ? "Read" : "Unread",
|
|
80
|
-
updatedAt: toRelativeDate(item.createdAt),
|
|
81
|
-
type: toStringValue(item.type, ""),
|
|
82
|
-
})),
|
|
83
|
-
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
84
|
-
});
|
|
85
19
|
const deleteMutation = useMutation({
|
|
86
20
|
mutationFn: async (id) => {
|
|
87
21
|
await apiClient.delete(ADMIN_ENDPOINTS.ADMIN_NOTIFICATION_BY_ID(id));
|
|
@@ -107,25 +41,65 @@ export function AdminNotificationsView({ children, ...props }) {
|
|
|
107
41
|
showToast(err?.message ?? "Failed to resend notification.", "error");
|
|
108
42
|
},
|
|
109
43
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const selection = useBulkSelection({ items: rows, keyExtractor: (r) => r.id });
|
|
113
|
-
if (hasChildren) {
|
|
114
|
-
return _jsx(ListingViewShell, { portal: "admin", ...props, children: children });
|
|
44
|
+
if (React.Children.count(children) > 0) {
|
|
45
|
+
return (_jsx(ListingLayout, { portal: "admin", ...props, children: children }));
|
|
115
46
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
47
|
+
const config = {
|
|
48
|
+
portal: "admin",
|
|
49
|
+
title: "Notifications",
|
|
50
|
+
searchPlaceholder: "Search by title or user ID",
|
|
51
|
+
emptyLabel: "No notifications found",
|
|
52
|
+
filterKeys: ["type"],
|
|
53
|
+
defaultSort: "-createdAt",
|
|
54
|
+
queryKey: ["admin", "notifications", "listing"],
|
|
55
|
+
endpoint: ADMIN_ENDPOINTS.ADMIN_NOTIFICATIONS,
|
|
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, `notif-${index}`),
|
|
62
|
+
primary: toStringValue(item.title, "Notification"),
|
|
63
|
+
secondary: [toStringValue(item.userId, ""), toStringValue(item.type, "")]
|
|
64
|
+
.filter(Boolean)
|
|
65
|
+
.join(" · "),
|
|
66
|
+
status: Boolean(item.isRead) ? "Read" : "Unread",
|
|
67
|
+
updatedAt: toRelativeDate(item.createdAt),
|
|
68
|
+
type: toStringValue(item.type, ""),
|
|
69
|
+
})),
|
|
70
|
+
getTotal: (response, mappedRows) => typeof response.total === "number" ? response.total : mappedRows.length,
|
|
71
|
+
buildFilters: (state) => state.type && state.type !== "All" ? `type==${state.type}` : undefined,
|
|
72
|
+
buildBulkActions: (selection) => [
|
|
73
|
+
{
|
|
74
|
+
id: ROW_ACTION_ID.MARK_READ,
|
|
75
|
+
label: ACTIONS.ADMIN["mark-read"].label,
|
|
76
|
+
variant: "primary",
|
|
77
|
+
onClick: () => selection.clearSelection(),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: ROW_ACTION_ID.DELETE,
|
|
81
|
+
label: ACTIONS.ADMIN["delete-notification"].label,
|
|
82
|
+
variant: "secondary",
|
|
83
|
+
onClick: () => selection.clearSelection(),
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
renderRowActions: (row) => (_jsx(RowActionMenu, { actions: [
|
|
87
|
+
{
|
|
88
|
+
label: ACTIONS.ADMIN["resend-notification"].label,
|
|
89
|
+
onClick: () => resendMutation.mutate(row.id),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: ROW_ACTION_META[ROW_ACTION_ID.DELETE].label,
|
|
93
|
+
destructive: ROW_ACTION_META[ROW_ACTION_ID.DELETE].destructive,
|
|
94
|
+
onClick: () => setDeleteTarget(row),
|
|
95
|
+
},
|
|
96
|
+
] })),
|
|
97
|
+
renderFilterPanel: ({ pendingFilters, setPendingFilters }) => (_jsxs("div", { className: "space-y-2", children: [_jsx(Text, { className: "text-xs font-semibold uppercase tracking-widest text-zinc-500 dark:text-zinc-400", children: "Type" }), _jsx("div", { className: "flex flex-wrap gap-2", children: NOTIF_TYPES.map((opt) => (_jsx("button", { type: "button", onClick: () => setPendingFilters((p) => ({ ...p, type: opt === "All" ? "" : opt })), className: `rounded-full px-3 py-1 text-xs font-medium border transition-colors ${(pendingFilters.type || "All") === opt
|
|
98
|
+
? "bg-primary text-white border-primary"
|
|
99
|
+
: "border-zinc-300 dark:border-slate-600 text-zinc-700 dark:text-zinc-300 hover:bg-zinc-50 dark:hover:bg-slate-800"}`, children: opt }, opt))) })] })),
|
|
100
|
+
};
|
|
101
|
+
return (_jsxs(_Fragment, { children: [_jsx(DataListingView, { config: config }), _jsx(ConfirmDeleteModal, { isOpen: Boolean(deleteTarget), onClose: () => setDeleteTarget(null), onConfirm: () => {
|
|
102
|
+
if (deleteTarget)
|
|
103
|
+
deleteMutation.mutate(deleteTarget.id);
|
|
104
|
+
}, isDeleting: deleteMutation.isPending, title: "Delete notification?", message: "This notification will be permanently removed.", confirmText: "Delete", variant: "danger" })] }));
|
|
131
105
|
}
|
|
@@ -6,13 +6,13 @@ import { Button, Form, FormActions, Input, Select, SideDrawer, useToast, } from
|
|
|
6
6
|
import { apiClient } from "../../../http";
|
|
7
7
|
import { ADMIN_ENDPOINTS } from "../../../constants/api-endpoints";
|
|
8
8
|
const STATUS_OPTIONS = [
|
|
9
|
-
{ label: "Pending", value: "
|
|
10
|
-
{ label: "Processing", value: "
|
|
11
|
-
{ label: "Shipped", value: "
|
|
12
|
-
{ label: "Delivered", value: "
|
|
13
|
-
{ label: "Cancelled", value: "
|
|
14
|
-
{ label: "Refunded", value: "
|
|
15
|
-
{ label: "Return requested", value: "
|
|
9
|
+
{ label: "Pending", value: "pending" },
|
|
10
|
+
{ label: "Processing", value: "processing" },
|
|
11
|
+
{ label: "Shipped", value: "shipped" },
|
|
12
|
+
{ label: "Delivered", value: "delivered" },
|
|
13
|
+
{ label: "Cancelled", value: "cancelled" },
|
|
14
|
+
{ label: "Refunded", value: "refunded" },
|
|
15
|
+
{ label: "Return requested", value: "return_requested" },
|
|
16
16
|
];
|
|
17
17
|
const CARRIER_OPTIONS = [
|
|
18
18
|
{ label: "Select carrier…", value: "" },
|
|
@@ -27,14 +27,14 @@ const CARRIER_OPTIONS = [
|
|
|
27
27
|
export function AdminOrderEditorView({ open, onClose, orderId, orderLabel, currentStatus, }) {
|
|
28
28
|
const queryClient = useQueryClient();
|
|
29
29
|
const { showToast } = useToast();
|
|
30
|
-
const [status, setStatus] = React.useState(currentStatus ?? "
|
|
30
|
+
const [status, setStatus] = React.useState(currentStatus ?? "pending");
|
|
31
31
|
const [trackingNumber, setTrackingNumber] = React.useState("");
|
|
32
32
|
const [carrier, setCarrier] = React.useState("");
|
|
33
33
|
const [notes, setNotes] = React.useState("");
|
|
34
34
|
const [refundAmount, setRefundAmount] = React.useState("");
|
|
35
35
|
React.useEffect(() => {
|
|
36
36
|
if (open) {
|
|
37
|
-
setStatus(currentStatus ?? "
|
|
37
|
+
setStatus(currentStatus ?? "pending");
|
|
38
38
|
setTrackingNumber("");
|
|
39
39
|
setCarrier("");
|
|
40
40
|
setNotes("");
|
|
@@ -70,5 +70,5 @@ export function AdminOrderEditorView({ open, onClose, orderId, orderLabel, curre
|
|
|
70
70
|
return (_jsx(SideDrawer, { isOpen: open, onClose: onClose, title: orderLabel ? `Order: ${orderLabel}` : "Update Order", children: _jsxs(Form, { onSubmit: (e) => {
|
|
71
71
|
e.preventDefault();
|
|
72
72
|
saveMutation.mutate();
|
|
73
|
-
}, className: "space-y-4 p-4", children: [_jsx(Select, { label: "Order status", options: STATUS_OPTIONS, value: status, onValueChange: setStatus }), _jsx(Input, { label: "Tracking number (optional)", value: trackingNumber, onChange: (e) => setTrackingNumber(e.target.value), placeholder: "e.g. DEL1234567890IN" }), _jsx(Select, { label: "Carrier (optional)", options: CARRIER_OPTIONS, value: carrier, onValueChange: setCarrier }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Internal note (optional)" }), _jsx("textarea", { value: notes, onChange: (e) => setNotes(e.target.value), rows: 3, placeholder: "Reason for status change, escalation notes\u2026", className: "w-full rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-primary-500" })] }), (status === "
|
|
73
|
+
}, className: "space-y-4 p-4", children: [_jsx(Select, { label: "Order status", options: STATUS_OPTIONS, value: status, onValueChange: setStatus }), _jsx(Input, { label: "Tracking number (optional)", value: trackingNumber, onChange: (e) => setTrackingNumber(e.target.value), placeholder: "e.g. DEL1234567890IN" }), _jsx(Select, { label: "Carrier (optional)", options: CARRIER_OPTIONS, value: carrier, onValueChange: setCarrier }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { className: "text-sm font-medium text-zinc-700 dark:text-zinc-300", children: "Internal note (optional)" }), _jsx("textarea", { value: notes, onChange: (e) => setNotes(e.target.value), rows: 3, placeholder: "Reason for status change, escalation notes\u2026", className: "w-full rounded-lg border border-zinc-300 dark:border-zinc-700 bg-white dark:bg-zinc-800 px-3 py-2 text-sm text-zinc-900 dark:text-zinc-100 placeholder-zinc-400 focus:outline-none focus:ring-2 focus:ring-primary-500" })] }), (status === "refunded" || status === "return_requested") && (_jsx(Input, { label: "Refund amount \u20B9 (optional)", type: "number", min: "0", step: "0.01", value: refundAmount, onChange: (e) => setRefundAmount(e.target.value), placeholder: "e.g. 499.00" })), _jsxs(FormActions, { align: "right", children: [_jsx(Button, { type: "button", variant: "secondary", onClick: onClose, children: "Cancel" }), _jsx(Button, { type: "submit", isLoading: saveMutation.isPending, disabled: !orderId || saveMutation.isPending, children: "Save changes" })] })] }) }));
|
|
74
74
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
}
|
|
1
|
+
import type { ListingLayoutProps } from "../../../ui";
|
|
2
|
+
export type AdminOrdersViewProps = ListingLayoutProps;
|
|
4
3
|
export declare function AdminOrdersView({ children, ...props }: AdminOrdersViewProps): import("react/jsx-runtime").JSX.Element;
|