medusa-storefront-data 2.5.8 → 2.5.10
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/segment-data/default-page-input.json +191 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +31 -0
- package/dist/src/cookies.d.ts +23 -0
- package/dist/src/cookies.d.ts.map +1 -0
- package/dist/src/cookies.js +140 -0
- package/dist/src/edge.d.ts +3 -0
- package/dist/src/edge.d.ts.map +1 -0
- package/dist/src/edge.js +1 -0
- package/dist/src/middleware.d.ts +3 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +1 -0
- package/dist/src/server/brand-pillars-from-categories.d.ts +8 -0
- package/dist/src/server/brand-pillars-from-categories.d.ts.map +1 -0
- package/dist/src/server/brand-pillars-from-categories.js +92 -0
- package/dist/src/server/cart.d.ts +96 -0
- package/dist/src/server/cart.d.ts.map +1 -0
- package/dist/src/server/cart.js +797 -0
- package/dist/src/server/categories.d.ts +4 -0
- package/dist/src/server/categories.d.ts.map +1 -0
- package/dist/src/server/categories.js +34 -0
- package/dist/src/server/collections.d.ts +8 -0
- package/dist/src/server/collections.d.ts.map +1 -0
- package/dist/src/server/collections.js +39 -0
- package/dist/src/server/config-merge.d.ts +3 -0
- package/dist/src/server/config-merge.d.ts.map +1 -0
- package/dist/src/server/config-merge.js +31 -0
- package/dist/src/server/contact.d.ts +34 -0
- package/dist/src/server/contact.d.ts.map +1 -0
- package/dist/src/server/contact.js +57 -0
- package/dist/src/server/customer-registration.d.ts +142 -0
- package/dist/src/server/customer-registration.d.ts.map +1 -0
- package/dist/src/server/customer-registration.js +295 -0
- package/dist/src/server/customer.d.ts +48 -0
- package/dist/src/server/customer.d.ts.map +1 -0
- package/dist/src/server/customer.js +413 -0
- package/dist/src/server/dynamic-config.d.ts +200 -0
- package/dist/src/server/dynamic-config.d.ts.map +1 -0
- package/dist/src/server/dynamic-config.js +788 -0
- package/dist/src/server/fulfillment.d.ts +5 -0
- package/dist/src/server/fulfillment.d.ts.map +1 -0
- package/dist/src/server/fulfillment.js +47 -0
- package/dist/src/server/guest.d.ts +81 -0
- package/dist/src/server/guest.d.ts.map +1 -0
- package/dist/src/server/guest.js +183 -0
- package/dist/src/server/help-faq-section-defaults.json +92 -0
- package/dist/src/server/help-sections/help-faq.d.ts +11 -0
- package/dist/src/server/help-sections/help-faq.d.ts.map +1 -0
- package/dist/src/server/help-sections/help-faq.js +6 -0
- package/dist/src/server/help-sections/index.d.ts +2 -0
- package/dist/src/server/help-sections/index.d.ts.map +1 -0
- package/dist/src/server/help-sections/index.js +1 -0
- package/dist/src/server/hero-banner-priority.d.ts +31 -0
- package/dist/src/server/hero-banner-priority.d.ts.map +1 -0
- package/dist/src/server/hero-banner-priority.js +26 -0
- package/dist/src/server/home-sections/about-brand.d.ts +9 -0
- package/dist/src/server/home-sections/about-brand.d.ts.map +1 -0
- package/dist/src/server/home-sections/about-brand.js +9 -0
- package/dist/src/server/home-sections/baptism-picks.d.ts +10 -0
- package/dist/src/server/home-sections/baptism-picks.d.ts.map +1 -0
- package/dist/src/server/home-sections/baptism-picks.js +27 -0
- package/dist/src/server/home-sections/baptism.d.ts +13 -0
- package/dist/src/server/home-sections/baptism.d.ts.map +1 -0
- package/dist/src/server/home-sections/baptism.js +43 -0
- package/dist/src/server/home-sections/blog-posts.d.ts +9 -0
- package/dist/src/server/home-sections/blog-posts.d.ts.map +1 -0
- package/dist/src/server/home-sections/blog-posts.js +9 -0
- package/dist/src/server/home-sections/brand-marquee.d.ts +8 -0
- package/dist/src/server/home-sections/brand-marquee.d.ts.map +1 -0
- package/dist/src/server/home-sections/brand-marquee.js +7 -0
- package/dist/src/server/home-sections/brand-pillars.d.ts +9 -0
- package/dist/src/server/home-sections/brand-pillars.d.ts.map +1 -0
- package/dist/src/server/home-sections/brand-pillars.js +9 -0
- package/dist/src/server/home-sections/category-pills.d.ts +9 -0
- package/dist/src/server/home-sections/category-pills.d.ts.map +1 -0
- package/dist/src/server/home-sections/category-pills.js +19 -0
- package/dist/src/server/home-sections/celebrity-trust.d.ts +12 -0
- package/dist/src/server/home-sections/celebrity-trust.d.ts.map +1 -0
- package/dist/src/server/home-sections/celebrity-trust.js +27 -0
- package/dist/src/server/home-sections/customer-stories.d.ts +9 -0
- package/dist/src/server/home-sections/customer-stories.d.ts.map +1 -0
- package/dist/src/server/home-sections/customer-stories.js +9 -0
- package/dist/src/server/home-sections/features.d.ts +9 -0
- package/dist/src/server/home-sections/features.d.ts.map +1 -0
- package/dist/src/server/home-sections/features.js +9 -0
- package/dist/src/server/home-sections/hero.d.ts +9 -0
- package/dist/src/server/home-sections/hero.d.ts.map +1 -0
- package/dist/src/server/home-sections/hero.js +9 -0
- package/dist/src/server/home-sections/instagram-posts.d.ts +9 -0
- package/dist/src/server/home-sections/instagram-posts.d.ts.map +1 -0
- package/dist/src/server/home-sections/instagram-posts.js +9 -0
- package/dist/src/server/home-sections/loved-by-moms.d.ts +12 -0
- package/dist/src/server/home-sections/loved-by-moms.d.ts.map +1 -0
- package/dist/src/server/home-sections/loved-by-moms.js +20 -0
- package/dist/src/server/home-sections/luxe-favourites.d.ts +11 -0
- package/dist/src/server/home-sections/luxe-favourites.d.ts.map +1 -0
- package/dist/src/server/home-sections/luxe-favourites.js +19 -0
- package/dist/src/server/home-sections/new-arrivals-classic.d.ts +8 -0
- package/dist/src/server/home-sections/new-arrivals-classic.d.ts.map +1 -0
- package/dist/src/server/home-sections/new-arrivals-classic.js +10 -0
- package/dist/src/server/home-sections/new-arrivals.d.ts +12 -0
- package/dist/src/server/home-sections/new-arrivals.d.ts.map +1 -0
- package/dist/src/server/home-sections/new-arrivals.js +28 -0
- package/dist/src/server/home-sections/promo-announcements.d.ts +11 -0
- package/dist/src/server/home-sections/promo-announcements.d.ts.map +1 -0
- package/dist/src/server/home-sections/promo-announcements.js +5 -0
- package/dist/src/server/home-sections/promo-countdown.d.ts +6 -0
- package/dist/src/server/home-sections/promo-countdown.d.ts.map +1 -0
- package/dist/src/server/home-sections/promo-countdown.js +5 -0
- package/dist/src/server/home-sections/shared.d.ts +10 -0
- package/dist/src/server/home-sections/shared.d.ts.map +1 -0
- package/dist/src/server/home-sections/shared.js +29 -0
- package/dist/src/server/home-sections/shop-by-age.d.ts +9 -0
- package/dist/src/server/home-sections/shop-by-age.d.ts.map +1 -0
- package/dist/src/server/home-sections/shop-by-age.js +17 -0
- package/dist/src/server/home-sections/shop-by-category.d.ts +10 -0
- package/dist/src/server/home-sections/shop-by-category.d.ts.map +1 -0
- package/dist/src/server/home-sections/shop-by-category.js +17 -0
- package/dist/src/server/home-sections/testimonials.d.ts +9 -0
- package/dist/src/server/home-sections/testimonials.d.ts.map +1 -0
- package/dist/src/server/home-sections/testimonials.js +9 -0
- package/dist/src/server/home-sections/theme-dresses.d.ts +12 -0
- package/dist/src/server/home-sections/theme-dresses.d.ts.map +1 -0
- package/dist/src/server/home-sections/theme-dresses.js +27 -0
- package/dist/src/server/home-sections/video-stories.d.ts +9 -0
- package/dist/src/server/home-sections/video-stories.d.ts.map +1 -0
- package/dist/src/server/home-sections/video-stories.js +9 -0
- package/dist/src/server/home-sections/why-choose-us.d.ts +9 -0
- package/dist/src/server/home-sections/why-choose-us.d.ts.map +1 -0
- package/dist/src/server/home-sections/why-choose-us.js +9 -0
- package/dist/src/server/home.d.ts +54 -0
- package/dist/src/server/home.d.ts.map +1 -0
- package/dist/src/server/home.js +1 -0
- package/dist/src/server/homepage-config.types.d.ts +405 -0
- package/dist/src/server/homepage-config.types.d.ts.map +1 -0
- package/dist/src/server/homepage-config.types.js +35 -0
- package/dist/src/server/homepage-section-defaults.d.ts +201 -0
- package/dist/src/server/homepage-section-defaults.d.ts.map +1 -0
- package/dist/src/server/homepage-section-defaults.js +192 -0
- package/dist/src/server/index.d.ts +26 -0
- package/dist/src/server/index.d.ts.map +1 -0
- package/dist/src/server/index.js +25 -0
- package/dist/src/server/locale-actions.d.ts +14 -0
- package/dist/src/server/locale-actions.d.ts.map +1 -0
- package/dist/src/server/locale-actions.js +58 -0
- package/dist/src/server/locales.d.ts +8 -0
- package/dist/src/server/locales.d.ts.map +1 -0
- package/dist/src/server/locales.js +12 -0
- package/dist/src/server/normalize-homepage-config.d.ts +7 -0
- package/dist/src/server/normalize-homepage-config.d.ts.map +1 -0
- package/dist/src/server/normalize-homepage-config.js +281 -0
- package/dist/src/server/notifications.d.ts +2 -0
- package/dist/src/server/notifications.d.ts.map +1 -0
- package/dist/src/server/notifications.js +20 -0
- package/dist/src/server/onboarding.d.ts +2 -0
- package/dist/src/server/onboarding.d.ts.map +1 -0
- package/dist/src/server/onboarding.js +8 -0
- package/dist/src/server/orders.d.ts +63 -0
- package/dist/src/server/orders.d.ts.map +1 -0
- package/dist/src/server/orders.js +230 -0
- package/dist/src/server/page-input.d.ts +25 -0
- package/dist/src/server/page-input.d.ts.map +1 -0
- package/dist/src/server/page-input.js +172 -0
- package/dist/src/server/payment-details.d.ts +5 -0
- package/dist/src/server/payment-details.d.ts.map +1 -0
- package/dist/src/server/payment-details.js +28 -0
- package/dist/src/server/payment.d.ts +3 -0
- package/dist/src/server/payment.d.ts.map +1 -0
- package/dist/src/server/payment.js +13 -0
- package/dist/src/server/pincode.d.ts +7 -0
- package/dist/src/server/pincode.d.ts.map +1 -0
- package/dist/src/server/pincode.js +30 -0
- package/dist/src/server/products.d.ts +54 -0
- package/dist/src/server/products.d.ts.map +1 -0
- package/dist/src/server/products.js +154 -0
- package/dist/src/server/regions.d.ts +5 -0
- package/dist/src/server/regions.d.ts.map +1 -0
- package/dist/src/server/regions.js +57 -0
- package/dist/src/server/returns.d.ts +29 -0
- package/dist/src/server/returns.d.ts.map +1 -0
- package/dist/src/server/returns.js +132 -0
- package/dist/src/server/shoppable-looks.d.ts +17 -0
- package/dist/src/server/shoppable-looks.d.ts.map +1 -0
- package/dist/src/server/shoppable-looks.js +136 -0
- package/dist/src/server/storefront-cms.d.ts +11 -0
- package/dist/src/server/storefront-cms.d.ts.map +1 -0
- package/dist/src/server/storefront-cms.js +24 -0
- package/dist/src/server/swaps.d.ts +15 -0
- package/dist/src/server/swaps.d.ts.map +1 -0
- package/dist/src/server/swaps.js +89 -0
- package/dist/src/server/variants.d.ts +3 -0
- package/dist/src/server/variants.d.ts.map +1 -0
- package/dist/src/server/variants.js +15 -0
- package/dist/src/server/wishlist.d.ts +11 -0
- package/dist/src/server/wishlist.d.ts.map +1 -0
- package/dist/src/server/wishlist.js +49 -0
- package/dist/src/util/get-locale-header.d.ts +4 -0
- package/dist/src/util/get-locale-header.d.ts.map +1 -0
- package/dist/src/util/get-locale-header.js +7 -0
- package/dist/src/util/medusa-error.d.ts +2 -0
- package/dist/src/util/medusa-error.d.ts.map +1 -0
- package/dist/src/util/medusa-error.js +18 -0
- package/dist/src/util/revalidate-cart.d.ts +2 -0
- package/dist/src/util/revalidate-cart.d.ts.map +1 -0
- package/dist/src/util/revalidate-cart.js +8 -0
- package/dist/src/util/sort-products.d.ts +3 -0
- package/dist/src/util/sort-products.d.ts.map +1 -0
- package/dist/src/util/sort-products.js +1 -0
- package/dist/src/util/store-client.d.ts +11 -0
- package/dist/src/util/store-client.d.ts.map +1 -0
- package/dist/src/util/store-client.js +75 -0
- package/package.json +32 -20
- package/src/server/dynamic-config.ts +136 -0
- package/src/server/hero-banner-priority.ts +63 -0
- package/src/server/home-sections/customer-stories.ts +23 -0
- package/src/server/homepage-config.types.ts +18 -0
- package/src/server/homepage-section-defaults.ts +2 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { getStoreAuthOptions } from "medusa-services/auth";
|
|
2
|
+
import { getAuthHeaders, getGuestAuthHeaders } from "../cookies";
|
|
3
|
+
import { getLocaleHeader } from "./get-locale-header";
|
|
4
|
+
import { cookies as nextCookies } from "next/headers";
|
|
5
|
+
function getBackendUrl() {
|
|
6
|
+
return (process.env.MEDUSA_BACKEND_URL?.replace(/\/$/, "") ||
|
|
7
|
+
process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL?.replace(/\/$/, "") ||
|
|
8
|
+
"http://localhost:9000");
|
|
9
|
+
}
|
|
10
|
+
function getPublishableApiKey() {
|
|
11
|
+
const key = process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY;
|
|
12
|
+
if (!key) {
|
|
13
|
+
throw new Error("NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY is not configured");
|
|
14
|
+
}
|
|
15
|
+
return key;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds portable Medusa store client options from Next.js cookies and env.
|
|
19
|
+
*/
|
|
20
|
+
export async function getStoreClientOptions() {
|
|
21
|
+
const auth = await getAuthHeaders();
|
|
22
|
+
const localeHeader = await getLocaleHeader().catch(() => ({}));
|
|
23
|
+
return {
|
|
24
|
+
backendUrl: getBackendUrl(),
|
|
25
|
+
publishableApiKey: getPublishableApiKey(),
|
|
26
|
+
authorization: "authorization" in auth ? auth.authorization : undefined,
|
|
27
|
+
headers: localeHeader["x-medusa-locale"]
|
|
28
|
+
? { "x-medusa-locale": localeHeader["x-medusa-locale"] }
|
|
29
|
+
: undefined,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function getMedusaBackendUrl() {
|
|
33
|
+
return getBackendUrl();
|
|
34
|
+
}
|
|
35
|
+
export async function getGuestStoreClientOptions() {
|
|
36
|
+
const guestAuth = await getGuestAuthHeaders();
|
|
37
|
+
let authorization = "authorization" in guestAuth ? guestAuth.authorization : undefined;
|
|
38
|
+
if (!authorization) {
|
|
39
|
+
try {
|
|
40
|
+
const cookieStore = await nextCookies();
|
|
41
|
+
const legacyToken = cookieStore.get("_medusa_guest_token")?.value;
|
|
42
|
+
if (legacyToken) {
|
|
43
|
+
authorization = `Bearer ${legacyToken}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!authorization)
|
|
51
|
+
return null;
|
|
52
|
+
return {
|
|
53
|
+
backendUrl: getBackendUrl(),
|
|
54
|
+
publishableApiKey: getPublishableApiKey(),
|
|
55
|
+
authorization,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export async function getStoreClientOptionsWithToken(token) {
|
|
59
|
+
return {
|
|
60
|
+
backendUrl: getBackendUrl(),
|
|
61
|
+
publishableApiKey: getPublishableApiKey(),
|
|
62
|
+
authorization: token.startsWith("Bearer ") ? token : `Bearer ${token}`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export async function getAuthClientOptions(authorization) {
|
|
66
|
+
if (authorization) {
|
|
67
|
+
return getStoreAuthOptions({
|
|
68
|
+
backendUrl: getBackendUrl(),
|
|
69
|
+
publishableApiKey: getPublishableApiKey(),
|
|
70
|
+
authorization,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const storeOptions = await getStoreClientOptions();
|
|
74
|
+
return getStoreAuthOptions(storeOptions);
|
|
75
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "medusa-storefront-data",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Medusa storefront server data layer extracted from Next.js storefront",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"test": "npm run build"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"next": ">=14",
|
|
25
|
-
"react": ">=18",
|
|
26
24
|
"@medusajs/js-sdk": ">=2",
|
|
27
25
|
"@medusajs/types": ">=2",
|
|
28
26
|
"medusa-reviews-logic": "*",
|
|
27
|
+
"medusa-services": "^1.0.0",
|
|
29
28
|
"medusa-wishlist-logic": "*",
|
|
30
|
-
"
|
|
29
|
+
"next": ">=14",
|
|
30
|
+
"react": ">=18"
|
|
31
31
|
},
|
|
32
32
|
"peerDependenciesMeta": {
|
|
33
33
|
"medusa-reviews-logic": {
|
|
@@ -39,13 +39,20 @@
|
|
|
39
39
|
"server-only": "^0.0.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"@types
|
|
44
|
-
"next": "^15.0.0",
|
|
45
|
-
"@medusajs/js-sdk": "^2.0.0",
|
|
46
|
-
"@medusajs/types": "^2.0.0",
|
|
42
|
+
"@medusajs/js-sdk": "^2.15.5",
|
|
43
|
+
"@medusajs/types": "^2.15.5",
|
|
47
44
|
"@types/node": "^22.0.0",
|
|
48
|
-
"
|
|
45
|
+
"@types/react": "^19.0.0",
|
|
46
|
+
"@types/react-dom": "^19.0.0",
|
|
47
|
+
"medusa-services": "^1.0.0",
|
|
48
|
+
"medusa-review-rating": "^0.0.38",
|
|
49
|
+
"medusa-reviews-logic": "^2.0.0",
|
|
50
|
+
"medusa-ui-home-config": "^1.0.0",
|
|
51
|
+
"medusa-wishlist-logic": "^2.0.0",
|
|
52
|
+
"next": "^15.0.0",
|
|
53
|
+
"react": "^19.0.0",
|
|
54
|
+
"react-dom": "^19.0.0",
|
|
55
|
+
"typescript": "^5.9.3"
|
|
49
56
|
},
|
|
50
57
|
"exports": {
|
|
51
58
|
"./package.json": "./package.json",
|
|
@@ -54,6 +61,16 @@
|
|
|
54
61
|
"import": "./src/server/index.ts",
|
|
55
62
|
"default": "./src/server/index.ts"
|
|
56
63
|
},
|
|
64
|
+
"./help/sections/helpFaq": {
|
|
65
|
+
"types": "./dist/server/help-sections/help-faq.d.ts",
|
|
66
|
+
"import": "./src/server/help-sections/help-faq.ts",
|
|
67
|
+
"default": "./src/server/help-sections/help-faq.ts"
|
|
68
|
+
},
|
|
69
|
+
"./storefront-cms": {
|
|
70
|
+
"types": "./src/server/storefront-cms.ts",
|
|
71
|
+
"import": "./src/server/storefront-cms.ts",
|
|
72
|
+
"default": "./src/server/storefront-cms.ts"
|
|
73
|
+
},
|
|
57
74
|
"./home/sections/promoAnnouncements": {
|
|
58
75
|
"types": "./dist/server/home-sections/promo-announcements.d.ts",
|
|
59
76
|
"import": "./src/server/home-sections/promo-announcements.ts",
|
|
@@ -129,6 +146,11 @@
|
|
|
129
146
|
"import": "./src/server/home-sections/testimonials.ts",
|
|
130
147
|
"default": "./src/server/home-sections/testimonials.ts"
|
|
131
148
|
},
|
|
149
|
+
"./home/sections/customerStories": {
|
|
150
|
+
"types": "./dist/server/home-sections/customer-stories.d.ts",
|
|
151
|
+
"import": "./src/server/home-sections/customer-stories.ts",
|
|
152
|
+
"default": "./src/server/home-sections/customer-stories.ts"
|
|
153
|
+
},
|
|
132
154
|
"./home/sections/brandPillars": {
|
|
133
155
|
"types": "./dist/server/home-sections/brand-pillars.d.ts",
|
|
134
156
|
"import": "./src/server/home-sections/brand-pillars.ts",
|
|
@@ -168,16 +190,6 @@
|
|
|
168
190
|
"types": "./dist/server/home-sections/blog-posts.d.ts",
|
|
169
191
|
"import": "./src/server/home-sections/blog-posts.ts",
|
|
170
192
|
"default": "./src/server/home-sections/blog-posts.ts"
|
|
171
|
-
},
|
|
172
|
-
"./help/sections/helpFaq": {
|
|
173
|
-
"types": "./dist/server/help-sections/help-faq.d.ts",
|
|
174
|
-
"import": "./src/server/help-sections/help-faq.ts",
|
|
175
|
-
"default": "./src/server/help-sections/help-faq.ts"
|
|
176
|
-
},
|
|
177
|
-
"./storefront-cms": {
|
|
178
|
-
"types": "./src/server/storefront-cms.ts",
|
|
179
|
-
"import": "./src/server/storefront-cms.ts",
|
|
180
|
-
"default": "./src/server/storefront-cms.ts"
|
|
181
193
|
}
|
|
182
194
|
},
|
|
183
195
|
"main": "./dist/server/index.js",
|
|
@@ -505,6 +505,142 @@ export function getTestimonialsFromPageInput(
|
|
|
505
505
|
return { title, subtitle, testimonials }
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
+
export type CustomerStoryItem = {
|
|
509
|
+
id: string
|
|
510
|
+
image: string
|
|
511
|
+
text: string
|
|
512
|
+
name: string
|
|
513
|
+
rating?: number
|
|
514
|
+
location?: string
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function parseCustomerStoryRow(
|
|
518
|
+
item: unknown,
|
|
519
|
+
index: number
|
|
520
|
+
): CustomerStoryItem | null {
|
|
521
|
+
if (!item || typeof item !== "object") return null
|
|
522
|
+
const row =
|
|
523
|
+
(item as Record<string, unknown>).story ??
|
|
524
|
+
(item as Record<string, unknown>).review ??
|
|
525
|
+
item
|
|
526
|
+
const r = row as Record<string, unknown>
|
|
527
|
+
const text = String(
|
|
528
|
+
r.text ?? r["review-description"] ?? r.description ?? r.quote ?? ""
|
|
529
|
+
).trim()
|
|
530
|
+
const name = String(
|
|
531
|
+
r.name ??
|
|
532
|
+
r["review-user-name"] ??
|
|
533
|
+
r["user-name"] ??
|
|
534
|
+
r.user_name ??
|
|
535
|
+
r.author ??
|
|
536
|
+
""
|
|
537
|
+
).trim()
|
|
538
|
+
const image = String(
|
|
539
|
+
r.image ??
|
|
540
|
+
r["review-profile-image"] ??
|
|
541
|
+
r["profile-image"] ??
|
|
542
|
+
r.profile_image ??
|
|
543
|
+
""
|
|
544
|
+
).trim()
|
|
545
|
+
/** Quote + name required; image optional (admin Ratings often has no photo). */
|
|
546
|
+
if (!text || !name) return null
|
|
547
|
+
const ratingRaw = r.rating ?? r["review-rating"]
|
|
548
|
+
const rating =
|
|
549
|
+
ratingRaw != null && ratingRaw !== ""
|
|
550
|
+
? parseFloat(String(ratingRaw))
|
|
551
|
+
: undefined
|
|
552
|
+
const location = String(r.location ?? "").trim()
|
|
553
|
+
return {
|
|
554
|
+
id: String(r.id ?? `${name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}-${index + 1}`),
|
|
555
|
+
image: image || "/Logo.png",
|
|
556
|
+
text,
|
|
557
|
+
name,
|
|
558
|
+
rating: Number.isFinite(rating) ? Math.max(0, Math.min(5, rating!)) : undefined,
|
|
559
|
+
location: location || undefined,
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function parseCustomerStoriesFromBlock(
|
|
564
|
+
block: Record<string, unknown>
|
|
565
|
+
): CustomerStoryItem[] {
|
|
566
|
+
const raw =
|
|
567
|
+
block.items ??
|
|
568
|
+
block.stories ??
|
|
569
|
+
block.reviews ??
|
|
570
|
+
block["customer-stories"] ??
|
|
571
|
+
[]
|
|
572
|
+
if (!Array.isArray(raw)) return []
|
|
573
|
+
return raw
|
|
574
|
+
.map((item, index) => parseCustomerStoryRow(item, index))
|
|
575
|
+
.filter((row): row is CustomerStoryItem => row !== null)
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function parseCustomerStoriesFromRatings(ratings: unknown): CustomerStoryItem[] {
|
|
579
|
+
if (!Array.isArray(ratings)) return []
|
|
580
|
+
return ratings
|
|
581
|
+
.map((item, index) => parseCustomerStoryRow(item, index))
|
|
582
|
+
.filter((row): row is CustomerStoryItem => row !== null)
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function getHomepageRatingsArray(
|
|
586
|
+
pageInput?: HomepageConfig | null
|
|
587
|
+
): unknown[] {
|
|
588
|
+
const resolved = resolvePageInput(pageInput)
|
|
589
|
+
const fromResolved = resolved["ratings"]
|
|
590
|
+
if (Array.isArray(fromResolved) && fromResolved.length > 0) {
|
|
591
|
+
return fromResolved
|
|
592
|
+
}
|
|
593
|
+
const fromOverride = pageInput?.["ratings"]
|
|
594
|
+
if (Array.isArray(fromOverride) && fromOverride.length > 0) {
|
|
595
|
+
return fromOverride
|
|
596
|
+
}
|
|
597
|
+
return []
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export function getCustomerStoriesFromPageInput(
|
|
601
|
+
pageInput?: HomepageConfig | null
|
|
602
|
+
): {
|
|
603
|
+
title: string
|
|
604
|
+
eyebrow: string
|
|
605
|
+
items: CustomerStoryItem[]
|
|
606
|
+
} {
|
|
607
|
+
const homepageConfig = resolvePageInput(pageInput)
|
|
608
|
+
const block = getMergedSectionBlock("customerStories", pageInput)
|
|
609
|
+
const copy = parseSectionCopy(block)
|
|
610
|
+
const ratingTitle = String(homepageConfig["rating-title"] ?? "").trim()
|
|
611
|
+
const title = copy.title ?? copy.name ?? ratingTitle
|
|
612
|
+
const eyebrow = copy.eyebrow ?? ""
|
|
613
|
+
const defaults = DEFAULT_HOMEPAGE_SECTIONS.customerStories as Record<string, unknown>
|
|
614
|
+
|
|
615
|
+
/** Admin "Ratings" (`homepage-config.ratings[].review`) — always before merged section defaults. */
|
|
616
|
+
const ratingsItems = parseCustomerStoriesFromRatings(
|
|
617
|
+
getHomepageRatingsArray(pageInput)
|
|
618
|
+
)
|
|
619
|
+
|
|
620
|
+
/** CMS `sections.customerStories` only (no package default stories mixed in). */
|
|
621
|
+
const cmsSectionBlock =
|
|
622
|
+
findSectionBlock(getHomepageSectionsRoot(pageInput), "customerStories") ?? {}
|
|
623
|
+
const sectionItems = parseCustomerStoriesFromBlock(cmsSectionBlock)
|
|
624
|
+
|
|
625
|
+
let items =
|
|
626
|
+
ratingsItems.length > 0
|
|
627
|
+
? ratingsItems
|
|
628
|
+
: sectionItems.length > 0
|
|
629
|
+
? sectionItems
|
|
630
|
+
: parseCustomerStoriesFromBlock(block)
|
|
631
|
+
if (items.length === 0) {
|
|
632
|
+
items = parseCustomerStoriesFromBlock(
|
|
633
|
+
defaults as Record<string, unknown>
|
|
634
|
+
)
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
return {
|
|
638
|
+
title: title || String(defaults.title ?? "Customer Stories"),
|
|
639
|
+
eyebrow: eyebrow || String(defaults.eyebrow ?? "WHAT PARENTS SAY"),
|
|
640
|
+
items,
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
508
644
|
|
|
509
645
|
export function getSocialLinksFromPageInput(
|
|
510
646
|
pageInput?: HomepageConfig | null
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Simplified banner shape used by hero sections (not legacy kebab-case CMS keys). */
|
|
2
|
+
export type HomepageBanner = {
|
|
3
|
+
image?: string
|
|
4
|
+
title?: string
|
|
5
|
+
subtitle?: string
|
|
6
|
+
description?: string
|
|
7
|
+
buttonName?: string
|
|
8
|
+
buttonLink?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ThemeHeroBannerFallbacks = {
|
|
12
|
+
home: HomepageBanner
|
|
13
|
+
app: HomepageBanner
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type HeroBannerSource = "dynamic-config" | "theme-copy" | "library-default"
|
|
17
|
+
|
|
18
|
+
export type ResolvedHeroBanners = {
|
|
19
|
+
homeBanners: HomepageBanner[]
|
|
20
|
+
appBanners: HomepageBanner[]
|
|
21
|
+
homeSource: HeroBannerSource
|
|
22
|
+
appSource: HeroBannerSource
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function hasBannerData(
|
|
26
|
+
banner: HomepageBanner | null | undefined
|
|
27
|
+
): boolean {
|
|
28
|
+
if (!banner) return false
|
|
29
|
+
return Boolean(
|
|
30
|
+
banner.image?.trim() ||
|
|
31
|
+
banner.title?.trim() ||
|
|
32
|
+
banner.subtitle?.trim() ||
|
|
33
|
+
banner.description?.trim() ||
|
|
34
|
+
banner.buttonName?.trim() ||
|
|
35
|
+
banner.buttonLink?.trim()
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whole-banner priority (not per-field):
|
|
41
|
+
* 1. dynamic-config 2. theme copy.ts 3. package library defaults
|
|
42
|
+
*/
|
|
43
|
+
export function pickHeroBannerBySource(
|
|
44
|
+
cms: HomepageBanner | null | undefined,
|
|
45
|
+
theme: HomepageBanner,
|
|
46
|
+
library: HomepageBanner
|
|
47
|
+
): { banner: HomepageBanner; source: HeroBannerSource } {
|
|
48
|
+
if (cms && hasBannerData(cms)) {
|
|
49
|
+
return { banner: cms, source: "dynamic-config" }
|
|
50
|
+
}
|
|
51
|
+
if (hasBannerData(theme)) {
|
|
52
|
+
return { banner: theme, source: "theme-copy" }
|
|
53
|
+
}
|
|
54
|
+
return { banner: library, source: "library-default" }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function resolveHeroBannerWithPriority(
|
|
58
|
+
cms: HomepageBanner | null | undefined,
|
|
59
|
+
theme: HomepageBanner,
|
|
60
|
+
library: HomepageBanner
|
|
61
|
+
): HomepageBanner {
|
|
62
|
+
return pickHeroBannerBySource(cms, theme, library).banner
|
|
63
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "server-only"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getCustomerStoriesFromPageInput,
|
|
5
|
+
getHomeSectionsCopyFromPageInput,
|
|
6
|
+
} from "../dynamic-config"
|
|
7
|
+
import type { SectionLoaderOptions } from "./shared"
|
|
8
|
+
|
|
9
|
+
export type CustomerStoriesSectionData = {
|
|
10
|
+
customerStories: ReturnType<typeof getCustomerStoriesFromPageInput>
|
|
11
|
+
copy: ReturnType<typeof getHomeSectionsCopyFromPageInput>["customerStories"]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function loadCustomerStoriesSectionData(
|
|
15
|
+
_countryCode: string,
|
|
16
|
+
options?: SectionLoaderOptions
|
|
17
|
+
): Promise<CustomerStoriesSectionData> {
|
|
18
|
+
const pageInput = options?.pageInput ?? null
|
|
19
|
+
return {
|
|
20
|
+
customerStories: getCustomerStoriesFromPageInput(pageInput),
|
|
21
|
+
copy: getHomeSectionsCopyFromPageInput(pageInput).customerStories,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -212,6 +212,22 @@ export type HomepageVideoStoriesSection = HomepageSectionCopyFields & {
|
|
|
212
212
|
"video-stories"?: HomepageVideoStoryEntry[]
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
export type HomepageCustomerStoryItem = {
|
|
216
|
+
id?: string
|
|
217
|
+
image?: string
|
|
218
|
+
text?: string
|
|
219
|
+
name?: string
|
|
220
|
+
rating?: number | string
|
|
221
|
+
location?: string
|
|
222
|
+
story?: HomepageCustomerStoryItem
|
|
223
|
+
review?: HomepageCustomerStoryItem
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export type HomepageCustomerStoriesSection = HomepageSectionCopyFields & {
|
|
227
|
+
items?: HomepageCustomerStoryItem[]
|
|
228
|
+
stories?: HomepageCustomerStoryItem[]
|
|
229
|
+
}
|
|
230
|
+
|
|
215
231
|
/** Per-section blocks under `homepage-config.sections`. */
|
|
216
232
|
export type HomepageSectionsConfig = {
|
|
217
233
|
promoAnnouncements?: HomepagePromoAnnouncementsSection
|
|
@@ -228,6 +244,7 @@ export type HomepageSectionsConfig = {
|
|
|
228
244
|
themeDresses?: HomepageSectionCopyFields
|
|
229
245
|
brandMarquee?: HomepageSectionCopyFields
|
|
230
246
|
aboutBrand?: HomepageAboutBrandSection
|
|
247
|
+
customerStories?: HomepageCustomerStoriesSection
|
|
231
248
|
testimonials?: HomepageTestimonialsSection
|
|
232
249
|
brandPillars?: HomepageBrandPillarsSection
|
|
233
250
|
instagramPosts?: HomepageInstagramPostsSection
|
|
@@ -457,6 +474,7 @@ export const HOMEPAGE_SECTION_IDS = [
|
|
|
457
474
|
"themeDresses",
|
|
458
475
|
"brandMarquee",
|
|
459
476
|
"aboutBrand",
|
|
477
|
+
"customerStories",
|
|
460
478
|
"testimonials",
|
|
461
479
|
"brandPillars",
|
|
462
480
|
"instagramPosts",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import helpFaqDefaults from "./help-faq-section-defaults.json"
|
|
2
|
+
import { customerStoriesSectionDefaults } from "medusa-ui-home-config/sections/customerStories"
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Default `homepage-config.sections` blocks.
|
|
@@ -71,6 +72,7 @@ export const DEFAULT_HOMEPAGE_SECTIONS = {
|
|
|
71
72
|
{ label: "Products", value: "3000+" },
|
|
72
73
|
],
|
|
73
74
|
},
|
|
75
|
+
customerStories: customerStoriesSectionDefaults,
|
|
74
76
|
testimonials: {
|
|
75
77
|
title: "What Clients Talk About Us",
|
|
76
78
|
description: "The Trust We've Earned",
|