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

export function useCreateProductType() {
  const queryClient = useQueryClient()
  return useMutation({
    mutationFn: (payload: CreateProductTypeRequest) => createProductType(payload),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['product-types'] })
    },
  })
}
