mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-14 08:53:11 +00:00
Adds electoral nuclei, leaderships, updates, and WhatsApp invite flows behind campaign auth, plus the consolidated schema migration that Vercel applies on deploy.
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import { nucleusUpdateSchema, type NucleusUpdateInput } from '@/lib/schemas/nucleus'
|
|
import {
|
|
boundedJsonFormValue,
|
|
checkboxFormValue,
|
|
nullableFormText,
|
|
nullableRelationshipFormValue,
|
|
requiredRelationshipFormValue,
|
|
} from '@/lib/formData'
|
|
|
|
export const parseNucleusIntelligenceFormData = (formData: FormData): NucleusUpdateInput => {
|
|
const hasTicketAlliance = ['partnerName', 'office', 'isCampaignPartner', 'allianceNotes'].some(
|
|
(field) => formData.has(field),
|
|
)
|
|
|
|
return nucleusUpdateSchema.parse({
|
|
id: requiredRelationshipFormValue(formData, 'nucleus'),
|
|
strengths: boundedJsonFormValue(formData, 'strengths', 100_000),
|
|
risks: boundedJsonFormValue(formData, 'risks', 100_000),
|
|
voterProfiles: boundedJsonFormValue(formData, 'voterProfiles', 100_000),
|
|
primaryContact: nullableRelationshipFormValue(formData, 'primaryContact'),
|
|
ticketAlliance: hasTicketAlliance
|
|
? {
|
|
partnerName: nullableFormText(formData, 'partnerName'),
|
|
office: nullableFormText(formData, 'office'),
|
|
isCampaignPartner: checkboxFormValue(formData, 'isCampaignPartner'),
|
|
notes: nullableFormText(formData, 'allianceNotes'),
|
|
}
|
|
: undefined,
|
|
})
|
|
}
|