From c6b12e9d60eae71fffbfa041869171cc2fea855c Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 1 Aug 2026 19:57:47 +0000 Subject: [PATCH] Fix missing back-in-stock email Live Preview (404) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'back-in-stock' was added to the Payload-side email-templates type but never wired into this repo's own EmailTemplateType union or the Live Preview page's VALID_TYPES/fallback-heading maps — every other type is registered in three places, this one was only in one, so opening its Live Preview 404'd. Co-Authored-By: Claude Sonnet 5 --- app/email-preview/[type]/page.tsx | 10 ++++++++++ app/lib/emailTemplates.ts | 1 + app/lib/payload.ts | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/email-preview/[type]/page.tsx b/app/email-preview/[type]/page.tsx index a1b4ecc..3fd3784 100644 --- a/app/email-preview/[type]/page.tsx +++ b/app/email-preview/[type]/page.tsx @@ -20,6 +20,7 @@ const VALID_TYPES: EmailTemplateType[] = [ "order-tracking-corrected", "order-delivered", "payment-method-switched", + "back-in-stock", ]; const STATUS_TYPE_FALLBACK_HEADING: Record = { @@ -31,6 +32,7 @@ const STATUS_TYPE_FALLBACK_HEADING: Record = { "order-tracking-corrected": "Korrigierte Sendungsnummer", "order-delivered": "Dein Paket ist angekommen", "payment-method-switched": "Erledigt!", + "back-in-stock": "Wieder da!", }; // Entered exclusively via EmailTemplates.ts's admin.livePreview.url (a @@ -39,6 +41,14 @@ const STATUS_TYPE_FALLBACK_HEADING: Record = { // draft:true so an unsaved edit in the admin shows up here immediately; // the actual sent email (orderEmail.ts) always reads the published version // instead. +// +// "back-in-stock" shares the generic order-status renderer below like +// every other status type — an approximation, not pixel-identical (its +// real send, lib/jobs/sendBackInStockEmails.ts on the Payload side, has no +// order number/link at all, just a product name + "Jetzt ansehen" button), +// same established gap as password-reset's own. Good enough to edit +// subject/heading/bodyText/footerText live, which is what this page is +// actually for. export default async function EmailPreviewPage({ params }: { params: Promise<{ type: string }> }) { const { type } = await params; if (!VALID_TYPES.includes(type as EmailTemplateType)) notFound(); diff --git a/app/lib/emailTemplates.ts b/app/lib/emailTemplates.ts index 165ea93..d616570 100644 --- a/app/lib/emailTemplates.ts +++ b/app/lib/emailTemplates.ts @@ -336,6 +336,7 @@ export const ORDER_STATUS_EMAIL_ICON: Record = { "order-tracking-corrected": "📦", "order-delivered": "🎉", "payment-method-switched": "💳", + "back-in-stock": "🔔", }; export function renderOrderStatusHtml( diff --git a/app/lib/payload.ts b/app/lib/payload.ts index 2cf1af2..d08b414 100644 --- a/app/lib/payload.ts +++ b/app/lib/payload.ts @@ -897,7 +897,8 @@ export type EmailTemplateType = | "order-tracking-added" | "order-tracking-corrected" | "order-delivered" - | "payment-method-switched"; + | "payment-method-switched" + | "back-in-stock"; type PayloadEmailTemplate = { type: EmailTemplateType;