33409352ee
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 28s
CI / test-go-edu-search (push) Successful in 28s
CI / test-python-klausur (push) Failing after 2m38s
CI / test-python-agent-core (push) Successful in 20s
CI / test-nodejs-website (push) Successful in 26s
Backend (school-service):
- calendar_events.go — Create/List/Delete on cal_school_event with
UUID[] handling for affected_class_ids. Default lead-days [7,1]
if caller omits the array.
- calendar_rollover.go — single-transaction promotion: graduating
classes (grade >= 13) get deleted first so the +1 update doesn't
bump them to invalid grade 14. defaultSchoolYearDates() picks the
next Aug-Jul pair when the caller doesn't specify.
- Handlers + routes: GET/POST /calendar/events,
DELETE /calendar/events/:id, POST /calendar/school-year-rollover.
Frontend (studio-v2):
- EventModal: form with Title / Typ / Datum/Zeit / unterrichtsfrei /
Beschreibung / Sichtbarkeit + Notification-Checkboxen. Per-Type
Farb-Mapping in types.ts.
- DayDetail: Modal das beim Klick auf einen Kalender-Tag aufgeht und
Feiertage + Schulferien + Schul-Events fuer diesen Tag listet,
inkl. Loeschen-Button pro Event.
- RolloverWizard: zwei-Schritt-Dialog mit Datums-Auswahl + Tipp-
Bestaetigung ("SCHULJAHR WECHSELN") gegen versehentliche Auslo-
sung, danach Ergebnis-Card mit promoted/graduated-Counts.
- MonthView gewinnt onDayClick + onAddEvent + onRollover Props,
rendert farb-codierte Punkte fuer School-Events am Tagesrand.
- Page laed Events parallel mit Holidays und reicht alle Handler
nach unten.
Tests:
- Go: 3 neue Tests fuer defaultSchoolYearDates + parseClassIDs.
Validator-Test fuer CreateSchoolEventRequest existiert bereits.
80 Subtests gesamt, alle gruen.
- Playwright: mockCalendarApi gewinnt Routes fuer events GET/POST/
DELETE und school-year-rollover. 6 neue Tests (EventModal open,
submit, DayDetail open, Rollover-Trigger, Confirm-Schutz,
Ergebnis-Anzeige).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
/**
|
|
* Schulkalender API client. Re-uses the same /api/school/* proxy + the JWT
|
|
* helper from stundenplan so we don't fork the auth flow.
|
|
*/
|
|
|
|
import { getStundenplanToken } from '@/lib/stundenplan/api'
|
|
import type {
|
|
PublicEvent, SchoolCalendarConfig, UpsertSchoolCalendarConfig,
|
|
SchoolEvent, CreateSchoolEvent, SchoolYearRolloverResult,
|
|
} from '@/app/schulkalender/types'
|
|
|
|
async function apiFetch<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
|
|
const headers: Record<string, string> = {
|
|
'Content-Type': 'application/json',
|
|
...(options.headers as Record<string, string> | undefined),
|
|
}
|
|
const token = getStundenplanToken()
|
|
if (token) headers['Authorization'] = `Bearer ${token}`
|
|
|
|
const res = await fetch(`/api/school${endpoint}`, { ...options, headers })
|
|
if (!res.ok) {
|
|
const err = await res.json().catch(() => ({ error: 'Unknown error' }))
|
|
throw new Error(err.error || err.detail || `HTTP ${res.status}`)
|
|
}
|
|
if (res.status === 204) return undefined as T
|
|
return res.json()
|
|
}
|
|
|
|
export const calendarApi = {
|
|
listHolidays: (region: string, from: string, to: string) =>
|
|
apiFetch<PublicEvent[]>(`/calendar/holidays?region=${encodeURIComponent(region)}&from=${from}&to=${to}`),
|
|
getConfig: () => apiFetch<SchoolCalendarConfig | null>('/calendar/config'),
|
|
upsertConfig: (data: UpsertSchoolCalendarConfig) =>
|
|
apiFetch<SchoolCalendarConfig>('/calendar/config', { method: 'PUT', body: JSON.stringify(data) }),
|
|
|
|
// School events
|
|
listEvents: (from: string, to: string) =>
|
|
apiFetch<SchoolEvent[]>(`/calendar/events?from=${from}&to=${to}`),
|
|
createEvent: (data: CreateSchoolEvent) =>
|
|
apiFetch<SchoolEvent>('/calendar/events', { method: 'POST', body: JSON.stringify(data) }),
|
|
deleteEvent: (id: string) =>
|
|
apiFetch<void>(`/calendar/events/${id}`, { method: 'DELETE' }),
|
|
|
|
rolloverSchoolYear: (newYearStart?: string, newYearEnd?: string) =>
|
|
apiFetch<SchoolYearRolloverResult>('/calendar/school-year-rollover', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
new_year_start: newYearStart,
|
|
new_year_end: newYearEnd,
|
|
}),
|
|
}),
|
|
}
|