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')),
|
.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 = {
|
type MoveRubroFormRaw = {
|
||||||
nuevoParentId: string
|
nuevoParentId: string
|
||||||
nuevoOrden: 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 = {
|
type MoveRubroFormOutput = {
|
||||||
nuevoParentId: number | null
|
nuevoParentId: number | null
|
||||||
nuevoOrden: number
|
nuevoOrden: number
|
||||||
@@ -152,8 +153,7 @@ export function MoveRubroDialog({
|
|||||||
if (!rubro) return
|
if (!rubro) return
|
||||||
setBackendError(null)
|
setBackendError(null)
|
||||||
|
|
||||||
const nuevoParentId = data.nuevoParentId
|
const { nuevoParentId, nuevoOrden } = data
|
||||||
const nuevoOrden = data.nuevoOrden
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await mutateAsync({ id: rubro.id, data: { nuevoParentId, nuevoOrden } })
|
await mutateAsync({ id: rubro.id, data: { nuevoParentId, nuevoOrden } })
|
||||||
@@ -183,7 +183,13 @@ export function MoveRubroDialog({
|
|||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<Form {...form}>
|
<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 && (
|
{backendError && (
|
||||||
<Alert variant="destructive">
|
<Alert variant="destructive">
|
||||||
<AlertCircle className="h-4 w-4" />
|
<AlertCircle className="h-4 w-4" />
|
||||||
|
|||||||
Reference in New Issue
Block a user