Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+80
@@ -0,0 +1,80 @@
|
||||
import { LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { buildWalkingSkeletonVM, type WalkingSkeletonVM } from "@toolctrl/view-models";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { requireAuth } from "~/utils/loaders.middleware";
|
||||
import { getTenantIdFromUrl } from "~/utils/services/.server/urlService";
|
||||
import { getUserInfo } from "~/utils/session.server";
|
||||
import { tenantHasModule } from "~/utils/connector/tenantConnector.server";
|
||||
import { WALKING_SKELETON_MODULE_KEY } from "~/modules/walkingSkeleton/constants";
|
||||
import { v2MetaFunction } from "~/utils/compat/v2MetaFunction";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
|
||||
/**
|
||||
* Walking-Skeleton-Route (R-P1c) — die dünne Ende-zu-Ende-Scheibe des Fundaments:
|
||||
* View-Model im Loader (synchron aufbereitet, UI rendert nur) + Konnektor-Gate `tenantHasModule()`
|
||||
* exemplarisch. Die finale Optik folgt Davids App-Shell-/Archetypen-Delta (Dev-Nachzug).
|
||||
*/
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
vm: WalkingSkeletonVM;
|
||||
};
|
||||
|
||||
export const meta: v2MetaFunction<LoaderData> = ({ data }) => [{ title: data?.title }];
|
||||
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
await requireAuth({ request, params });
|
||||
const { t } = await getTranslations(request);
|
||||
const [tenantId, userInfo] = await Promise.all([getTenantIdFromUrl(params), getUserInfo(request)]);
|
||||
|
||||
// Konnektor-Pflicht-Gate (R-P1b): darf dieser Tenant das Modul nutzen?
|
||||
const allowed = await tenantHasModule({
|
||||
tenantId,
|
||||
userId: userInfo.userId,
|
||||
moduleKey: WALKING_SKELETON_MODULE_KEY,
|
||||
});
|
||||
|
||||
const vm = buildWalkingSkeletonVM({
|
||||
tenantId,
|
||||
moduleKey: WALKING_SKELETON_MODULE_KEY,
|
||||
connectorState: allowed ? "active" : "locked",
|
||||
});
|
||||
|
||||
const data: LoaderData = {
|
||||
title: `${t("walkingSkeleton.title")} | ${process.env.APP_NAME}`,
|
||||
vm,
|
||||
};
|
||||
return Response.json(data);
|
||||
};
|
||||
|
||||
export default function WalkingSkeletonRoute() {
|
||||
const { t } = useTranslation();
|
||||
const { vm } = useLoaderData<LoaderData>();
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return (
|
||||
<main className="mx-auto max-w-3xl px-4 py-10" data-ui-id="ui.walkingSkeleton.page" data-connector-state="empty">
|
||||
<h1 className="text-foreground text-xl font-semibold">{t("walkingSkeleton.empty.headline")}</h1>
|
||||
<p className="text-muted-foreground mt-2">{t("walkingSkeleton.empty.body")}</p>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
const { connectorState, headlineKey, bodyKey, ctaKey } = vm.data;
|
||||
return (
|
||||
<main className="mx-auto max-w-3xl px-4 py-10" data-ui-id="ui.walkingSkeleton.page" data-connector-state={connectorState}>
|
||||
<h1 className="text-foreground text-xl font-semibold">{t(headlineKey)}</h1>
|
||||
<p className="text-muted-foreground mt-2">{t(bodyKey)}</p>
|
||||
{connectorState === "locked" && ctaKey ? (
|
||||
<p className="text-theme-600 mt-4 inline-flex font-medium" data-ui-id="ui.walkingSkeleton.upsell">
|
||||
{t(ctaKey)}
|
||||
</p>
|
||||
) : null}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
return <ServerError />;
|
||||
}
|
||||
Reference in new issue
Block a user