import { TRPCError } from '@trpc/server'; import { CheckCircle2, AlertCircle } from 'lucide-react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@repo/ui'; import { Alert, AlertDescription, AlertTitle } from '@repo/ui'; import { api } from '@/lib/trpc/server'; import { PingClient } from './ping-client'; /** * Smoke-test home page. Uses the RSC tRPC caller (server-side) to invoke the * ping procedure end-to-end: * * RSC → tRPC caller → protectedProcedure → Prisma → Postgres → Tenant row * * If the call throws (e.g. UNAUTHORIZED because no session), the error is * caught and rendered as a legible failure card. */ export default async function HomePage() { let result: | { ok: true; payload: Awaited> } | { ok: false; message: string; code: string } = { ok: false, message: 'init', code: 'INIT', }; try { const payload = await api.ping.ping(); result = { ok: true, payload }; } catch (err) { if (err instanceof TRPCError) { result = { ok: false, message: err.message, code: err.code }; } else if (err instanceof Error) { result = { ok: false, message: err.message, code: 'UNKNOWN' }; } else { result = { ok: false, message: String(err), code: 'UNKNOWN' }; } } return (

FieldOps Operator

Scaffold smoke test

{result.ok ? ( Connected End-to-end path verified: RSC → tRPC → Prisma → Postgres.
Tenant: {result.payload.tenant.name}
id: {result.payload.tenant.id}
at: {result.payload.timestamp}
) : ( Ping failed ({result.code})

{result.message}

If this says UNAUTHORIZED, set{' '} AUTH_DEV_AUTOLOGIN=true in .env for local dev, or sign in via Auth.js.

)}
); }