mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-25 11:13:09 +00:00
react-audit(família 2): view model mínimo cruza o fio RSC — PetitionForm.tsx:29 deixa de receber o doc Petition inteiro (richText/consent/tracking ficam no server)
This commit is contained in:
parent
e273e9ecfa
commit
34c04d6966
3 changed files with 16 additions and 4 deletions
|
|
@ -237,7 +237,11 @@ export default async function Page({ params }: { params: Promise<{ id: string }>
|
||||||
<div className="rounded-xl border border-border bg-card p-5 text-card-foreground shadow-[0_24px_60px_rgb(122_25_18/0.12)] sm:p-7">
|
<div className="rounded-xl border border-border bg-card p-5 text-card-foreground shadow-[0_24px_60px_rgb(122_25_18/0.12)] sm:p-7">
|
||||||
<PetitionForm
|
<PetitionForm
|
||||||
id="formulario"
|
id="formulario"
|
||||||
petition={petition}
|
petition={{
|
||||||
|
id: petition.id,
|
||||||
|
title: petition.title,
|
||||||
|
form: { title: petition.form.title, subtitle: petition.form.subtitle },
|
||||||
|
}}
|
||||||
consentHTML={consentHTML}
|
consentHTML={consentHTML}
|
||||||
facebookPixelId={facebookPixelId ?? undefined}
|
facebookPixelId={facebookPixelId ?? undefined}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import {
|
||||||
} from '@/components/ui/field'
|
} from '@/components/ui/field'
|
||||||
import { trackMetaLead } from '@/lib/facebookPixel'
|
import { trackMetaLead } from '@/lib/facebookPixel'
|
||||||
import { petitionFormSchema, type PetitionFormInput } from '@/lib/schemas/petition-form'
|
import { petitionFormSchema, type PetitionFormInput } from '@/lib/schemas/petition-form'
|
||||||
import { Petition } from '@/payload-types'
|
|
||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
import { useState, useTransition } from 'react'
|
import { useState, useTransition } from 'react'
|
||||||
import { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'
|
import { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'
|
||||||
|
|
@ -26,9 +25,18 @@ import { StateSelect } from './StateSelect'
|
||||||
import { Button } from './ui/button'
|
import { Button } from './ui/button'
|
||||||
import { Textarea } from './ui/textarea'
|
import { Textarea } from './ui/textarea'
|
||||||
|
|
||||||
|
// View model — the server page selects only the fields this form renders, so
|
||||||
|
// the full petition document (body richText, consent relation, tracking,
|
||||||
|
// timestamps) never crosses the RSC wire into this client component.
|
||||||
|
type PetitionFormPetition = {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
form: { title?: string | null; subtitle?: string | null }
|
||||||
|
}
|
||||||
|
|
||||||
interface PetitionFormProps {
|
interface PetitionFormProps {
|
||||||
id: string
|
id: string
|
||||||
petition: Petition
|
petition: PetitionFormPetition
|
||||||
consentHTML: string
|
consentHTML: string
|
||||||
facebookPixelId?: string
|
facebookPixelId?: string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ vi.mock('@/lib/facebookPixel', async (importOriginal) => {
|
||||||
const PIXEL_ID = '123456789012345'
|
const PIXEL_ID = '123456789012345'
|
||||||
|
|
||||||
const petition = {
|
const petition = {
|
||||||
id: 1,
|
id: '1',
|
||||||
title: 'Pela manutenção do Hospital do Subúrbio',
|
title: 'Pela manutenção do Hospital do Subúrbio',
|
||||||
form: { title: 'Assine a petição', subtitle: '' },
|
form: { title: 'Assine a petição', subtitle: '' },
|
||||||
} as unknown as Petition
|
} as unknown as Petition
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue