From 33875395fb3d1584d3225424c51ba265e3aeae0a Mon Sep 17 00:00:00 2001 From: weeihan Date: Sat, 11 Jul 2026 07:57:00 +0800 Subject: [PATCH] fix: cast Supabase join types through unknown for TSC compatibility Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01AWxyMibCuGGtSQSqfajDQ7 --- app/(protected)/hse/dashboard/page.tsx | 2 +- app/api/dashboard/stats/route.ts | 2 +- lib/notifications/email.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/(protected)/hse/dashboard/page.tsx b/app/(protected)/hse/dashboard/page.tsx index c5fe64f..b253958 100644 --- a/app/(protected)/hse/dashboard/page.tsx +++ b/app/(protected)/hse/dashboard/page.tsx @@ -33,7 +33,7 @@ export default async function HseDashboardPage() { const siteMap: Record = {} for (const r of rows) { - const name = (r.sites as { name: string } | null)?.name ?? 'Unknown' + const name = (r.sites as unknown as { name: string } | null)?.name ?? 'Unknown' siteMap[name] = (siteMap[name] ?? 0) + 1 } const by_site = Object.entries(siteMap).map(([name, count]) => ({ name, count })) diff --git a/app/api/dashboard/stats/route.ts b/app/api/dashboard/stats/route.ts index ecf7e96..6b4bc28 100644 --- a/app/api/dashboard/stats/route.ts +++ b/app/api/dashboard/stats/route.ts @@ -26,7 +26,7 @@ export async function GET() { const siteMap: Record = {} for (const r of rows) { - const name = (r.sites as { name: string } | null)?.name ?? 'Unknown' + const name = (r.sites as unknown as { name: string } | null)?.name ?? 'Unknown' siteMap[name] = (siteMap[name] ?? 0) + 1 } const by_site = Object.entries(siteMap).map(([name, count]) => ({ name, count })) diff --git a/lib/notifications/email.ts b/lib/notifications/email.ts index 586647a..08a232b 100644 --- a/lib/notifications/email.ts +++ b/lib/notifications/email.ts @@ -27,8 +27,8 @@ export async function sendNewIncidentEmail( .eq('id', incidentId) .single() - const siteName = (incident?.sites as { name: string } | null)?.name ?? 'Unknown Site' - const reporterName = (incident?.reporter as { name: string } | null)?.name ?? 'Unknown' + const siteName = (incident?.sites as unknown as { name: string } | null)?.name ?? 'Unknown Site' + const reporterName = (incident?.reporter as unknown as { name: string } | null)?.name ?? 'Unknown' const reportedAt = incident?.reported_at ? new Date(incident.reported_at).toLocaleString('en-MY', { timeZone: 'Asia/Kuala_Lumpur' }) : '-'