All files / app/src/entities/bush/model get-bushes-collection-query.ts

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

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 251x           1x 4x 4x 4x 4x 4x 4x   1x 4x 4x 4x 4x 4x 4x 4x 4x 4x  
import { QueryParams, queryFactory } from '@/shared/lib'
import { Bush, GET_BUSH_COLLECTION_PRIMARY_KEY } from '../lib'
import { queryGetBushesById } from './requests'
import { useRouter } from 'next/router'
import { CollectionResponse } from '@/shared/@types'
 
const bushesByIdQuery = (id: string) =>
  queryFactory(
    GET_BUSH_COLLECTION_PRIMARY_KEY,
    queryGetBushesById(id)
  )(filters => ({
    params: filters,
  }))
 
export const useBushesById = (id: string, params?: QueryParams<CollectionResponse<Bush>>) => {
  const { locale } = useRouter()
  return bushesByIdQuery(id).useHookInitializer({
    ...params,
    filters: {
      locale,
      ...params?.filters,
    },
  })
}