Remove the generic $lib/svelte-admin CRUD layer and AdminTable.svelte; each admin route now owns its own form/modal logic. Add DataTable.svelte, superform-errors.ts, and profile-specific modal/field components. Flatten proclamation categories/groups and drop subscription levels; add the v2 groups API; update v1/v2 endpoints, serializers, auth, and regenerated Prisma client with the new migrations. Document the overhaul plan in docs/ADMIN_OVERHAUL.md.
24 lines
779 B
TypeScript
24 lines
779 B
TypeScript
export function superFormErrorsToFieldErrors(superErrors: Record<string, unknown>): {
|
|
error: string;
|
|
fieldErrors: Record<string, string>;
|
|
} {
|
|
const fieldErrors: Record<string, string> = {};
|
|
let formError = '';
|
|
for (const [key, value] of Object.entries(superErrors)) {
|
|
if (key === '_errors' && Array.isArray(value)) {
|
|
formError = (value[0] as string) ?? '';
|
|
} else if (
|
|
value &&
|
|
typeof value === 'object' &&
|
|
'_errors' in value &&
|
|
Array.isArray((value as Record<string, unknown>)._errors)
|
|
) {
|
|
const errMsg = ((value as Record<string, unknown>)._errors as string[])[0];
|
|
fieldErrors[key] = errMsg;
|
|
} else if (Array.isArray(value) && typeof value[0] === 'string') {
|
|
fieldErrors[key] = value[0];
|
|
}
|
|
}
|
|
return { error: formError, fieldErrors };
|
|
}
|