mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-19 17:13:07 +00:00
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).
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
import { positiveRelationshipId, trimmedOptionalText } from '@/lib/schemas/primitives'
|
|
|
|
export const plazaUpdateKinds = ['semanal', 'urgente', 'nota'] as const
|
|
export type PlazaUpdateKind = (typeof plazaUpdateKinds)[number]
|
|
|
|
export const plazaUpdateKindLabels: Record<PlazaUpdateKind, string> = {
|
|
semanal: 'Semanal',
|
|
urgente: 'Urgente',
|
|
nota: 'Nota',
|
|
}
|
|
|
|
const optionalCount = z.number().int().min(0).max(1_000_000).optional()
|
|
|
|
export const plazaUpdateCreateSchema = z
|
|
.object({
|
|
plaza: positiveRelationshipId,
|
|
kind: z.enum(plazaUpdateKinds).default('semanal'),
|
|
worked: trimmedOptionalText(3000),
|
|
failed: trimmedOptionalText(3000),
|
|
needs: trimmedOptionalText(3000),
|
|
body: trimmedOptionalText(5000),
|
|
activeVolunteers: optionalCount,
|
|
newSupports: optionalCount,
|
|
})
|
|
.superRefine((data, context) => {
|
|
if (data.kind === 'semanal') {
|
|
if (!data.worked) {
|
|
context.addIssue({ code: 'custom', message: 'Informe o que funcionou.', path: ['worked'] })
|
|
}
|
|
if (!data.failed) {
|
|
context.addIssue({
|
|
code: 'custom',
|
|
message: 'Informe o que não funcionou.',
|
|
path: ['failed'],
|
|
})
|
|
}
|
|
if (!data.needs) {
|
|
context.addIssue({
|
|
code: 'custom',
|
|
message: 'Informe o que você precisa.',
|
|
path: ['needs'],
|
|
})
|
|
}
|
|
} else if (!data.body) {
|
|
context.addIssue({
|
|
code: 'custom',
|
|
message: 'Informe o texto da atualização.',
|
|
path: ['body'],
|
|
})
|
|
}
|
|
})
|
|
|
|
export type PlazaUpdateCreateInput = z.input<typeof plazaUpdateCreateSchema>
|