mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 10:44:23 +00:00
e1c5daeccb
The server owns the arithmetic entitlements are computed with, but the grid has to render the same twelve months and the overlays have to filter against the same range, so the window resolves on both sides. yearWindow.ts is that mirror, including the Feb-29 clamp and the anniversary-without-a-hire-date fallback. The store loads the settings before the year list picks a default — with a shifted year the current period is not necessarily the current calendar year. Holidays are fetched per calendar year the window touches and clipped back to what the grid draws; a school break straddling New Year comes back from both fetches, so markers are de-duplicated per day. The label is part of that identity, otherwise two calendars left on the same colour collapse into one.
176 lines
5.1 KiB
TypeScript
176 lines
5.1 KiB
TypeScript
import { http, HttpResponse } from 'msw';
|
|
|
|
export const vacayHandlers = [
|
|
http.get('/api/addons/vacay/plan', () => {
|
|
return HttpResponse.json({
|
|
plan: {
|
|
id: 1,
|
|
holidays_enabled: false,
|
|
holidays_region: null,
|
|
holiday_calendars: [],
|
|
block_weekends: true,
|
|
carry_over_enabled: false,
|
|
company_holidays_enabled: false,
|
|
},
|
|
users: [{ id: 1, username: 'user1', color: '#3b82f6' }],
|
|
pendingInvites: [],
|
|
incomingInvites: [],
|
|
isOwner: true,
|
|
isFused: false,
|
|
});
|
|
}),
|
|
|
|
http.put('/api/addons/vacay/plan', () => {
|
|
return HttpResponse.json({
|
|
plan: {
|
|
id: 1,
|
|
holidays_enabled: true,
|
|
holidays_region: null,
|
|
holiday_calendars: [],
|
|
block_weekends: true,
|
|
carry_over_enabled: false,
|
|
company_holidays_enabled: false,
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/year-settings', () => {
|
|
return HttpResponse.json({
|
|
settings: { year_type: 'calendar', year_start_month: 1, year_start_day: 1, hire_date: null },
|
|
});
|
|
}),
|
|
|
|
http.put('/api/addons/vacay/year-settings', async ({ request }) => {
|
|
const body = (await request.json()) as Record<string, unknown>;
|
|
return HttpResponse.json({
|
|
settings: { year_type: 'calendar', year_start_month: 1, year_start_day: 1, hire_date: null, ...body },
|
|
});
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/years', () => {
|
|
return HttpResponse.json({ years: [2025, 2026] });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/years', () => {
|
|
return HttpResponse.json({ years: [2025, 2026, 2027] });
|
|
}),
|
|
|
|
http.delete('/api/addons/vacay/years/:year', () => {
|
|
return HttpResponse.json({ years: [2025] });
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/entries/:year', () => {
|
|
return HttpResponse.json({
|
|
entries: [
|
|
{ date: '2025-06-15', user_id: 1 },
|
|
{ date: '2025-06-16', user_id: 1 },
|
|
],
|
|
companyHolidays: [],
|
|
});
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/entries/toggle', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/entries/company-holiday', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/stats/:year', () => {
|
|
return HttpResponse.json({
|
|
stats: [{ user_id: 1, vacation_days: 30, used: 2 }],
|
|
});
|
|
}),
|
|
|
|
http.put('/api/addons/vacay/stats/:year', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/holidays/countries', () => {
|
|
return HttpResponse.json({ countries: ['DE', 'US', 'FR'] });
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/holidays/:year/:country', () => {
|
|
return HttpResponse.json([
|
|
{ date: '2025-12-25', name: 'Christmas', localName: 'Weihnachten', global: true, counties: null },
|
|
{ date: '2025-01-01', name: 'New Year', localName: 'Neujahr', global: true, counties: null },
|
|
]);
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/school-holidays/regions/:country', () => {
|
|
return HttpResponse.json({
|
|
groups: [
|
|
{ code: 'NL-NO', shortName: 'NO', name: [{ language: 'EN', text: 'Northern Region' }] },
|
|
{ code: 'NL-MI', shortName: 'MI', name: [{ language: 'EN', text: 'Central Region' }] },
|
|
{ code: 'NL-ZU', shortName: 'ZU', name: [{ language: 'EN', text: 'Southern Region' }] },
|
|
],
|
|
subdivisions: [],
|
|
});
|
|
}),
|
|
|
|
http.put('/api/addons/vacay/color', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/invite', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/invite/accept', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/invite/decline', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/invite/cancel', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/dissolve', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/plan/holiday-calendars', () => {
|
|
return HttpResponse.json({
|
|
calendar: { id: 1, plan_id: 1, region: 'DE', label: null, color: '#ef4444', sort_order: 0 },
|
|
});
|
|
}),
|
|
|
|
http.put('/api/addons/vacay/plan/holiday-calendars/:id', () => {
|
|
return HttpResponse.json({
|
|
calendar: { id: 1, plan_id: 1, region: 'US', label: 'US Holidays', color: '#3b82f6', sort_order: 0 },
|
|
});
|
|
}),
|
|
|
|
http.delete('/api/addons/vacay/plan/holiday-calendars/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/shares', () => {
|
|
return HttpResponse.json({ outgoing: [], incoming: [] });
|
|
}),
|
|
|
|
http.post('/api/addons/vacay/shares', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/shares/available-users', () => {
|
|
return HttpResponse.json({ users: [] });
|
|
}),
|
|
|
|
http.get('/api/addons/vacay/shares/calendars/:year', () => {
|
|
return HttpResponse.json({ calendars: [] });
|
|
}),
|
|
|
|
http.put('/api/addons/vacay/shares/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.delete('/api/addons/vacay/shares/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
];
|