feat(web): object-detail tab title, caption element fix, login title (#57)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 17:22:18 +02:00
parent 6e1f5ea50f
commit 8511aebb53
4 changed files with 28 additions and 6 deletions
+12 -2
View File
@@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";
import type { components } from "../api/schema";
import { useObject, useFieldDefinitions } from "../api/queries";
import { formatDate } from "../lib/format-date";
import { useDocumentTitle } from "../lib/use-document-title";
import { DeleteObjectDialog } from "./delete-object-dialog";
import { FlexibleFieldValue } from "./flexible-field-value";
import { PublishControl } from "./publish-control";
@@ -13,6 +14,7 @@ import { buttonVariants } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
type FieldDefinitionView = components["schemas"]["FieldDefinitionView"];
type AdminObjectView = components["schemas"]["AdminObjectView"];
function Field({ label, value }: { label: string; value: ReactNode }) {
const empty = value === null || value === undefined || value === "";
@@ -26,10 +28,9 @@ function Field({ label, value }: { label: string; value: ReactNode }) {
}
export function ObjectDetail() {
const { t, i18n } = useTranslation();
const { t } = useTranslation();
const { id } = useParams();
const { data: object, isLoading, isError } = useObject(id!);
const { data: definitions } = useFieldDefinitions();
if (isLoading) {
return (
@@ -43,6 +44,15 @@ export function ObjectDetail() {
if (!object) return <p className="p-4 text-sm text-muted-foreground">{t("objects.notFound")}</p>;
return <ObjectDetailLoaded object={object} />;
}
function ObjectDetailLoaded({ object }: { object: AdminObjectView }) {
const { t, i18n } = useTranslation();
const { data: definitions } = useFieldDefinitions();
useDocumentTitle(object.object_number);
// Prefer the active locale's label, then English, then the raw key.
const lang = i18n.language.startsWith("sv") ? "sv" : "en";
const labelFor = (key: string) => {