/m/lotse mit Verlauf, Chips, Sprungzielen, Aktionskarten (Bestätigen/Bearbeiten/Verwerfen), Spracheingabe mit editierbarem Transkript und Offline-Hinweis; Navigationseintrag, Button „Lotse fragen“ im Auftragsdetail, Schalter und Datenfluss in /settings/lotse, Audit-Labels. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
64 lines
3.3 KiB
TypeScript
64 lines
3.3 KiB
TypeScript
import Link from "next/link";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { requireAppAccess } from "@/server/app-access";
|
|
import { can } from "@/server/services/context";
|
|
import { fieldPageContext } from "@/server/services/field/page-context";
|
|
import { getMyActiveSession } from "@/server/services/field/sessions";
|
|
import { countPendingTimeEntries } from "@/server/services/field/time-entries";
|
|
import { canUseLotseChat } from "@/server/services/lotse/chat/access";
|
|
import { cn } from "@/lib/utils";
|
|
import { CraftviaLogo } from "@/components/brand/craftvia-logo";
|
|
import { AccountInactiveNotice } from "@/components/account-inactive-notice";
|
|
import { BottomNav } from "@/components/field/bottom-nav";
|
|
import { OnlineBadge } from "@/components/field/online-badge";
|
|
import { RunningClockBar, type ClockSession } from "@/components/field/running-clock-bar";
|
|
import { OfflineRuntime } from "@/components/offline/offline-runtime";
|
|
|
|
/** L12: own running/paused session + open approvals for the shell (never blocks the page). */
|
|
async function shellTimeState(): Promise<{ clock: ClockSession | null; approvals: number; lotseChat: boolean }> {
|
|
try {
|
|
const ctx = await fieldPageContext();
|
|
const [session, approvals, lotseChat] = await Promise.all([can(ctx, "field:execute") ? getMyActiveSession(ctx) : Promise.resolve(null), countPendingTimeEntries(ctx), canUseLotseChat(ctx)]);
|
|
return {
|
|
clock: session
|
|
? { status: session.status, workOrderId: session.workOrderId, number: session.number, title: session.title, segmentType: session.segmentType, segmentStartedAt: session.segmentStartedAt, closedSeconds: session.closedSeconds }
|
|
: null,
|
|
approvals,
|
|
lotseChat, // L16
|
|
};
|
|
} catch {
|
|
// module "field" disabled or no field permissions: shell without clock/badge
|
|
return { clock: null, approvals: 0, lotseChat: false };
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Mobile shell `/m` (ARCHITEKTUR §5): same session/account/MFA checks as the backoffice
|
|
* (src/server/app-access.ts), no sidebar, bottom navigation, online/offline badge.
|
|
* Module gates live one level below: (core) → "field", emergency → "emergency".
|
|
* L12: running clock bar above the bottom navigation on every /m page.
|
|
*/
|
|
export default async function FieldShell({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
const access = await requireAppAccess();
|
|
if (access.kind === "inactive") return <AccountInactiveNotice />;
|
|
const [t, time] = await Promise.all([getTranslations("field.nav"), shellTimeState()]);
|
|
|
|
return (
|
|
<div className="flex min-h-screen flex-1 flex-col bg-background">
|
|
<header className="sticky top-0 z-20 flex h-14 items-center justify-between gap-3 border-b bg-card px-4 pt-[env(safe-area-inset-top)]">
|
|
<Link href="/m" aria-label={t("today")} className="flex min-h-12 items-center">
|
|
<CraftviaLogo variant="horizontal" height={26} />
|
|
</Link>
|
|
<div className="flex items-center gap-2">
|
|
{/* Slot für L6: <NotificationBell variant="mobile" /> aus src/components/notifications/bell.tsx */}
|
|
<OfflineRuntime />
|
|
<OnlineBadge />
|
|
</div>
|
|
</header>
|
|
<div className={cn("mx-auto w-full max-w-xl flex-1", time.clock ? "pb-48" : "pb-28")}>{children}</div>
|
|
<RunningClockBar initial={time.clock} />
|
|
<BottomNav approvals={time.approvals} lotse={time.lotseChat} />
|
|
</div>
|
|
);
|
|
}
|