All files / app/src/entities/nomenclature/model get-nomenclature-sides-by-diameter-query.ts

100% Statements 26/26
100% Branches 3/3
100% Functions 2/2
100% Lines 26/26

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 361x             1x 1x 1x 1x   1x 9x 9x 9x 9x 9x 9x 9x   1x 9x 9x 9x 9x   9x 9x 9x 9x 9x 9x 9x 9x  
import { useRouter } from 'next/router'
import { queryFetchSidesByDiameter } from './nomenclature-requests'
import { queryFactory, QueryParams } from '@/shared/lib'
import { CollectionResponse, Nullable } from '@/shared/@types'
import { SELECT_INITIAL_FILTERS } from '@/shared/config'
import { NOMENCLATURE_SIDES_BY_DIAMETER_PRIMARY_KEY, NomenclatureSide } from '../lib'
 
const NOMENCLATURE_SIDE_BY_DIAMETER_QUERY_FILTERS = {
  ...SELECT_INITIAL_FILTERS,
  value: null as Nullable<string>,
}
 
const nomenclatureSidesByDiameterCollectionQuery = (id: string) =>
  queryFactory(
    NOMENCLATURE_SIDES_BY_DIAMETER_PRIMARY_KEY,
    queryFetchSidesByDiameter(id),
    NOMENCLATURE_SIDE_BY_DIAMETER_QUERY_FILTERS
  )(filters => ({
    params: filters,
  }))
 
export const useNomenclatureSidesByDiameterCollection = (
  id: string,
  params?: QueryParams<CollectionResponse<NomenclatureSide>, typeof NOMENCLATURE_SIDE_BY_DIAMETER_QUERY_FILTERS>
) => {
  const { locale } = useRouter()
 
  return nomenclatureSidesByDiameterCollectionQuery(id).useHookInitializer({
    ...params,
    filters: {
      locale,
      ...params?.filters,
    },
  })
}