'use client' import { useActionState } from 'react' import { Alert, AlertDescription } from '@/components/ui/Alert' import { Button } from '@/components/ui/button' import { Field, FieldError, FieldLabel } from '@/components/ui/field' import { Input } from '@/components/ui/input' import { Spinner } from '@/components/ui/Spinner' import type { CampaignFormActionState } from '@/utilities/campaignFormActionError' import { fieldError } from '@/utilities/campaignFormFields' type PledgeEstimateFormProps = { pledgeID: number currentEstimatedVotes: number | null currentEstimateNote: string | null formAction: ( state: CampaignFormActionState, formData: FormData, ) => Promise } /** Staff-only inline estimate. The leader never sees these fields. */ export const PledgeEstimateForm = ({ pledgeID, currentEstimatedVotes, currentEstimateNote, formAction, }: PledgeEstimateFormProps) => { const [state, submitAction, isPending] = useActionState(formAction, {}) return (
Estimativa do assessor Justificativa
{fieldError(state.fieldErrors, 'estimatedVotes') ? ( {fieldError(state.fieldErrors, 'estimatedVotes')} ) : null} {state.message && state.status !== 'success' ? ( {state.message} ) : null}
) }