From 1fe646d82d23c3d0f493cc4ce8844f5c19c8b699 Mon Sep 17 00:00:00 2001 From: weeihan Date: Sat, 11 Jul 2026 07:59:07 +0800 Subject: [PATCH] fix: extract zone fields explicitly to avoid Supabase join type narrowing to never Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7 --- app/report/page.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/report/page.tsx b/app/report/page.tsx index 25e2161..060ddec 100644 --- a/app/report/page.tsx +++ b/app/report/page.tsx @@ -15,7 +15,8 @@ export default async function ReportPage({ searchParams }: Props) { if (authError || !data?.user) redirect(`/login?redirect=/report${zone ? `?zone=${zone}` : ''}`) - let zoneData: { id: string; name: string; site_id: string; sites: { name: string } } | null = null + let zoneName: string | null = null + let siteName: string | null = null if (zone) { const { data: zd } = await supabase @@ -23,22 +24,25 @@ export default async function ReportPage({ searchParams }: Props) { .select('id, name, site_id, sites (name)') .eq('qr_code_token', zone) .single() - zoneData = zd as typeof zoneData + if (zd) { + zoneName = (zd as { name: string }).name ?? null + siteName = (zd.sites as unknown as { name: string } | null)?.name ?? null + } } return (

Report an Incident

- {zoneData ? ( + {zoneName ? (

- {zoneData.sites.name} — {zoneData.name} + {siteName ?? 'Unknown Site'} — {zoneName}

) : (

No zone detected — zone will not be recorded

)}
- +
) }