From 1fac1e0e2caf0ab6733fb3412bf45e94ceaab7b4 Mon Sep 17 00:00:00 2001 From: Karl Ludwig Weise Date: Mon, 24 Nov 2025 21:42:14 +0100 Subject: [PATCH] Completed email renderer poc for appointment confirmation --- project.inlang/messages/de.json | 11 +++ project.inlang/messages/en.json | 11 +++ src/lib/const/locales.ts | 2 + src/lib/emails/AppointmentBooked.svelte | 72 +++++++++++++------ src/lib/emails/components/EmailButton.svelte | 5 +- .../emails/components/EmailHeadline.svelte | 7 ++ src/lib/emails/components/EmailLayout.svelte | 34 ++------- src/lib/emails/components/EmailText.svelte | 7 +- src/lib/emails/utils.ts | 58 +++++++++++++++ src/lib/server/email/email-service.ts | 43 +++++++++-- .../[test=dev]/e-mail-templates/+server.ts | 14 ---- .../appointment-booked/+server.ts | 42 +++++++++++ 12 files changed, 233 insertions(+), 73 deletions(-) create mode 100644 src/lib/emails/components/EmailHeadline.svelte delete mode 100644 src/routes/(local-only)/[test=dev]/e-mail-templates/+server.ts create mode 100644 src/routes/(local-only)/[test=dev]/e-mail-templates/appointment-booked/+server.ts diff --git a/project.inlang/messages/de.json b/project.inlang/messages/de.json index ac6c353..618d5ab 100644 --- a/project.inlang/messages/de.json +++ b/project.inlang/messages/de.json @@ -907,5 +907,16 @@ "reserved": "reserviert" } } + }, + "emails": { + "poweredBy": "Betrieben mit", + "greeting": "Hallo {name},", + "oclock": "Uhr", + "appointmentBooked": { + "subject": "{channel} bei {tenant} gebucht", + "introduction": "Ihr Termin wurde gebucht.", + "action": "Termin absagen", + "reason": "Sie erhalten diese E-Mail, weil jemand mit Ihrer E-Mail Adresse einen Termin bei gebucht hat." + } } } diff --git a/project.inlang/messages/en.json b/project.inlang/messages/en.json index 1af7752..7d116f5 100644 --- a/project.inlang/messages/en.json +++ b/project.inlang/messages/en.json @@ -916,5 +916,16 @@ "reserved": "reserved" } } + }, + "emails": { + "poweredBy": "Powered by", + "greeting": "Hello {name},", + "oclock": "", + "appointmentBooked": { + "subject": "{channel} at {tenant} booked successfully", + "introduction": "your appointment for has been booked.", + "action": "Cancel appointment", + "reason": "You are receiving this email because someone booked an appointment with your e-mail address." + } } } diff --git a/src/lib/const/locales.ts b/src/lib/const/locales.ts index dabcb15..99ced3b 100644 --- a/src/lib/const/locales.ts +++ b/src/lib/const/locales.ts @@ -2,6 +2,8 @@ import { m } from "$i18n/messages"; export const supportedLocales = ["en", "de"] as const; +export type SupportedLocale = (typeof supportedLocales)[number]; + export const translatedLocales = { en: m["locales.en"](), de: m["locales.de"](), diff --git a/src/lib/emails/AppointmentBooked.svelte b/src/lib/emails/AppointmentBooked.svelte index fd8ec61..b8290c6 100644 --- a/src/lib/emails/AppointmentBooked.svelte +++ b/src/lib/emails/AppointmentBooked.svelte @@ -1,33 +1,65 @@ - -

{m["absences.add.description"]()} {name},

-

your appointment has been booked.

-

Vaccination Appointment

-

- Dr. John Doe
- June 30, 2024
- 10:00 AM - 10:15 AM -

-

Praxis Dr. Jane Doe

-

- Musterstraße 10
- Etage 4
- 12345 Musterstadt -

- View Appointments + {m["emails.greeting"]({ name: user.email })} + + {m["emails.appointmentBooked.introduction"]()} + + {channel} + + {appointment.agentName}
+ {renderAppointmentDate(appointment.appointmentDate, locale)}
+ {renderAppointmentTime(appointment.appointmentDate, locale)} + {m["emails.oclock"]()} +
+ {tenant.longName} + + {address.street} + {address.number}
+ {#if address.additionalAddressInfo}{address.additionalAddressInfo}
{/if} + {address.zip} + {address.city} +
+ {m["emails.appointmentBooked.action"]()} - You are receiving this email because someone booked an appointment with your e-mail address. + {m["emails.appointmentBooked.reason"]()}
diff --git a/src/lib/emails/components/EmailButton.svelte b/src/lib/emails/components/EmailButton.svelte index e16724e..066a34a 100644 --- a/src/lib/emails/components/EmailButton.svelte +++ b/src/lib/emails/components/EmailButton.svelte @@ -15,8 +15,7 @@ .button { font-size: 16px; line-height: 1.5; - color: #ffffff; - background-color: #000000; + border: 1px solid #000000; padding: 12px 32px; padding: 0.75rem 2rem; text-decoration: none; @@ -24,8 +23,8 @@ border-radius: 12px; } .button:hover { - background-color: #333333; cursor: pointer; + background-color: rgb(0 0 0 / 0.1); } diff --git a/src/lib/emails/components/EmailHeadline.svelte b/src/lib/emails/components/EmailHeadline.svelte new file mode 100644 index 0000000..47ee03c --- /dev/null +++ b/src/lib/emails/components/EmailHeadline.svelte @@ -0,0 +1,7 @@ + + + it).join(" ")}> + {@render children?.()} + diff --git a/src/lib/emails/components/EmailLayout.svelte b/src/lib/emails/components/EmailLayout.svelte index 04346b6..da760e4 100644 --- a/src/lib/emails/components/EmailLayout.svelte +++ b/src/lib/emails/components/EmailLayout.svelte @@ -1,4 +1,5 @@ -{@render children?.()} +

it).join(" ")}>{@render children?.()}