fix: add array guards to all frontend components consuming API responses
Prevents "M.forEach is not a function" crashes when API returns error objects or unexpected shapes instead of arrays. Guards all useQuery consumers with Array.isArray checks and safe defaults for object props. Files fixed: DeadlineList, AppointmentList, TenantSwitcher, DeadlineTrafficLights, UpcomingTimeline, CaseOverviewGrid, AISummaryCard, TeamSettings, and all page-level components (dashboard, cases, fristen, termine, ai/extract).
This commit is contained in:
@@ -21,13 +21,16 @@ function formatDayLabel(date: Date): string {
|
||||
}
|
||||
|
||||
export function UpcomingTimeline({ deadlines, appointments }: Props) {
|
||||
const safeDeadlines = Array.isArray(deadlines) ? deadlines : [];
|
||||
const safeAppointments = Array.isArray(appointments) ? appointments : [];
|
||||
|
||||
const items: TimelineItem[] = [
|
||||
...deadlines.map((d) => ({
|
||||
...safeDeadlines.map((d) => ({
|
||||
type: "deadline" as const,
|
||||
date: parseISO(d.due_date),
|
||||
data: d,
|
||||
})),
|
||||
...appointments.map((a) => ({
|
||||
...safeAppointments.map((a) => ({
|
||||
type: "appointment" as const,
|
||||
date: parseISO(a.start_at),
|
||||
data: a,
|
||||
|
||||
Reference in New Issue
Block a user