fix: use per-day-of-week colors in PDF export (weekday/sat/sun)
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
This commit is contained in:
parent
f75bd6ebe5
commit
72c51c2bea
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user