diff --git a/apps/api/prisma/seed.ts b/apps/api/prisma/seed.ts index 8d86828..2c44699 100644 --- a/apps/api/prisma/seed.ts +++ b/apps/api/prisma/seed.ts @@ -646,13 +646,36 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem }; async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTemplate): Promise { + const packageSample = getTemplateSampleContent(template.templateKey); + const sampleOfferings = packageSample?.offerings ?? []; + const offerings = template.offerings.map((item, index) => ({ + ...item, + ...(sampleOfferings[index] + ? { + name: sampleOfferings[index].name, + summary: sampleOfferings[index].summary, + config: { + ...item.config, + categoryKey: sampleOfferings[index].categoryKey, + }, + } + : {}), + })); + const trustContent = packageSample?.trustContent?.length + ? packageSample.trustContent.map((item, index) => ({ + ...template.trustContent[index], + type: item.type, + title: item.title, + content: item.content, + })) + : template.trustContent; await prisma.brandProfile.update({ where: { id: brandId }, data: { config: template.brandConfig, }, }); - for (const [sortOrder, item] of template.offerings.entries()) { + for (const [sortOrder, item] of offerings.entries()) { const offering = await prisma.offering.findUnique({ where: { brandId_name: { brandId, name: item.name } }, }); @@ -719,7 +742,7 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla }, }); } - for (const [sortOrder, item] of template.trustContent.entries()) { + for (const [sortOrder, item] of trustContent.entries()) { const existing = await prisma.trustContent.findFirst({ where: { brandId, type: item.type, title: item.title }, }); @@ -731,7 +754,6 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla where: { brandId, targetType: "brand" }, orderBy: { createdAt: "asc" }, }); - const packageSample = getTemplateSampleContent(template.templateKey); const formData = { name: template.inquiryForm.name, purpose: "inquiry",