All files / app/src/entities/responsibility-person/model mutate-warehouse-contract-responsibility-person-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 341x                 1x 2x                     2x 2x 2x 2x     2x 2x 2x 2x 2x 2x  
import { useMutation, UseMutationOptions } from 'react-query'
import { AxiosError, AxiosRequestConfig } from 'axios'
import {
  queryUpdateWarehouseContractResponsibilityPerson,
  RESPONSIBILITY_PERSON_SINGLE_PRIMARY_KEY,
  ResponsibilityPerson,
} from '@/entities/responsibility-person'
import { BaseWarehouseEdit } from '@/entities/warehouse'
 
export const useMutateWarehouseContractResponsibilityPerson = (
  options?: Omit<
    UseMutationOptions<
      ResponsibilityPerson,
      AxiosError,
      BaseWarehouseEdit & {
        data: ResponsibilityPerson
        id: string
      }
    >,
    'mutationFn'
  >,
  config?: AxiosRequestConfig
) => {
  return useMutation(
    ({ id, data, warehouseId, contractId }) => {
      return queryUpdateWarehouseContractResponsibilityPerson(warehouseId, contractId, id)({ ...config, data })()
    },
    {
      ...options,
      mutationKey: RESPONSIBILITY_PERSON_SINGLE_PRIMARY_KEY,
    }
  )
}