@sgflabs/storefront-core 0.1.4 → 0.1.5

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.
Files changed (23) hide show
  1. package/package.json +7 -7
  2. package/src/components/atoms/Breadcrumbs/Breadcrumbs.tsx +22 -11
  3. package/src/components/atoms/Input/Input.tsx +2 -0
  4. package/src/components/cells/ActiveFilterElement/ActiveFilterElement.tsx +2 -0
  5. package/src/components/cells/ProductBuyBox/ProductBuyBox.tsx +11 -1
  6. package/src/components/cells/ProductDetailsHeader/ProductDetailsHeader.tsx +48 -13
  7. package/src/components/cells/ProductPageDetails/ProductPageDetails.tsx +2 -1
  8. package/src/components/cells/WishlistButton/WishlistButton.tsx +2 -0
  9. package/src/components/molecules/LoginForm/LoginForm.tsx +4 -1
  10. package/src/components/molecules/RegisterForm/RegisterForm.tsx +13 -1
  11. package/src/components/organisms/BlogCard/BlogCard.tsx +18 -0
  12. package/src/components/organisms/Header/HeaderAccountControls.tsx +1 -0
  13. package/src/components/organisms/HomeProductsCarousel/HomeProductsCarousel.tsx +2 -13
  14. package/src/components/organisms/ListingFilterSidebar/ListingFilterSidebar.tsx +12 -2
  15. package/src/components/organisms/ProductQuickViewModal/ProductQuickViewModal.tsx +6 -1
  16. package/src/components/providers/BrandSlots/BrandSlotsProvider.tsx +14 -0
  17. package/src/components/sections/BlogSection/BlogSection.tsx +30 -2
  18. package/src/components/sections/HomeProductSection/HomeProductSection.tsx +24 -1
  19. package/src/data/footerLinks.ts +6 -0
  20. package/src/lib/data/bidding.ts +19 -10
  21. package/src/lib/helpers/format-specification-cell.ts +23 -0
  22. package/src/pages/main/auctions/[id]/page.tsx +5 -1
  23. package/src/pages/main/user/orders/[id]/page.tsx +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sgflabs/storefront-core",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Shared storefront library consumed as raw TypeScript source by the brand apps.",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "sideEffects": [
@@ -55,9 +55,9 @@
55
55
  "devDependencies": {
56
56
  "@sentry/nextjs": "^10.63.0",
57
57
  "@sgflabs/artha-go-sdk": "^0.2.0",
58
- "@sgflabs/gstin": "^0.1.4",
59
- "@sgflabs/page-spec": "^0.1.4",
60
- "@sgflabs/storefront-core-common": "^0.1.4",
58
+ "@sgflabs/gstin": "^0.1.5",
59
+ "@sgflabs/page-spec": "^0.1.5",
60
+ "@sgflabs/storefront-core-common": "^0.1.5",
61
61
  "@testing-library/dom": "^10.4.1",
62
62
  "@testing-library/jest-dom": "^7.0.0",
63
63
  "@testing-library/react": "^16.3.2",
@@ -73,9 +73,9 @@
73
73
  "peerDependencies": {
74
74
  "@sentry/nextjs": "^10.63.0",
75
75
  "@sgflabs/artha-go-sdk": "^0.2.0",
76
- "@sgflabs/gstin": "^0.1.4",
77
- "@sgflabs/page-spec": "^0.1.4",
78
- "@sgflabs/storefront-core-common": "^0.1.4",
76
+ "@sgflabs/gstin": "^0.1.5",
77
+ "@sgflabs/page-spec": "^0.1.5",
78
+ "@sgflabs/storefront-core-common": "^0.1.5",
79
79
  "next": "15.5.27",
80
80
  "react": "^19.2.3",
81
81
  "react-dom": "^19.2.3"
@@ -22,17 +22,28 @@ export function Breadcrumbs({ items, className, "data-testid": dataTestId }: Bre
22
22
  return (
23
23
  <li key={path} className="inline-flex items-center" data-testid={`breadcrumb-item-${index}`}>
24
24
  {index > 0 && <ForwardIcon size={16} />}
25
- <LocalizedClientLink
26
- href={path}
27
- className={cn(
28
- "inline-flex items-center label-md text-primary",
29
- index > 0 && "ml-2",
30
- isActive && "text-secondary"
31
- )}
32
- data-testid={dataTestId ? `${dataTestId}-link-${index}` : `breadcrumbs-link-${index}`}
33
- >
34
- {label}
35
- </LocalizedClientLink>
25
+ {path === "" ? (
26
+ // Current page: no destination, so no link (an empty href resolved to the homepage).
27
+ <span
28
+ aria-current="page"
29
+ className={cn("inline-flex items-center label-md text-secondary", index > 0 && "ml-2")}
30
+ data-testid={dataTestId ? `${dataTestId}-link-${index}` : `breadcrumbs-link-${index}`}
31
+ >
32
+ {label}
33
+ </span>
34
+ ) : (
35
+ <LocalizedClientLink
36
+ href={path}
37
+ className={cn(
38
+ "inline-flex items-center label-md text-primary",
39
+ index > 0 && "ml-2",
40
+ isActive && "text-secondary"
41
+ )}
42
+ data-testid={dataTestId ? `${dataTestId}-link-${index}` : `breadcrumbs-link-${index}`}
43
+ >
44
+ {label}
45
+ </LocalizedClientLink>
46
+ )}
36
47
  </li>
37
48
  )
38
49
  })}
@@ -100,6 +100,8 @@ export function Input({
100
100
  <button
101
101
  type="button"
102
102
  onClick={() => setShowPassword(!showPassword)}
103
+ aria-label={showPassword ? "Hide password" : "Show password"}
104
+ aria-pressed={showPassword}
103
105
  className="text-ui-fg-subtle px-4 focus:outline-none transition-all duration-150 outline-none focus:text-ui-fg-base absolute right-0 top-4"
104
106
  data-testid={dataTestId ? `${dataTestId}-password-button` : 'input-password-button'}
105
107
  >
@@ -24,6 +24,8 @@ const filtersLabels: Record<string, string> = {
24
24
  size: "Size",
25
25
  condition: "Condition",
26
26
  has_sample: "Sample",
27
+ has_price: "Price",
28
+ certification_type: "Certification",
27
29
  }
28
30
 
29
31
  /** Maps filter key -> value (id) -> display label (name) */
@@ -13,9 +13,11 @@ import {
13
13
  selectOfferBySellerHandle,
14
14
  toEffectiveProduct,
15
15
  } from "../../../lib/helpers/product-offers"
16
+ import { getProductPrice } from "../../../lib/helpers/get-product-price"
16
17
  import { resolveSelectedVariantId } from "../../../lib/helpers/resolve-selected-variant-id"
17
18
  import { ProductDetailsHeader } from "../ProductDetailsHeader/ProductDetailsHeader"
18
19
  import { VolumePricingTable } from "../VolumePricingTable/VolumePricingTable"
20
+ import { useUnpricedLabel } from "../../providers/BrandSlots/BrandSlotsProvider"
19
21
  import { VendorSelector } from "../../molecules/VendorSelector/VendorSelector"
20
22
  import type { MoqRule } from "../../../lib/data/moq-rules"
21
23
  import type { QuoteThreshold } from "../../../lib/data/quote-thresholds"
@@ -88,8 +90,15 @@ export function ProductBuyBox({
88
90
  const selectedOfferVariant =
89
91
  activeOffer?.variants.find((variant) => variant.id === selectedEffectiveVariantId) ?? null
90
92
 
93
+ // A brand that opts in (BrandSlots `unpricedLabel`) words an unpriced product
94
+ // as e.g. "Price on request" instead of a regional restriction.
95
+ const unpricedLabel = useUnpricedLabel()
96
+ const isUnpriced = getProductPrice({ product: effectiveProduct }).cheapestPrice === null
97
+
91
98
  const addToCartDisabledReason = noValidOffer
92
- ? NOT_AVAILABLE_REASON
99
+ ? isUnpriced
100
+ ? (unpricedLabel ?? NOT_AVAILABLE_REASON)
101
+ : NOT_AVAILABLE_REASON
93
102
  : missingPackSize
94
103
  ? NOT_OFFERED_REASON
95
104
  : null
@@ -112,6 +121,7 @@ export function ProductBuyBox({
112
121
  onUnitsQuantityChange={handleUnitsQuantityChange}
113
122
  addToCartDisabledReason={addToCartDisabledReason}
114
123
  authContinueInPlace={authContinueInPlace}
124
+ pageHandle={product.handle}
115
125
  />
116
126
  <VolumePricingTable
117
127
  tiers={selectedOfferVariant?.tiers ?? []}
@@ -17,6 +17,7 @@ import { WishlistButton } from "../WishlistButton/WishlistButton"
17
17
  import { toast } from "../../../lib/helpers/toast"
18
18
  import { track } from "../../../lib/vendor-analytics/track"
19
19
  import { useCartContext } from "../../providers"
20
+ import { useSampleIdleLabel, useUnpricedLabel } from "../../providers/BrandSlots/BrandSlotsProvider"
20
21
  import { useEffect, useMemo, useState, type ReactElement } from "react"
21
22
  import type { MoqRule } from "../../../lib/data/moq-rules"
22
23
  import type { QuoteThreshold } from "../../../lib/data/quote-thresholds"
@@ -78,6 +79,7 @@ export const ProductDetailsHeader = ({
78
79
  onUnitsQuantityChange,
79
80
  addToCartDisabledReason = null,
80
81
  authContinueInPlace = false,
82
+ pageHandle,
81
83
  }: {
82
84
  product: HttpTypes.StoreProduct & { seller?: SellerProps }
83
85
  locale: string
@@ -91,8 +93,12 @@ export const ProductDetailsHeader = ({
91
93
  addToCartDisabledReason?: string | null
92
94
  /** Quick View: embed login in the sample prompt so the modal stays open after password/OTP. */
93
95
  authContinueInPlace?: boolean
96
+ /** Handle of the page's own product, for the share link. Defaults to `product.handle`; a multi-seller page passes its own because `product` is then the active offer's. */
97
+ pageHandle?: string
94
98
  }) => {
95
99
  const { addToCart, onAddToCart, cart, isAddingItem } = useCartContext()
100
+ const sampleIdleLabel = useSampleIdleLabel() ?? "Add sample"
101
+ const unpricedLabel = useUnpricedLabel()
96
102
  const pathname = usePathname()
97
103
  const searchParams = useSearchParams()
98
104
  // A per_lb product reads in lb unless the shopper has explicitly chosen a
@@ -116,12 +122,28 @@ export const ProductDetailsHeader = ({
116
122
  const [copied, setCopied] = useState(false)
117
123
  const [pageUrl, setPageUrl] = useState("")
118
124
 
125
+ // The product's own URL, not window.location: inside Quick View that is the
126
+ // listing the modal is open on (`/categories?preview=...`).
127
+ const handle = pageHandle ?? product.handle
128
+ // Keep the selection (?seller=, option params) so the link opens the same
129
+ // view; in Quick View (`preview`) only ?seller= is kept.
130
+ const shareQuery = useMemo(() => {
131
+ const query = new URLSearchParams(searchParams?.toString() ?? "")
132
+ // Quick View sits on a listing: its filters and pagination are not the product's selection.
133
+ if (query.has("preview")) {
134
+ const seller = query.get("seller")
135
+ return seller ? new URLSearchParams({ seller }).toString() : ""
136
+ }
137
+ return query.toString()
138
+ }, [searchParams])
119
139
  useEffect(() => {
120
- setPageUrl(window.location.href)
121
- }, [])
140
+ setPageUrl(
141
+ `${window.location.origin}/${locale}/products/${handle}${shareQuery ? `?${shareQuery}` : ""}`
142
+ )
143
+ }, [locale, handle, shareQuery])
122
144
 
123
145
  const handleCopyLink = () => {
124
- navigator.clipboard.writeText(window.location.href).then(() => {
146
+ navigator.clipboard.writeText(pageUrl).then(() => {
125
147
  setCopied(true)
126
148
  setTimeout(() => setCopied(false), 2000)
127
149
  })
@@ -139,8 +161,9 @@ export const ProductDetailsHeader = ({
139
161
  )
140
162
  }, [moqRules, selectedVariantRow?.id])
141
163
  const variantThreshold = useMemo(
142
- () => quoteThresholds?.find((t) => t.variant_id === selectedVariantRow?.id) ?? null,
143
- [quoteThresholds, selectedVariantRow?.id]
164
+ // A Sample pack is never quoted, so it carries no quote minimum.
165
+ () => (isSelectedSampleVariant ? null : quoteThresholds?.find((t) => t.variant_id === selectedVariantRow?.id) ?? null),
166
+ [quoteThresholds, selectedVariantRow?.id, isSelectedSampleVariant]
144
167
  )
145
168
  const variantMoqRequirement = useMemo(
146
169
  () => moqRequirements?.find((r) => r.variant_id === selectedVariantRow?.id) ?? null,
@@ -611,7 +634,7 @@ export const ProductDetailsHeader = ({
611
634
  </div>
612
635
  ) : (
613
636
  <span className="text-sm text-secondary" data-testid="product-price-unavailable">
614
- Not available in your region
637
+ {unpricedLabel ?? "Not available in your region"}
615
638
  </span>
616
639
  )}
617
640
  </div>
@@ -663,7 +686,13 @@ export const ProductDetailsHeader = ({
663
686
  )}
664
687
  data-testid="product-add-to-cart-button"
665
688
  >
666
- {!hasAnyPrice ? "NOT AVAILABLE IN YOUR REGION" : isPriceOnRequest ? "Price on Request" : variantHasPrice ? "Add to Cart" : "NOT AVAILABLE"}
689
+ {!hasAnyPrice
690
+ ? (unpricedLabel ?? "NOT AVAILABLE IN YOUR REGION")
691
+ : isPriceOnRequest
692
+ ? "Price on Request"
693
+ : variantHasPrice
694
+ ? "Add to Cart"
695
+ : "NOT AVAILABLE"}
667
696
  </Button>
668
697
  )}
669
698
  {hasAnyPrice && variantHasPrice && !quoteEligibility.hidden && (
@@ -707,7 +736,7 @@ export const ProductDetailsHeader = ({
707
736
  "w-full py-2.5 rounded-lg bg-neutral-900 text-white hover:bg-neutral-800 transition-colors text-sm font-bold uppercase tracking-wide disabled:opacity-50 disabled:cursor-not-allowed flex justify-center items-center gap-2",
708
737
  promptClassName:
709
738
  "w-full py-2.5 rounded-lg bg-neutral-900 text-white hover:bg-neutral-800 transition-colors text-sm font-bold uppercase tracking-wide flex justify-center items-center gap-2",
710
- idleLabel: "Add sample",
739
+ idleLabel: sampleIdleLabel,
711
740
  inCartPrefix: "In cart",
712
741
  })}
713
742
 
@@ -744,7 +773,7 @@ export const ProductDetailsHeader = ({
744
773
  )}
745
774
  </>
746
775
  ) : (
747
- <span className="text-sm text-neutral-500">Not available in your region</span>
776
+ <span className="text-sm text-neutral-500">{unpricedLabel ?? "Not available in your region"}</span>
748
777
  )}
749
778
  {addToCartDisabledReason && (
750
779
  <span className="mt-0.5 text-[11px] text-neutral-500">{addToCartDisabledReason}</span>
@@ -761,7 +790,13 @@ export const ProductDetailsHeader = ({
761
790
  )}
762
791
  data-testid="product-mobile-add-to-cart-button"
763
792
  >
764
- {!hasAnyPrice ? "Unavailable" : isPriceOnRequest ? "Price on Request" : variantHasPrice ? "Add to Cart" : "Unavailable"}
793
+ {!hasAnyPrice
794
+ ? (unpricedLabel ?? "Unavailable")
795
+ : isPriceOnRequest
796
+ ? "Price on Request"
797
+ : variantHasPrice
798
+ ? "Add to Cart"
799
+ : "Unavailable"}
765
800
  </Button>
766
801
  )}
767
802
  </div>
@@ -850,7 +885,7 @@ export const ProductDetailsHeader = ({
850
885
  </div>
851
886
  ) : (
852
887
  <span className="text-sm text-secondary" data-testid="product-price-unavailable">
853
- Not available in your region
888
+ {unpricedLabel ?? "Not available in your region"}
854
889
  </span>
855
890
  )}
856
891
  </div>
@@ -889,7 +924,7 @@ export const ProductDetailsHeader = ({
889
924
  data-testid="product-add-to-cart-button"
890
925
  >
891
926
  {!hasAnyPrice
892
- ? "NOT AVAILABLE IN YOUR REGION"
927
+ ? (unpricedLabel ?? "NOT AVAILABLE IN YOUR REGION")
893
928
  : isPriceOnRequest
894
929
  ? "Price on Request"
895
930
  : variantHasPrice
@@ -934,7 +969,7 @@ export const ProductDetailsHeader = ({
934
969
  "w-full mt-1.5 py-2 rounded-lg border border-neutral-800 bg-neutral-900 text-white hover:bg-neutral-800 transition-colors text-sm font-semibold uppercase tracking-wide disabled:opacity-50 disabled:cursor-not-allowed flex justify-center",
935
970
  promptClassName:
936
971
  "w-full mt-1.5 py-2 rounded-lg border border-neutral-800 bg-neutral-900 text-white hover:bg-neutral-800 transition-colors text-sm font-semibold uppercase tracking-wide flex justify-center",
937
- idleLabel: "Add sample",
972
+ idleLabel: sampleIdleLabel,
938
973
  inCartPrefix: "Sample in cart",
939
974
  })}
940
975
 
@@ -1,4 +1,5 @@
1
1
  import { ProductPageAccordion } from "../../molecules"
2
+ import { formatSpecificationCell } from "../../../lib/helpers/format-specification-cell"
2
3
  import { productDescriptionToMarkdown } from "../../../lib/helpers/product-description-markdown"
3
4
  import { Children, isValidElement } from "react"
4
5
  import type { ComponentPropsWithoutRef, ReactNode } from "react"
@@ -63,7 +64,7 @@ function TechnicalSpecificationCell({
63
64
  node: _node,
64
65
  ...props
65
66
  }: ComponentPropsWithoutRef<"td"> & ExtraProps) {
66
- return <td {...props}>{getTextContent(children)}</td>
67
+ return <td {...props}>{formatSpecificationCell(getTextContent(children))}</td>
67
68
  }
68
69
 
69
70
  function getTextContent(children: ReactNode): string {
@@ -70,6 +70,8 @@ export const WishlistButton = ({
70
70
  <Button
71
71
  onClick={isWishlisted ? () => handleRemoveFromWishlist() : () => handleAddToWishlist()}
72
72
  variant="tonal"
73
+ aria-label={isWishlisted ? "Remove from wishlist" : "Add to wishlist"}
74
+ aria-pressed={isWishlisted}
73
75
  className="flex h-10 w-10 items-center justify-center p-0"
74
76
  loading={isWishlistAdding}
75
77
  disabled={isWishlistAdding}
@@ -407,10 +407,12 @@ const Form = ({
407
407
  </div>
408
408
 
409
409
  {mode === 'password' ? (
410
- <form onSubmit={handleSubmit(submit)} data-testid="login-form">
410
+ <form onSubmit={handleSubmit(submit)} noValidate data-testid="login-form">
411
411
  <div className="space-y-4">
412
412
  <LabeledInput
413
413
  label="E-mail"
414
+ type="email"
415
+ autoComplete="email"
414
416
  placeholder="Your e-mail address"
415
417
  error={
416
418
  (errors.email as FieldError) ||
@@ -425,6 +427,7 @@ const Form = ({
425
427
  label="Password"
426
428
  placeholder="Your password"
427
429
  type="password"
430
+ autoComplete="current-password"
428
431
  error={
429
432
  (errors.password as FieldError) ||
430
433
  (isAuthError ? ({ message: '' } as FieldError) : undefined)
@@ -173,9 +173,21 @@ const Form = ({ isUnlinkedCompletion }: { isUnlinkedCompletion: boolean }) => {
173
173
  </div>
174
174
  )}
175
175
 
176
+ <p className="label-sm text-secondary mt-6" data-testid="register-consent-notice">
177
+ By creating an account you agree to our{" "}
178
+ <Link href={`/${locale}/legal/terms`} className="underline">
179
+ Terms &amp; Conditions
180
+ </Link>{" "}
181
+ and acknowledge our{" "}
182
+ <Link href={`/${locale}/legal/privacy`} className="underline">
183
+ Privacy Policy
184
+ </Link>
185
+ , which explains what personal data we collect and why.
186
+ </p>
187
+
176
188
  <Button
177
189
  type="submit"
178
- className="w-full flex justify-center mt-8 uppercase"
190
+ className="w-full flex justify-center mt-4 uppercase"
179
191
  disabled={isSubmitting}
180
192
  loading={isSubmitting}
181
193
  data-testid="register-submit-button"
@@ -10,6 +10,24 @@ interface BlogCardProps {
10
10
  }
11
11
 
12
12
  export function BlogCard({ post, index }: BlogCardProps) {
13
+ // A post with no link and no image (the specialty-chemical copy) is a plain
14
+ // card: there is nowhere to send the shopper and nothing to illustrate it.
15
+ if (!post.href || !post.image) {
16
+ return (
17
+ <article
18
+ className={cn(
19
+ "flex h-full flex-col rounded-lg border border-neutral-800 bg-neutral-900 p-5"
20
+ )}
21
+ >
22
+ <p className="mb-2 text-xs font-semibold uppercase tracking-wider text-neutral-300">
23
+ {post.category}
24
+ </p>
25
+ <h3 className="mb-2 text-lg font-semibold text-white">{post.title}</h3>
26
+ <p className="text-sm text-neutral-400">{post.excerpt}</p>
27
+ </article>
28
+ )
29
+ }
30
+
13
31
  return (
14
32
  <LocalizedClientLink
15
33
  href={post.href}
@@ -25,6 +25,7 @@ export const HeaderAccountControls = ({ locale }: { locale: string }) => {
25
25
  <LocalizedClientLink
26
26
  href="/user/wishlist"
27
27
  className="relative"
28
+ aria-label="Wishlist"
28
29
  data-testid="header-wishlist-link"
29
30
  >
30
31
  <HeartIcon size={20} />
@@ -4,22 +4,11 @@ import { ProductCard } from "../ProductCard/ProductCard"
4
4
  import { listProducts, listProductsWithSort } from "../../../lib/data/products"
5
5
  import { fetchQuoteThresholdsForProducts } from "../../../lib/helpers/fetch-quote-thresholds-for-products"
6
6
 
7
- /**
8
- * A 404 from a seller-scoped route, however the SDK surfaced it. Checked
9
- * structurally rather than by message so a reworded backend error does not
10
- * silently turn a degraded section back into a failed page.
11
- */
12
- function isNotFound(error: unknown): boolean {
13
- if (typeof error !== "object" || error === null) {
14
- return false
15
- }
16
- const status = (error as { status?: unknown }).status
17
- return status === 404
18
- }
19
7
  import {
20
8
  HOME_FEATURED_PRODUCT_FIELDS,
21
9
  PRODUCT_CARD_FIELDS,
22
10
  } from "../../../lib/data/product-fields"
11
+ import { isNotFoundError } from "../../../lib/helpers/medusa-error"
23
12
  import { SellerProps } from "../../../types/seller"
24
13
 
25
14
  const CAROUSEL_SLIDE =
@@ -119,7 +108,7 @@ export const HomeProductsCarousel = async ({
119
108
  // products"; anything else still throws, because hiding a real
120
109
  // failure behind an empty carousel is the bug this PR removed
121
110
  // everywhere else.
122
- if (isNotFound(error)) {
111
+ if (isNotFoundError(error)) {
123
112
  return { response: { products: [], count: 0 } }
124
113
  }
125
114
  throw error
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
 
3
3
  import { usePathname, useRouter, useSearchParams } from "next/navigation"
4
- import { useState } from "react"
4
+ import { useEffect, useState } from "react"
5
5
 
6
6
  import { CloseIcon } from "../../../icons"
7
7
  import { cn } from "../../../lib/utils"
@@ -27,6 +27,15 @@ export const ListingFilterSidebar = ({
27
27
  const pathname = usePathname()
28
28
  const searchParams = useSearchParams()
29
29
 
30
+ useEffect(() => {
31
+ if (!filterModal) return
32
+ const onKeyDown = (event: KeyboardEvent) => {
33
+ if (event.key === "Escape") setFilterModal(false)
34
+ }
35
+ document.addEventListener("keydown", onKeyDown)
36
+ return () => document.removeEventListener("keydown", onKeyDown)
37
+ }, [filterModal])
38
+
30
39
  const clearAll = () => {
31
40
  const kept = new URLSearchParams()
32
41
  for (const key of preserveParams) {
@@ -55,7 +64,8 @@ export const ListingFilterSidebar = ({
55
64
  className={cn(
56
65
  "w-full bg-primary md:rounded-md md:border md:border-primary md:overflow-hidden",
57
66
  filterModal
58
- ? "fixed inset-0 z-20 md:relative md:inset-auto md:z-10"
67
+ ? // z-50: must clear the sticky site header (z-40) or Close/Clear all are untappable.
68
+ "fixed inset-0 z-50 md:relative md:inset-auto md:z-10"
59
69
  : "hidden md:block md:sticky md:top-[88px] md:z-10"
60
70
  )}
61
71
  data-testid="listing-sidebar-drawer"
@@ -214,7 +214,12 @@ function QuickViewContent({ locale }: { locale: string }) {
214
214
  <div className="absolute inset-0 bg-black/50 backdrop-blur-sm" onClick={close} />
215
215
 
216
216
  {/* Modal panel */}
217
- <div className="relative bg-white rounded-2xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden flex flex-col">
217
+ <div
218
+ role="dialog"
219
+ aria-modal="true"
220
+ aria-label="Quick view"
221
+ className="relative bg-white rounded-2xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden flex flex-col"
222
+ >
218
223
 
219
224
  {/* Cart-added confirmation banner (sits above header bar) */}
220
225
  {addedToCart && (
@@ -20,6 +20,10 @@ type BrandSlots = {
20
20
  renderAddToPlaylist?: (track: StreamingTrack) => ReactNode
21
21
  /** Name on the vendor hero's support-WhatsApp quote button ("WhatsApp <label> for a quote"). Defaults to "Artha". */
22
22
  quoteWhatsappLabel?: string
23
+ /** Idle label of the product page's sample button ("Add sample" by default; e.g. "Order a sample"). */
24
+ sampleIdleLabel?: string
25
+ /** Copy for a product with no price in the region (e.g. "Price on request"). Unset keeps the regional "Not available in your region". */
26
+ unpricedLabel?: string
23
27
  }
24
28
 
25
29
  const BrandSlotsContext = createContext<BrandSlots>({})
@@ -44,3 +48,13 @@ export function useAddToPlaylistSlot() {
44
48
  export function useQuoteWhatsappLabel() {
45
49
  return useContext(BrandSlotsContext).quoteWhatsappLabel
46
50
  }
51
+
52
+ /** The brand's idle label for the sample button, or undefined when the app registers none. */
53
+ export function useSampleIdleLabel() {
54
+ return useContext(BrandSlotsContext).sampleIdleLabel
55
+ }
56
+
57
+ /** The brand's copy for an unpriced product, or undefined to keep the regional default. */
58
+ export function useUnpricedLabel() {
59
+ return useContext(BrandSlotsContext).unpricedLabel
60
+ }
@@ -34,7 +34,35 @@ export const blogPosts: BlogPost[] = [
34
34
  },
35
35
  ]
36
36
 
37
- export default function BlogSection() {
37
+ /**
38
+ * Opt-in copy for the specialty-chemicals storefront (`<BlogSection posts=... />`).
39
+ * Unlinked and image-free, so the cards render as plain text.
40
+ */
41
+ export const specialtyChemicalBlogPosts: BlogPost[] = [
42
+ {
43
+ id: 1,
44
+ title: "Verified Specialty Chemical Suppliers Across India",
45
+ excerpt:
46
+ "Connect with verified manufacturers and distributors of polymer additives, resins and specialty chemicals.",
47
+ category: "SUPPLIERS",
48
+ },
49
+ {
50
+ id: 2,
51
+ title: "Bulk Procurement Made Simple for Manufacturers",
52
+ excerpt:
53
+ "Source chemicals in bulk with transparent pricing, verified vendors and streamlined quote workflows.",
54
+ category: "PROCUREMENT",
55
+ },
56
+ {
57
+ id: 3,
58
+ title: "Quality-Controlled Chemicals With Technical Data",
59
+ excerpt:
60
+ "Ensure consistency and compliance with suppliers who publish technical data sheets and lab-tested grades.",
61
+ category: "QUALITY",
62
+ },
63
+ ]
64
+
65
+ export default function BlogSection({ posts = blogPosts }: { posts?: BlogPost[] }) {
38
66
  return (
39
67
  <section className="w-full bg-black py-20">
40
68
  <div className="content-container">
@@ -43,7 +71,7 @@ export default function BlogSection() {
43
71
  </h2>
44
72
 
45
73
  <div className="grid grid-cols-1 gap-6 md:grid-cols-3">
46
- {blogPosts.map((post, index) => (
74
+ {posts.map((post, index) => (
47
75
  <BlogCard key={post.id} post={post} index={index} />
48
76
  ))}
49
77
  </div>
@@ -1,7 +1,8 @@
1
1
  import { HttpTypes } from "@medusajs/types"
2
2
  import { HomeProductsCarousel } from "../../organisms"
3
3
  import LocalizedClientLink from "../../molecules/LocalizedLink/LocalizedLink"
4
- import { listProducts } from "../../../lib/data/products"
4
+ import { listProducts, listProductsWithSort } from "../../../lib/data/products"
5
+ import { isNotFoundError } from "../../../lib/helpers/medusa-error"
5
6
  import { HOME_FEATURED_PRODUCT_FIELDS, PRODUCT_CARD_FIELDS } from "../../../lib/data/product-fields"
6
7
  import { SellerProps } from "../../../types/seller"
7
8
 
@@ -61,6 +62,28 @@ export const HomeProductSection = async ({
61
62
  if (siblings.length === 0) return null
62
63
  }
63
64
 
65
+ // Seller section: suppress the heading when the seller has no other product
66
+ // (this one is excluded), same orphan-heading guard as the type branch. Same
67
+ // fetch shape as the carousel so both dedupe in the Data Cache; a suspended
68
+ // seller (404) means "nothing to show", as in the carousel.
69
+ if (sellerHandle && !home && !typeId) {
70
+ const { response } = await listProductsWithSort({
71
+ countryCode: locale,
72
+ seller_handle: sellerHandle,
73
+ sortBy: "created_at",
74
+ queryParams: { limit: 20, fields: PRODUCT_CARD_FIELDS },
75
+ forceCache: true,
76
+ }).catch((error: unknown) => {
77
+ if (isNotFoundError(error)) return { response: { products: [], count: 0 } }
78
+ throw error
79
+ })
80
+ const excludeId = excludeProductId ? String(excludeProductId) : undefined
81
+ const others = excludeId
82
+ ? response.products.filter((p) => String(p.id) !== excludeId)
83
+ : response.products
84
+ if (others.length === 0) return null
85
+ }
86
+
64
87
  // Same probe for the paginated home sections (e.g. "Featured products" page
65
88
  // 2): suppress the orphan heading when the carousel's fetch returns nothing.
66
89
  // Identical arguments to the carousel's call, so the request is deduped.
@@ -18,4 +18,10 @@ const links = {
18
18
  ],
19
19
  }
20
20
 
21
+ /** Same links minus the "#" placeholders ("About us", "FAQs") that have no page yet. Opt-in. */
22
+ export const footerLinksWithoutPlaceholders = {
23
+ ...links,
24
+ company: links.company.filter((link) => link.path !== "#"),
25
+ }
26
+
21
27
  export default links
@@ -87,10 +87,19 @@ export const listAuctions = async ({
87
87
  }
88
88
  }
89
89
 
90
- export const getAuction = async (auctionId: string): Promise<Auction | null> => {
90
+ /**
91
+ * `throwOnError` is for a caller that must tell a missing auction (null, the
92
+ * backend answered 404) from a failed lookup (throws): the page uses it so a
93
+ * 5xx or a dropped connection reaches the error boundary instead of a 404.
94
+ */
95
+ export const getAuction = async (
96
+ auctionId: string,
97
+ { throwOnError = false }: { throwOnError?: boolean } = {}
98
+ ): Promise<Auction | null> => {
99
+ let failedStatus: number | null = null
91
100
  try {
92
101
  const headers = await getAuthHeaders()
93
- const response = await fetchQuery(`/store/auctions/${auctionId}`, {
102
+ let response = await fetchQuery(`/store/auctions/${auctionId}`, {
94
103
  method: "GET",
95
104
  headers,
96
105
  })
@@ -98,24 +107,24 @@ export const getAuction = async (auctionId: string): Promise<Auction | null> =>
98
107
  // An expired or non-customer token triggers blockNonCustomerActors → 401.
99
108
  // Retry without auth so guests (and stale sessions) still see the auction.
100
109
  if (response.status === 401) {
101
- const guestResponse = await fetchQuery(`/store/auctions/${auctionId}`, {
110
+ response = await fetchQuery(`/store/auctions/${auctionId}`, {
102
111
  method: "GET",
103
112
  })
104
- if (!guestResponse.ok || !guestResponse.data) return null
105
- return mapSingleAuctionPayload(guestResponse.data)
106
- }
107
-
108
- if (!response.ok || !response.data) {
109
- return null
110
113
  }
111
114
 
112
- return mapSingleAuctionPayload(response.data)
115
+ // An ok response without a body is "not found", not a failed lookup.
116
+ if (response.ok) return response.data ? mapSingleAuctionPayload(response.data) : null
117
+ failedStatus = response.status
113
118
  } catch (error) {
114
119
  // AuctionDetailsPage already renders a "not found" state for a null
115
120
  // auction, so this degrades gracefully — but it shouldn't be silent.
116
121
  reportError(error)
122
+ if (throwOnError) throw error
117
123
  return null
118
124
  }
125
+ // Thrown outside the try so reportError never sees this synthetic error.
126
+ if (throwOnError && failedStatus !== 404) throw new Error(`Failed to load auction (HTTP ${failedStatus})`)
127
+ return null
119
128
  }
120
129
 
121
130
  export const getAuctionBids = async (
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Spec-table cells are authored upstream with LaTeX fragments (`\pm`, `~`,
3
+ * `^{*}`) and a unit that is also repeated in the value. Render them as plain
4
+ * text. A trailing repeat is only collapsed when it holds a letter, so a
5
+ * genuine "10 10" is left alone.
6
+ */
7
+ export function formatSpecificationCell(text: string): string {
8
+ const cleaned = text
9
+ .replace(/\\pm/g, "±")
10
+ // Only a tilde glued between two characters is the LaTeX non-breaking space;
11
+ // a leading or standalone one ("~5 kg") means "approximately" and stays.
12
+ .replace(/(?<=\S)~(?=\S)/g, " ")
13
+ .replace(/\^\{([^}]*)\}/g, "$1")
14
+ .replace(/\s+/g, " ")
15
+ .trim()
16
+ // Whitespace is now single spaces, so the last two tokens are found by index
17
+ // (a backtracking regex here is quadratic on long vendor-authored cells).
18
+ const lastSpace = cleaned.lastIndexOf(" ")
19
+ if (lastSpace < 0) return cleaned
20
+ const last = cleaned.slice(lastSpace + 1)
21
+ const previous = cleaned.slice(cleaned.lastIndexOf(" ", lastSpace - 1) + 1, lastSpace)
22
+ return last === previous && /[A-Za-z]/.test(last) ? cleaned.slice(0, lastSpace) : cleaned
23
+ }
@@ -1,4 +1,5 @@
1
1
  import { Metadata } from "next"
2
+ import { notFound } from "next/navigation"
2
3
  import { AuctionDetailsPage } from "../../../../components/sections/AuctionDetailsPage/AuctionDetailsPage"
3
4
  import { getAuction, getAuctionBids } from "../../../../lib/data/bidding"
4
5
  import { retrieveCustomer } from "../../../../lib/data/customer"
@@ -36,12 +37,15 @@ export default async function AuctionPage({
36
37
  const depositConfirmed = resolvedSearch["deposit"] === "confirmed"
37
38
 
38
39
  const [auction, bidsData, customer, region] = await Promise.all([
39
- getAuction(id),
40
+ getAuction(id, { throwOnError: true }),
40
41
  getAuctionBids(id),
41
42
  retrieveCustomer().catch(() => null),
42
43
  getRegion(locale),
43
44
  ])
44
45
 
46
+ // A real 404 (not a 200 "not found" body) for an unknown auction; other failures threw above.
47
+ if (!auction) notFound()
48
+
45
49
  return (
46
50
  <AuctionDetailsPage
47
51
  auctionId={id}
@@ -10,6 +10,7 @@ import { ArrowLeftIcon } from "../../../../../icons"
10
10
  import { fetchOrderHandoffHistory } from "../../../../../lib/data/cart-handoff"
11
11
  import { retrieveCustomer } from "../../../../../lib/data/customer"
12
12
  import { retrieveOrderSet } from "../../../../../lib/data/orders"
13
+ import { isNotFoundError } from "../../../../../lib/helpers/medusa-error"
13
14
 
14
15
  export default async function UserPage({
15
16
  params,
@@ -19,9 +20,17 @@ export default async function UserPage({
19
20
  const { id } = await params
20
21
 
21
22
  const user = await retrieveCustomer()
22
- const orderSet = await retrieveOrderSet(id)
23
-
23
+ // Before any order fetch: the backend rejects an unauthenticated read, which
24
+ // would otherwise surface as a 500 instead of the login redirect.
24
25
  if (!user) return redirect("/login")
26
+
27
+ // An unknown (or not-yours) id is a 404 from the backend; show the orders
28
+ // list rather than letting the thrown error become a 500.
29
+ const orderSet = await retrieveOrderSet(id).catch((error: unknown) => {
30
+ if (isNotFoundError(error)) return null
31
+ throw error
32
+ })
33
+
25
34
  if (!orderSet) return redirect("/user/orders")
26
35
 
27
36
  // The hand-off history route is keyed by an individual order id, not the