All files / app/src/entities/nomenclature/model get-nomenclature-strength-groups-query.tsx

100% Statements 21/21
100% Branches 2/2
100% Functions 1/1
100% Lines 21/21

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 311x             1x   1x 1x 1x 1x 1x 9x 1x   1x 9x 9x 9x   9x 9x 9x 9x 9x 9x 9x 9x  
import { useRouter } from 'next/router'
import { queryFetchStrengthGroups } from './nomenclature-requests'
import { queryFactory, QueryParams } from '@/shared/lib'
import { CollectionResponse, Nullable } from '@/shared/@types'
import { SELECT_INITIAL_FILTERS } from '@/shared/config'
import { NomenclatureStrengthGroup, NOMENCLATURE_STRENGTH_GROUPS_PRIMARY_KEY } from '../lib'
 
const NOMENCLATURE_STRENGTH_GROUP_FILTERS = { ...SELECT_INITIAL_FILTERS, value: null as Nullable<string> }
 
const nomenclatureStrengthGroupsCollectionQuery = queryFactory(
  NOMENCLATURE_STRENGTH_GROUPS_PRIMARY_KEY,
  queryFetchStrengthGroups,
  NOMENCLATURE_STRENGTH_GROUP_FILTERS
)(filters => ({
  params: filters,
}))
 
export const useNomenclatureStrengthGroupsCollection = (
  params?: QueryParams<CollectionResponse<NomenclatureStrengthGroup>, typeof NOMENCLATURE_STRENGTH_GROUP_FILTERS>
) => {
  const { locale } = useRouter()
 
  return nomenclatureStrengthGroupsCollectionQuery.useHookInitializer({
    ...params,
    filters: {
      locale,
      ...params?.filters,
    },
  })
}