feat(web): single-language content authoring (LabelEditor + localized_text at default lang)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import type { components } from "../api/schema";
|
||||
import { useAuthorities, useTerms } from "../api/queries";
|
||||
import { useConfig } from "../config/config-context";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
@@ -70,6 +71,7 @@ export function FieldInput<TValues extends { fields: Record<string, unknown> }>(
|
||||
form: FieldForm<TValues>;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { default_language } = useConfig();
|
||||
const lang = i18n.language.startsWith("sv") ? "sv" : "en";
|
||||
const label = labelIn(definition.labels, lang);
|
||||
const name = fieldPath<TValues>(definition.key);
|
||||
@@ -128,30 +130,12 @@ export function FieldInput<TValues extends { fields: Record<string, unknown> }>(
|
||||
case "localized_text":
|
||||
return (
|
||||
<div className="space-y-1">
|
||||
<div className="text-sm font-medium">{label}</div>
|
||||
|
||||
<Label
|
||||
htmlFor={`${definition.key}-en`}
|
||||
className="text-xs text-neutral-500"
|
||||
>
|
||||
{label} (EN)
|
||||
</Label>
|
||||
|
||||
<Label htmlFor={definition.key}>{label}</Label>
|
||||
<Input
|
||||
id={`${definition.key}-en`}
|
||||
{...form.register(fieldPath<TValues>(`${definition.key}.en`), { required: definition.required })}
|
||||
/>
|
||||
|
||||
<Label
|
||||
htmlFor={`${definition.key}-sv`}
|
||||
className="text-xs text-neutral-500"
|
||||
>
|
||||
{label} (SV)
|
||||
</Label>
|
||||
|
||||
<Input
|
||||
id={`${definition.key}-sv`}
|
||||
{...form.register(fieldPath<TValues>(`${definition.key}.sv`))}
|
||||
id={definition.key}
|
||||
{...form.register(fieldPath<TValues>(`${definition.key}.${default_language}`), {
|
||||
required: definition.required,
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user