@mohasinac/appkit 4.56.0 → 4.58.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/.build-stamp.json +4 -4
- package/dist/_internal/server/features/beys/data.d.ts +44 -0
- package/dist/_internal/server/features/beys/data.js +107 -0
- package/dist/_internal/server/features/beys/og.d.ts +42 -0
- package/dist/_internal/server/features/beys/og.js +89 -0
- package/dist/_internal/server/features/checkout/actions.d.ts +31 -0
- package/dist/_internal/server/features/checkout/actions.js +117 -5
- package/dist/_internal/server/features/orders/actions.d.ts +30 -0
- package/dist/_internal/server/features/orders/actions.js +103 -0
- package/dist/_internal/server/features/orders/adapters.js +7 -0
- package/dist/_internal/server/features/parts/data.js +3 -2
- package/dist/_internal/shared/actions/action-registry.d.ts +1 -1
- package/dist/_internal/shared/actions/action-registry.js +139 -0
- package/dist/_internal/shared/shipping/quote.js +5 -6
- package/dist/client.d.ts +23 -0
- package/dist/client.js +3 -0
- package/dist/constants/api-endpoints.d.ts +12 -0
- package/dist/constants/api-endpoints.js +10 -0
- package/dist/constants/field-names.d.ts +46 -0
- package/dist/constants/field-names.js +46 -0
- package/dist/features/about/components/PublicProfileView.js +2 -1
- package/dist/features/account/components/UserOrdersView.js +25 -3
- package/dist/features/admin/components/AdminBeysView.d.ts +27 -0
- package/dist/features/admin/components/AdminBeysView.js +178 -0
- package/dist/features/admin/components/AdminPartsView.d.ts +27 -0
- package/dist/features/admin/components/AdminPartsView.js +160 -0
- package/dist/features/admin/components/OwnerQuickActions.d.ts +19 -2
- package/dist/features/admin/components/OwnerQuickActions.js +83 -8
- package/dist/features/admin/components/RecordOwnerQuickActions.d.ts +31 -0
- package/dist/features/admin/components/RecordOwnerQuickActions.js +128 -0
- package/dist/features/admin/components/ReferenceRecordEditor.d.ts +45 -0
- package/dist/features/admin/components/ReferenceRecordEditor.js +153 -0
- package/dist/features/admin/schemas/firestore.d.ts +1 -1
- package/dist/features/auctions/components/MarketplaceAuctionCard.js +15 -2
- package/dist/features/auth/permissions/constants.d.ts +1 -1
- package/dist/features/auth/permissions/constants.js +12 -1
- package/dist/features/beys/components/BeyDetailPageView.d.ts +50 -0
- package/dist/features/beys/components/BeyDetailPageView.js +98 -0
- package/dist/features/beys/schemas/firestore.d.ts +417 -0
- package/dist/features/beys/schemas/firestore.js +65 -0
- package/dist/features/blog/components/BlogFeaturedCard.js +15 -2
- package/dist/features/blog/components/BlogPostView.js +2 -1
- package/dist/features/cart/components/CartPriceBreakdown.d.ts +2 -0
- package/dist/features/cart/components/CartPriceBreakdown.js +1 -1
- package/dist/features/categories/components/BrandDetailPageView.js +4 -2
- package/dist/features/categories/components/BundleDetailView.js +2 -2
- package/dist/features/categories/components/CategoryDetailPageView.js +36 -3
- package/dist/features/categories/components/CategoryGrid.js +24 -2
- package/dist/features/categories/components/FranchiseDetailPageView.js +2 -1
- package/dist/features/events/components/EventCard.js +15 -2
- package/dist/features/faq/components/FAQPageContent.js +17 -4
- package/dist/features/faq/constants/help-guides.d.ts +36 -0
- package/dist/features/faq/constants/help-guides.js +64 -0
- package/dist/features/grouped/components/GroupedListingDetailView.js +2 -3
- package/dist/features/homepage/components/CustomCardsSection.js +67 -50
- package/dist/features/homepage/components/HeroCarousel.js +3 -1
- package/dist/features/homepage/components/ShopByCategorySection.js +23 -10
- package/dist/features/homepage/lib/section-renderer.js +2 -1
- package/dist/features/homepage/schemas/index.d.ts +10 -10
- package/dist/features/orders/components/EmiInstallmentsPanel.d.ts +19 -0
- package/dist/features/orders/components/EmiInstallmentsPanel.js +57 -0
- package/dist/features/orders/components/index.d.ts +1 -0
- package/dist/features/orders/components/index.js +1 -0
- package/dist/features/orders/schemas/index.d.ts +2 -2
- package/dist/features/orders/types/index.d.ts +15 -0
- package/dist/features/parts/components/PartDetailPageView.js +5 -3
- package/dist/features/parts/components/PartsSearchBox.js +79 -4
- package/dist/features/parts/schemas/admin-edit.d.ts +81 -0
- package/dist/features/parts/schemas/admin-edit.js +89 -0
- package/dist/features/parts/schemas/firestore.d.ts +2 -1
- package/dist/features/points/repository/points.repository.js +5 -5
- package/dist/features/points/schemas/firestore.d.ts +16 -0
- package/dist/features/points/schemas/firestore.js +17 -0
- package/dist/features/pre-orders/components/MarketplacePreorderCard.js +15 -2
- package/dist/features/products/components/MarketplaceBundleCard.js +15 -2
- package/dist/features/products/components/MarketplacePrizeDrawCard.js +15 -2
- package/dist/features/products/components/ProductGrid.js +18 -2
- package/dist/features/products/schemas/firestore.d.ts +18 -0
- package/dist/features/reviews/components/ReviewDetailPageView.js +3 -2
- package/dist/features/seller/components/CategoryInlineSelect.d.ts +10 -1
- package/dist/features/seller/components/CategoryInlineSelect.js +53 -5
- package/dist/features/seller/components/SellerProductShell.d.ts +39 -0
- package/dist/features/seller/components/SellerProductShell.js +31 -3
- package/dist/features/stores/components/StoreHeader.js +3 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +13 -0
- package/dist/next/routing/route-map.d.ts +17 -1
- package/dist/next/routing/route-map.js +39 -0
- package/dist/schemas/registry.d.ts +8 -8
- package/dist/seed/_helpers/category-models/chunk0.d.ts +2 -0
- package/dist/seed/_helpers/category-models/chunk0.js +2648 -0
- package/dist/seed/_helpers/category-models/chunk1.d.ts +2 -0
- package/dist/seed/_helpers/category-models/chunk1.js +2318 -0
- package/dist/seed/_helpers/category-models/chunk2.d.ts +2 -0
- package/dist/seed/_helpers/category-models/chunk2.js +2560 -0
- package/dist/seed/_helpers/category-models/chunk3.d.ts +2 -0
- package/dist/seed/_helpers/category-models/chunk3.js +2196 -0
- package/dist/seed/_helpers/category-models/chunk4.d.ts +2 -0
- package/dist/seed/_helpers/category-models/chunk4.js +1732 -0
- package/dist/seed/_helpers/category-models.d.ts +9 -2
- package/dist/seed/_helpers/category-models.js +19 -1368
- package/dist/seed/_helpers/category-parts-glossary-map.js +38 -38
- package/dist/seed/_helpers/category-parts.js +39 -39
- package/dist/seed/bey-products-seed-data.d.ts +18 -0
- package/dist/seed/bey-products-seed-data.js +18011 -0
- package/dist/seed/beys/chunk0.d.ts +17 -0
- package/dist/seed/beys/chunk0.js +36733 -0
- package/dist/seed/beys/chunk1.d.ts +17 -0
- package/dist/seed/beys/chunk1.js +35728 -0
- package/dist/seed/beys/chunk2.d.ts +17 -0
- package/dist/seed/beys/chunk2.js +35857 -0
- package/dist/seed/beys/chunk3.d.ts +17 -0
- package/dist/seed/beys/chunk3.js +34476 -0
- package/dist/seed/beys-seed-data.d.ts +18 -0
- package/dist/seed/beys-seed-data.js +11 -0
- package/dist/seed/homepage-sections-seed-data.js +16 -0
- package/dist/seed/index.d.ts +2 -0
- package/dist/seed/index.js +3 -0
- package/dist/seed/media-assets-seed-data.js +4 -4
- package/dist/seed/products-catalogue/chunk0.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk0.js +7262 -0
- package/dist/seed/products-catalogue/chunk1.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk1.js +7290 -0
- package/dist/seed/products-catalogue/chunk10.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk10.js +7290 -0
- package/dist/seed/products-catalogue/chunk11.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk11.js +7005 -0
- package/dist/seed/products-catalogue/chunk12.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk12.js +7002 -0
- package/dist/seed/products-catalogue/chunk13.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk13.js +7002 -0
- package/dist/seed/products-catalogue/chunk14.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk14.js +7002 -0
- package/dist/seed/products-catalogue/chunk15.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk15.js +7002 -0
- package/dist/seed/products-catalogue/chunk16.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk16.js +7002 -0
- package/dist/seed/products-catalogue/chunk17.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk17.js +7002 -0
- package/dist/seed/products-catalogue/chunk18.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk18.js +4398 -0
- package/dist/seed/products-catalogue/chunk2.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk2.js +7268 -0
- package/dist/seed/products-catalogue/chunk3.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk3.js +7264 -0
- package/dist/seed/products-catalogue/chunk4.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk4.js +7268 -0
- package/dist/seed/products-catalogue/chunk5.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk5.js +7258 -0
- package/dist/seed/products-catalogue/chunk6.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk6.js +7268 -0
- package/dist/seed/products-catalogue/chunk7.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk7.js +7311 -0
- package/dist/seed/products-catalogue/chunk8.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk8.js +7304 -0
- package/dist/seed/products-catalogue/chunk9.d.ts +12 -0
- package/dist/seed/products-catalogue/chunk9.js +7309 -0
- package/dist/seed/products-catalogue-seed-data.d.ts +2 -22
- package/dist/seed/products-catalogue-seed-data.js +58 -86382
- package/dist/seed/seed-purpose.js +9 -0
- package/dist/server.d.ts +5 -1
- package/dist/server.js +19 -0
- package/dist/styles.css +468 -1
- package/dist/tailwind-utilities.css +1 -1
- package/dist/ui/components/PosterCard.d.ts +99 -0
- package/dist/ui/components/PosterCard.js +109 -0
- package/dist/ui/components/PosterCard.style.css +466 -0
- package/dist/ui/components/index.style.css +1 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/package.json +1 -1
- package/scripts/seed-cli.mjs +108 -1
|
@@ -4,26 +4,39 @@ import { useState } from "react";
|
|
|
4
4
|
import Image from "next/image.js";
|
|
5
5
|
import Link from "next/link.js";
|
|
6
6
|
import { THEMED_TEXT_PRIMARY } from "../../../_internal/shared/styles/themed.js";
|
|
7
|
-
import { Button, Div, Heading, HorizontalScroller, Row, Section, Span,
|
|
7
|
+
import { Button, Div, Heading, HorizontalScroller, POSTER_CLASS, Row, Section, Span, Text, } from "../../../ui/index.js";
|
|
8
8
|
import { ROUTES } from "../../../next/routing/route-map.js";
|
|
9
9
|
import { resolveMediaUrl } from "../../../utils/media-url.js";
|
|
10
10
|
import { useTopCategories } from "../hooks/useTopCategories.js";
|
|
11
11
|
import { CAROUSEL_PER_VIEW } from "../constants/carousel-per-view.js";
|
|
12
|
-
const __P = {
|
|
13
|
-
p3: "p-[var(--appkit-space-3)]",
|
|
14
|
-
};
|
|
15
|
-
const __O = {
|
|
16
|
-
hidden: "overflow-hidden",
|
|
17
|
-
};
|
|
18
12
|
function isImageUrl(s) {
|
|
19
13
|
return s.startsWith("http") || s.startsWith("/") || s.startsWith("data:");
|
|
20
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* One category tile.
|
|
17
|
+
*
|
|
18
|
+
* 🛑 Image-LED, not image-on-top-of-a-body. The previous shape was a 16:9 crop
|
|
19
|
+
* stacked over a white block holding an icon square, the name, a count and a
|
|
20
|
+
* "Browse category →" line — four separate type sizes and a redundant CTA on a
|
|
21
|
+
* tile that is already entirely a link. It also letterboxed the artwork: every
|
|
22
|
+
* generation cover is portrait key art, so `aspect-video` cropped it to a
|
|
23
|
+
* horizontal band through the middle.
|
|
24
|
+
*
|
|
25
|
+
* Now it is the same `PosterCard` the systems matrix uses, so the two bands on
|
|
26
|
+
* the homepage read as one system rather than two designs.
|
|
27
|
+
*/
|
|
21
28
|
function CategoryChip({ category }) {
|
|
22
29
|
const iconSrc = category.display?.icon;
|
|
23
30
|
const coverImage = category.display?.coverImage;
|
|
24
|
-
const
|
|
31
|
+
const resolvedCover = coverImage && isImageUrl(coverImage) ? resolveMediaUrl(coverImage) : undefined;
|
|
25
32
|
const productCount = category.metrics?.totalProductCount ?? category.metrics?.productCount ?? 0;
|
|
26
|
-
|
|
33
|
+
/*
|
|
34
|
+
* `display.icon` holds an EMOJI in the seed and a URL in other writers —
|
|
35
|
+
* the ambiguity `resolveTaxonomyVisual` exists for. Only the emoji form is
|
|
36
|
+
* used as an eyebrow glyph here; a URL would print as raw text.
|
|
37
|
+
*/
|
|
38
|
+
const emoji = iconSrc && !isImageUrl(iconSrc) ? iconSrc : undefined;
|
|
39
|
+
return (_jsxs(Link, { href: ROUTES.PUBLIC.CATEGORY_DETAIL(category.slug), className: `${POSTER_CLASS.root} ${POSTER_CLASS.compact} w-full`, children: [resolvedCover ? (_jsx(Div, { className: POSTER_CLASS.media, children: _jsx(Image, { src: resolvedCover, alt: "", fill: true, sizes: "(min-width: 1024px) 20rem, (min-width: 640px) 45vw, 80vw", className: "h-full w-full object-cover" }) })) : null, _jsx(Div, { className: POSTER_CLASS.scrim, "aria-hidden": "true" }), _jsxs(Div, { className: POSTER_CLASS.body, children: [emoji && (_jsx(Span, { className: POSTER_CLASS.eyebrow, "aria-hidden": "true", children: emoji })), _jsx(Span, { className: POSTER_CLASS.title, children: category.name }), _jsxs(Span, { className: POSTER_CLASS.meta, children: [productCount.toLocaleString(), " items"] })] })] }));
|
|
27
40
|
}
|
|
28
41
|
const CTA_CLASSES = {
|
|
29
42
|
filled: "rounded-lg bg-[var(--appkit-color-primary)] px-[var(--appkit-space-5)] py-[var(--appkit-space-2)] text-[length:var(--appkit-text-sm)] font-semibold text-white hover:opacity-90",
|
|
@@ -69,5 +82,5 @@ export function ShopByCategorySection({ title = "Shop by Category", subtitle, li
|
|
|
69
82
|
if (!cat)
|
|
70
83
|
return null;
|
|
71
84
|
return (_jsx(FilterChip, { label: cat.name, active: activeFilter === id, onClick: () => setActiveFilter(activeFilter === id ? "all" : id) }, id));
|
|
72
|
-
})] })), isLoading ? (_jsx(Div, { layout: "flex", gap: "3",
|
|
85
|
+
})] })), isLoading ? (_jsx(Div, { layout: "flex", gap: "3", overflow: "hidden", className: "px-[0.25rem]", children: Array.from({ length: 6 }).map((_, i) => (_jsx(Div, { className: "flex-none h-[104px] w-[108px] animate-pulse", surface: "subtle", rounded: "xl" }, i))) })) : (_jsx(HorizontalScroller, { items: categories, renderItem: (cat) => _jsx(CategoryChip, { category: cat }), perView: CAROUSEL_PER_VIEW.standard, gap: 16, keyExtractor: (cat) => cat.id, autoScroll: autoScroll, autoScrollInterval: scrollInterval, showArrows: true, snapToItems: true, showScrollbar: false, loop: loop, pauseOnHover: true })), cta && !isLoading && (_jsx(Div, { className: "mt-6 text-left", children: _jsx(Link, { href: cta.href, className: CTA_CLASSES[cta.variant], children: cta.label }) })), !cta && viewMoreHref && !isLoading && (_jsx(Div, { className: "mt-6 text-left", children: _jsx(Link, { href: viewMoreHref, className: "inline-flex items-center gap-[0.375rem] rounded-[var(--appkit-radius-md)] px-[var(--appkit-space-3)] py-[var(--appkit-space-1)] text-[length:var(--appkit-text-sm)] font-semibold transition-colors bg-primary text-white hover:bg-primary-600", children: viewMoreLabel }) }))] }) }));
|
|
73
86
|
}
|
|
@@ -48,6 +48,7 @@ import { CollectionCardsSection } from "../components/CollectionCardsSection.js"
|
|
|
48
48
|
import { HowItWorksSection } from "../components/HowItWorksSection.js";
|
|
49
49
|
import { TestimonialsCarousel } from "../components/TestimonialsCarousel.js";
|
|
50
50
|
import { PromoGrid } from "../components/PromoGrid.js";
|
|
51
|
+
import { OwnerQuickActions } from "../../admin/components/OwnerQuickActions.js";
|
|
51
52
|
const AD_SLOT_MAP = {
|
|
52
53
|
carousel: "afterHero",
|
|
53
54
|
products: "afterFeaturedProducts",
|
|
@@ -433,6 +434,6 @@ export function renderSection(section, adSlots, newsletterFormSlot, faqItems, sl
|
|
|
433
434
|
if (!sectionElement)
|
|
434
435
|
return null;
|
|
435
436
|
const adSlotKey = AD_SLOT_MAP[section.type];
|
|
436
|
-
return (_jsxs(React.Fragment, { children: [_jsx(HomepageSectionBoundary, { sectionId: section.id, sectionType: section.type, children: sectionElement }), adSlots && adSlotKey !== undefined && adSlotKey in adSlots && adSlots[adSlotKey]] }, section.id));
|
|
437
|
+
return (_jsxs(React.Fragment, { children: [_jsx(OwnerQuickActions, { resource: "SECTION", placement: "detail", className: "justify-end", recordLabel: section.type, editHref: String(ROUTES.ADMIN.SECTIONS) }), _jsx(HomepageSectionBoundary, { sectionId: section.id, sectionType: section.type, children: sectionElement }), adSlots && adSlotKey !== undefined && adSlotKey in adSlots && adSlots[adSlotKey]] }, section.id));
|
|
437
438
|
}
|
|
438
439
|
export { AnnouncementBar, hashBannerMessage };
|
|
@@ -215,15 +215,15 @@ export declare const carouselCardSchema: z.ZodObject<{
|
|
|
215
215
|
description?: string | undefined;
|
|
216
216
|
textColor?: string | undefined;
|
|
217
217
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
218
|
-
subtitle?: string | undefined;
|
|
219
218
|
eyebrow?: string | undefined;
|
|
219
|
+
subtitle?: string | undefined;
|
|
220
220
|
}, {
|
|
221
221
|
title?: string | undefined;
|
|
222
222
|
description?: string | undefined;
|
|
223
223
|
textColor?: string | undefined;
|
|
224
224
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
225
|
-
subtitle?: string | undefined;
|
|
226
225
|
eyebrow?: string | undefined;
|
|
226
|
+
subtitle?: string | undefined;
|
|
227
227
|
}>>;
|
|
228
228
|
buttons: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
229
229
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -282,8 +282,8 @@ export declare const carouselCardSchema: z.ZodObject<{
|
|
|
282
282
|
description?: string | undefined;
|
|
283
283
|
textColor?: string | undefined;
|
|
284
284
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
285
|
-
subtitle?: string | undefined;
|
|
286
285
|
eyebrow?: string | undefined;
|
|
286
|
+
subtitle?: string | undefined;
|
|
287
287
|
} | undefined;
|
|
288
288
|
hover?: {
|
|
289
289
|
effect: "none" | "color" | "scale" | "glow";
|
|
@@ -323,8 +323,8 @@ export declare const carouselCardSchema: z.ZodObject<{
|
|
|
323
323
|
description?: string | undefined;
|
|
324
324
|
textColor?: string | undefined;
|
|
325
325
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
326
|
-
subtitle?: string | undefined;
|
|
327
326
|
eyebrow?: string | undefined;
|
|
327
|
+
subtitle?: string | undefined;
|
|
328
328
|
} | undefined;
|
|
329
329
|
hover?: {
|
|
330
330
|
effect: "none" | "color" | "scale" | "glow";
|
|
@@ -555,15 +555,15 @@ export declare const carouselSlideFirestoreSchema: z.ZodObject<{
|
|
|
555
555
|
description?: string | undefined;
|
|
556
556
|
textColor?: string | undefined;
|
|
557
557
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
558
|
-
subtitle?: string | undefined;
|
|
559
558
|
eyebrow?: string | undefined;
|
|
559
|
+
subtitle?: string | undefined;
|
|
560
560
|
}, {
|
|
561
561
|
title?: string | undefined;
|
|
562
562
|
description?: string | undefined;
|
|
563
563
|
textColor?: string | undefined;
|
|
564
564
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
565
|
-
subtitle?: string | undefined;
|
|
566
565
|
eyebrow?: string | undefined;
|
|
566
|
+
subtitle?: string | undefined;
|
|
567
567
|
}>>;
|
|
568
568
|
buttons: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
569
569
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -622,8 +622,8 @@ export declare const carouselSlideFirestoreSchema: z.ZodObject<{
|
|
|
622
622
|
description?: string | undefined;
|
|
623
623
|
textColor?: string | undefined;
|
|
624
624
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
625
|
-
subtitle?: string | undefined;
|
|
626
625
|
eyebrow?: string | undefined;
|
|
626
|
+
subtitle?: string | undefined;
|
|
627
627
|
} | undefined;
|
|
628
628
|
hover?: {
|
|
629
629
|
effect: "none" | "color" | "scale" | "glow";
|
|
@@ -663,8 +663,8 @@ export declare const carouselSlideFirestoreSchema: z.ZodObject<{
|
|
|
663
663
|
description?: string | undefined;
|
|
664
664
|
textColor?: string | undefined;
|
|
665
665
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
666
|
-
subtitle?: string | undefined;
|
|
667
666
|
eyebrow?: string | undefined;
|
|
667
|
+
subtitle?: string | undefined;
|
|
668
668
|
} | undefined;
|
|
669
669
|
hover?: {
|
|
670
670
|
effect: "none" | "color" | "scale" | "glow";
|
|
@@ -802,8 +802,8 @@ export declare const carouselSlideFirestoreSchema: z.ZodObject<{
|
|
|
802
802
|
description?: string | undefined;
|
|
803
803
|
textColor?: string | undefined;
|
|
804
804
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
805
|
-
subtitle?: string | undefined;
|
|
806
805
|
eyebrow?: string | undefined;
|
|
806
|
+
subtitle?: string | undefined;
|
|
807
807
|
} | undefined;
|
|
808
808
|
hover?: {
|
|
809
809
|
effect: "none" | "color" | "scale" | "glow";
|
|
@@ -911,8 +911,8 @@ export declare const carouselSlideFirestoreSchema: z.ZodObject<{
|
|
|
911
911
|
description?: string | undefined;
|
|
912
912
|
textColor?: string | undefined;
|
|
913
913
|
textAlign?: "center" | "left" | "right" | undefined;
|
|
914
|
-
subtitle?: string | undefined;
|
|
915
914
|
eyebrow?: string | undefined;
|
|
915
|
+
subtitle?: string | undefined;
|
|
916
916
|
} | undefined;
|
|
917
917
|
hover?: {
|
|
918
918
|
effect: "none" | "color" | "scale" | "glow";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { EmiInstallment } from "../schemas/firestore";
|
|
3
|
+
export interface EmiInstallmentsPanelProps {
|
|
4
|
+
orderId: string;
|
|
5
|
+
installments: readonly EmiInstallment[];
|
|
6
|
+
/** Sum of unpaid instalments, as recorded on the order. */
|
|
7
|
+
remainingBalance?: number;
|
|
8
|
+
currency?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Submits one instalment. Supplied by the consumer so this component does
|
|
11
|
+
* no fetching of its own — the same slot shape the rest of the orders
|
|
12
|
+
* feature uses.
|
|
13
|
+
*/
|
|
14
|
+
onSubmit: (input: {
|
|
15
|
+
installmentIndex: number;
|
|
16
|
+
transactionId: string;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function EmiInstallmentsPanel({ orderId, installments, remainingBalance, currency, onSubmit, }: EmiInstallmentsPanelProps): React.JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Badge, Button, Div, Form, Row, Stack, Text, useToast } from "../../../ui/index.js";
|
|
5
|
+
import { FieldInput } from "../../../ui/forms/index.js";
|
|
6
|
+
import { formatCurrency } from "../../../utils/number.formatter.js";
|
|
7
|
+
import { normalizeError } from "../../../errors/normalize.js";
|
|
8
|
+
function stateOf(i) {
|
|
9
|
+
if (i.status === "paid")
|
|
10
|
+
return "paid";
|
|
11
|
+
// A reference the buyer submitted but nobody has confirmed. The status
|
|
12
|
+
// field cannot express this: an instalment is created "pending" and stays
|
|
13
|
+
// "pending" until it is paid, so the presence of a reference is the signal.
|
|
14
|
+
if (i.transactionId)
|
|
15
|
+
return "awaiting-review";
|
|
16
|
+
return "payable";
|
|
17
|
+
}
|
|
18
|
+
const STATE_LABEL = {
|
|
19
|
+
paid: "Paid",
|
|
20
|
+
"awaiting-review": "Awaiting confirmation",
|
|
21
|
+
payable: "Due",
|
|
22
|
+
};
|
|
23
|
+
export function EmiInstallmentsPanel({ orderId, installments, remainingBalance, currency = "INR", onSubmit, }) {
|
|
24
|
+
const { showToast } = useToast();
|
|
25
|
+
const [openIndex, setOpenIndex] = useState(null);
|
|
26
|
+
const [reference, setReference] = useState("");
|
|
27
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
28
|
+
const money = (value) => formatCurrency(value, currency);
|
|
29
|
+
const ordered = [...installments].sort((a, b) => a.index - b.index);
|
|
30
|
+
const outstanding = ordered.filter((i) => i.status !== "paid").length;
|
|
31
|
+
const submit = async (index) => {
|
|
32
|
+
setIsSubmitting(true);
|
|
33
|
+
try {
|
|
34
|
+
await onSubmit({ installmentIndex: index, transactionId: reference.trim() });
|
|
35
|
+
showToast("Payment reference submitted — the seller will confirm it.", "success");
|
|
36
|
+
setOpenIndex(null);
|
|
37
|
+
setReference("");
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
void normalizeError(err);
|
|
41
|
+
// The action's own message is surfaced by the caller's error mapping;
|
|
42
|
+
// this only has to stop the panel pretending the submission landed.
|
|
43
|
+
showToast("Couldn't submit that payment. Please try again.", "error");
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
setIsSubmitting(false);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return (_jsx(Div, { surface: "card", border: "default", rounded: "lg", padding: "md", children: _jsxs(Stack, { gap: "sm", children: [_jsxs(Row, { align: "center", justify: "between", gap: "sm", children: [_jsx(Text, { weight: "semibold", children: "Your EMI plan" }), remainingBalance !== undefined && remainingBalance > 0 && (_jsxs(Text, { size: "sm", color: "muted", children: [money(remainingBalance), " outstanding across ", outstanding, " instalment", outstanding === 1 ? "" : "s"] }))] }), _jsx(Text, { size: "xs", color: "muted", children: "You can pay any instalment whenever you like, including ahead of its due date \u2014 paying early settles the plan sooner and does not cost more." }), _jsx(Stack, { gap: "xs", children: ordered.map((inst) => {
|
|
50
|
+
const state = stateOf(inst);
|
|
51
|
+
const due = inst.dueDate ? new Date(inst.dueDate) : null;
|
|
52
|
+
return (_jsxs(Div, { border: "default", rounded: "md", padding: "sm", children: [_jsxs(Row, { align: "center", justify: "between", gap: "sm", className: "min-w-0", children: [_jsxs(Stack, { gap: "xs", className: "min-w-0", children: [_jsxs(Text, { size: "sm", weight: "medium", children: ["Instalment ", inst.index, " \u00B7 ", money(inst.amount)] }), _jsx(Text, { size: "xs", color: "muted", children: due ? `Due ${due.toLocaleDateString()}` : "No due date recorded" })] }), _jsxs(Row, { align: "center", gap: "xs", className: "flex-shrink-0", children: [_jsx(Badge, { variant: state === "paid" ? "success" : state === "awaiting-review" ? "warning" : "default", children: STATE_LABEL[state] }), state === "payable" && (_jsx(Button, { type: "button", size: "sm", variant: "secondary", onClick: () => {
|
|
53
|
+
setOpenIndex(openIndex === inst.index ? null : inst.index);
|
|
54
|
+
setReference("");
|
|
55
|
+
}, children: openIndex === inst.index ? "Cancel" : "Pay now" }))] })] }), openIndex === inst.index && (_jsx(Div, { className: "mt-3", children: _jsx(Form, { onSubmit: (e) => e.preventDefault(), children: () => (_jsxs(Stack, { gap: "sm", children: [_jsxs(Text, { size: "xs", color: "muted", children: ["Transfer ", money(inst.amount), " to the seller, then enter the UTR or reference number so they can confirm it."] }), _jsx(FieldInput, { name: `emi-reference-${orderId}-${inst.index}`, label: "UTR / reference number", required: true, value: reference, onChange: setReference }), _jsx(Button, { type: "submit", size: "sm", isLoading: isSubmitting, disabled: reference.trim().length === 0 || isSubmitting, onClick: () => { void submit(inst.index); }, children: "Submit payment reference" })] })) }) }))] }, inst.index));
|
|
56
|
+
}) })] }) }));
|
|
57
|
+
}
|
|
@@ -14,3 +14,4 @@ export { RefundRequestView } from "./RefundRequestView";
|
|
|
14
14
|
export type { RefundRequestViewProps } from "./RefundRequestView";
|
|
15
15
|
export { YourPurchaseStrip } from "./YourPurchaseStrip";
|
|
16
16
|
export type { YourPurchaseStripProps, PurchaseContext } from "./YourPurchaseStrip";
|
|
17
|
+
export { EmiInstallmentsPanel, type EmiInstallmentsPanelProps, } from "./EmiInstallmentsPanel";
|
|
@@ -7,3 +7,4 @@ export { OrderStatusTimeline } from "./OrderStatusTimeline.js";
|
|
|
7
7
|
export { RefundHistoryTable } from "./RefundHistoryTable.js";
|
|
8
8
|
export { RefundRequestView } from "./RefundRequestView.js";
|
|
9
9
|
export { YourPurchaseStrip } from "./YourPurchaseStrip.js";
|
|
10
|
+
export { EmiInstallmentsPanel, } from "./EmiInstallmentsPanel.js";
|
|
@@ -614,6 +614,7 @@ export declare const orderFirestoreSchema: z.ZodObject<{
|
|
|
614
614
|
} | undefined;
|
|
615
615
|
offerId?: string | undefined;
|
|
616
616
|
orderType?: string | undefined;
|
|
617
|
+
isNonRefundable?: boolean | undefined;
|
|
617
618
|
imageUrls?: string[] | undefined;
|
|
618
619
|
refundFeeDeducted?: number | undefined;
|
|
619
620
|
refundNetAmount?: number | undefined;
|
|
@@ -650,7 +651,6 @@ export declare const orderFirestoreSchema: z.ZodObject<{
|
|
|
650
651
|
}[] | undefined;
|
|
651
652
|
emiRemainingBalance?: number | undefined;
|
|
652
653
|
emiComplete?: boolean | undefined;
|
|
653
|
-
isNonRefundable?: boolean | undefined;
|
|
654
654
|
paymentBatchId?: string | undefined;
|
|
655
655
|
refunds?: {
|
|
656
656
|
type: "full" | "partial";
|
|
@@ -762,6 +762,7 @@ export declare const orderFirestoreSchema: z.ZodObject<{
|
|
|
762
762
|
} | undefined;
|
|
763
763
|
offerId?: string | undefined;
|
|
764
764
|
orderType?: string | undefined;
|
|
765
|
+
isNonRefundable?: boolean | undefined;
|
|
765
766
|
imageUrls?: string[] | undefined;
|
|
766
767
|
refundFeeDeducted?: number | undefined;
|
|
767
768
|
refundNetAmount?: number | undefined;
|
|
@@ -798,7 +799,6 @@ export declare const orderFirestoreSchema: z.ZodObject<{
|
|
|
798
799
|
}[] | undefined;
|
|
799
800
|
emiRemainingBalance?: number | undefined;
|
|
800
801
|
emiComplete?: boolean | undefined;
|
|
801
|
-
isNonRefundable?: boolean | undefined;
|
|
802
802
|
paymentBatchId?: string | undefined;
|
|
803
803
|
refunds?: {
|
|
804
804
|
type: "full" | "partial";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EmiInstallment } from "../schemas/firestore";
|
|
1
2
|
import type { ListingType } from "../../products/types/index";
|
|
2
3
|
import type { OrderType } from "../utils/order-splitter";
|
|
3
4
|
import type { AppliedOrderDiscount, OrderSourceContext } from "../schemas/firestore";
|
|
@@ -183,6 +184,20 @@ export interface Order {
|
|
|
183
184
|
* read it from site settings, because `gst` is in `PRIVATE_SITE_FIELDS`
|
|
184
185
|
* after an earlier deny-list projection shipped it publicly (Root Cause #70).
|
|
185
186
|
*/
|
|
187
|
+
/**
|
|
188
|
+
* ── EMI, buyer-facing ─────────────────────────────────────────────────
|
|
189
|
+
*
|
|
190
|
+
* 🛑 Declared here because `EmiInstallmentsPanel` is useless without it,
|
|
191
|
+
* and the absence was Root Cause #57's exact shape: the whole EMI schedule
|
|
192
|
+
* sat on `OrderDocument` and `orderDocumentToOrder` mapped none of it, so
|
|
193
|
+
* every buyer surface would have rendered its "no EMI plan" fallback with
|
|
194
|
+
* a real plan on the record. That reads as "this order isn't on EMI"
|
|
195
|
+
* rather than as a bug, which is why it survives.
|
|
196
|
+
*/
|
|
197
|
+
emiEnabled?: boolean;
|
|
198
|
+
emiInstallments?: EmiInstallment[];
|
|
199
|
+
/** Sum of unpaid instalments. 0 once the plan is settled. */
|
|
200
|
+
emiRemainingBalance?: number;
|
|
186
201
|
supplierGstin?: string;
|
|
187
202
|
supplierLegalName?: string;
|
|
188
203
|
supplierAddress?: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Section, Container, Stack, Row, Div, Heading, Text, Span, TextLink, Badge, } from "../../../ui/index.js";
|
|
2
|
+
import { Section, Container, Stack, Row, Div, Heading, Text, Span, TextLink, Badge, Anchor, } from "../../../ui/index.js";
|
|
3
3
|
import { SpecTable } from "../../../ui/components/SpecTable.js";
|
|
4
|
+
import { RecordOwnerQuickActions } from "../../admin/components/RecordOwnerQuickActions.js";
|
|
5
|
+
import { ROUTES } from "../../../next/routing/route-map.js";
|
|
4
6
|
import { PART_SLOT_LABEL, } from "../schemas/firestore.js";
|
|
5
7
|
/**
|
|
6
8
|
* The buyer-facing label for each WBO tournament format, in the order a
|
|
@@ -100,12 +102,12 @@ export function PartDetailPageView({ part, usedBy, listings, listingsTruncated,
|
|
|
100
102
|
: [];
|
|
101
103
|
/* Only the formats this part is actually ruled on — see the note below. */
|
|
102
104
|
const legalFormats = Object.entries(part.wboLegality ?? {}).filter(([, v]) => typeof v === "boolean");
|
|
103
|
-
return (_jsx(Section, { padding: "y-lg", children: _jsx(Container, { size: "lg", children: _jsxs(Stack, { gap: "lg", className: "min-w-0", children: [_jsxs(Stack, { gap: "xs", className: "min-w-0", children: [_jsx(Text, { size: "sm", color: "muted", children: _jsx(TextLink, { href: hrefForClassification(part.slot), children: classification }) }), _jsx(Heading, { level: 1, children: part.name }), _jsxs(Row, { gap: "xs", wrap: true, align: "center", className: "min-w-0", children: [part.code && _jsx(Badge, { variant: "info", children: part.code }), typeof part.weightG === "number" && (_jsxs(Badge, { variant: "default", children: [part.weightG, " g"] }))] }), aliases.length > 0 && (_jsxs(Text, { size: "sm", color: "muted", children: ["Also written: ", aliases.join(" · ")] }))] }), specRows.length > 1 && (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: "Specifications" }), _jsx(SpecTable, { rows: specRows })] })), ratingRows.length > 0 && (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: "Ratings" }), _jsx(SpecTable, { rows: ratingRows.map((r) => ({
|
|
105
|
+
return (_jsx(Section, { padding: "y-lg", children: _jsx(Container, { size: "lg", children: _jsxs(Stack, { gap: "lg", className: "min-w-0", children: [_jsxs(Stack, { gap: "xs", className: "min-w-0", children: [_jsx(Text, { size: "sm", color: "muted", children: _jsx(TextLink, { href: hrefForClassification(part.slot), children: classification }) }), _jsx(Heading, { level: 1, children: part.name }), _jsx(RecordOwnerQuickActions, { resource: "PART", recordId: part.id, placement: "detail", recordLabel: part.name }), _jsxs(Row, { gap: "xs", wrap: true, align: "center", className: "min-w-0", children: [part.code && _jsx(Badge, { variant: "info", children: part.code }), typeof part.weightG === "number" && (_jsxs(Badge, { variant: "default", children: [part.weightG, " g"] }))] }), aliases.length > 0 && (_jsxs(Text, { size: "sm", color: "muted", children: ["Also written: ", aliases.join(" · ")] }))] }), specRows.length > 1 && (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: "Specifications" }), _jsx(SpecTable, { rows: specRows })] })), ratingRows.length > 0 && (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: "Ratings" }), _jsx(SpecTable, { rows: ratingRows.map((r) => ({
|
|
104
106
|
name: r.label,
|
|
105
107
|
value: `${r.value} / 100`,
|
|
106
108
|
})) }), _jsxs(Text, { size: "xs", color: "faint", children: ["Rescaled to 0\u2013100 for comparison across generations", typeof part.ratingScale === "number"
|
|
107
109
|
? `; rated 0–${part.ratingScale} at source`
|
|
108
|
-
: "", "."] })] })), legalFormats.length > 0 && (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: "Tournament legality" }), _jsx(Row, { gap: "xs", wrap: true, align: "center", className: "min-w-0", children: legalFormats.map(([format, allowed]) => (_jsxs(Badge, { variant: allowed ? "success" : "danger", children: [WBO_FORMAT_LABEL[format] ?? format, allowed ? " ✓" : " ✗"] }, format))) }), _jsx(Text, { size: "xs", color: "faint", children: "World Beyblade Organization formats this part is ruled on. A format not listed has no ruling for it." })] })), _jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: usedBy.length > 0
|
|
110
|
+
: "", "."] })] })), legalFormats.length > 0 && (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: "Tournament legality" }), _jsx(Row, { gap: "xs", wrap: true, align: "center", className: "min-w-0", children: legalFormats.map(([format, allowed]) => (_jsxs(Badge, { variant: allowed ? "success" : "danger", children: [WBO_FORMAT_LABEL[format] ?? format, allowed ? " ✓" : " ✗"] }, format))) }), _jsx(Text, { size: "xs", color: "faint", children: "World Beyblade Organization formats this part is ruled on. A format not listed has no ruling for it." })] })), part.sourceUrl && (_jsx(Div, { children: _jsxs(Text, { size: "xs", color: "faint", children: ["Facts on this page are drawn from a community wiki under CC\u00A0BY-SA.", " ", _jsx(Anchor, { href: part.sourceUrl, tone: "muted", underline: "always", children: "Source" }), " · ", _jsx(TextLink, { href: String(ROUTES.PUBLIC.CREDITS), children: "Credits" })] }) })), _jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Heading, { level: 2, size: "lg", children: usedBy.length > 0
|
|
109
111
|
? `Used by ${usedBy.length} ${usedBy.length === 1 ? "model" : "models"}`
|
|
110
112
|
: "Used by" }), usedBy.length === 0 ? (_jsx(Text, { color: "muted", size: "sm", children: "No model in our database records this part yet." })) : (_jsx(Stack, { gap: "xs", className: "min-w-0", children: usedBy.map((m) => (_jsxs(Row, { gap: "sm", align: "center", padding: "inline", surface: "card", rounded: "md", border: "subtle", className: "min-w-0", children: [_jsxs(Div, { className: "flex-1 min-w-0", children: [m.categoryId ? (_jsx(TextLink, { href: hrefForModel(m.categoryId), children: m.name })) : (
|
|
111
113
|
/* 49 of 259 compositions did not join to a category.
|
|
@@ -35,13 +35,88 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
35
35
|
import React from "react";
|
|
36
36
|
import { Div, Input, Stack, Text, TextLink } from "../../../ui/index.js";
|
|
37
37
|
import { useSiteSearch } from "../../search/hooks/useSiteSearch.js";
|
|
38
|
+
import { useUrlTable } from "../../../react/hooks/useUrlTable.js";
|
|
39
|
+
import { TABLE_KEYS } from "../../../constants/table-keys.js";
|
|
38
40
|
/** Only this slice of the index. See `resolveEntity`'s `types` parameter. */
|
|
39
41
|
const PART_TYPES = ["part"];
|
|
40
42
|
/** Stable identity — a `useMemo` dependency inside the hook. */
|
|
41
43
|
const partLabel = () => "Parts";
|
|
42
44
|
export function PartsSearchBox({ indexEnabled, placeholder = "Search parts by name or code — RF, 105, Rubber Flat…", limit = 10, }) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
/*
|
|
46
|
+
* ── 🛑 THE QUERY LIVES IN THE URL, SO A SEARCH IS SHAREABLE ──────────────
|
|
47
|
+
*
|
|
48
|
+
* This was `React.useState("")`, which meant typing filtered the list and
|
|
49
|
+
* left the address bar on `/parts`. Every detail page here is a real slug
|
|
50
|
+
* (`/parts/{classification}/{code}`, `/beys/{slug}`) and every other listing
|
|
51
|
+
* surface puts its state in the URL — `/search?q=…` reads `searchParams`
|
|
52
|
+
* server-side, and the category pages go as far as path segments
|
|
53
|
+
* (`/categories/{slug}/{tab}/sort/{sortKey}/page/{page}`). A client-local
|
|
54
|
+
* box was the one surface where you could not send someone what you were
|
|
55
|
+
* looking at.
|
|
56
|
+
*
|
|
57
|
+
* `useUrlTable` is the mechanism, not a second one invented here: it owns
|
|
58
|
+
* `router.replace()`, uses replace rather than push so typing does not fill
|
|
59
|
+
* the back button, and `TABLE_KEYS.QUERY` is the same `q` the rest of the
|
|
60
|
+
* app reads.
|
|
61
|
+
*
|
|
62
|
+
* 🛑 TWO pieces of state, deliberately, and they are not redundant. `draft`
|
|
63
|
+
* drives the input so a keystroke is never waiting on a navigation; the URL
|
|
64
|
+
* is the shareable record, written on a debounce. Driving the input straight
|
|
65
|
+
* from `searchParams` makes every character a round trip through the router
|
|
66
|
+
* and the field feels broken on a slow render.
|
|
67
|
+
*
|
|
68
|
+
* 🛑 `useSearchParams` requires a `<Suspense>` ancestor or the build fails
|
|
69
|
+
* on prerender (Root Cause #17b). The root locale layout has one, which is
|
|
70
|
+
* what the ~246 comments citing that pattern are about.
|
|
71
|
+
*/
|
|
72
|
+
/*
|
|
73
|
+
* 🛑 DESTRUCTURED, because `useUrlTable` returns a fresh object literal every
|
|
74
|
+
* render while the callbacks inside it are `useCallback`-memoised. Depending
|
|
75
|
+
* on `table` would make the effect below re-run on every render; depending on
|
|
76
|
+
* `set`/`clear` is stable. Same trap as the `loadOptions` identity bug in
|
|
77
|
+
* `PaginatedSelect`, where an unstable function re-triggered a fetch effect.
|
|
78
|
+
*/
|
|
79
|
+
const { get, set, clear } = useUrlTable();
|
|
80
|
+
const urlQuery = get(TABLE_KEYS.QUERY) ?? "";
|
|
81
|
+
const [draft, setDraft] = React.useState(urlQuery);
|
|
82
|
+
/*
|
|
83
|
+
* 🛑 SEEDED FROM THE URL, not `false`.
|
|
84
|
+
*
|
|
85
|
+
* `useSiteSearch` only fetches the index when `active`, which previously
|
|
86
|
+
* meant "the user has focused the box". Arriving on `/parts?q=rubber-flat`
|
|
87
|
+
* from a shared link, `active` would be false — so the query would sit in
|
|
88
|
+
* the field and in the address bar having searched NOTHING until the visitor
|
|
89
|
+
* clicked into the input. That defeats the entire reason for putting the
|
|
90
|
+
* query in the URL, and it is the kind of gap that looks like the link
|
|
91
|
+
* "didn't work" rather than like a missing fetch.
|
|
92
|
+
*/
|
|
93
|
+
const [active, setActive] = React.useState(urlQuery.length > 0);
|
|
94
|
+
/*
|
|
95
|
+
* Back/forward and a shared link both change the URL without touching the
|
|
96
|
+
* input, so the draft follows the URL when the URL moves on its own.
|
|
97
|
+
* Guarded on inequality — without that this fights the user's typing.
|
|
98
|
+
*/
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
setDraft((prev) => (prev === urlQuery ? prev : urlQuery));
|
|
101
|
+
}, [urlQuery]);
|
|
102
|
+
/*
|
|
103
|
+
* 🛑 Debounced, because `router.replace` on every keystroke is a navigation
|
|
104
|
+
* per character. 300ms is the same order the rest of the app uses for a
|
|
105
|
+
* search field, and the cleanup makes the last keystroke the one that wins.
|
|
106
|
+
*/
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
if (draft === urlQuery)
|
|
109
|
+
return;
|
|
110
|
+
const t = setTimeout(() => {
|
|
111
|
+
if (draft)
|
|
112
|
+
set(TABLE_KEYS.QUERY, draft);
|
|
113
|
+
else
|
|
114
|
+
clear([TABLE_KEYS.QUERY]);
|
|
115
|
+
}, 300);
|
|
116
|
+
return () => clearTimeout(t);
|
|
117
|
+
}, [draft, urlQuery, set, clear]);
|
|
118
|
+
/* The index is searched on the URL's value — the thing that is shareable. */
|
|
119
|
+
const query = urlQuery;
|
|
45
120
|
const { status, result } = useSiteSearch(query, {
|
|
46
121
|
active,
|
|
47
122
|
indexEnabled,
|
|
@@ -50,8 +125,8 @@ export function PartsSearchBox({ indexEnabled, placeholder = "Search parts by na
|
|
|
50
125
|
});
|
|
51
126
|
const hits = result?.groups[0]?.hits ?? [];
|
|
52
127
|
const typed = query.trim().length > 0;
|
|
53
|
-
return (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Input, { type: "search", value:
|
|
128
|
+
return (_jsxs(Stack, { gap: "sm", className: "min-w-0", children: [_jsx(Input, { type: "search", value: draft, placeholder: placeholder, "aria-label": "Search parts", onFocus: () => setActive(true), onChange: (event) => {
|
|
54
129
|
setActive(true);
|
|
55
|
-
|
|
130
|
+
setDraft(event.target.value);
|
|
56
131
|
} }), typed && status === "loading" && _jsx(Text, { color: "muted", children: "Searching\u2026" }), typed && (status === "failed" || status === "disabled") && (_jsx(Text, { size: "sm", color: "muted", children: "Part search is unavailable right now \u2014 browse by classification below." })), typed && status === "ready" && hits.length === 0 && (_jsx(Text, { color: "muted", children: "No part matches that name or code." })), hits.length > 0 && (_jsx(Stack, { gap: "xs", className: "min-w-0", children: hits.slice(0, limit).map((hit) => (_jsxs(Div, { surface: "card", padding: "sm", rounded: "md", border: "subtle", children: [_jsx(TextLink, { href: hit.href, children: hit.title }), hit.detail && (_jsx(Text, { size: "xs", color: "muted", children: hit.detail }))] }, hit.id))) }))] }));
|
|
57
132
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level protection for hand-corrections to GENERATED reference data.
|
|
3
|
+
*
|
|
4
|
+
* ── 🛑 THE PROBLEM THIS SOLVES ────────────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* `partGlossary` (2,488 rows) and `beys` (1,988) are produced by committed
|
|
7
|
+
* generators from a crawled corpus, and `appkit-seed load` writes them with
|
|
8
|
+
* `set(doc, { merge: true })`. A merge-write overwrites every key present in
|
|
9
|
+
* the payload — so an admin who corrects a wrong extracted weight loses that
|
|
10
|
+
* correction on the next reseed, silently, and the row goes back to being
|
|
11
|
+
* wrong while `appkit-seed status` reports the collection perfectly in sync
|
|
12
|
+
* (it counts ids, and the id did not change).
|
|
13
|
+
*
|
|
14
|
+
* That is not hypothetical for this dataset. This session alone found five
|
|
15
|
+
* wrong claims in the source corpus — an inverted tip transition, a mode that
|
|
16
|
+
* was actually launch spin direction, a mechanism on the wrong part, a part
|
|
17
|
+
* with no modes at all, and a part named "Duo:Dual" that is Delta Drive. A
|
|
18
|
+
* hand-correction is the fast path for exactly those, and it has to survive.
|
|
19
|
+
*
|
|
20
|
+
* ── 🛑 FIELD-LEVEL, NOT ROW-LEVEL ────────────────────────────────────────
|
|
21
|
+
*
|
|
22
|
+
* The obvious shape is one boolean meaning "do not touch this row". It is
|
|
23
|
+
* wrong: freezing a whole row because somebody fixed one weight means the row
|
|
24
|
+
* stops receiving every genuine improvement the generator makes afterwards —
|
|
25
|
+
* a better description, a newly resolved part id, a corrected release date.
|
|
26
|
+
* The row quietly falls out of the dataset's own maintenance.
|
|
27
|
+
*
|
|
28
|
+
* So `adminEditedFields` names the keys a human owns. The loader strips
|
|
29
|
+
* exactly those from its payload and writes everything else, which means a
|
|
30
|
+
* corrected weight and an improved description can both be true at once.
|
|
31
|
+
*
|
|
32
|
+
* `adminEdited` is a plain boolean beside it purely so the loader can find
|
|
33
|
+
* these rows with ONE equality query per collection instead of reading all
|
|
34
|
+
* 4,476 documents to discover the handful that matter. `array-contains` on
|
|
35
|
+
* `adminEditedFields` cannot answer "has any value", and an `orderBy` or `!=`
|
|
36
|
+
* on it would silently exclude every row that lacks the field — which is all
|
|
37
|
+
* of them (Root Cause #100).
|
|
38
|
+
*
|
|
39
|
+
* 🛑 KEEP THE TWO IN SYNC. `adminEdited` is `adminEditedFields.length > 0`.
|
|
40
|
+
* Writing one without the other either hides a protected row from the loader
|
|
41
|
+
* (so the edit is lost anyway) or makes the loader fetch a row with nothing to
|
|
42
|
+
* protect. `applyAdminEdit` is the only function that should set either.
|
|
43
|
+
*/
|
|
44
|
+
/** The fields a human has taken ownership of on one generated row. */
|
|
45
|
+
export interface AdminEditableRecord {
|
|
46
|
+
/**
|
|
47
|
+
* `true` iff `adminEditedFields` is non-empty. Exists ONLY so the seed
|
|
48
|
+
* loader can find protected rows with one indexed equality.
|
|
49
|
+
*/
|
|
50
|
+
adminEdited?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Keys the generator must not overwrite. Dot paths are NOT supported — a
|
|
53
|
+
* nested object is owned whole, because a merge-write replaces a map wholesale
|
|
54
|
+
* and protecting one leaf of it is not something `{ merge: true }` can express.
|
|
55
|
+
*/
|
|
56
|
+
adminEditedFields?: string[];
|
|
57
|
+
/** When the most recent hand-edit landed. Audit trail, never read by logic. */
|
|
58
|
+
adminEditedAt?: Date;
|
|
59
|
+
/** Who. The Auth UID, never a name — this travels into no public projection. */
|
|
60
|
+
adminEditedBy?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Merge a hand-edit into a record, keeping the two protection fields honest.
|
|
64
|
+
*
|
|
65
|
+
* Returns the patch to write — the caller's changed fields plus the updated
|
|
66
|
+
* ownership set. 🛑 Ownership is CUMULATIVE: editing the weight today and the
|
|
67
|
+
* description tomorrow must leave both protected, so the existing set is
|
|
68
|
+
* unioned rather than replaced.
|
|
69
|
+
*/
|
|
70
|
+
export declare function applyAdminEdit<TChanges extends object>(existing: Pick<AdminEditableRecord, "adminEditedFields"> | null | undefined, changes: TChanges, actorUid: string): TChanges & Required<Pick<AdminEditableRecord, "adminEdited" | "adminEditedFields">> & {
|
|
71
|
+
adminEditedAt: Date;
|
|
72
|
+
adminEditedBy: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Strip the fields a human owns out of a generator payload.
|
|
76
|
+
*
|
|
77
|
+
* Used by `appkit/scripts/seed-cli.mjs`. Exported from here rather than
|
|
78
|
+
* duplicated there so the rule has one definition — the CLI is `.mjs` and
|
|
79
|
+
* reads this through the built package, the same way it reads the seed data.
|
|
80
|
+
*/
|
|
81
|
+
export declare function stripAdminOwnedFields<T extends object>(payload: T, ownedFields: readonly string[] | undefined): Partial<T>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level protection for hand-corrections to GENERATED reference data.
|
|
3
|
+
*
|
|
4
|
+
* ── 🛑 THE PROBLEM THIS SOLVES ────────────────────────────────────────────
|
|
5
|
+
*
|
|
6
|
+
* `partGlossary` (2,488 rows) and `beys` (1,988) are produced by committed
|
|
7
|
+
* generators from a crawled corpus, and `appkit-seed load` writes them with
|
|
8
|
+
* `set(doc, { merge: true })`. A merge-write overwrites every key present in
|
|
9
|
+
* the payload — so an admin who corrects a wrong extracted weight loses that
|
|
10
|
+
* correction on the next reseed, silently, and the row goes back to being
|
|
11
|
+
* wrong while `appkit-seed status` reports the collection perfectly in sync
|
|
12
|
+
* (it counts ids, and the id did not change).
|
|
13
|
+
*
|
|
14
|
+
* That is not hypothetical for this dataset. This session alone found five
|
|
15
|
+
* wrong claims in the source corpus — an inverted tip transition, a mode that
|
|
16
|
+
* was actually launch spin direction, a mechanism on the wrong part, a part
|
|
17
|
+
* with no modes at all, and a part named "Duo:Dual" that is Delta Drive. A
|
|
18
|
+
* hand-correction is the fast path for exactly those, and it has to survive.
|
|
19
|
+
*
|
|
20
|
+
* ── 🛑 FIELD-LEVEL, NOT ROW-LEVEL ────────────────────────────────────────
|
|
21
|
+
*
|
|
22
|
+
* The obvious shape is one boolean meaning "do not touch this row". It is
|
|
23
|
+
* wrong: freezing a whole row because somebody fixed one weight means the row
|
|
24
|
+
* stops receiving every genuine improvement the generator makes afterwards —
|
|
25
|
+
* a better description, a newly resolved part id, a corrected release date.
|
|
26
|
+
* The row quietly falls out of the dataset's own maintenance.
|
|
27
|
+
*
|
|
28
|
+
* So `adminEditedFields` names the keys a human owns. The loader strips
|
|
29
|
+
* exactly those from its payload and writes everything else, which means a
|
|
30
|
+
* corrected weight and an improved description can both be true at once.
|
|
31
|
+
*
|
|
32
|
+
* `adminEdited` is a plain boolean beside it purely so the loader can find
|
|
33
|
+
* these rows with ONE equality query per collection instead of reading all
|
|
34
|
+
* 4,476 documents to discover the handful that matter. `array-contains` on
|
|
35
|
+
* `adminEditedFields` cannot answer "has any value", and an `orderBy` or `!=`
|
|
36
|
+
* on it would silently exclude every row that lacks the field — which is all
|
|
37
|
+
* of them (Root Cause #100).
|
|
38
|
+
*
|
|
39
|
+
* 🛑 KEEP THE TWO IN SYNC. `adminEdited` is `adminEditedFields.length > 0`.
|
|
40
|
+
* Writing one without the other either hides a protected row from the loader
|
|
41
|
+
* (so the edit is lost anyway) or makes the loader fetch a row with nothing to
|
|
42
|
+
* protect. `applyAdminEdit` is the only function that should set either.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Merge a hand-edit into a record, keeping the two protection fields honest.
|
|
46
|
+
*
|
|
47
|
+
* Returns the patch to write — the caller's changed fields plus the updated
|
|
48
|
+
* ownership set. 🛑 Ownership is CUMULATIVE: editing the weight today and the
|
|
49
|
+
* description tomorrow must leave both protected, so the existing set is
|
|
50
|
+
* unioned rather than replaced.
|
|
51
|
+
*/
|
|
52
|
+
export function applyAdminEdit(existing, changes, actorUid) {
|
|
53
|
+
const owned = new Set(existing?.adminEditedFields ?? []);
|
|
54
|
+
for (const key of Object.keys(changes)) {
|
|
55
|
+
/*
|
|
56
|
+
* The protection fields themselves are never protected — that would make
|
|
57
|
+
* the set unmodifiable by the next edit.
|
|
58
|
+
*/
|
|
59
|
+
if (key.startsWith("adminEdited"))
|
|
60
|
+
continue;
|
|
61
|
+
owned.add(key);
|
|
62
|
+
}
|
|
63
|
+
const fields = [...owned].sort();
|
|
64
|
+
return {
|
|
65
|
+
...changes,
|
|
66
|
+
adminEditedFields: fields,
|
|
67
|
+
adminEdited: fields.length > 0,
|
|
68
|
+
adminEditedAt: new Date(),
|
|
69
|
+
adminEditedBy: actorUid,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Strip the fields a human owns out of a generator payload.
|
|
74
|
+
*
|
|
75
|
+
* Used by `appkit/scripts/seed-cli.mjs`. Exported from here rather than
|
|
76
|
+
* duplicated there so the rule has one definition — the CLI is `.mjs` and
|
|
77
|
+
* reads this through the built package, the same way it reads the seed data.
|
|
78
|
+
*/
|
|
79
|
+
export function stripAdminOwnedFields(payload, ownedFields) {
|
|
80
|
+
if (!ownedFields?.length)
|
|
81
|
+
return payload;
|
|
82
|
+
const out = {};
|
|
83
|
+
for (const [k, v] of Object.entries(payload)) {
|
|
84
|
+
if (ownedFields.includes(k))
|
|
85
|
+
continue;
|
|
86
|
+
out[k] = v;
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|