From 72c51c2bea1e5b34d8b737fd51f84b4221a3ab1c Mon Sep 17 00:00:00 2001 From: mARTin Date: Thu, 9 Apr 2026 10:31:43 +0200 Subject: [PATCH] fix: use per-day-of-week colors in PDF export (weekday/sat/sun) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PDF was showing all day headers in the same weekdayColor. The webapp uses three separate color settings: weekdayColor (Mon–Fri), weekendColorSat, and weekendColorSun. Fetch both weekend colors from DB and apply via dayColor() helper based on d.getDay(). v1.95.1 --- src/app/api/user/export-week-view/route.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/app/api/user/export-week-view/route.ts b/src/app/api/user/export-week-view/route.ts index 6686127..75457b2 100644 --- a/src/app/api/user/export-week-view/route.ts +++ b/src/app/api/user/export-week-view/route.ts @@ -169,11 +169,21 @@ type WeatherDay = { maxTemp: number | null; code: number | null; }; // User-specific style settings passed to the PDF type UserStyle = { weekdayColor: string; // e.g. "#0ea5e9" + weekendColorSat: string; // e.g. "#ffc107" + weekendColorSun: string; // e.g. "#dc2626" dateColor: string; // e.g. "#888888" headlineFontWeight: string; // e.g. "900" useOswald: boolean; // whether Oswald was successfully registered }; +function dayColor(d: Date, isToday: boolean, us: UserStyle): string { + if (isToday) return '#6366f1'; + const dow = d.getDay(); + if (dow === 6) return us.weekendColorSat; + if (dow === 0) return us.weekendColorSun; + return us.weekdayColor; +} + // ── PDF Document ────────────────────────────────────────────────────────────── function WeekCalendarPDF({ @@ -388,7 +398,7 @@ function WeekCalendarPDF({ fontFamily: headlineFontFamily, fontWeight: headlineFW, fontSize: dayNameSize, - color: isToday ? '#6366f1' : userStyle.weekdayColor, + color: dayColor(d, isToday, userStyle), textAlign: 'center', letterSpacing: 0.5, lineHeight: 1.1, @@ -397,7 +407,7 @@ function WeekCalendarPDF({ React.createElement(Text, { style: { fontSize: 7.5, - color: isToday ? '#6366f1' : userStyle.dateColor, + color: dayColor(d, isToday, userStyle), textAlign: 'center', marginTop: 2, fontFamily: 'Helvetica', @@ -623,8 +633,8 @@ export async function GET(request: Request) { select: { id: true, name: true, email: true, timezone: true, - weekdayColor: true, dateColor: true, - headlineFontWeight: true, + weekdayColor: true, weekendColorSat: true, weekendColorSun: true, + dateColor: true, headlineFontWeight: true, weatherLat: true, weatherLon: true, }, }); @@ -638,6 +648,8 @@ export async function GET(request: Request) { const userStyle: UserStyle = { weekdayColor: (user as any).weekdayColor || '#0ea5e9', + weekendColorSat: (user as any).weekendColorSat || '#ffc107', + weekendColorSun: (user as any).weekendColorSun || '#dc2626', dateColor: (user as any).dateColor || '#888888', headlineFontWeight: (user as any).headlineFontWeight || '900', useOswald: oswaldAvailable,