refactor(web): adopt useLang + segmentClass/rowStateClass across sites (#66)

This commit is contained in:
2026-06-08 23:45:24 +02:00
parent 00a7ce772e
commit 900f85f8ac
9 changed files with 33 additions and 29 deletions
+3 -2
View File
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
import type { components } from "../api/schema";
import { useObject, useFieldDefinitions } from "../api/queries";
import { useLang } from "../lib/use-lang";
import { groupDefinitions } from "../lib/group-fields";
import { formatDate } from "../lib/format-date";
import { useDocumentTitle } from "../lib/use-document-title";
@@ -49,14 +50,14 @@ export function ObjectDetail() {
}
function ObjectDetailLoaded({ object }: { object: AdminObjectView }) {
const { t, i18n } = useTranslation();
const { t } = useTranslation();
const { data: definitions } = useFieldDefinitions();
useDocumentTitle(object.object_number);
useBreadcrumb([{ label: t("nav.objects"), to: "/objects" }, { label: object.object_number }]);
// Prefer the active locale's label, then English, then the raw key.
const lang = i18n.language.startsWith("sv") ? "sv" : "en";
const lang = useLang();
const labelFor = (key: string) => {
const labels = definitions?.find((d) => d.key === key)?.labels;
const byLang = labels?.find((l) => l.lang === lang)?.label;