Skip to content

Commit

Permalink
fix: kakao shop index correction
Browse files Browse the repository at this point in the history
  • Loading branch information
halfmoon-mind committed Sep 1, 2023
1 parent e1fb0b3 commit 7fcfe21
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/component/ShopPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,18 @@ const ShopPost = ({userId, category, setStoreName}) => {
}
const response = await fetchKakaoShops(shopTitle, category);
setKakaoShops(response.data['documents']);
setLatitude(response.data['documents'][0].y);
setLongitude(response.data['documents'][0].x);
setPhoneNumber(response.data['documents'][0].phone);
setPlaceUrl(response.data['documents'][0].place_url);
if (response.data['documents'].length == 0) return;
setSelectedShopIndex(0);
};

React.useEffect(() => {
if (kakaoShops.length == 0) return;
setLatitude(kakaoShops[selectedShopIndex].y);
setLongitude(kakaoShops[selectedShopIndex].x);
setPhoneNumber(kakaoShops[selectedShopIndex].phone);
setPlaceUrl(kakaoShops[selectedShopIndex].place_url);
}, [selectedShopIndex]);

React.useEffect(() => {
searchKakaoShops();
}, [shopTitle]);
Expand Down

0 comments on commit 7fcfe21

Please sign in to comment.