All files / app/src/entities/nomenclature/model nomenclature-requests.ts

45% Statements 27/60
100% Branches 2/2
40% Functions 2/5
45% Lines 27/60

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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 881x                                         1x 1x 1x   1x 1x 1x 1x 1x 1x   1x 1x 1x   1x 9x 9x 9x   1x 9x 9x 9x   1x 1x 1x 1x                     1x                           1x                          
import { getSingleRequestTarget, queryFetchFactory } from '@/shared/lib'
import { CollectionResponse } from '@/shared/@types'
import {
  NomenclatureConnection,
  NomenclatureDiameter,
  NomenclatureSide,
  NomenclatureStrengthGroup,
  NOMENCLATURE_CONNECTIONS_REQUEST_TARGET,
  NOMENCLATURE_DIAMETERS_BY_CONNECTIONS_REQUEST_TARGET,
  NOMENCLATURE_SIDES_BY_DIAMETER_REQUEST_TARGET,
  NOMENCLATURE_STRENGTH_GROUPS_REQUEST_TARGET,
  NOMENCLATURE_DIAMETERS_COLLECTIONS_TARGET,
  NOMENCLATURE_SIDES_COLLECTIONS_TARGET,
  NomenclatureProductionStandart,
  NOMENCLATURE_PRODUCTION_STANDARDS_COLLECTIONS_TARGET,
  Nomenclature,
  WAREHOUSE_CONTRACT_NOMENCLATURES_REQUEST_TARGET,
  WAREHOUSE_CONTRACT_NOMENCLATURES_SINGLE_REQUEST_TARGET,
} from '../lib'
import { BaseWarehouseEdit } from '@/entities/warehouse'
 
export const queryFetchConnections = queryFetchFactory<CollectionResponse<NomenclatureConnection>>(
  NOMENCLATURE_CONNECTIONS_REQUEST_TARGET
)
 
export const queryFetchDiameters = queryFetchFactory<CollectionResponse<NomenclatureDiameter>>(
  NOMENCLATURE_DIAMETERS_COLLECTIONS_TARGET
)
export const queryFetchProductsStandards = queryFetchFactory<CollectionResponse<NomenclatureProductionStandart>>(
  NOMENCLATURE_PRODUCTION_STANDARDS_COLLECTIONS_TARGET
)
 
export const queryFetchSides = queryFetchFactory<CollectionResponse<NomenclatureSide>>(
  NOMENCLATURE_SIDES_COLLECTIONS_TARGET
)
 
export const queryFetchDiametersByConnection = (id: string) =>
  queryFetchFactory<CollectionResponse<NomenclatureDiameter>>(
    getSingleRequestTarget(id, NOMENCLATURE_DIAMETERS_BY_CONNECTIONS_REQUEST_TARGET)
  )
 
export const queryFetchSidesByDiameter = (id: string) =>
  queryFetchFactory<CollectionResponse<NomenclatureSide>>(
    getSingleRequestTarget(id, NOMENCLATURE_SIDES_BY_DIAMETER_REQUEST_TARGET)
  )
 
export const queryFetchStrengthGroups = queryFetchFactory<CollectionResponse<NomenclatureStrengthGroup>>(
  NOMENCLATURE_STRENGTH_GROUPS_REQUEST_TARGET
)
export const queryCreateWarehouseContractNomenclature = (data: BaseWarehouseEdit) =>
  queryFetchFactory<Nomenclature>(
    WAREHOUSE_CONTRACT_NOMENCLATURES_REQUEST_TARGET.replace(':warehouseId', data.warehouseId).replace(
      ':contractId',
      data.contractId
    ),
    {
      method: 'POST',
    }
  )
 
export const queryUpdateWarehouseContractNomenclature = (data: BaseWarehouseEdit) =>
  queryFetchFactory<Nomenclature>(
    getSingleRequestTarget(
      data.id as string,
      WAREHOUSE_CONTRACT_NOMENCLATURES_SINGLE_REQUEST_TARGET.replace(':warehouseId', data.warehouseId).replace(
        ':contractId',
        data.contractId
      )
    ),
    {
      method: 'PATCH',
    }
  )
 
export const queryDeleteWarehouseContractNomenclature = (data: BaseWarehouseEdit) =>
  queryFetchFactory<Nomenclature>(
    getSingleRequestTarget(
      data.id as string,
      WAREHOUSE_CONTRACT_NOMENCLATURES_SINGLE_REQUEST_TARGET.replace(':warehouseId', data.warehouseId).replace(
        ':contractId',
        data.contractId
      )
    ),
    {
      method: 'DELETE',
    }
  )