import { useMutation, useQueryClient } from '@tanstack/react-query'
import { updateSeccion } from '../api/updateSeccion'
import type { UpdateSeccionRequest } from '../types'

export function useUpdateSeccion(id: number) {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: (payload: UpdateSeccionRequest) => updateSeccion(id, payload),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['secciones'] })
    },
  })
}
