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

export function useCreateMedio() {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: (payload: CreateMedioRequest) => createMedio(payload),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['medios'] })
    },
  })
}
