2026-10-04 16:36:09 +00:00
|
|
|
import { AssetCatalogPage } from "@metis/assets/client";
|
2026-10-03 13:19:20 +00:00
|
|
|
import { AccessWorkspacePage, CompaniesPage } from "@metis/companies/client";
|
2026-10-03 10:36:03 +00:00
|
|
|
import { HomePage } from "@metis/core/client";
|
|
|
|
|
import { IdentityWorkspace } from "@metis/identity/client";
|
|
|
|
|
import {
|
|
|
|
|
Select,
|
|
|
|
|
SelectContent,
|
|
|
|
|
SelectItem,
|
|
|
|
|
SelectTrigger,
|
|
|
|
|
SelectValue,
|
|
|
|
|
} from "@repo/shadcn-ui/components/select";
|
|
|
|
|
import { useId, useState } from "react";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
|
|
|
|
|
const LANGUAGE_OPTIONS = [
|
|
|
|
|
{ value: "es", label: "Español" },
|
|
|
|
|
{ value: "en", label: "English" },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function App() {
|
|
|
|
|
const { t: companyTranslation } = useTranslation("companies");
|
2026-10-04 16:36:09 +00:00
|
|
|
const { t: assetTranslation } = useTranslation("assets");
|
2026-10-03 13:19:20 +00:00
|
|
|
const { t: accessTranslation } = useTranslation("access");
|
2026-10-03 10:36:03 +00:00
|
|
|
const { t, i18n } = useTranslation("core");
|
|
|
|
|
const [languageError, setLanguageError] = useState(false);
|
|
|
|
|
const languageLabelId = useId();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="min-h-screen bg-background">
|
|
|
|
|
<header className="border-b border-border bg-card">
|
|
|
|
|
<div className="mx-auto flex max-w-5xl items-center justify-between gap-6 px-6 py-5">
|
|
|
|
|
<span className="text-xl font-semibold tracking-tight text-foreground">
|
|
|
|
|
Metis Desk<span className="ml-1 text-primary">.</span>
|
|
|
|
|
</span>
|
|
|
|
|
<div className="flex items-center gap-3 text-sm text-muted-foreground">
|
|
|
|
|
<span id={languageLabelId}>{t("language")}</span>
|
|
|
|
|
<Select
|
|
|
|
|
items={LANGUAGE_OPTIONS}
|
|
|
|
|
onValueChange={(language) => {
|
|
|
|
|
if (language !== "es" && language !== "en") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
setLanguageError(false);
|
|
|
|
|
i18n
|
|
|
|
|
.changeLanguage(language)
|
|
|
|
|
.then(() => {
|
|
|
|
|
document.documentElement.lang = i18n.resolvedLanguage ?? "es";
|
|
|
|
|
})
|
|
|
|
|
.catch(() => setLanguageError(true));
|
|
|
|
|
}}
|
|
|
|
|
value={i18n.resolvedLanguage ?? "es"}
|
|
|
|
|
>
|
|
|
|
|
<SelectTrigger aria-labelledby={languageLabelId} className="min-w-28">
|
|
|
|
|
<SelectValue />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
{LANGUAGE_OPTIONS.map((language) => (
|
|
|
|
|
<SelectItem key={language.value} value={language.value}>
|
|
|
|
|
{language.label}
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{languageError && (
|
|
|
|
|
<p className="px-6 pb-4 text-destructive" role="alert">
|
|
|
|
|
{t("languageError")}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</header>
|
|
|
|
|
<IdentityWorkspace
|
|
|
|
|
pages={[
|
2026-10-03 13:19:20 +00:00
|
|
|
{
|
|
|
|
|
id: "catalogs",
|
|
|
|
|
label: accessTranslation("catalogTitle"),
|
|
|
|
|
render: (session) => (
|
|
|
|
|
<AccessWorkspacePage csrfToken={session.csrfToken} scope="global" />
|
|
|
|
|
),
|
|
|
|
|
},
|
2026-10-04 16:36:09 +00:00
|
|
|
{
|
|
|
|
|
id: "asset-catalog",
|
|
|
|
|
label: assetTranslation("title"),
|
|
|
|
|
render: (session) => <AssetCatalogPage csrfToken={session.csrfToken} scope="global" />,
|
|
|
|
|
},
|
2026-10-03 10:36:03 +00:00
|
|
|
{
|
|
|
|
|
id: "companies",
|
|
|
|
|
label: companyTranslation("title"),
|
|
|
|
|
render: (session) => <CompaniesPage csrfToken={session.csrfToken} />,
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<HomePage />
|
|
|
|
|
</IdentityWorkspace>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|