Files
craftvia/src/components/offline/offline-runtime.tsx
T

17 lines
771 B
TypeScript

import { auth } from "@/server/auth";
import { parseMaxDays } from "@/lib/offline/bundle-core";
import { OfflineRuntimeClient } from "./offline-runtime-client";
/**
* Offline runtime of the mobile shell (lane L7) — mounted once in `(field)/m/layout.tsx`.
* Passes the signed-in tenant/user (local data is separated per context) and OFFLINE_MAX_DAYS
* to the client: service worker registration + update notice, outbox sync loop, sync badge.
*/
export async function OfflineRuntime() {
const session = await auth();
const tenantId = session?.user?.tenantId;
const userId = session?.user?.id;
if (!tenantId || !userId) return null;
return <OfflineRuntimeClient tenantId={tenantId} userId={userId} maxDays={parseMaxDays(process.env.OFFLINE_MAX_DAYS)} />;
}