All files / app/src/entities/property/model get-property-by-id-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 241x         1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { queryFactory, QueryParams } from '@/shared/lib'
import { queryFetchPropertyById } from './requests'
import { Property, GET_PROPERTY_BY_ID_PRIMARY_KEY } from '../lib'
import { useRouter } from 'next/router'
 
const propertyByIdQuery = (id: string) =>
  queryFactory(
    GET_PROPERTY_BY_ID_PRIMARY_KEY,
    queryFetchPropertyById(id)
  )(filters => ({
    params: filters,
  }))
 
export const usePropertyById = (id: string, params?: QueryParams<Property>) => {
  const { locale } = useRouter()
  return propertyByIdQuery(id).useHookInitializer({
    ...params,
    filters: {
      locale,
      ...params?.filters,
    },
  })
}