AbiirSkincare/Hydrogen/web/app/lib/abiirPdpDefaults.ts

125 lines
3.7 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type {AbiirPdpCms} from './abiirProductDetail.ts';
import {PDP_DEFAULT_SHIPPING_RETURNS} from './abiirProductDetail.ts';
/**
* Storefront fallback PDP copy when Sanity `abiirPdp` is empty (was defined next to the PDP UI).
* Keep aligned with product card mocks in `featuredProducts.ts` where handles overlap.
*/
export const MOCK_ABIIR_PRODUCT_DETAIL_CMS: AbiirPdpCms = {
subtitle: 'Radiance Ritual Mask',
shortDescription:
"Get ready to glow with this amazing face mask! Packed with the incredible benefits of anti-inflammatory and brightening turmeric extract, holy basil, nourishing hempseed oil and exfoliating fruit-based acids, this blend is designed to give you a radiant complexion at any age or stage.",
benefitChips: ['Brightens', 'Purifies', 'Glows'],
keyIngredients: [
{
name: 'Turmeric Extract',
benefit:
'Anti-inflammatory brightener that fades spots and reduces redness',
},
{
name: 'Holy Basil (Basil extract)',
benefit: 'Purifying and calming — balances skin and reduces blemishes',
},
{
name: 'Hemp Seed Oil',
benefit:
'Deeply nourishing omega-rich oil that hydrates without clogging pores',
},
{
name: 'Kaolin & Bentonite Clay',
benefit:
'Gently detoxifies and draws out impurities for a clearer complexion',
},
],
howToUse:
'Apply Brightening Face Mask generously to cleansed skin, leave for 10–15 minutes and rinse thoroughly. For best results use 1–2 times a week.',
ingredients: [
'Aqua',
'Carbopol 940',
'Glycerin',
'Zemea',
'Shea butter',
'Kojic acid',
'Murumuru butter',
'Avocado oil',
'Almond oil',
'Grapeseed oil',
],
shippingReturns: PDP_DEFAULT_SHIPPING_RETURNS,
rating: 0,
reviewCount: 0,
relatedProductHandles: ['face-scrub', 'copper-gua-sha', 'experience-kit'],
};
/** Handles and card-level copy used to specialize the seeded PDP (matches featured strip mocks). */
const FEATURED_PDP_OVERRIDES: Array<
Pick<AbiirPdpCms, 'subtitle' | 'benefitChips' | 'rating' | 'reviewCount'> & {
handle: string;
}
> = [
{
handle: 'face-mask',
subtitle: 'Radiance Ritual Mask',
benefitChips: ['Brightens', 'Purifies', 'Glows'],
rating: 4.9,
reviewCount: 334,
},
{
handle: 'face-scrub',
subtitle: 'Skincare Rooted in Ayurveda',
benefitChips: ['Exfoliates', 'Brightens', 'Smooths'],
rating: 4.8,
reviewCount: 156,
},
{
handle: 'experience-kit',
subtitle: 'Ayurvedic Ritual Starter Set',
benefitChips: ['Cleanses', 'Hydrates', 'Glows'],
rating: 4.9,
reviewCount: 289,
},
{
handle: 'glow-with-love-bundle',
subtitle: 'Complete Ritual Collection',
benefitChips: ['Hydrates', 'Sculpts', 'Glows'],
rating: 5,
reviewCount: 167,
},
];
const RELATED_POOL = [
'face-mask',
'face-scrub',
'experience-kit',
'glow-with-love-bundle',
'copper-gua-sha',
'cleansing-oil',
'face-serum',
'ayurvedic-face-cream',
];
function relatedHandlesFor(handle: string): string[] {
return RELATED_POOL.filter((h) => h !== handle).slice(0, 3);
}
/**
* Full `abiirPdp` object for Sanity / seed scripts: base copy from the live PDP mock, plus
* subtitle / chips / ratings for known handles and sensible “You may also love” handles.
*/
export function buildAbiirPdpSanityPayloadForHandle(handle: string): AbiirPdpCms {
const h = handle.trim();
const base: AbiirPdpCms = {
...MOCK_ABIIR_PRODUCT_DETAIL_CMS,
relatedProductHandles: relatedHandlesFor(h),
};
const row = FEATURED_PDP_OVERRIDES.find((r) => r.handle === h);
if (!row) return base;
return {
...base,
subtitle: row.subtitle,
benefitChips: [...row.benefitChips],
rating: row.rating,
reviewCount: row.reviewCount,
};
}