medusa-storefront-data 2.1.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOMEPAGE_CONFIG.md +99 -0
- package/dist/segment-data/default-page-input.json +191 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/cookies.d.ts.map +1 -0
- package/dist/src/edge.d.ts.map +1 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/server/cart.d.ts.map +1 -0
- package/dist/src/server/categories.d.ts.map +1 -0
- package/dist/src/server/collections.d.ts.map +1 -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.map +1 -0
- package/dist/src/server/customer-registration.d.ts.map +1 -0
- package/dist/src/server/customer.d.ts.map +1 -0
- package/dist/src/server/dynamic-config.d.ts +240 -0
- package/dist/src/server/dynamic-config.d.ts.map +1 -0
- package/dist/src/server/dynamic-config.js +703 -0
- package/dist/src/server/fulfillment.d.ts.map +1 -0
- package/dist/src/server/guest.d.ts.map +1 -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/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 +7 -0
- package/dist/src/server/home-sections/promo-announcements.d.ts.map +1 -0
- package/dist/src/server/home-sections/promo-announcements.js +7 -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 +62 -0
- package/dist/src/server/home.d.ts.map +1 -0
- package/dist/src/server/home.js +122 -0
- package/dist/src/server/homepage-config.types.d.ts +274 -0
- package/dist/src/server/homepage-config.types.d.ts.map +1 -0
- package/dist/src/server/homepage-config.types.js +33 -0
- package/dist/src/server/homepage-section-defaults.d.ts +188 -0
- package/dist/src/server/homepage-section-defaults.d.ts.map +1 -0
- package/dist/src/server/homepage-section-defaults.js +188 -0
- package/dist/{server → src/server}/index.d.ts +2 -0
- package/dist/src/server/index.d.ts.map +1 -0
- package/dist/{server → src/server}/index.js +2 -0
- package/dist/src/server/locale-actions.d.ts.map +1 -0
- package/dist/src/server/locales.d.ts.map +1 -0
- package/dist/src/server/notifications.d.ts.map +1 -0
- package/dist/src/server/onboarding.d.ts.map +1 -0
- package/dist/src/server/orders.d.ts.map +1 -0
- package/dist/src/server/page-input.d.ts +19 -0
- package/dist/src/server/page-input.d.ts.map +1 -0
- package/dist/src/server/page-input.js +40 -0
- package/dist/src/server/payment-details.d.ts.map +1 -0
- package/dist/src/server/payment.d.ts.map +1 -0
- package/dist/src/server/pincode.d.ts.map +1 -0
- package/dist/src/server/products.d.ts.map +1 -0
- package/dist/src/server/regions.d.ts.map +1 -0
- package/dist/src/server/resolve-home-segment-data.d.ts +25 -0
- package/dist/src/server/resolve-home-segment-data.d.ts.map +1 -0
- package/dist/src/server/resolve-home-segment-data.js +20 -0
- package/dist/src/server/returns.d.ts.map +1 -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/swaps.d.ts.map +1 -0
- package/dist/src/server/variants.d.ts.map +1 -0
- package/dist/src/server/wishlist.d.ts.map +1 -0
- package/dist/src/util/get-locale-header.d.ts.map +1 -0
- package/dist/src/util/medusa-error.d.ts.map +1 -0
- package/dist/src/util/revalidate-cart.d.ts.map +1 -0
- package/dist/src/util/sort-products.d.ts.map +1 -0
- package/dist/src/util/store-client.d.ts.map +1 -0
- package/homepage-config.example.json +209 -0
- package/homepage-sections.example.json +55 -0
- package/package.json +121 -2
- package/segment-data/default-page-input.json +191 -0
- package/src/server/config-merge.ts +31 -0
- package/src/server/dynamic-config.ts +838 -248
- package/src/server/home-sections/about-brand.ts +24 -0
- package/src/server/home-sections/baptism-picks.ts +46 -0
- package/src/server/home-sections/baptism.ts +64 -0
- package/src/server/home-sections/blog-posts.ts +23 -0
- package/src/server/home-sections/brand-marquee.ts +17 -0
- package/src/server/home-sections/brand-pillars.ts +23 -0
- package/src/server/home-sections/category-pills.ts +32 -0
- package/src/server/home-sections/celebrity-trust.ts +42 -0
- package/src/server/home-sections/features.ts +23 -0
- package/src/server/home-sections/hero.ts +24 -0
- package/src/server/home-sections/instagram-posts.ts +23 -0
- package/src/server/home-sections/loved-by-moms.ts +34 -0
- package/src/server/home-sections/luxe-favourites.ts +30 -0
- package/src/server/home-sections/new-arrivals-classic.ts +21 -0
- package/src/server/home-sections/new-arrivals.ts +47 -0
- package/src/server/home-sections/promo-announcements.ts +17 -0
- package/src/server/home-sections/promo-countdown.ts +15 -0
- package/src/server/home-sections/shared.ts +44 -0
- package/src/server/home-sections/shop-by-age.ts +26 -0
- package/src/server/home-sections/shop-by-category.ts +28 -0
- package/src/server/home-sections/testimonials.ts +23 -0
- package/src/server/home-sections/theme-dresses.ts +49 -0
- package/src/server/home-sections/video-stories.ts +23 -0
- package/src/server/home-sections/why-choose-us.ts +23 -0
- package/src/server/home.ts +173 -16
- package/src/server/homepage-config.types.ts +335 -0
- package/src/server/homepage-section-defaults.ts +199 -0
- package/src/server/index.ts +2 -0
- package/src/server/page-input.ts +64 -0
- package/src/server/resolve-home-segment-data.ts +63 -0
- package/src/server/shoppable-looks.ts +178 -0
- package/dist/config.d.ts.map +0 -1
- package/dist/cookies.d.ts.map +0 -1
- package/dist/edge.d.ts.map +0 -1
- package/dist/middleware.d.ts.map +0 -1
- package/dist/server/cart.d.ts.map +0 -1
- package/dist/server/categories.d.ts.map +0 -1
- package/dist/server/collections.d.ts.map +0 -1
- package/dist/server/contact.d.ts.map +0 -1
- package/dist/server/customer-registration.d.ts.map +0 -1
- package/dist/server/customer.d.ts.map +0 -1
- package/dist/server/dynamic-config.d.ts +0 -125
- package/dist/server/dynamic-config.d.ts.map +0 -1
- package/dist/server/dynamic-config.js +0 -289
- package/dist/server/fulfillment.d.ts.map +0 -1
- package/dist/server/guest.d.ts.map +0 -1
- package/dist/server/home.d.ts +0 -15
- package/dist/server/home.d.ts.map +0 -1
- package/dist/server/home.js +0 -45
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/locale-actions.d.ts.map +0 -1
- package/dist/server/locales.d.ts.map +0 -1
- package/dist/server/notifications.d.ts.map +0 -1
- package/dist/server/onboarding.d.ts.map +0 -1
- package/dist/server/orders.d.ts.map +0 -1
- package/dist/server/payment-details.d.ts.map +0 -1
- package/dist/server/payment.d.ts.map +0 -1
- package/dist/server/pincode.d.ts.map +0 -1
- package/dist/server/products.d.ts.map +0 -1
- package/dist/server/regions.d.ts.map +0 -1
- package/dist/server/returns.d.ts.map +0 -1
- package/dist/server/swaps.d.ts.map +0 -1
- package/dist/server/variants.d.ts.map +0 -1
- package/dist/server/wishlist.d.ts.map +0 -1
- package/dist/util/get-locale-header.d.ts.map +0 -1
- package/dist/util/medusa-error.d.ts.map +0 -1
- package/dist/util/revalidate-cart.d.ts.map +0 -1
- package/dist/util/sort-products.d.ts.map +0 -1
- package/dist/util/store-client.d.ts.map +0 -1
- /package/dist/{config.d.ts → src/config.d.ts} +0 -0
- /package/dist/{config.js → src/config.js} +0 -0
- /package/dist/{cookies.d.ts → src/cookies.d.ts} +0 -0
- /package/dist/{cookies.js → src/cookies.js} +0 -0
- /package/dist/{edge.d.ts → src/edge.d.ts} +0 -0
- /package/dist/{edge.js → src/edge.js} +0 -0
- /package/dist/{middleware.d.ts → src/middleware.d.ts} +0 -0
- /package/dist/{middleware.js → src/middleware.js} +0 -0
- /package/dist/{server → src/server}/cart.d.ts +0 -0
- /package/dist/{server → src/server}/cart.js +0 -0
- /package/dist/{server → src/server}/categories.d.ts +0 -0
- /package/dist/{server → src/server}/categories.js +0 -0
- /package/dist/{server → src/server}/collections.d.ts +0 -0
- /package/dist/{server → src/server}/collections.js +0 -0
- /package/dist/{server → src/server}/contact.d.ts +0 -0
- /package/dist/{server → src/server}/contact.js +0 -0
- /package/dist/{server → src/server}/customer-registration.d.ts +0 -0
- /package/dist/{server → src/server}/customer-registration.js +0 -0
- /package/dist/{server → src/server}/customer.d.ts +0 -0
- /package/dist/{server → src/server}/customer.js +0 -0
- /package/dist/{server → src/server}/fulfillment.d.ts +0 -0
- /package/dist/{server → src/server}/fulfillment.js +0 -0
- /package/dist/{server → src/server}/guest.d.ts +0 -0
- /package/dist/{server → src/server}/guest.js +0 -0
- /package/dist/{server → src/server}/locale-actions.d.ts +0 -0
- /package/dist/{server → src/server}/locale-actions.js +0 -0
- /package/dist/{server → src/server}/locales.d.ts +0 -0
- /package/dist/{server → src/server}/locales.js +0 -0
- /package/dist/{server → src/server}/notifications.d.ts +0 -0
- /package/dist/{server → src/server}/notifications.js +0 -0
- /package/dist/{server → src/server}/onboarding.d.ts +0 -0
- /package/dist/{server → src/server}/onboarding.js +0 -0
- /package/dist/{server → src/server}/orders.d.ts +0 -0
- /package/dist/{server → src/server}/orders.js +0 -0
- /package/dist/{server → src/server}/payment-details.d.ts +0 -0
- /package/dist/{server → src/server}/payment-details.js +0 -0
- /package/dist/{server → src/server}/payment.d.ts +0 -0
- /package/dist/{server → src/server}/payment.js +0 -0
- /package/dist/{server → src/server}/pincode.d.ts +0 -0
- /package/dist/{server → src/server}/pincode.js +0 -0
- /package/dist/{server → src/server}/products.d.ts +0 -0
- /package/dist/{server → src/server}/products.js +0 -0
- /package/dist/{server → src/server}/regions.d.ts +0 -0
- /package/dist/{server → src/server}/regions.js +0 -0
- /package/dist/{server → src/server}/returns.d.ts +0 -0
- /package/dist/{server → src/server}/returns.js +0 -0
- /package/dist/{server → src/server}/swaps.d.ts +0 -0
- /package/dist/{server → src/server}/swaps.js +0 -0
- /package/dist/{server → src/server}/variants.d.ts +0 -0
- /package/dist/{server → src/server}/variants.js +0 -0
- /package/dist/{server → src/server}/wishlist.d.ts +0 -0
- /package/dist/{server → src/server}/wishlist.js +0 -0
- /package/dist/{util → src/util}/get-locale-header.d.ts +0 -0
- /package/dist/{util → src/util}/get-locale-header.js +0 -0
- /package/dist/{util → src/util}/medusa-error.d.ts +0 -0
- /package/dist/{util → src/util}/medusa-error.js +0 -0
- /package/dist/{util → src/util}/revalidate-cart.d.ts +0 -0
- /package/dist/{util → src/util}/revalidate-cart.js +0 -0
- /package/dist/{util → src/util}/sort-products.d.ts +0 -0
- /package/dist/{util → src/util}/sort-products.js +0 -0
- /package/dist/{util → src/util}/store-client.d.ts +0 -0
- /package/dist/{util → src/util}/store-client.js +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { listProducts } from "../products";
|
|
3
|
+
import { getRegion } from "../regions";
|
|
4
|
+
export async function requireRegion(countryCode) {
|
|
5
|
+
return getRegion(countryCode);
|
|
6
|
+
}
|
|
7
|
+
export async function productsForCategoryIds(countryCode, categoryIds, limit) {
|
|
8
|
+
if (!categoryIds.length)
|
|
9
|
+
return [];
|
|
10
|
+
try {
|
|
11
|
+
const { response } = await listProducts({
|
|
12
|
+
countryCode,
|
|
13
|
+
queryParams: {
|
|
14
|
+
category_id: categoryIds,
|
|
15
|
+
limit,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return response.products ?? [];
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function categoryIdsMatching(categories, pattern) {
|
|
25
|
+
return categories
|
|
26
|
+
.filter((c) => pattern.test((c.name || c.handle || "").toLowerCase()))
|
|
27
|
+
.map((c) => c.id)
|
|
28
|
+
.filter(Boolean);
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getHomeSectionsCopyFromPageInput } from "../dynamic-config";
|
|
3
|
+
import { type SectionLoaderOptions } from "./shared";
|
|
4
|
+
export type ShopByAgeSectionData = {
|
|
5
|
+
collections: Array<Record<string, unknown>>;
|
|
6
|
+
copy: ReturnType<typeof getHomeSectionsCopyFromPageInput>["shopByAge"];
|
|
7
|
+
};
|
|
8
|
+
export declare function loadShopByAgeSectionData(countryCode: string, options?: SectionLoaderOptions): Promise<ShopByAgeSectionData | null>;
|
|
9
|
+
//# sourceMappingURL=shop-by-age.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shop-by-age.d.ts","sourceRoot":"","sources":["../../../../src/server/home-sections/shop-by-age.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAA;AAEpE,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEnE,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IAC3C,IAAI,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,WAAW,CAAC,CAAA;CACvE,CAAA;AAED,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAWtC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getHomeSectionsCopyFromPageInput } from "../dynamic-config";
|
|
3
|
+
import { listCollections } from "../collections";
|
|
4
|
+
import { requireRegion } from "./shared";
|
|
5
|
+
export async function loadShopByAgeSectionData(countryCode, options) {
|
|
6
|
+
const region = await requireRegion(countryCode);
|
|
7
|
+
if (!region)
|
|
8
|
+
return null;
|
|
9
|
+
const collectionsResult = await listCollections({
|
|
10
|
+
fields: "id, handle, title, metadata",
|
|
11
|
+
}).catch(() => ({ collections: [] }));
|
|
12
|
+
return {
|
|
13
|
+
collections: (collectionsResult.collections ??
|
|
14
|
+
[]),
|
|
15
|
+
copy: getHomeSectionsCopyFromPageInput(options?.pageInput ?? null).shopByAge,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { HttpTypes } from "@medusajs/types";
|
|
3
|
+
import { getHomeSectionsCopyFromPageInput } from "../dynamic-config";
|
|
4
|
+
import { type SectionLoaderOptions } from "./shared";
|
|
5
|
+
export type ShopByCategorySectionData = {
|
|
6
|
+
categories: HttpTypes.StoreProductCategory[];
|
|
7
|
+
copy: ReturnType<typeof getHomeSectionsCopyFromPageInput>["shopByCategory"];
|
|
8
|
+
};
|
|
9
|
+
export declare function loadShopByCategorySectionData(countryCode: string, options?: SectionLoaderOptions): Promise<ShopByCategorySectionData | null>;
|
|
10
|
+
//# sourceMappingURL=shop-by-category.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shop-by-category.d.ts","sourceRoot":"","sources":["../../../../src/server/home-sections/shop-by-category.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAA;AAEpE,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEnE,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,SAAS,CAAC,oBAAoB,EAAE,CAAA;IAC5C,IAAI,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,gBAAgB,CAAC,CAAA;CAC5E,CAAA;AAED,wBAAsB,6BAA6B,CACjD,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAY3C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getHomeSectionsCopyFromPageInput } from "../dynamic-config";
|
|
3
|
+
import { listCategories } from "../categories";
|
|
4
|
+
import { requireRegion } from "./shared";
|
|
5
|
+
export async function loadShopByCategorySectionData(countryCode, options) {
|
|
6
|
+
const region = await requireRegion(countryCode);
|
|
7
|
+
if (!region)
|
|
8
|
+
return null;
|
|
9
|
+
const categories = (await listCategories({
|
|
10
|
+
limit: 100,
|
|
11
|
+
fields: "id,handle,name,metadata,parent_category_id,*parent_category,*parent_category.parent_category",
|
|
12
|
+
}).catch(() => []));
|
|
13
|
+
return {
|
|
14
|
+
categories,
|
|
15
|
+
copy: getHomeSectionsCopyFromPageInput(options?.pageInput ?? null).shopByCategory,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getHomeSectionsCopyFromPageInput, getTestimonialsFromPageInput } from "../dynamic-config";
|
|
3
|
+
import type { SectionLoaderOptions } from "./shared";
|
|
4
|
+
export type TestimonialsSectionData = {
|
|
5
|
+
testimonials: ReturnType<typeof getTestimonialsFromPageInput>;
|
|
6
|
+
copy: ReturnType<typeof getHomeSectionsCopyFromPageInput>["testimonials"];
|
|
7
|
+
};
|
|
8
|
+
export declare function loadTestimonialsSectionData(_countryCode: string, options?: SectionLoaderOptions): Promise<TestimonialsSectionData>;
|
|
9
|
+
//# sourceMappingURL=testimonials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testimonials.d.ts","sourceRoot":"","sources":["../../../../src/server/home-sections/testimonials.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC7B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAA;IAC7D,IAAI,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,cAAc,CAAC,CAAA;CAC1E,CAAA;AAED,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAMlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getHomeSectionsCopyFromPageInput, getTestimonialsFromPageInput, } from "../dynamic-config";
|
|
3
|
+
export async function loadTestimonialsSectionData(_countryCode, options) {
|
|
4
|
+
const pageInput = options?.pageInput ?? null;
|
|
5
|
+
return {
|
|
6
|
+
testimonials: getTestimonialsFromPageInput(pageInput),
|
|
7
|
+
copy: getHomeSectionsCopyFromPageInput(pageInput).testimonials,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { HttpTypes } from "@medusajs/types";
|
|
3
|
+
import { getHomeSectionsCopyFromPageInput } from "../dynamic-config";
|
|
4
|
+
import { requireRegion, type SectionLoaderOptions } from "./shared";
|
|
5
|
+
export type ThemeDressesSectionData = {
|
|
6
|
+
region: NonNullable<Awaited<ReturnType<typeof requireRegion>>>;
|
|
7
|
+
themeProducts: HttpTypes.StoreProduct[];
|
|
8
|
+
ratings: unknown[];
|
|
9
|
+
copy: ReturnType<typeof getHomeSectionsCopyFromPageInput>["themeDresses"];
|
|
10
|
+
};
|
|
11
|
+
export declare function loadThemeDressesSectionData(countryCode: string, options?: SectionLoaderOptions): Promise<ThemeDressesSectionData | null>;
|
|
12
|
+
//# sourceMappingURL=theme-dresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-dresses.d.ts","sourceRoot":"","sources":["../../../../src/server/home-sections/theme-dresses.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAA;AAGpE,OAAO,EAGL,aAAa,EACb,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAA;AAEjB,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAA;IAC9D,aAAa,EAAE,SAAS,CAAC,YAAY,EAAE,CAAA;IACvC,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,IAAI,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,cAAc,CAAC,CAAA;CAC1E,CAAA;AAED,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAwBzC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { fetchRatings } from "medusa-reviews-logic/server";
|
|
3
|
+
import { getHomeSectionsCopyFromPageInput } from "../dynamic-config";
|
|
4
|
+
import { listCategories } from "../categories";
|
|
5
|
+
import { getProductsByTag } from "../products";
|
|
6
|
+
import { categoryIdsMatching, productsForCategoryIds, requireRegion, } from "./shared";
|
|
7
|
+
export async function loadThemeDressesSectionData(countryCode, options) {
|
|
8
|
+
const region = await requireRegion(countryCode);
|
|
9
|
+
if (!region)
|
|
10
|
+
return null;
|
|
11
|
+
const pageInput = options?.pageInput ?? null;
|
|
12
|
+
const [themeByTag, categoriesResult, ratings] = await Promise.all([
|
|
13
|
+
getProductsByTag({ tagValue: "theme", limit: 8, countryCode }).catch(() => []),
|
|
14
|
+
listCategories({ limit: 100 }).catch(() => []),
|
|
15
|
+
fetchRatings(),
|
|
16
|
+
]);
|
|
17
|
+
const categories = (categoriesResult ?? []);
|
|
18
|
+
const themeProducts = themeByTag.length > 0
|
|
19
|
+
? themeByTag
|
|
20
|
+
: await productsForCategoryIds(countryCode, categoryIdsMatching(categories, /theme/), 8);
|
|
21
|
+
return {
|
|
22
|
+
region,
|
|
23
|
+
themeProducts,
|
|
24
|
+
ratings: ratings ?? [],
|
|
25
|
+
copy: getHomeSectionsCopyFromPageInput(pageInput).themeDresses,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getHomeSectionsCopyFromPageInput, getVideoStoriesFromPageInput } from "../dynamic-config";
|
|
3
|
+
import type { SectionLoaderOptions } from "./shared";
|
|
4
|
+
export type VideoStoriesSectionData = {
|
|
5
|
+
videoStories: ReturnType<typeof getVideoStoriesFromPageInput>;
|
|
6
|
+
copy: ReturnType<typeof getHomeSectionsCopyFromPageInput>["videoStories"];
|
|
7
|
+
};
|
|
8
|
+
export declare function loadVideoStoriesSectionData(_countryCode: string, options?: SectionLoaderOptions): Promise<VideoStoriesSectionData>;
|
|
9
|
+
//# sourceMappingURL=video-stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video-stories.d.ts","sourceRoot":"","sources":["../../../../src/server/home-sections/video-stories.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC7B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAA;IAC7D,IAAI,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,cAAc,CAAC,CAAA;CAC1E,CAAA;AAED,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAMlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getHomeSectionsCopyFromPageInput, getVideoStoriesFromPageInput, } from "../dynamic-config";
|
|
3
|
+
export async function loadVideoStoriesSectionData(_countryCode, options) {
|
|
4
|
+
const pageInput = options?.pageInput ?? null;
|
|
5
|
+
return {
|
|
6
|
+
videoStories: getVideoStoriesFromPageInput(pageInput),
|
|
7
|
+
copy: getHomeSectionsCopyFromPageInput(pageInput).videoStories,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getFeaturesFromPageInput, getHomeSectionsCopyFromPageInput } from "../dynamic-config";
|
|
3
|
+
import type { SectionLoaderOptions } from "./shared";
|
|
4
|
+
export type WhyChooseUsSectionData = {
|
|
5
|
+
whyChooseUsFeatures: ReturnType<typeof getFeaturesFromPageInput>;
|
|
6
|
+
copy: ReturnType<typeof getHomeSectionsCopyFromPageInput>["whyChooseUs"];
|
|
7
|
+
};
|
|
8
|
+
export declare function loadWhyChooseUsSectionData(_countryCode: string, options?: SectionLoaderOptions): Promise<WhyChooseUsSectionData>;
|
|
9
|
+
//# sourceMappingURL=why-choose-us.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"why-choose-us.d.ts","sourceRoot":"","sources":["../../../../src/server/home-sections/why-choose-us.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EACjC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,MAAM,MAAM,sBAAsB,GAAG;IACnC,mBAAmB,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;IAChE,IAAI,EAAE,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,aAAa,CAAC,CAAA;CACzE,CAAA;AAED,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CAMjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { getFeaturesFromPageInput, getHomeSectionsCopyFromPageInput, } from "../dynamic-config";
|
|
3
|
+
export async function loadWhyChooseUsSectionData(_countryCode, options) {
|
|
4
|
+
const pageInput = options?.pageInput ?? null;
|
|
5
|
+
return {
|
|
6
|
+
whyChooseUsFeatures: getFeaturesFromPageInput(pageInput),
|
|
7
|
+
copy: getHomeSectionsCopyFromPageInput(pageInput).whyChooseUs,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { HttpTypes } from "@medusajs/types";
|
|
3
|
+
import { getRegion } from "./regions";
|
|
4
|
+
import type { HomepageConfig } from "./homepage-config.types";
|
|
5
|
+
import type { InstagramPostsData, AboutBrandConfig, BrandPillarConfig, BlogPostConfig, HomeSectionsCopy, TrustFeaturesConfig, HomepageBanner } from "./dynamic-config";
|
|
6
|
+
import { type ShoppableLook } from "./shoppable-looks";
|
|
7
|
+
export type HomePageData = {
|
|
8
|
+
region: Awaited<ReturnType<typeof getRegion>>;
|
|
9
|
+
collections: Array<Record<string, unknown>>;
|
|
10
|
+
categories: HttpTypes.StoreProductCategory[];
|
|
11
|
+
newArrivals: HttpTypes.StoreProduct[];
|
|
12
|
+
bestsellers: HttpTypes.StoreProduct[];
|
|
13
|
+
testimonials: unknown | null;
|
|
14
|
+
ratings: unknown[];
|
|
15
|
+
videoStories: {
|
|
16
|
+
title: string;
|
|
17
|
+
videoUrls: string[];
|
|
18
|
+
} | null;
|
|
19
|
+
announcementMessages: string[];
|
|
20
|
+
promoCountdown: {
|
|
21
|
+
code: string | null;
|
|
22
|
+
message: string | null;
|
|
23
|
+
endAt: string | null;
|
|
24
|
+
active: boolean;
|
|
25
|
+
ctaLabel: string | null;
|
|
26
|
+
ctaHref: string | null;
|
|
27
|
+
};
|
|
28
|
+
luxeFavourites: HttpTypes.StoreProduct[];
|
|
29
|
+
celebrityProduct: HttpTypes.StoreProduct | null;
|
|
30
|
+
baptismGirl: HttpTypes.StoreProduct[];
|
|
31
|
+
baptismBoy: HttpTypes.StoreProduct[];
|
|
32
|
+
baptismPicks: ShoppableLook[];
|
|
33
|
+
themeProducts: HttpTypes.StoreProduct[];
|
|
34
|
+
aboutBrand: AboutBrandConfig;
|
|
35
|
+
brandPillars: {
|
|
36
|
+
sectionTitle: string;
|
|
37
|
+
pillars: BrandPillarConfig[];
|
|
38
|
+
};
|
|
39
|
+
blogPosts: BlogPostConfig[];
|
|
40
|
+
instagramPosts: InstagramPostsData;
|
|
41
|
+
sectionsCopy: HomeSectionsCopy;
|
|
42
|
+
trustFeatures: TrustFeaturesConfig;
|
|
43
|
+
homeBanners: HomepageBanner[] | null;
|
|
44
|
+
appBanners: HomepageBanner[] | null;
|
|
45
|
+
whyChooseUsFeatures: {
|
|
46
|
+
title: string;
|
|
47
|
+
features: Array<{
|
|
48
|
+
name: string;
|
|
49
|
+
icon: string;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type LoadHomePageDataOptions = {
|
|
54
|
+
/** Merged `homepage-config` from main project (fetched via dynamic-config API there). */
|
|
55
|
+
pageInput?: HomepageConfig | null;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Parallel home page data loader. Catalog APIs run here; segment copy comes from
|
|
59
|
+
* `pageInput` (or package JSON defaults) — no dynamic-config fetch in this package.
|
|
60
|
+
*/
|
|
61
|
+
export declare function loadHomePageData(countryCode: string, options?: LoadHomePageDataOptions): Promise<HomePageData | null>;
|
|
62
|
+
//# sourceMappingURL=home.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"home.d.ts","sourceRoot":"","sources":["../../../src/server/home.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAC;AAiC3B,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IAC9C,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,UAAU,EAAE,SAAS,CAAC,oBAAoB,EAAE,CAAC;IAC7C,WAAW,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACtC,WAAW,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACtC,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;IAC5D,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,MAAM,EAAE,OAAO,CAAC;QAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;IACF,cAAc,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACzC,gBAAgB,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC;IAChD,WAAW,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACtC,UAAU,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACrC,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,aAAa,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC;IACxC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,YAAY,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;IACrE,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,cAAc,EAAE,kBAAkB,CAAC;IACnC,YAAY,EAAE,gBAAgB,CAAC;IAC/B,aAAa,EAAE,mBAAmB,CAAC;IACnC,WAAW,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IACpC,mBAAmB,EAAE;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACjD,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,yFAAyF;IACzF,SAAS,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAwH9B"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { listCollections } from "./collections";
|
|
3
|
+
import { listCategories } from "./categories";
|
|
4
|
+
import { listProductsWithSort, getProductsByTag, listProducts } from "./products";
|
|
5
|
+
import { getRegion } from "./regions";
|
|
6
|
+
import { fetchRatings } from "medusa-reviews-logic/server";
|
|
7
|
+
import { getBaptismPicksLooks, } from "./shoppable-looks";
|
|
8
|
+
import { resolveHomeSegmentConfigData } from "./resolve-home-segment-data";
|
|
9
|
+
async function productsForCategoryIds(countryCode, categoryIds, limit) {
|
|
10
|
+
if (!categoryIds.length)
|
|
11
|
+
return [];
|
|
12
|
+
try {
|
|
13
|
+
const { response } = await listProducts({
|
|
14
|
+
countryCode,
|
|
15
|
+
queryParams: {
|
|
16
|
+
category_id: categoryIds,
|
|
17
|
+
limit,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return response.products ?? [];
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function categoryIdsMatching(categories, pattern) {
|
|
27
|
+
return categories
|
|
28
|
+
.filter((c) => pattern.test((c.name || c.handle || "").toLowerCase()))
|
|
29
|
+
.map((c) => c.id)
|
|
30
|
+
.filter(Boolean);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parallel home page data loader. Catalog APIs run here; segment copy comes from
|
|
34
|
+
* `pageInput` (or package JSON defaults) — no dynamic-config fetch in this package.
|
|
35
|
+
*/
|
|
36
|
+
export async function loadHomePageData(countryCode, options) {
|
|
37
|
+
const pageInput = options?.pageInput ?? null;
|
|
38
|
+
const segmentConfig = resolveHomeSegmentConfigData(pageInput);
|
|
39
|
+
const region = await getRegion(countryCode);
|
|
40
|
+
if (!region)
|
|
41
|
+
return null;
|
|
42
|
+
const [collectionsResult, categoriesResult, newArrivalsResult, bestsellersResult, allRatings, themeByTag, baptismByTag,] = await Promise.all([
|
|
43
|
+
listCollections({ fields: "id, handle, title, metadata" }).catch(() => ({
|
|
44
|
+
collections: [],
|
|
45
|
+
})),
|
|
46
|
+
listCategories({
|
|
47
|
+
limit: 100,
|
|
48
|
+
fields: "id,handle,name,metadata,parent_category_id,*parent_category,*parent_category.parent_category",
|
|
49
|
+
}).catch(() => []),
|
|
50
|
+
listProductsWithSort({
|
|
51
|
+
page: 1,
|
|
52
|
+
queryParams: { limit: 12 },
|
|
53
|
+
sortBy: "created_at",
|
|
54
|
+
countryCode,
|
|
55
|
+
}).catch(() => ({ response: { products: [] } })),
|
|
56
|
+
getProductsByTag({
|
|
57
|
+
tagValue: "bestseller",
|
|
58
|
+
limit: 10,
|
|
59
|
+
countryCode,
|
|
60
|
+
}).catch(() => []),
|
|
61
|
+
fetchRatings(),
|
|
62
|
+
getProductsByTag({ tagValue: "theme", limit: 8, countryCode }).catch(() => []),
|
|
63
|
+
getProductsByTag({ tagValue: "baptism", limit: 12, countryCode }).catch(() => []),
|
|
64
|
+
]);
|
|
65
|
+
const categories = (categoriesResult ?? []);
|
|
66
|
+
const collections = collectionsResult.collections ?? [];
|
|
67
|
+
const newArrivals = newArrivalsResult
|
|
68
|
+
.response?.products ?? [];
|
|
69
|
+
const bestsellers = (bestsellersResult ?? []);
|
|
70
|
+
const girlIds = categoryIdsMatching(categories, /baptism.*girl|girl.*baptism|^girl$/);
|
|
71
|
+
const boyIds = categoryIdsMatching(categories, /baptism.*boy|boy.*baptism|^boy$/);
|
|
72
|
+
const baptismIds = categoryIdsMatching(categories, /baptism/);
|
|
73
|
+
const [baptismGirl, baptismBoy] = await Promise.all([
|
|
74
|
+
girlIds.length
|
|
75
|
+
? productsForCategoryIds(countryCode, girlIds, 8)
|
|
76
|
+
: baptismByTag.filter((p) => /girl/i.test(p.title || "")).slice(0, 8),
|
|
77
|
+
boyIds.length
|
|
78
|
+
? productsForCategoryIds(countryCode, boyIds, 8)
|
|
79
|
+
: baptismByTag.filter((p) => /boy/i.test(p.title || "")).slice(0, 8),
|
|
80
|
+
]);
|
|
81
|
+
let baptismFallback = [];
|
|
82
|
+
if (baptismGirl.length === 0 && baptismBoy.length === 0) {
|
|
83
|
+
baptismFallback =
|
|
84
|
+
baptismIds.length > 0
|
|
85
|
+
? await productsForCategoryIds(countryCode, baptismIds, 12)
|
|
86
|
+
: baptismByTag;
|
|
87
|
+
}
|
|
88
|
+
const resolvedBaptismGirl = baptismGirl.length > 0 ? baptismGirl : baptismFallback.slice(0, 8);
|
|
89
|
+
const resolvedBaptismBoy = baptismBoy.length > 0 ? baptismBoy : baptismFallback.slice(0, 8);
|
|
90
|
+
const themeProducts = themeByTag.length > 0
|
|
91
|
+
? themeByTag
|
|
92
|
+
: await productsForCategoryIds(countryCode, categoryIdsMatching(categories, /theme/), 8);
|
|
93
|
+
const baptismPicksFallback = (baptismByTag.length ? baptismByTag : baptismFallback).slice(0, 8);
|
|
94
|
+
const baptismPicks = await getBaptismPicksLooks(countryCode, baptismPicksFallback, pageInput);
|
|
95
|
+
return {
|
|
96
|
+
region,
|
|
97
|
+
collections: collections,
|
|
98
|
+
categories,
|
|
99
|
+
newArrivals,
|
|
100
|
+
bestsellers,
|
|
101
|
+
testimonials: segmentConfig.testimonials,
|
|
102
|
+
ratings: allRatings ?? [],
|
|
103
|
+
videoStories: segmentConfig.videoStories,
|
|
104
|
+
announcementMessages: segmentConfig.announcementMessages,
|
|
105
|
+
promoCountdown: segmentConfig.promoCountdown,
|
|
106
|
+
luxeFavourites: bestsellers.slice(0, 4),
|
|
107
|
+
celebrityProduct: bestsellers[0] ?? newArrivals[0] ?? null,
|
|
108
|
+
baptismGirl: resolvedBaptismGirl,
|
|
109
|
+
baptismBoy: resolvedBaptismBoy,
|
|
110
|
+
baptismPicks,
|
|
111
|
+
themeProducts,
|
|
112
|
+
aboutBrand: segmentConfig.aboutBrand,
|
|
113
|
+
brandPillars: segmentConfig.brandPillars,
|
|
114
|
+
blogPosts: segmentConfig.blogPosts,
|
|
115
|
+
instagramPosts: segmentConfig.instagramPosts,
|
|
116
|
+
sectionsCopy: segmentConfig.sectionsCopy,
|
|
117
|
+
trustFeatures: segmentConfig.trustFeatures,
|
|
118
|
+
homeBanners: segmentConfig.homeBanners,
|
|
119
|
+
appBanners: segmentConfig.appBanners,
|
|
120
|
+
whyChooseUsFeatures: segmentConfig.whyChooseUsFeatures,
|
|
121
|
+
};
|
|
122
|
+
}
|