@sgflabs/storefront-core 0.1.18 → 0.1.20
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/package.json +9 -7
- package/src/components/cells/CartDropdown/CartDropdown.tsx +1 -1
- package/src/components/cells/CartItemsProducts/CartItemsProducts.tsx +4 -2
- package/src/components/cells/MobileNavbar/MobileNavbar.tsx +4 -1
- package/src/components/cells/UserDropdown/UserDropdown.tsx +9 -6
- package/src/components/molecules/CartDropdownItem/CartDropdownItem.tsx +5 -2
- package/src/components/molecules/LoginReturnLink/LoginReturnLink.tsx +2 -2
- package/src/components/molecules/NativeSelect/NativeSelect.tsx +2 -0
- package/src/components/molecules/ProductImage/ProductImage.tsx +1 -1
- package/src/components/organisms/CartEmpty/CartEmpty.tsx +1 -1
- package/src/components/organisms/Header/Header.tsx +10 -4
- package/src/components/organisms/Header/HeaderAccountControls.tsx +8 -7
- package/src/components/organisms/Header/HeaderMessages.tsx +14 -0
- package/src/components/organisms/ListingToolbar/ListingToolbar.tsx +8 -2
- package/src/components/organisms/OrderItems/Item.tsx +5 -2
- package/src/components/organisms/ProductCard/ProductCard.tsx +8 -3
- package/src/components/organisms/ProductListingHeader/ProductListingHeader.tsx +7 -3
- package/src/components/sections/Cart/Cart.tsx +1 -0
- package/src/lib/data/bidding.ts +5 -1
- package/src/lib/data/brand.ts +3 -3
- package/src/lib/data/seller.ts +17 -2
- package/src/lib/data/vendor-signup.ts +31 -0
- package/src/lib/helpers/build-product-gallery-slides.ts +25 -0
- package/src/lib/helpers/resolve-image-alt.ts +14 -0
- package/src/lib/helpers/seo.ts +140 -65
- package/src/lib/helpers/store-image-alt.ts +8 -0
- package/src/lib/seo/indexing.ts +11 -0
- package/src/lib/seo/locale-redirect.ts +11 -0
- package/src/lib/seo/seo-config.d.ts +9 -0
- package/src/lib/seo/seo-config.js +42 -0
- package/src/pages/auth/forgot-password/page.tsx +2 -0
- package/src/pages/auth/login/page.tsx +12 -0
- package/src/pages/auth/register/page.tsx +11 -0
- package/src/pages/invite/page.tsx +2 -2
- package/src/pages/main/applications/[handle]/page.tsx +2 -1
- package/src/pages/main/auctions/page.tsx +30 -2
- package/src/pages/main/best-sellers/page.tsx +2 -1
- package/src/pages/main/categories/[category]/page.tsx +4 -2
- package/src/pages/main/categories/page.tsx +2 -1
- package/src/pages/main/legal/[type]/page.tsx +23 -9
- package/src/pages/main/legal/page.tsx +16 -4
- package/src/pages/main/sellers/[handle]/page.tsx +23 -2
- package/src/pages/main/user/layout.tsx +3 -0
- package/src/pages/robots.ts +25 -2
- package/src/pages/sitemap.ts +21 -3
- package/src/pages/sitemap.xml/route.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sgflabs/storefront-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
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": [
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
],
|
|
9
9
|
"exports": {
|
|
10
10
|
".": "./src/index.ts",
|
|
11
|
+
"./lib/seo/seo-config": "./src/lib/seo/seo-config.js",
|
|
11
12
|
"./*": "./src/*"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
@@ -55,9 +56,9 @@
|
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@sentry/nextjs": "^10.63.0",
|
|
57
58
|
"@sgflabs/artha-go-sdk": "^0.3.0",
|
|
58
|
-
"@sgflabs/gstin": "^0.1.
|
|
59
|
-
"@sgflabs/page-spec": "^0.1.
|
|
60
|
-
"@sgflabs/storefront-core-common": "^0.1.
|
|
59
|
+
"@sgflabs/gstin": "^0.1.20",
|
|
60
|
+
"@sgflabs/page-spec": "^0.1.20",
|
|
61
|
+
"@sgflabs/storefront-core-common": "^0.1.20",
|
|
61
62
|
"@testing-library/dom": "^10.4.1",
|
|
62
63
|
"@testing-library/jest-dom": "^7.0.0",
|
|
63
64
|
"@testing-library/react": "^16.3.2",
|
|
@@ -73,14 +74,15 @@
|
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"@sentry/nextjs": "^10.63.0",
|
|
75
76
|
"@sgflabs/artha-go-sdk": "^0.3.0",
|
|
76
|
-
"@sgflabs/gstin": "^0.1.
|
|
77
|
-
"@sgflabs/page-spec": "^0.1.
|
|
78
|
-
"@sgflabs/storefront-core-common": "^0.1.
|
|
77
|
+
"@sgflabs/gstin": "^0.1.20",
|
|
78
|
+
"@sgflabs/page-spec": "^0.1.20",
|
|
79
|
+
"@sgflabs/storefront-core-common": "^0.1.20",
|
|
79
80
|
"next": "15.5.27",
|
|
80
81
|
"react": "^19.3.1",
|
|
81
82
|
"react-dom": "^19.3.1"
|
|
82
83
|
},
|
|
83
84
|
"scripts": {
|
|
85
|
+
"seo:check": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/seo-html-check.ts",
|
|
84
86
|
"test": "vitest run",
|
|
85
87
|
"typecheck": "tsc --noEmit"
|
|
86
88
|
},
|
|
@@ -97,9 +97,9 @@ export const CartDropdown = () => {
|
|
|
97
97
|
<LocalizedClientLink
|
|
98
98
|
href="/cart"
|
|
99
99
|
className="relative"
|
|
100
|
-
aria-label="Go to cart"
|
|
101
100
|
>
|
|
102
101
|
<CartIcon size={20} />
|
|
102
|
+
<span className="sr-only">Go to cart</span>
|
|
103
103
|
{Boolean(cartItemsCount) && (
|
|
104
104
|
<Badge className="absolute -top-2 -right-2 w-4 h-4 p-0">
|
|
105
105
|
{cartItemsCount}
|
|
@@ -12,6 +12,7 @@ import { DeleteCartItemButton } from '../../molecules';
|
|
|
12
12
|
import LocalizedClientLink from '../../molecules/LocalizedLink/LocalizedLink';
|
|
13
13
|
import { UpdateCartItemButton } from '../../molecules/UpdateCartItemButton/UpdateCartItemButton';
|
|
14
14
|
import { variantOptionTitle } from '../../../lib/helpers/variant-option-title';
|
|
15
|
+
import { resolveStoreImageAlt } from '../../../lib/helpers/store-image-alt';
|
|
15
16
|
import { filterValidCartItems } from '../../../lib/helpers/filter-valid-cart-items';
|
|
16
17
|
import { getCartLineItemDisplayAmount } from '../../../lib/helpers/cart-line-item';
|
|
17
18
|
import { convertToLocale } from '../../../lib/helpers/money';
|
|
@@ -74,6 +75,7 @@ export const CartItemsProducts = ({
|
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
const lineKey = product.id ?? `cart-line-${index}`
|
|
78
|
+
const imageAlt = resolveStoreImageAlt(product.product?.images?.[0], product.product_title ?? "", 0)
|
|
77
79
|
|
|
78
80
|
// Winner's auction settlement line: shows gross price, the deposit
|
|
79
81
|
// credit applied, and the net amount actually charged. Only present
|
|
@@ -94,7 +96,7 @@ export const CartItemsProducts = ({
|
|
|
94
96
|
{product.thumbnail ? (
|
|
95
97
|
<ProductImage
|
|
96
98
|
src={product.thumbnail}
|
|
97
|
-
alt=
|
|
99
|
+
alt={imageAlt}
|
|
98
100
|
width={100}
|
|
99
101
|
height={132}
|
|
100
102
|
className="h-[132px] w-[100px] rounded-xs object-contain"
|
|
@@ -102,7 +104,7 @@ export const CartItemsProducts = ({
|
|
|
102
104
|
) : (
|
|
103
105
|
<Image
|
|
104
106
|
src={'/images/placeholder.svg'}
|
|
105
|
-
alt=
|
|
107
|
+
alt={imageAlt}
|
|
106
108
|
width={50}
|
|
107
109
|
height={66}
|
|
108
110
|
className="h-[66px] w-[50px] rounded-xs object-contain opacity-30"
|
|
@@ -17,10 +17,13 @@ export const MobileNavbar = ({
|
|
|
17
17
|
categories,
|
|
18
18
|
parentCategories,
|
|
19
19
|
isLoggedIn = false,
|
|
20
|
+
vendorSignupUrl = `${process.env.NEXT_PUBLIC_VENDOR_URL}/register`,
|
|
20
21
|
}: {
|
|
21
22
|
categories: HttpTypes.StoreProductCategory[];
|
|
22
23
|
parentCategories: HttpTypes.StoreProductCategory[];
|
|
23
24
|
isLoggedIn?: boolean;
|
|
25
|
+
/** Where "Become a Vendor" goes; a seller storefront passes the link carrying its referral code. */
|
|
26
|
+
vendorSignupUrl?: string;
|
|
24
27
|
}) => {
|
|
25
28
|
const [isOpen, setIsOpen] = useState(false);
|
|
26
29
|
|
|
@@ -112,7 +115,7 @@ export const MobileNavbar = ({
|
|
|
112
115
|
Auctions
|
|
113
116
|
</LocalizedClientLink>
|
|
114
117
|
<a
|
|
115
|
-
href={
|
|
118
|
+
href={vendorSignupUrl}
|
|
116
119
|
target="_blank"
|
|
117
120
|
rel="noopener noreferrer"
|
|
118
121
|
className="text-sm font-medium text-action"
|
|
@@ -16,9 +16,9 @@ import { useState } from "react"
|
|
|
16
16
|
* with no space for it (design §1) — it moved into the account menu rather than
|
|
17
17
|
* being dropped. External link, so not a LocalizedClientLink.
|
|
18
18
|
*/
|
|
19
|
-
const BecomeVendorItem = () => (
|
|
19
|
+
const BecomeVendorItem = ({ href }: { href: string }) => (
|
|
20
20
|
<a
|
|
21
|
-
href={
|
|
21
|
+
href={href}
|
|
22
22
|
target="_blank"
|
|
23
23
|
rel="noopener noreferrer"
|
|
24
24
|
className="block px-4 py-3 label-md hover:bg-component-secondary"
|
|
@@ -30,8 +30,11 @@ const BecomeVendorItem = () => (
|
|
|
30
30
|
|
|
31
31
|
export const UserDropdown = ({
|
|
32
32
|
isLoggedIn,
|
|
33
|
+
vendorSignupUrl = `${process.env.NEXT_PUBLIC_VENDOR_URL}/register`,
|
|
33
34
|
}: {
|
|
34
35
|
isLoggedIn: boolean
|
|
36
|
+
/** Where "Become a vendor" goes; a seller storefront passes the link carrying its referral code. */
|
|
37
|
+
vendorSignupUrl?: string
|
|
35
38
|
}) => {
|
|
36
39
|
const [open, setOpen] = useState(false)
|
|
37
40
|
|
|
@@ -46,17 +49,17 @@ export const UserDropdown = ({
|
|
|
46
49
|
<LocalizedClientLink
|
|
47
50
|
href="/user"
|
|
48
51
|
className="relative"
|
|
49
|
-
aria-label="Go to user profile"
|
|
50
52
|
>
|
|
51
53
|
<ProfileIcon size={20} />
|
|
54
|
+
<span className="sr-only">Go to user profile</span>
|
|
52
55
|
</LocalizedClientLink>
|
|
53
56
|
) : (
|
|
54
57
|
<LoginReturnLink
|
|
55
58
|
href="/login"
|
|
56
59
|
className="relative"
|
|
57
|
-
aria-label="Go to user profile"
|
|
58
60
|
>
|
|
59
61
|
<ProfileIcon size={20} />
|
|
62
|
+
<span className="sr-only">Go to user profile</span>
|
|
60
63
|
</LoginReturnLink>
|
|
61
64
|
)}
|
|
62
65
|
<Dropdown show={open}>
|
|
@@ -80,7 +83,7 @@ export const UserDropdown = ({
|
|
|
80
83
|
<NavigationItem href="/user/bids">My bids</NavigationItem>
|
|
81
84
|
<Divider />
|
|
82
85
|
<NavigationItem href="/user/settings">Settings</NavigationItem>
|
|
83
|
-
<BecomeVendorItem />
|
|
86
|
+
<BecomeVendorItem href={vendorSignupUrl} />
|
|
84
87
|
<LogoutButton />
|
|
85
88
|
</div>
|
|
86
89
|
) : (
|
|
@@ -98,7 +101,7 @@ export const UserDropdown = ({
|
|
|
98
101
|
Register
|
|
99
102
|
</LoginReturnLink>
|
|
100
103
|
<Divider />
|
|
101
|
-
<BecomeVendorItem />
|
|
104
|
+
<BecomeVendorItem href={vendorSignupUrl} />
|
|
102
105
|
</div>
|
|
103
106
|
)}
|
|
104
107
|
</Dropdown>
|
|
@@ -10,6 +10,8 @@ import { useMeasurement } from "../../providers/Measurement/MeasurementProvider"
|
|
|
10
10
|
import { HttpTypes } from "@medusajs/types"
|
|
11
11
|
import Image from "next/image"
|
|
12
12
|
|
|
13
|
+
import { resolveStoreImageAlt } from "../../../lib/helpers/store-image-alt"
|
|
14
|
+
|
|
13
15
|
import { ProductImage } from "../ProductImage/ProductImage"
|
|
14
16
|
|
|
15
17
|
export const CartDropdownItem = ({
|
|
@@ -20,6 +22,7 @@ export const CartDropdownItem = ({
|
|
|
20
22
|
currency_code: string
|
|
21
23
|
}) => {
|
|
22
24
|
const { system } = useMeasurement()
|
|
25
|
+
const imageAlt = resolveStoreImageAlt(item.product?.images?.[0], item.product_title ?? "", 0)
|
|
23
26
|
const original_total = convertToLocale({
|
|
24
27
|
amount: (item.compare_at_unit_price || 0) * item.quantity,
|
|
25
28
|
currency_code,
|
|
@@ -36,7 +39,7 @@ export const CartDropdownItem = ({
|
|
|
36
39
|
{item.thumbnail ? (
|
|
37
40
|
<ProductImage
|
|
38
41
|
src={item.thumbnail}
|
|
39
|
-
alt={
|
|
42
|
+
alt={imageAlt}
|
|
40
43
|
width={80}
|
|
41
44
|
height={90}
|
|
42
45
|
className="w-[80px] h-[90px] object-cover rounded-xs"
|
|
@@ -45,7 +48,7 @@ export const CartDropdownItem = ({
|
|
|
45
48
|
) : (
|
|
46
49
|
<Image
|
|
47
50
|
src={"/images/placeholder.svg"}
|
|
48
|
-
alt=
|
|
51
|
+
alt={imageAlt}
|
|
49
52
|
width={50}
|
|
50
53
|
height={66}
|
|
51
54
|
className="rounded-xs w-[50px] h-[66px] object-contain opacity-30"
|
|
@@ -63,7 +63,7 @@ function LoginReturnLinkInner({
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
return (
|
|
66
|
-
<LocalizedClientLink href={hrefWithRedirect} onClick={handleClick} {...props}>
|
|
66
|
+
<LocalizedClientLink href={hrefWithRedirect} onClick={handleClick} rel="nofollow" {...props}>
|
|
67
67
|
{children}
|
|
68
68
|
</LocalizedClientLink>
|
|
69
69
|
)
|
|
@@ -84,7 +84,7 @@ export function LoginReturnLink(props: LoginReturnLinkProps) {
|
|
|
84
84
|
return (
|
|
85
85
|
<Suspense
|
|
86
86
|
fallback={
|
|
87
|
-
<LocalizedClientLink href={fallbackHref} className={className} {...rest}>
|
|
87
|
+
<LocalizedClientLink href={fallbackHref} className={className} rel="nofollow" {...rest}>
|
|
88
88
|
{children}
|
|
89
89
|
</LocalizedClientLink>
|
|
90
90
|
}
|
|
@@ -53,6 +53,8 @@ const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
|
|
|
53
53
|
ref={innerRef}
|
|
54
54
|
defaultValue={defaultValue}
|
|
55
55
|
{...props}
|
|
56
|
+
// An id or aria-labelledby means the caller labels it; aria-label would override that.
|
|
57
|
+
aria-label={props["aria-label"] ?? (props.id || props["aria-labelledby"] ? undefined : placeholder)}
|
|
56
58
|
className="appearance-none flex-1 bg-transparent border-none px-4 py-2.5 transition-colors duration-150 outline-none "
|
|
57
59
|
>
|
|
58
60
|
<option disabled value="">
|
|
@@ -5,7 +5,7 @@ export function CartEmpty() {
|
|
|
5
5
|
return (
|
|
6
6
|
<div className="col-span-12 pt-4 py-6 flex justify-center" data-testid="cart-empty">
|
|
7
7
|
<div className="w-[466px] flex flex-col">
|
|
8
|
-
<
|
|
8
|
+
<h1 className="text-primary heading-lg text-center">SHOPPING CART</h1>
|
|
9
9
|
<p className="mt-2 text-lg text-secondary text-center">
|
|
10
10
|
Your shopping cart is currently empty
|
|
11
11
|
</p>
|
|
@@ -13,6 +13,7 @@ import LocalizedClientLink from "../../molecules/LocalizedLink/LocalizedLink"
|
|
|
13
13
|
import { listCategories } from "../../../lib/data/categories"
|
|
14
14
|
import { listAllCollectionsForBrowse } from "../../../lib/data/collections"
|
|
15
15
|
import { listRegions } from "../../../lib/data/regions"
|
|
16
|
+
import { getVendorSignupUrl } from "../../../lib/data/vendor-signup"
|
|
16
17
|
import { listBrowseApplications } from "../../../lib/data/browse-navigation"
|
|
17
18
|
import { listAllSellersForNav } from "../../../lib/data/seller"
|
|
18
19
|
import { isCategoriesCollectionsBrowseMode } from "../../../lib/storefront/browse-nav-flags"
|
|
@@ -21,16 +22,18 @@ import { HeaderSearch } from "./HeaderSearch"
|
|
|
21
22
|
import { BrowsePanel, BrowsePanelProvider, BrowseTrigger } from "../BrowsePanel/BrowsePanel"
|
|
22
23
|
import { VendorHeaderDropdown } from "../VendorHeaderDropdown/VendorHeaderDropdown"
|
|
23
24
|
|
|
24
|
-
export const Header = async ({ locale, logo, actions, hideVendors = false }: {
|
|
25
|
+
export const Header = async ({ locale, logo, actions, siteName = "Home", hideVendors = false }: {
|
|
25
26
|
locale: string
|
|
26
27
|
/** Single-vendor storefronts: skip the Vendors dropdown and its fetch. */
|
|
27
28
|
hideVendors?: boolean
|
|
28
29
|
/** Brand mark, rendered by the caller — Logo differs per brand app. */
|
|
29
30
|
logo?: ReactNode
|
|
31
|
+
/** Names the home link for assistive tech and crawlers; the logo mark is often an image with empty alt. */
|
|
32
|
+
siteName?: string
|
|
30
33
|
/** Optional brand call-to-action for the desktop row, placed after Auctions. */
|
|
31
34
|
actions?: ReactNode
|
|
32
35
|
}) => {
|
|
33
|
-
const regions = await listRegions()
|
|
36
|
+
const [regions, vendorSignupUrl] = await Promise.all([listRegions(), getVendorSignupUrl()])
|
|
34
37
|
const categoriesCollectionsMode = isCategoriesCollectionsBrowseMode()
|
|
35
38
|
|
|
36
39
|
// listCategories rejects when the calling publishable key isn't linked to
|
|
@@ -105,6 +108,7 @@ export const Header = async ({ locale, logo, actions, hideVendors = false }: {
|
|
|
105
108
|
<LocalizedClientLink
|
|
106
109
|
href="/"
|
|
107
110
|
data-testid="header-logo-link"
|
|
111
|
+
aria-label={siteName}
|
|
108
112
|
className="flex-shrink-0 text-primary hover:opacity-80"
|
|
109
113
|
>
|
|
110
114
|
{logo}
|
|
@@ -147,7 +151,7 @@ export const Header = async ({ locale, logo, actions, hideVendors = false }: {
|
|
|
147
151
|
<Suspense fallback={<div className="w-16 h-10" aria-hidden />}>
|
|
148
152
|
<CountrySelector regions={regions} />
|
|
149
153
|
</Suspense>
|
|
150
|
-
<HeaderAccountControls locale={locale} />
|
|
154
|
+
<HeaderAccountControls locale={locale} vendorSignupUrl={vendorSignupUrl} />
|
|
151
155
|
<CartDropdown />
|
|
152
156
|
</div>
|
|
153
157
|
</div>
|
|
@@ -161,12 +165,14 @@ export const Header = async ({ locale, logo, actions, hideVendors = false }: {
|
|
|
161
165
|
parentCategories={parentCategories}
|
|
162
166
|
categories={categories}
|
|
163
167
|
isLoggedIn={false}
|
|
168
|
+
vendorSignupUrl={vendorSignupUrl}
|
|
164
169
|
/>
|
|
165
170
|
</div>
|
|
166
171
|
|
|
167
172
|
<LocalizedClientLink
|
|
168
173
|
href="/"
|
|
169
174
|
data-testid="header-logo-link-mobile"
|
|
175
|
+
aria-label={siteName}
|
|
170
176
|
className="flex-shrink-0 text-primary hover:opacity-80"
|
|
171
177
|
>
|
|
172
178
|
{logo}
|
|
@@ -176,7 +182,7 @@ export const Header = async ({ locale, logo, actions, hideVendors = false }: {
|
|
|
176
182
|
className="ml-auto flex items-center gap-3.5"
|
|
177
183
|
data-testid="header-actions-mobile"
|
|
178
184
|
>
|
|
179
|
-
<HeaderAccountControls locale={locale} />
|
|
185
|
+
<HeaderAccountControls locale={locale} vendorSignupUrl={vendorSignupUrl} />
|
|
180
186
|
<CartDropdown />
|
|
181
187
|
</div>
|
|
182
188
|
</div>
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import dynamic from "next/dynamic"
|
|
4
4
|
|
|
5
5
|
import { Badge } from "../../atoms/Badge/Badge"
|
|
6
6
|
import LocalizedClientLink from "../../molecules/LocalizedLink/LocalizedLink"
|
|
7
|
-
import { MessageButton } from "../../molecules/MessageButton/MessageButton"
|
|
8
7
|
import { UserDropdown } from "../../cells/UserDropdown/UserDropdown"
|
|
9
8
|
import { HeartIcon } from "../../../icons"
|
|
10
9
|
import { useCustomerSession } from "../../../hooks/useCustomerSession"
|
|
11
10
|
|
|
12
11
|
const TALKJS_APP_ID = process.env.NEXT_PUBLIC_TALKJS_APP_ID || ""
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
const HeaderMessages = dynamic(() => import("./HeaderMessages"), { ssr: false })
|
|
14
|
+
|
|
15
|
+
export const HeaderAccountControls = ({ locale, vendorSignupUrl }: { locale: string; vendorSignupUrl?: string }) => {
|
|
15
16
|
const session = useCustomerSession(locale)
|
|
16
17
|
// Match ProductCard: undefined = still loading, distinct from logged-out.
|
|
17
18
|
const isSessionLoading = session === undefined
|
|
@@ -39,7 +40,7 @@ export const HeaderAccountControls = ({ locale }: { locale: string }) => {
|
|
|
39
40
|
)}
|
|
40
41
|
</LocalizedClientLink>
|
|
41
42
|
)}
|
|
42
|
-
{!isSessionLoading && <UserDropdown isLoggedIn={isLoggedIn} />}
|
|
43
|
+
{!isSessionLoading && <UserDropdown isLoggedIn={isLoggedIn} vendorSignupUrl={vendorSignupUrl} />}
|
|
43
44
|
</>
|
|
44
45
|
)
|
|
45
46
|
|
|
@@ -48,9 +49,9 @@ export const HeaderAccountControls = ({ locale }: { locale: string }) => {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
return (
|
|
51
|
-
|
|
52
|
-
<
|
|
52
|
+
<>
|
|
53
|
+
<HeaderMessages appId={TALKJS_APP_ID} userId={user.id} />
|
|
53
54
|
{accountControls}
|
|
54
|
-
|
|
55
|
+
</>
|
|
55
56
|
)
|
|
56
57
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Session } from "@talkjs/react"
|
|
4
|
+
|
|
5
|
+
import { MessageButton } from "../../molecules/MessageButton/MessageButton"
|
|
6
|
+
|
|
7
|
+
/** Kept in its own module so the TalkJS SDK stays out of the header bundle until a signed-in user needs it. */
|
|
8
|
+
export default function HeaderMessages({ appId, userId }: { appId: string; userId: string }) {
|
|
9
|
+
return (
|
|
10
|
+
<Session appId={appId} userId={userId}>
|
|
11
|
+
<MessageButton />
|
|
12
|
+
</Session>
|
|
13
|
+
)
|
|
14
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { useId } from "react"
|
|
4
|
+
|
|
3
5
|
import useUpdateSearchParams from "../../../hooks/useUpdateSearchParams"
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -27,6 +29,8 @@ export const ListingToolbar = <TSort extends string>({
|
|
|
27
29
|
sortOptions?: ReadonlyArray<{ value: TSort; label: string }>
|
|
28
30
|
currentSort?: TSort
|
|
29
31
|
}) => {
|
|
32
|
+
const displayId = useId()
|
|
33
|
+
const sortId = useId()
|
|
30
34
|
const updateSearchParams = useUpdateSearchParams()
|
|
31
35
|
const updateParam = (key: string, value: string) =>
|
|
32
36
|
updateSearchParams(key, value, { resetPage: true })
|
|
@@ -48,11 +52,12 @@ export const ListingToolbar = <TSort extends string>({
|
|
|
48
52
|
|
|
49
53
|
<div className="flex flex-wrap items-center gap-3">
|
|
50
54
|
<div className="flex items-center gap-2">
|
|
51
|
-
<
|
|
55
|
+
<label htmlFor={displayId} className="text-sm text-neutral-600 whitespace-nowrap">Display:</label>
|
|
52
56
|
<select
|
|
53
57
|
value={limit}
|
|
54
58
|
onChange={(e) => updateParam("limit", e.target.value)}
|
|
55
59
|
className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
|
|
60
|
+
id={displayId}
|
|
56
61
|
data-testid="listing-toolbar-display-select"
|
|
57
62
|
>
|
|
58
63
|
{limitOptions.map((n) => (
|
|
@@ -65,11 +70,12 @@ export const ListingToolbar = <TSort extends string>({
|
|
|
65
70
|
|
|
66
71
|
{sortOptions && (
|
|
67
72
|
<div className="flex items-center gap-2">
|
|
68
|
-
<
|
|
73
|
+
<label htmlFor={sortId} className="text-sm text-neutral-600 whitespace-nowrap">Sort by:</label>
|
|
69
74
|
<select
|
|
70
75
|
value={currentSort}
|
|
71
76
|
onChange={(e) => updateParam("sort", e.target.value)}
|
|
72
77
|
className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
|
|
78
|
+
id={sortId}
|
|
73
79
|
data-testid="listing-toolbar-sort-select"
|
|
74
80
|
>
|
|
75
81
|
{sortOptions.map(({ label, value }) => (
|
|
@@ -8,6 +8,8 @@ import { useMeasurement } from "../../providers/Measurement/MeasurementProvider"
|
|
|
8
8
|
import { HttpTypes } from "@medusajs/types"
|
|
9
9
|
import Image from "next/image"
|
|
10
10
|
|
|
11
|
+
import { resolveStoreImageAlt } from "../../../lib/helpers/store-image-alt"
|
|
12
|
+
|
|
11
13
|
import { ProductImage } from "../../molecules/ProductImage/ProductImage"
|
|
12
14
|
export const Item = ({
|
|
13
15
|
item,
|
|
@@ -17,6 +19,7 @@ export const Item = ({
|
|
|
17
19
|
currencyCode: string
|
|
18
20
|
}) => {
|
|
19
21
|
const { system } = useMeasurement()
|
|
22
|
+
const imageAlt = resolveStoreImageAlt(item.product?.images?.[0], item.product_title ?? "", 0)
|
|
20
23
|
// Order line items carry the variant relation (see `*items.variant` in the
|
|
21
24
|
// orders fetch fields, matching CartDropdownItem's cart line item pattern)
|
|
22
25
|
// — options come along with it, so the display can convert/format exactly
|
|
@@ -45,7 +48,7 @@ export const Item = ({
|
|
|
45
48
|
{item.thumbnail ? (
|
|
46
49
|
<ProductImage
|
|
47
50
|
src={item.thumbnail}
|
|
48
|
-
alt=
|
|
51
|
+
alt={imageAlt}
|
|
49
52
|
width={100}
|
|
50
53
|
height={132}
|
|
51
54
|
className="rounded-xs w-[100px] h-[132px] object-contain"
|
|
@@ -53,7 +56,7 @@ export const Item = ({
|
|
|
53
56
|
) : (
|
|
54
57
|
<Image
|
|
55
58
|
src={"/images/placeholder.svg"}
|
|
56
|
-
alt=
|
|
59
|
+
alt={imageAlt}
|
|
57
60
|
width={50}
|
|
58
61
|
height={66}
|
|
59
62
|
className="rounded-xs w-[50px] h-[66px] object-contain opacity-30"
|
|
@@ -21,7 +21,7 @@ import { certificationLabel } from "../../../lib/helpers/certification-label"
|
|
|
21
21
|
import { UnitPriceDisplay } from "../../molecules/UnitPriceDisplay/UnitPriceDisplay"
|
|
22
22
|
import LocalizedClientLink from "../../molecules/LocalizedLink/LocalizedLink"
|
|
23
23
|
import { VegNonVegIndicator } from "../../atoms/VegNonVegIndicator/VegNonVegIndicator"
|
|
24
|
-
import {
|
|
24
|
+
import { resolveStoreImageAlt } from "../../../lib/helpers/store-image-alt"
|
|
25
25
|
import { getVegNonVegStatus } from "../../../lib/helpers/veg-non-veg"
|
|
26
26
|
import { useCartContext } from "../../providers"
|
|
27
27
|
import { toast } from "../../../lib/helpers/toast"
|
|
@@ -273,8 +273,13 @@ export const ProductCard = ({
|
|
|
273
273
|
(product as { seller?: { name?: string | null } }).seller?.name ?? null
|
|
274
274
|
const trimmedImage = typeof primaryImage === "string" ? primaryImage.trim() : ""
|
|
275
275
|
const isPlaceholder = trimmedImage.length === 0 || trimmedImage === "/images/placeholder.svg"
|
|
276
|
-
|
|
277
|
-
const
|
|
276
|
+
// A local file: the third-party placeholder host is only for the client-side load-error fallback.
|
|
277
|
+
const imageSrc = isPlaceholder ? "/images/placeholder.svg" : trimmedImage
|
|
278
|
+
const imageAlt = resolveStoreImageAlt(
|
|
279
|
+
(product as { images?: { metadata?: Record<string, unknown> | null }[] }).images?.[0],
|
|
280
|
+
vendorName ? `${productName} by ${vendorName}` : productName,
|
|
281
|
+
0
|
|
282
|
+
)
|
|
278
283
|
const handle = product.handle ?? ""
|
|
279
284
|
|
|
280
285
|
const showSampleButton = hasAnyPrice && Boolean(sampleVariant)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { SellerCartToggle } from '../../molecules';
|
|
4
4
|
import { useSearchParams } from 'next/navigation';
|
|
5
|
-
import { type ReactNode } from 'react';
|
|
5
|
+
import { type ReactNode, useId } from 'react';
|
|
6
6
|
import { cn } from '../../../lib/utils';
|
|
7
7
|
import useUpdateSearchParams from '../../../hooks/useUpdateSearchParams';
|
|
8
8
|
|
|
@@ -37,6 +37,8 @@ export const ProductListingHeader = ({
|
|
|
37
37
|
*/
|
|
38
38
|
heading?: string
|
|
39
39
|
}) => {
|
|
40
|
+
const displayId = useId();
|
|
41
|
+
const sortId = useId();
|
|
40
42
|
const searchParams = useSearchParams();
|
|
41
43
|
const updateSearchParams = useUpdateSearchParams();
|
|
42
44
|
|
|
@@ -87,11 +89,12 @@ export const ProductListingHeader = ({
|
|
|
87
89
|
<div className="flex items-center gap-3 flex-wrap">
|
|
88
90
|
{/* Display per page */}
|
|
89
91
|
<div className="flex items-center gap-2">
|
|
90
|
-
<
|
|
92
|
+
<label htmlFor={displayId} className="text-sm text-neutral-600 whitespace-nowrap">Display:</label>
|
|
91
93
|
<select
|
|
92
94
|
value={limit}
|
|
93
95
|
onChange={(e) => updateParam('limit', e.target.value)}
|
|
94
96
|
className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
|
|
97
|
+
id={displayId}
|
|
95
98
|
data-testid="product-listing-display-select"
|
|
96
99
|
>
|
|
97
100
|
{DISPLAY_OPTIONS.map((n) => (
|
|
@@ -102,11 +105,12 @@ export const ProductListingHeader = ({
|
|
|
102
105
|
|
|
103
106
|
{/* Sort */}
|
|
104
107
|
<div className="flex items-center gap-2">
|
|
105
|
-
<
|
|
108
|
+
<label htmlFor={sortId} className="text-sm text-neutral-600 whitespace-nowrap">Sort by:</label>
|
|
106
109
|
<select
|
|
107
110
|
value={currentSort}
|
|
108
111
|
onChange={(e) => updateParam('sort', e.target.value)}
|
|
109
112
|
className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
|
|
113
|
+
id={sortId}
|
|
110
114
|
data-testid="product-listing-sort-select"
|
|
111
115
|
>
|
|
112
116
|
{SORT_OPTIONS.map(({ label, value }) => (
|
package/src/lib/data/bidding.ts
CHANGED
|
@@ -57,7 +57,9 @@ export const listAuctions = async ({
|
|
|
57
57
|
pageParam?: number
|
|
58
58
|
limit?: number
|
|
59
59
|
filters?: AuctionFilters
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
{ throwOnError = false }: { throwOnError?: boolean } = {}
|
|
62
|
+
): Promise<{
|
|
61
63
|
auctions: Auction[]
|
|
62
64
|
count: number
|
|
63
65
|
nextPage: number | null
|
|
@@ -72,6 +74,8 @@ export const listAuctions = async ({
|
|
|
72
74
|
})
|
|
73
75
|
|
|
74
76
|
if (!response.ok || !response.data) {
|
|
77
|
+
// Metadata passes throwOnError so a 5xx is not mistaken for an empty listing and noindexed.
|
|
78
|
+
if (throwOnError) throw new Error(`Failed to list auctions (HTTP ${response.status})`)
|
|
75
79
|
return { auctions: [], count: 0, nextPage: null }
|
|
76
80
|
}
|
|
77
81
|
|
package/src/lib/data/brand.ts
CHANGED
|
@@ -61,7 +61,7 @@ const readPageSpec = (raw: unknown) => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// `cache` is a server-render API; plain React (unit tests) has none, and a single call needs no dedupe.
|
|
64
|
-
const perRequest: <T>(fn: () => Promise<T>) => () => Promise<T> = React.cache ?? ((fn) => fn)
|
|
64
|
+
export const perRequest: <T>(fn: () => Promise<T>) => () => Promise<T> = React.cache ?? ((fn) => fn)
|
|
65
65
|
|
|
66
66
|
// The backend already refuses anything else; this keeps a bad link inert if that ever changes.
|
|
67
67
|
const isSafeLink = (url: string) => /^https:\/\/\S+$/.test(url) || /^\/(?![/\\])\S*$/.test(url)
|
|
@@ -73,10 +73,10 @@ let failures = 0
|
|
|
73
73
|
export const brandFetchFailures = () => failures
|
|
74
74
|
|
|
75
75
|
// ponytail: races the call, the SDK method takes no AbortSignal so the socket lives on until the platform's own timeout; thread a signal through the generated SDK if that matters.
|
|
76
|
-
const withTimeout = <T>(work: Promise<T
|
|
76
|
+
export const withTimeout = <T>(work: Promise<T>, label = "brand fetch") => {
|
|
77
77
|
let timer: ReturnType<typeof setTimeout>
|
|
78
78
|
const timeout = new Promise<never>((_, reject) => {
|
|
79
|
-
timer = setTimeout(() => reject(new Error(
|
|
79
|
+
timer = setTimeout(() => reject(new Error(`${label} timed out`)), BRAND_TIMEOUT_MS)
|
|
80
80
|
})
|
|
81
81
|
return Promise.race([work, timeout]).finally(() => clearTimeout(timer))
|
|
82
82
|
}
|
package/src/lib/data/seller.ts
CHANGED
|
@@ -163,9 +163,12 @@ const MAX_LIST_SELLERS_PAGES = 10
|
|
|
163
163
|
export const listSellers = async ({
|
|
164
164
|
limit = LIST_SELLERS_PAGE_SIZE,
|
|
165
165
|
offset = 0,
|
|
166
|
+
isStatic = false,
|
|
166
167
|
}: {
|
|
167
168
|
limit?: number
|
|
168
169
|
offset?: number
|
|
170
|
+
/** Read with the env key (`getStaticSdk`, never `headers()`) so a static/ISR route such as the sitemap stays static. */
|
|
171
|
+
isStatic?: boolean
|
|
169
172
|
} = {}): Promise<{
|
|
170
173
|
sellers: StoreSellerNavItem[]
|
|
171
174
|
count: number
|
|
@@ -173,7 +176,7 @@ export const listSellers = async ({
|
|
|
173
176
|
rawPageLength: number
|
|
174
177
|
}> => {
|
|
175
178
|
try {
|
|
176
|
-
const data = await (await getSdk()).client.fetch<{
|
|
179
|
+
const data = await (await (isStatic ? getStaticSdk() : getSdk())).client.fetch<{
|
|
177
180
|
sellers?: StoreSellerNavItem[]
|
|
178
181
|
count?: number
|
|
179
182
|
}>("/store/seller", {
|
|
@@ -216,7 +219,9 @@ export const listSellers = async ({
|
|
|
216
219
|
* (still exposed as rawPageLength). Client-side `has_published_products`
|
|
217
220
|
* filtering remains as defense in depth.
|
|
218
221
|
*/
|
|
219
|
-
export const listAllSellersForNav = async (
|
|
222
|
+
export const listAllSellersForNav = async ({
|
|
223
|
+
isStatic = false,
|
|
224
|
+
}: { isStatic?: boolean } = {}): Promise<StoreSellerNavItem[]> => {
|
|
220
225
|
const sellers: StoreSellerNavItem[] = []
|
|
221
226
|
let seen = 0
|
|
222
227
|
for (let page = 0; page < MAX_LIST_SELLERS_PAGES; page++) {
|
|
@@ -224,6 +229,7 @@ export const listAllSellersForNav = async (): Promise<StoreSellerNavItem[]> => {
|
|
|
224
229
|
const batch = await listSellers({
|
|
225
230
|
limit: LIST_SELLERS_PAGE_SIZE,
|
|
226
231
|
offset,
|
|
232
|
+
isStatic,
|
|
227
233
|
})
|
|
228
234
|
sellers.push(...batch.sellers)
|
|
229
235
|
seen += batch.rawPageLength
|
|
@@ -234,6 +240,15 @@ export const listAllSellersForNav = async (): Promise<StoreSellerNavItem[]> => {
|
|
|
234
240
|
return sellers
|
|
235
241
|
}
|
|
236
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Handles of public sellers for the sitemap: the nav listing read with the env key, so the sitemap
|
|
245
|
+
* shard stays static/ISR-compatible. `listSellers` already requires a handle, ACTIVE status and
|
|
246
|
+
* bounds the paging; a failure is reported there and yields no seller URLs rather than failing the
|
|
247
|
+
* sitemap build.
|
|
248
|
+
*/
|
|
249
|
+
export const listSellerHandlesForSitemap = async (): Promise<string[]> =>
|
|
250
|
+
(await listAllSellersForNav({ isStatic: true })).map((seller) => seller.handle)
|
|
251
|
+
|
|
237
252
|
/**
|
|
238
253
|
* Description of the marketplace's single seller (edited in the vendor panel),
|
|
239
254
|
* used as the footer tagline on single-vendor storefronts. Cached and read with
|