diff --git a/client/src/components/Vacay/VacayCalendar.tsx b/client/src/components/Vacay/VacayCalendar.tsx index fd252e1..15536df 100644 --- a/client/src/components/Vacay/VacayCalendar.tsx +++ b/client/src/components/Vacay/VacayCalendar.tsx @@ -26,6 +26,7 @@ export default function VacayCalendar() { }, [entries]) const blockWeekends = plan?.block_weekends !== false + const weekendDays: number[] = plan?.weekend_days ? String(plan.weekend_days).split(',').map(Number) : [0, 6] const companyHolidaysEnabled = plan?.company_holidays_enabled !== false const handleCellClick = useCallback(async (dateStr) => { @@ -35,7 +36,7 @@ export default function VacayCalendar() { return } if (holidays[dateStr]) return - if (blockWeekends && isWeekend(dateStr)) return + if (blockWeekends && isWeekend(dateStr, weekendDays)) return if (companyHolidaysEnabled && companyHolidaySet.has(dateStr)) return await toggleEntry(dateStr, selectedUserId || undefined) }, [companyMode, toggleEntry, toggleCompanyHoliday, holidays, companyHolidaySet, blockWeekends, companyHolidaysEnabled, selectedUserId]) @@ -57,6 +58,7 @@ export default function VacayCalendar() { onCellClick={handleCellClick} companyMode={companyMode} blockWeekends={blockWeekends} + weekendDays={weekendDays} /> ))} diff --git a/client/src/components/Vacay/VacayMonthCard.tsx b/client/src/components/Vacay/VacayMonthCard.tsx index d28bce4..9c1e8ad 100644 --- a/client/src/components/Vacay/VacayMonthCard.tsx +++ b/client/src/components/Vacay/VacayMonthCard.tsx @@ -29,11 +29,12 @@ interface VacayMonthCardProps { onCellClick: (date: string) => void companyMode: boolean blockWeekends: boolean + weekendDays?: number[] } export default function VacayMonthCard({ year, month, holidays, companyHolidaySet, companyHolidaysEnabled = true, entryMap, - onCellClick, companyMode, blockWeekends + onCellClick, companyMode, blockWeekends, weekendDays = [0, 6] }: VacayMonthCardProps) { const { language } = useTranslation() const weekdays = language === 'de' ? WEEKDAYS_DE : language === 'es' ? WEEKDAYS_ES : language === 'ar' ? WEEKDAYS_AR : WEEKDAYS_EN @@ -76,7 +77,8 @@ export default function VacayMonthCard({ if (day === null) return
const dateStr = `${year}-${pad(month + 1)}-${pad(day)}` - const weekend = di >= 5 + const dayOfWeek = new Date(year, month, day).getDay() + const weekend = weekendDays.includes(dayOfWeek) const holiday = holidays[dateStr] const isCompany = companyHolidaysEnabled && companyHolidaySet.has(dateStr) const dayEntries = entryMap[dateStr] || [] diff --git a/client/src/components/Vacay/VacaySettings.tsx b/client/src/components/Vacay/VacaySettings.tsx index 8513ada..36b4875 100644 --- a/client/src/components/Vacay/VacaySettings.tsx +++ b/client/src/components/Vacay/VacaySettings.tsx @@ -49,6 +49,42 @@ export default function VacaySettings({ onClose }: VacaySettingsProps) { onChange={() => toggle('block_weekends')} /> + {/* Weekend days selector */} + {plan.block_weekends !== false && ( +
+

{t('vacay.weekendDays')}

+
+ {[ + { day: 1, label: t('vacay.mon') }, + { day: 2, label: t('vacay.tue') }, + { day: 3, label: t('vacay.wed') }, + { day: 4, label: t('vacay.thu') }, + { day: 5, label: t('vacay.fri') }, + { day: 6, label: t('vacay.sat') }, + { day: 0, label: t('vacay.sun') }, + ].map(({ day, label }) => { + const current: number[] = plan.weekend_days ? String(plan.weekend_days).split(',').map(Number) : [0, 6] + const active = current.includes(day) + return ( + + ) + })} +
+
+ )} + {/* Carry-over */} { router.put('/plan', async (req: Request, res: Response) => { const authReq = req as AuthRequest; const planId = getActivePlanId(authReq.user.id); - const { block_weekends, holidays_enabled, holidays_region, company_holidays_enabled, carry_over_enabled } = req.body; + const { block_weekends, holidays_enabled, holidays_region, company_holidays_enabled, carry_over_enabled, weekend_days } = req.body; const updates: string[] = []; const params: (string | number)[] = []; @@ -205,6 +205,7 @@ router.put('/plan', async (req: Request, res: Response) => { if (holidays_region !== undefined) { updates.push('holidays_region = ?'); params.push(holidays_region); } if (company_holidays_enabled !== undefined) { updates.push('company_holidays_enabled = ?'); params.push(company_holidays_enabled ? 1 : 0); } if (carry_over_enabled !== undefined) { updates.push('carry_over_enabled = ?'); params.push(carry_over_enabled ? 1 : 0); } + if (weekend_days !== undefined) { updates.push('weekend_days = ?'); params.push(String(weekend_days)); } if (updates.length > 0) { params.push(planId);