fix(frontend): MoveRubroDialog type cast para zodResolver output (CAT-001)
This commit is contained in:
@@ -77,13 +77,14 @@ const moveRubroSchema = z.object({
|
||||
.pipe(z.number().int().min(0, 'El orden debe ser 0 o mayor')),
|
||||
})
|
||||
|
||||
// Raw form field types (what useForm sees before zod transforms)
|
||||
// Raw form field types (what useForm sees — strings before zod transforms).
|
||||
type MoveRubroFormRaw = {
|
||||
nuevoParentId: string
|
||||
nuevoOrden: string
|
||||
}
|
||||
|
||||
// Output type after zod transforms
|
||||
// Output type after zod transforms run (what handleSubmit receives at runtime
|
||||
// thanks to zodResolver). We type-cast to reconcile with SubmitHandler<Raw>.
|
||||
type MoveRubroFormOutput = {
|
||||
nuevoParentId: number | null
|
||||
nuevoOrden: number
|
||||
@@ -152,8 +153,7 @@ export function MoveRubroDialog({
|
||||
if (!rubro) return
|
||||
setBackendError(null)
|
||||
|
||||
const nuevoParentId = data.nuevoParentId
|
||||
const nuevoOrden = data.nuevoOrden
|
||||
const { nuevoParentId, nuevoOrden } = data
|
||||
|
||||
try {
|
||||
await mutateAsync({ id: rubro.id, data: { nuevoParentId, nuevoOrden } })
|
||||
@@ -183,7 +183,13 @@ export function MoveRubroDialog({
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4" noValidate>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(
|
||||
handleSubmit as unknown as Parameters<typeof form.handleSubmit>[0],
|
||||
)}
|
||||
className="space-y-4"
|
||||
noValidate
|
||||
>
|
||||
{backendError && (
|
||||
<Alert variant="destructive">
|
||||
<AlertCircle className="h-4 w-4" />
|
||||
|
||||
Reference in New Issue
Block a user