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

export function useUpdateMedio(id: number) {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: (payload: UpdateMedioRequest) => updateMedio(id, payload),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['medios'] })
    },
  })
}
