Archived
Type caught errors as unknown in the frontend
Replace `catch (e: any)` with `catch (e)` and read the message through a new errorMessage() helper. ApiError.data gets a real type, and useDismissingState's setter keeps one identity across renders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import React, { useMemo, useState } from "react";
|
||||
import { Users, Send } from "lucide-react";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
import { isMinorOn } from "@/components/shared/AttendeeNamesEditor";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
|
||||
const CONSENT_LABEL: Record<string, { text: string; cls: string }> = {
|
||||
pending: { text: "consent pending", cls: "text-amber-700" },
|
||||
@@ -100,8 +101,8 @@ export function AttendeesPanel({ registration, token, canEdit, hasForm, onSaved,
|
||||
setEditing(false);
|
||||
onMessage("Attendees saved.");
|
||||
onSaved();
|
||||
} catch (e: any) {
|
||||
setError(e?.message || "Couldn't save attendees");
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || "Couldn't save attendees");
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
@@ -111,8 +112,8 @@ export function AttendeesPanel({ registration, token, canEdit, hasForm, onSaved,
|
||||
try {
|
||||
const res = await apiFetch<{ message: string }>(`/api/registrations/${encodeURIComponent(registration.id)}/attendees/${encodeURIComponent(a.id)}/send-form-link`, { method: "POST", authToken: token });
|
||||
onMessage(res.message);
|
||||
} catch (e: any) {
|
||||
setError(e?.message || "Couldn't send the form link");
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || "Couldn't send the form link");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -122,8 +123,8 @@ export function AttendeesPanel({ registration, token, canEdit, hasForm, onSaved,
|
||||
try {
|
||||
const res = await apiFetch<{ message: string }>(`/api/consent/requests/${encodeURIComponent(requestId)}/resend`, { method: "POST", authToken: token });
|
||||
onMessage(res.message);
|
||||
} catch (e: any) {
|
||||
setError(e?.message || "Couldn't re-send the consent request");
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || "Couldn't re-send the consent request");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user