feat(cms): add recovery history and operational reliability tools
CI / check (push) Failing after 22s
CI / deploy (push) Skipped
CI / publish-container (push) Skipped

This commit is contained in:
Simo committed 2026-09-09 21:57:56 +02:00
1 parent 89526af344
commit 1ef405be0a
92 files changed
+6384 -267

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
"use client";
import { type RefObject, useEffect } from "react";
export function useFormErrorFocus(
form: RefObject<HTMLFormElement | null>,
errors: Record<string, string[]>,
pending: boolean,
) {
useEffect(() => {
if (pending) return;
for (const field of Object.keys(errors)) {
const control = form.current?.elements.namedItem(field);
if (control instanceof HTMLElement && !control.hasAttribute("disabled")) {
control.focus();
break;
}
}
}, [form, errors, pending]);
}
export function FormFieldError({
name,
errors,
}: {
name: string;
errors: Record<string, string[]>;
}) {
const messages = errors[name];
return messages?.length ? (
<p id={`error-${name}`} role="alert" className="text-sm text-destructive">
{messages.join(" · ")}
</p>
) : null;
}