All files / app/src/entities/nomenclature/model create-warehouse-contract-nomenclature-query.ts

86.66% Statements 13/15
100% Branches 1/1
50% Functions 1/2
86.66% Lines 13/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 351x                 1x 2x                       2x 2x 2x 2x     2x 2x 2x 2x 2x 2x  
import { useMutation, UseMutationOptions } from 'react-query'
import { AxiosError, AxiosRequestConfig } from 'axios'
import {
  Nomenclature,
  queryCreateWarehouseContractNomenclature,
  WAREHOUSE_CONTRACT_NOMENCLATURES_PRIMARY_KEY,
  WarehouseContractNomenclature,
} from '@/entities/nomenclature'
 
export const useCreateWarehouseContractNomenclature = (
  options?: Omit<
    UseMutationOptions<
      Nomenclature,
      AxiosError,
      {
        data: WarehouseContractNomenclature
        warehouseId: string
        contractId: string
      }
    >,
    'mutationFn'
  >,
  config?: AxiosRequestConfig
) => {
  return useMutation(
    ({ warehouseId, contractId, data }) => {
      return queryCreateWarehouseContractNomenclature({ warehouseId, contractId })({ ...config, data })()
    },
    {
      ...options,
      mutationKey: WAREHOUSE_CONTRACT_NOMENCLATURES_PRIMARY_KEY,
    }
  )
}