File tree Expand file tree Collapse file tree 3 files changed +17
-19
lines changed
components/HomeWithPosition Expand file tree Collapse file tree 3 files changed +17
-19
lines changed Original file line number Diff line number Diff line change @@ -3,28 +3,14 @@ import KakaoMap from '@/pages/Home/components/KakaoMap';
33import PlaceList from '@/pages/Home/components/PlaceList' ;
44import { PlaceListSkeleton } from '@/pages/Home/components/PlaceList/PlaceListSkeleton' ;
55import { usePlacesQuery } from '@/pages/Home/hooks/usePlacesQuery' ;
6- import { useQueryParamsStore } from '@/pages/Home/hooks/useQueryParamsStore' ;
76import styles from '../../index.module.scss' ;
87
98interface HomeWithPositionProps {
109 position : PositionType ;
1110}
1211
1312export const HomeWithPosition = ( { position } : HomeWithPositionProps ) => {
14- const [ pickPoint , radius_KM , numOfPlaces ] = useQueryParamsStore ( state => [
15- state . pickPoint ,
16- state . radius_KM ,
17- state . numOfPlaces
18- ] ) ;
19- const { data : places , isLoading } = usePlacesQuery (
20- {
21- numOfRows : numOfPlaces ,
22- mapX : pickPoint ? pickPoint . lon : position ?. lon ,
23- mapY : pickPoint ? pickPoint . lat : position ?. lat ,
24- radius : radius_KM * 1000
25- } ,
26- position
27- ) ;
13+ const { data : places , isLoading } = usePlacesQuery ( position ) ;
2814 return (
2915 < >
3016 < KakaoMap position = { position } places = { places } isLoading = { isLoading } />
Original file line number Diff line number Diff line change @@ -4,10 +4,22 @@ import { PlaceParams, PlaceType } from '@/pages/Home/types';
44import { getPlaces } from '@/query/queryFn' ;
55import queryKeys from '@/query/queryKeys' ;
66import { PositionType } from '@/pages/Home' ;
7+ import { useQueryParamsStore } from '@/pages/Home/hooks/useQueryParamsStore' ;
8+
9+ export const usePlacesQuery = ( position : PositionType ) => {
10+ const [ pickPoint , radius_KM , numOfPlaces ] = useQueryParamsStore ( state => [
11+ state . pickPoint ,
12+ state . radius_KM ,
13+ state . numOfPlaces
14+ ] ) ;
15+
16+ const placeParams : PlaceParams = {
17+ numOfRows : numOfPlaces ,
18+ mapX : pickPoint ? pickPoint . lon : position ?. lon ,
19+ mapY : pickPoint ? pickPoint . lat : position ?. lat ,
20+ radius : radius_KM * 1000
21+ } ;
722
8- export const usePlacesQuery = ( placeParams : PlaceParams , position : PositionType ) => {
9- //! TODO 여기에서 useQueryParamsStore 호출? 고민해보기
10- // const [pickPoint, radius_KM, numOfPlaces] = useQueryParamsStore(state => [..])
1123 const query = useQuery ( {
1224 queryKey : queryKeys . PLACES ( placeParams ) ,
1325 queryFn : async ( ) => await getPlaces ( placeParams ) ,
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { PlaceType } from '@/pages/Home/types';
77import { renderAppWithRouterMatch } from '@/utils/test/renderWidthQuery' ;
88import { fireEvent , render , screen } from '@testing-library/react' ;
99
10- describe ( '위치를 모를ㅎ때 ' , ( ) => {
10+ describe ( '위치를 모를때 ' , ( ) => {
1111 test ( "위치추적 안되었을때 '현재 위치를 받아오고 있다는 문구' 노출" , ( ) => {
1212 render ( renderAppWithRouterMatch ( < Home /> ) ) ;
1313 const loadingTextForGettingPosition = screen . getByText ( '현재 위치를 받아오고 있습니다.' ) ;
You can’t perform that action at this time.
0 commit comments