Per-file type-only fixes surfaced after the Supabase client was correctly typed. All fixes preserve runtime behavior; no any/ts-ignore/ts-expect-error. - lib/supabase/client.ts: annotate the browser client as SupabaseClient<Database> (same ssr/js drift as server.ts; fixes it centrally for all callers). - Supabase embedded-select joins whose FK metadata is missing from the generated types are bridged with `as unknown as <target>` + a TODO to remove after regenerating types/database.ts. - setState optimistic-update variance and raw <select> enum values cast to the precise element/union type; .insert payload fields (Json, enums) given the precise column type via satisfies/field casts. - Added narrowing guards where a value was legitimately nullable (comms channel, public form page) without changing the intended path. The 14 remaining errors are confined to the four files fixed in Phase B (real bugs + the tautological actions.test rewrite). 639 tests still green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { createClient } from '@/lib/supabase/server'
|
|
import { getPublicForm } from '@/lib/actions'
|
|
import { parseFormSchema } from '@/lib/forms-schema'
|
|
import { PublicFormClient } from './public-form-client'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
export default async function PublicFormPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ space: string; slug: string }>
|
|
}) {
|
|
const { space, slug } = await params
|
|
const res = await getPublicForm({ space, slug })
|
|
|
|
if ('error' in res && res.error) {
|
|
return (
|
|
<main className="mx-auto flex min-h-screen max-w-xl flex-col items-center justify-center p-6 text-center">
|
|
<h1 className="text-xl font-semibold">This form is not available</h1>
|
|
<p className="mt-2 text-sm text-muted-foreground">
|
|
It may be unpublished, closed, or the link is wrong.
|
|
</p>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
const form = res.data
|
|
if (!form) {
|
|
return (
|
|
<main className="mx-auto flex min-h-screen max-w-xl flex-col items-center justify-center p-6 text-center">
|
|
<h1 className="text-xl font-semibold">This form is not available</h1>
|
|
<p className="mt-2 text-sm text-muted-foreground">
|
|
It may be unpublished, closed, or the link is wrong.
|
|
</p>
|
|
</main>
|
|
)
|
|
}
|
|
const supabase = await createClient()
|
|
const {
|
|
data: { user },
|
|
} = await supabase.auth.getUser()
|
|
|
|
return (
|
|
<main className="mx-auto max-w-2xl p-4 md:p-8">
|
|
<PublicFormClient
|
|
formId={form.id}
|
|
nextPath={`/f/${space}/${slug}`}
|
|
title={form.title}
|
|
description={form.description}
|
|
kind={form.kind}
|
|
visibility={form.visibility}
|
|
legalText={form.legal_text}
|
|
fields={parseFormSchema(form.schema)}
|
|
authed={Boolean(user)}
|
|
/>
|
|
</main>
|
|
)
|
|
}
|