From 25aac5c3ba0d09bb70e90f6ca2ad7d8cde523c26 Mon Sep 17 00:00:00 2001 From: GardKalland Date: Fri, 26 Sep 2025 14:19:48 +0200 Subject: [PATCH] Email utc issue fixed --- programmerbar-email-templates/templates/new-shift.tsx | 6 ++++-- programmerbar-web/src/lib/remotes/events.remote.ts | 3 +++ programmerbar-web/src/lib/services/email.service.tsx | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/programmerbar-email-templates/templates/new-shift.tsx b/programmerbar-email-templates/templates/new-shift.tsx index 46e9adb..5804b42 100644 --- a/programmerbar-email-templates/templates/new-shift.tsx +++ b/programmerbar-email-templates/templates/new-shift.tsx @@ -6,6 +6,8 @@ export const NewShiftEmailSchema = z.object({ id: z.string(), // Not used in the email, but can be useful for ICS generation startAt: z.string(), endAt: z.string(), + startAtFormatted: z.string(), + endAtFormatted: z.string(), summary: z.string(), description: z.string().optional() }), @@ -31,11 +33,11 @@ export function NewShiftEmail({ shift, user }: NewShiftEmailSchemaType) { Du har blitt tildelt en vakt med følgende detaljer: - Fra: {new Date(shift.startAt).toLocaleString("nb-NO")} + Fra: {shift.startAtFormatted} - Til: {new Date(shift.endAt).toLocaleString("nb-NO")} + Til: {shift.endAtFormatted} {shift.description && ( diff --git a/programmerbar-web/src/lib/remotes/events.remote.ts b/programmerbar-web/src/lib/remotes/events.remote.ts index 437c477..9a16c20 100644 --- a/programmerbar-web/src/lib/remotes/events.remote.ts +++ b/programmerbar-web/src/lib/remotes/events.remote.ts @@ -1,5 +1,6 @@ import { CreateEventSchema } from '$lib/validators'; import type { ShiftEmailProps } from '$lib/services/email.service'; +import { normalDate } from '$lib/date'; import { z } from 'zod'; import { command, getRequestEvent } from '$app/server'; @@ -91,6 +92,8 @@ async function sendShiftEmails( id: shift.id, startAt: new Date(shift.startAt).toISOString(), endAt: new Date(shift.endAt).toISOString(), + startAtFormatted: normalDate(shift.startAt), + endAtFormatted: normalDate(shift.endAt), summary: `Vakt: ${eventName}`, description: `Du har fått en vakt på "${eventName}".` } diff --git a/programmerbar-web/src/lib/services/email.service.tsx b/programmerbar-web/src/lib/services/email.service.tsx index a3c9ad5..d27b38e 100644 --- a/programmerbar-web/src/lib/services/email.service.tsx +++ b/programmerbar-web/src/lib/services/email.service.tsx @@ -32,6 +32,8 @@ export type ShiftEmailProps = { id: string; startAt: string; endAt: string; + startAtFormatted: string; + endAtFormatted: string; summary: string; description?: string; };