'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { Button } from '@/components/ui/button' import { FormRenderer } from '@/components/forms/form-renderer' import { submitForm } from '@/lib/actions' import type { FormField } from '@/lib/forms-schema' // Authenticated member fill surface for members-only / in-app forms. The // member is already signed in, so submitForm's visibility check passes; // submission is by formId (slugs are per-space now). export function MemberFillClient({ formId, description, kind, legalText, fields, }: { formId: string description: string | null kind: string legalText: string | null fields: FormField[] }) { const router = useRouter() const [values, setValues] = useState>({}) const [consent, setConsent] = useState(false) const [submitting, setSubmitting] = useState(false) const [error, setError] = useState(null) const [done, setDone] = useState(false) const isWaiver = kind === 'waiver' async function submit() { setError(null) setSubmitting(true) const res = await submitForm({ formId, answers: values, consent: isWaiver ? consent : undefined, }) setSubmitting(false) if ('error' in res && res.error) { setError(res.error) return } setDone(true) } if (done) { return (

Thank you

Your response has been recorded.

) } return (
{description &&

{description}

} {isWaiver && legalText && (
{legalText}
)} setValues(p => ({ ...p, [k]: v }))} /> {isWaiver && ( )} {error &&

{error}

}
) }