diff --git a/scripts/pb-seed.mjs b/scripts/pb-seed.mjs index f8fde0e..d4e1ef0 100644 --- a/scripts/pb-seed.mjs +++ b/scripts/pb-seed.mjs @@ -48,7 +48,7 @@ const GIFTING_TABS = [ product_handles: "mozimo-dark-chocolate-bar-85\n9-pralines-box\nbars-box", collection_handle: "gift-collection", cta_label: "View all Signature gifts", - cta_url: "https://shop.mozimo.in/collections/gift-collection", + cta_url: "/collections/gift-collection", sort: 1, visible: true, }, @@ -64,7 +64,7 @@ const GIFTING_TABS = [ "pistachio-spread-60\nmozimo-almond-dragees-60\nkunafa-chocolate-bar\nspreads-box", collection_handle: "best-sellers", cta_label: "Shop Best Sellers", - cta_url: "https://shop.mozimo.in/collections/best-sellers", + cta_url: "/collections/best-sellers", sort: 2, visible: true, }, @@ -80,7 +80,7 @@ const GIFTING_TABS = [ "mozimo-carnival-celebration-s\nmozimo-carnival-celebration-m", collection_handle: "gift-collection", cta_label: "View the full collection", - cta_url: "https://shop.mozimo.in/collections/gift-collection", + cta_url: "/collections/gift-collection", sort: 3, visible: true, }, @@ -95,7 +95,7 @@ const GIFTING_TABS = [ product_handles: "mozimo-carnival-celebration-l\nmozimo-celestial-s", collection_handle: "gift-collection", cta_label: "View the full collection", - cta_url: "https://shop.mozimo.in/collections/gift-collection", + cta_url: "/collections/gift-collection", sort: 4, visible: true, }, @@ -109,7 +109,7 @@ const GIFTING_TABS = [ tile_url: "/products/mozi-30.jpg", collection_handle: "gift-collection", cta_label: "Shop the Seasonal Edit", - cta_url: "https://shop.mozimo.in/collections/gift-collection", + cta_url: "/collections/gift-collection", sort: 5, visible: true, }, @@ -455,6 +455,26 @@ async function main() { console.log( `[pb-seed] "${name}" already has ${existing.body.totalItems} record(s) — leaving as is`, ); + // one-off migration: gifting tab CTAs must keep users on mozimo.in, + // never bounce them out to the shopify domain + if (name === "gifting_tabs") { + const all = await authed(`/api/collections/${name}/records?perPage=100`); + for (const rec of all.body.items ?? []) { + const url = rec.cta_url ?? ""; + if (url.startsWith("https://shop.mozimo.in/")) { + const internal = url.replace("https://shop.mozimo.in", ""); + const patched = await authed(`/api/collections/${name}/records/${rec.id}`, { + method: "PATCH", + body: JSON.stringify({ cta_url: internal }), + }); + if (patched.ok) { + console.log(`[pb-seed] migrated cta_url for "${rec.name}" -> ${internal}`); + } else { + console.warn(`[pb-seed] cta migration failed for "${rec.name}":`, patched.status); + } + } + } + } continue; } for (const record of SEEDS[name]) { diff --git a/src/app/bespoke.tsx b/src/app/bespoke.tsx index 3d36296..599af13 100644 --- a/src/app/bespoke.tsx +++ b/src/app/bespoke.tsx @@ -197,7 +197,7 @@ function BespokePage() {