teqo/src/lib/schemas/campaignDemandInput.ts
Francisco Ignácio Fontoura Solla cf13c441aa Remodel /campanha around predefined Praças replacing electoral nuclei.
436 seeded Praças (municipality-based; per-TSE-zone in Salvador/Camaçari) become
the operational unit; roles renamed to coordinator/advisor/leader with advisors
scoped to administered Praças. Leadership is one record per person across many
Praças/organizations; vote pledges split leader-declared vs staff-estimated
(estimates never serialized to leaders). Adds organizations, demand workflow
with staff-only cost/receipts, action-plan results with deputy presence, manual
political trend, multi-candidate comparison and the diverging red/white/blue
map mode. Migration 20260721_020109_remodel_plazas deliberately resets the
campaign vertical in production (public site untouched); test suite ported to
the new model (unit 187 / int 306 / e2e 9 green).
2026-07-21 02:28:00 -03:00

41 lines
1.5 KiB
TypeScript

import { z } from 'zod'
import { campaignDemandKinds, campaignDemandStatuses } from '@/lib/schemas/campaignDemand'
import {
positiveRelationshipId,
trimmedNullableText,
trimmedOptionalText,
} from '@/lib/schemas/primitives'
export const campaignDemandCreateSchema = z.object({
title: z.string().trim().min(2).max(160),
kind: z.enum(campaignDemandKinds),
description: trimmedOptionalText(4000),
plaza: positiveRelationshipId,
actionPlan: positiveRelationshipId.optional(),
/** Staff may record on behalf of a leadership; leaders get their own. */
leadership: positiveRelationshipId.optional(),
})
export const campaignDemandDetailsUpdateSchema = z.object({
id: positiveRelationshipId,
kind: z.enum(campaignDemandKinds).optional(),
description: trimmedNullableText(4000),
actionPlan: positiveRelationshipId.nullable().optional(),
})
export const campaignDemandTransitionSchema = z.object({
id: positiveRelationshipId,
status: z.enum(campaignDemandStatuses),
decisionNote: trimmedNullableText(2000),
})
export const campaignDemandCostSchema = z.object({
id: positiveRelationshipId,
cost: z.number().min(0).max(100_000_000).nullable(),
})
export type CampaignDemandCreateInput = z.input<typeof campaignDemandCreateSchema>
export type CampaignDemandDetailsUpdateInput = z.input<typeof campaignDemandDetailsUpdateSchema>
export type CampaignDemandTransitionInput = z.input<typeof campaignDemandTransitionSchema>
export type CampaignDemandCostInput = z.input<typeof campaignDemandCostSchema>