'use client' import { type ReactNode, useActionState } from 'react' import { CheckCircle2Icon, ShieldCheckIcon } from 'lucide-react' import type { BoundCampaignInviteFormAction, CampaignInviteFormState, } from '@/app/(campaign)/campanha/convite/[token]/formActions' import { Alert, AlertDescription, AlertTitle } from '@/components/ui/Alert' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Checkbox } from '@/components/ui/Checkbox' import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, } from '@/components/ui/field' import { Input } from '@/components/ui/input' import { NativeSelect, NativeSelectOption } from '@/components/ui/native-select' import { Spinner } from '@/components/ui/Spinner' import { Textarea } from '@/components/ui/textarea' import { leadershipGenderLabels, leadershipSectorLabels } from '@/utilities/leadershipUi' type CampaignInviteProfile = { name: string phone: string email: string | null gender: keyof typeof leadershipGenderLabels | null sector: keyof typeof leadershipSectorLabels | null | undefined sectorNotes: string | null } const genderOptions = Object.entries(leadershipGenderLabels) as Array< [NonNullable, string] > const sectorOptions = Object.entries(leadershipSectorLabels) as Array< [NonNullable, string] > const firstError = (state: CampaignInviteFormState, field: string) => state.fieldErrors?.[field]?.[0] const CampaignInviteFeedback = ({ state }: { state: CampaignInviteFormState }) => { if (!state.message || state.status === 'success') return null return ( Não foi possível confirmar {state.message} ) } const ConsentField = ({ children, error, }: { children: ReactNode error?: string }) => (

Leia o texto e confirme somente se estiver de acordo.{' '} Ler o texto completo

Li e concordo com o texto de consentimento * Você confirma os próprios dados enviados neste formulário. {error ? {error} : null}
) const ProfileFields = ({ preview, state, }: { preview: { profile: CampaignInviteProfile } state: CampaignInviteFormState }) => { const { profile } = preview return ( Nome * {firstError(state, 'name') ? ( {firstError(state, 'name')} ) : null} Celular (WhatsApp) * {firstError(state, 'phone') ? ( {firstError(state, 'phone')} ) : null} E-mail (opcional) {firstError(state, 'email') ? ( {firstError(state, 'email')} ) : null}
Gênero Não informar {genderOptions.map(([value, label]) => ( {label} ))} {firstError(state, 'gender') ? ( {firstError(state, 'gender')} ) : null} Setor Não informar {sectorOptions.map(([value, label]) => ( {label} ))} {firstError(state, 'sector') ? ( {firstError(state, 'sector')} ) : null}
Como você atua nesse setor? (opcional)