All files / app/src/entities/nomenclature/model mutate-warehouse-contract-nomenclatuer-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 281x                   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,
  queryUpdateWarehouseContractNomenclature,
  WAREHOUSE_CONTRACT_NOMENCLATURES_SINGLE_PRIMARY_KEY,
  WarehouseContractNomenclature,
} from '@/entities/nomenclature'
import { BaseWarehouseEdit } from '@/entities/warehouse'
 
export const useMutateWarehouseContractNomenclature = (
  options?: Omit<
    UseMutationOptions<Nomenclature, AxiosError, BaseWarehouseEdit & { data: WarehouseContractNomenclature }>,
    'mutationFn'
  >,
  config?: AxiosRequestConfig
) => {
  return useMutation(
    ({ id, data, warehouseId, contractId }) => {
      return queryUpdateWarehouseContractNomenclature({ warehouseId, contractId, id })({ ...config, data })()
    },
    {
      ...options,
      mutationKey: WAREHOUSE_CONTRACT_NOMENCLATURES_SINGLE_PRIMARY_KEY,
    }
  )
}