refactor(web): FieldInput form type unknown (drop any); wire localized_text required; a11y/comment nits

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 00:36:04 +02:00
parent cb191225cc
commit cf0b34b254
+7 -7
View File
@@ -10,8 +10,7 @@ import { Label } from "@/components/ui/label";
type FieldDefinitionView = components["schemas"]["FieldDefinitionView"];
type LabelView = components["schemas"]["LabelView"];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyForm = UseFormReturn<{ fields: Record<string, any> }>;
type FieldForm = UseFormReturn<{ fields: Record<string, unknown> }>;
function labelIn(labels: LabelView[], lang: string): string {
return (
@@ -62,7 +61,7 @@ export function FieldInput({
form,
}: {
definition: FieldDefinitionView;
form: AnyForm;
form: FieldForm;
}) {
const { t, i18n } = useTranslation();
const lang = i18n.language.startsWith("sv") ? "sv" : "en";
@@ -101,6 +100,7 @@ export function FieldInput({
);
case "boolean":
// A checkbox always has a boolean value, so `required` is a no-op here.
return (
<div className="flex items-center gap-2">
<Controller
@@ -122,7 +122,7 @@ export function FieldInput({
case "localized_text":
return (
<div className="space-y-1">
<Label>{label}</Label>
<div className="text-sm font-medium">{label}</div>
<Label
htmlFor={`${definition.key}-en`}
@@ -133,7 +133,7 @@ export function FieldInput({
<Input
id={`${definition.key}-en`}
{...form.register(`fields.${definition.key}.en` as `fields.${string}`)}
{...form.register(`fields.${definition.key}.en` as `fields.${string}`, { required: definition.required })}
/>
<Label
@@ -195,7 +195,7 @@ function TermField({
placeholder,
}: {
definition: FieldDefinitionView;
form: AnyForm;
form: FieldForm;
label: string;
lang: string;
placeholder: string;
@@ -233,7 +233,7 @@ function AuthorityField({
placeholder,
}: {
definition: FieldDefinitionView;
form: AnyForm;
form: FieldForm;
label: string;
lang: string;
placeholder: string;