From cab14332f9ba75fbd5de2285ec90a691f1f2af61 Mon Sep 17 00:00:00 2001 From: "euncho.kang" Date: Wed, 20 Dec 2023 16:31:42 +0900 Subject: [PATCH 1/6] feat: change API address and reformat type annotation --- src/apis/api/getPoll.tsx | 8 ++++++-- src/apis/api/getRestaurantInfo.tsx | 12 ++++++++++++ src/apis/api/getResult.tsx | 10 +++++++--- src/apis/api/postRandomListApi.tsx | 2 +- src/apis/api/postResuggestOneApi.tsx | 10 +++++----- src/apis/api/postRetryApi.tsx | 8 ++++++-- src/apis/api/postVoteApi.tsx | 2 +- src/apis/query/useGetResult.tsx | 4 ++-- src/apis/query/useGetRoom.tsx | 2 +- src/components/common/MenuCard/MenuCard.styled.ts | 2 +- src/components/common/MenuCard/MenuCard.tsx | 2 +- src/pages/RandomList/RandomList.tsx | 6 +++--- src/recoil/roomIdData.ts | 2 +- 13 files changed, 47 insertions(+), 23 deletions(-) create mode 100644 src/apis/api/getRestaurantInfo.tsx diff --git a/src/apis/api/getPoll.tsx b/src/apis/api/getPoll.tsx index 9681d99..787e31b 100644 --- a/src/apis/api/getPoll.tsx +++ b/src/apis/api/getPoll.tsx @@ -1,7 +1,11 @@ import { axiosInstance } from 'apis/base/instance'; -const getPoll = async (roomId: string | undefined) => { - const response = await axiosInstance.get(`/${roomId}`); +interface PollParams { + roomId: string | undefined; +} + +const getPoll = async ({ roomId }: PollParams) => { + const response = await axiosInstance.get(`/api/v1/${roomId}`); return response; }; diff --git a/src/apis/api/getRestaurantInfo.tsx b/src/apis/api/getRestaurantInfo.tsx new file mode 100644 index 0000000..93343d6 --- /dev/null +++ b/src/apis/api/getRestaurantInfo.tsx @@ -0,0 +1,12 @@ +import { axiosInstance } from 'apis/base/instance'; + +interface RestaurantInfoParams { + restaurantId: string; +} + +const getRestaurantInfo = async ({ restaurantId }: RestaurantInfoParams) => { + const response = await axiosInstance.get(`/api/v1/${restaurantId}`); + return response; +}; + +export default getRestaurantInfo; diff --git a/src/apis/api/getResult.tsx b/src/apis/api/getResult.tsx index 45076b2..999e26d 100644 --- a/src/apis/api/getResult.tsx +++ b/src/apis/api/getResult.tsx @@ -1,8 +1,12 @@ import { axiosInstance } from 'apis/base/instance'; -const getResult = async (roomId: string | any) => { - const response = await axiosInstance.get(`/${roomId}/result`); +interface ResultParams { + roomId: string | undefined; +} + +const getResult = async ({ roomId }: ResultParams) => { + const response = await axiosInstance.get(`/api/v1/${roomId}/result`); return response; }; -export { getResult }; +export default getResult; diff --git a/src/apis/api/postRandomListApi.tsx b/src/apis/api/postRandomListApi.tsx index 5d0e53b..a89bf04 100644 --- a/src/apis/api/postRandomListApi.tsx +++ b/src/apis/api/postRandomListApi.tsx @@ -6,7 +6,7 @@ interface RandomListApiParams { } const postRandomListApi = async ({ longitude, latitude }: RandomListApiParams) => { - const response = await axiosInstance.post('/create', { + const response = await axiosInstance.post('/api/v1/create', { longitude, latitude, }); diff --git a/src/apis/api/postResuggestOneApi.tsx b/src/apis/api/postResuggestOneApi.tsx index b59f20e..c328b70 100644 --- a/src/apis/api/postResuggestOneApi.tsx +++ b/src/apis/api/postResuggestOneApi.tsx @@ -1,12 +1,12 @@ import { axiosInstance } from 'apis/base/instance'; -interface ResuggestProps { - roomId: number; - restaurantId: number; +interface ResuggestParams { + roomId: string; + restaurantId: string; } -const postResuggestOneApi = async ({ roomId, restaurantId }: ResuggestProps) => { - const response = await axiosInstance.post(`/${roomId}/resuggest/${restaurantId}`); +const postResuggestOneApi = async ({ roomId, restaurantId }: ResuggestParams) => { + const response = await axiosInstance.post(`/api/v1/${roomId}/resuggest/${restaurantId}`); return response.data; }; diff --git a/src/apis/api/postRetryApi.tsx b/src/apis/api/postRetryApi.tsx index 97c02ba..26c22a1 100644 --- a/src/apis/api/postRetryApi.tsx +++ b/src/apis/api/postRetryApi.tsx @@ -1,7 +1,11 @@ import { axiosInstance } from 'apis/base/instance'; -const postRetryApi = async (roomId: number) => { - const response = await axiosInstance.post(`/retry/${roomId}`); +interface RetryApiParams { + roomId: string; +} + +const postRetryApi = async ({ roomId }: RetryApiParams) => { + const response = await axiosInstance.post(`/api/v1/retry/${roomId}`); return response.data; }; diff --git a/src/apis/api/postVoteApi.tsx b/src/apis/api/postVoteApi.tsx index f48a40a..92e7228 100644 --- a/src/apis/api/postVoteApi.tsx +++ b/src/apis/api/postVoteApi.tsx @@ -6,7 +6,7 @@ interface VoteApiParams { } const postVoteApi = async ({ roomId, voteList }: VoteApiParams) => { - const response = await axiosInstance.post(`${roomId}/vote`, { restaurantIdList: voteList }); + const response = await axiosInstance.post(`/api/v1${roomId}/vote`, { restaurantIdList: voteList }); return response.data; }; diff --git a/src/apis/query/useGetResult.tsx b/src/apis/query/useGetResult.tsx index 8582fec..ec07f2e 100644 --- a/src/apis/query/useGetResult.tsx +++ b/src/apis/query/useGetResult.tsx @@ -1,6 +1,6 @@ import { useRef } from 'react'; import { useQuery } from '@tanstack/react-query'; -import { getResult } from 'apis/api/getResult'; +import getResult from 'apis/api/getResult'; const useGetResult = (roomId: string | undefined) => { const isFirstRun = useRef(true); @@ -10,7 +10,7 @@ const useGetResult = (roomId: string | undefined) => { await new Promise((resolve) => setTimeout(resolve, 3000)); isFirstRun.current = false; } - return getResult(roomId); + return getResult({ roomId }); }; const { data: voteOverallResultData, refetch } = useQuery({ diff --git a/src/apis/query/useGetRoom.tsx b/src/apis/query/useGetRoom.tsx index 89fe215..e6172dc 100644 --- a/src/apis/query/useGetRoom.tsx +++ b/src/apis/query/useGetRoom.tsx @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query'; import getPoll from 'apis/api/getPoll'; export const useGetRoom = (roomId: string | undefined) => { - const { data, isLoading, isError } = useQuery({ queryKey: ['room', roomId], queryFn: () => getPoll(roomId) }); + const { data, isLoading, isError } = useQuery({ queryKey: ['room', roomId], queryFn: () => getPoll({ roomId }) }); return { data, diff --git a/src/components/common/MenuCard/MenuCard.styled.ts b/src/components/common/MenuCard/MenuCard.styled.ts index 65424b8..a3a2146 100644 --- a/src/components/common/MenuCard/MenuCard.styled.ts +++ b/src/components/common/MenuCard/MenuCard.styled.ts @@ -21,7 +21,7 @@ export const RestaurantName = styled.strong` font-size: var(--md); `; -export const RestaurantLink = styled.img` +export const RestaurantLinkImg = styled.img` display: inline-block; `; diff --git a/src/components/common/MenuCard/MenuCard.tsx b/src/components/common/MenuCard/MenuCard.tsx index e7da8a3..395d07c 100644 --- a/src/components/common/MenuCard/MenuCard.tsx +++ b/src/components/common/MenuCard/MenuCard.tsx @@ -59,7 +59,7 @@ const MenuCard = (props: MenuCardProps) => {
{title} - + {categories.map((category, i) => ( diff --git a/src/pages/RandomList/RandomList.tsx b/src/pages/RandomList/RandomList.tsx index 546fbe7..2d1133c 100644 --- a/src/pages/RandomList/RandomList.tsx +++ b/src/pages/RandomList/RandomList.tsx @@ -46,7 +46,7 @@ const RandomList = () => { category: 'click', action: '투표공유하기_버튼', label: '음식점 추천 화면', - value: roomId, + value: Number(roomId), }); } navigate(`/random-menu/${roomId}`); @@ -58,7 +58,7 @@ const RandomList = () => { setIsAlertModalOn(false); }; - const handleClick = (restaurantId: number, index: number) => { + const handleClick = (restaurantId: string, index: number) => { ReactGA.event({ category: 'click', action: '마이너스_버튼', @@ -91,7 +91,7 @@ const RandomList = () => { label: '음식점 추천 화면', }); if (roomId) { - retryMutate(roomId, { onSuccess: retryOnSuccess }); + retryMutate({ roomId }, { onSuccess: retryOnSuccess }); } }; diff --git a/src/recoil/roomIdData.ts b/src/recoil/roomIdData.ts index 5bde07a..488763f 100644 --- a/src/recoil/roomIdData.ts +++ b/src/recoil/roomIdData.ts @@ -6,7 +6,7 @@ const { persistAtom } = recoilPersist({ storage: sessionStorage, }); -export const roomIdData = atom({ +export const roomIdData = atom({ key: 'roomIdData', default: null, effects_UNSTABLE: [persistAtom], From e70b3fdba7728b9eaeeeddb27fa636e742eee4db Mon Sep 17 00:00:00 2001 From: "euncho.kang" Date: Mon, 25 Dec 2023 14:42:06 +0900 Subject: [PATCH 2/6] fix: fix wrong api connection in postRetryApi --- src/apis/api/postRetryApi.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/api/postRetryApi.tsx b/src/apis/api/postRetryApi.tsx index 26c22a1..3c67e58 100644 --- a/src/apis/api/postRetryApi.tsx +++ b/src/apis/api/postRetryApi.tsx @@ -5,7 +5,7 @@ interface RetryApiParams { } const postRetryApi = async ({ roomId }: RetryApiParams) => { - const response = await axiosInstance.post(`/api/v1/retry/${roomId}`); + const response = await axiosInstance.post(`/api/v1/resuggest/${roomId}`); return response.data; }; From 0f757020b90786a60e2804311d89a4a199b8a63d Mon Sep 17 00:00:00 2001 From: "euncho.kang" Date: Mon, 25 Dec 2023 15:12:53 +0900 Subject: [PATCH 3/6] fix: fix error when resuggest one restaurant --- src/pages/RandomList/RandomList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/RandomList/RandomList.tsx b/src/pages/RandomList/RandomList.tsx index 2d1133c..3e69bac 100644 --- a/src/pages/RandomList/RandomList.tsx +++ b/src/pages/RandomList/RandomList.tsx @@ -69,7 +69,7 @@ const RandomList = () => { if (prev) { const updatedList = [...prev]; updatedList.splice(index, 1); - updatedList.push(data); + updatedList.push(data.restaurantResList[4]); return updatedList; } return prev; From b310afa17b7285945d92f36c0e21b8326e3e165a Mon Sep 17 00:00:00 2001 From: "euncho.kang" Date: Mon, 25 Dec 2023 15:33:15 +0900 Subject: [PATCH 4/6] fix: fix postVoteApi address --- src/apis/api/postVoteApi.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/api/postVoteApi.tsx b/src/apis/api/postVoteApi.tsx index 92e7228..edcb49c 100644 --- a/src/apis/api/postVoteApi.tsx +++ b/src/apis/api/postVoteApi.tsx @@ -6,7 +6,7 @@ interface VoteApiParams { } const postVoteApi = async ({ roomId, voteList }: VoteApiParams) => { - const response = await axiosInstance.post(`/api/v1${roomId}/vote`, { restaurantIdList: voteList }); + const response = await axiosInstance.post(`/api/v1/${roomId}/vote`, { restaurantIdList: voteList }); return response.data; }; From c797662dd56aba892fea6916bc1dd8fb0dfbb270 Mon Sep 17 00:00:00 2001 From: "euncho.kang" Date: Mon, 25 Dec 2023 16:07:27 +0900 Subject: [PATCH 5/6] style: fix retryFromScratch button position --- .../OverallRanking/OverallRanking.styled.ts | 8 ++------ src/pages/OverallRanking/OverallRanking.tsx | 16 +++++++--------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/pages/OverallRanking/OverallRanking.styled.ts b/src/pages/OverallRanking/OverallRanking.styled.ts index a20fb19..966d99b 100644 --- a/src/pages/OverallRanking/OverallRanking.styled.ts +++ b/src/pages/OverallRanking/OverallRanking.styled.ts @@ -10,8 +10,9 @@ export const OverallRankingWrapper = styled.div` padding: 45px 19px 43px; display: flex; flex-direction: column; - height: 100%; + justify-content: space-between; gap: 25px; + height: 100vh; .page-title { margin-bottom: 3px; @@ -97,7 +98,6 @@ export const Distance = styled.p` export const ButtonLayout = styled.div` display: flex; flex-direction: column; - height: 100%; flex-grow: 1; `; @@ -115,7 +115,3 @@ export const ButtonShare = styled.button` vertical-align: bottom; } `; - -export const RetryButtonLayout = styled.div` - margin-top: 12px; -`; diff --git a/src/pages/OverallRanking/OverallRanking.tsx b/src/pages/OverallRanking/OverallRanking.tsx index 05fcbc9..837ee3c 100644 --- a/src/pages/OverallRanking/OverallRanking.tsx +++ b/src/pages/OverallRanking/OverallRanking.tsx @@ -103,16 +103,14 @@ function OverallRanking() { ))} - - - share result icon - 공유하기 - - - - - + + share result icon + 공유하기 + + + + {/* 모달은 포탈 써서 전역으로 나중에 바꿀게요!! */} From 48dd3938ff89b68093321e54641e8cb2a9cb0697 Mon Sep 17 00:00:00 2001 From: "euncho.kang" Date: Mon, 25 Dec 2023 17:38:08 +0900 Subject: [PATCH 6/6] remove: remove unnecessary API file --- src/apis/api/getRestaurantInfo.tsx | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 src/apis/api/getRestaurantInfo.tsx diff --git a/src/apis/api/getRestaurantInfo.tsx b/src/apis/api/getRestaurantInfo.tsx deleted file mode 100644 index 93343d6..0000000 --- a/src/apis/api/getRestaurantInfo.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { axiosInstance } from 'apis/base/instance'; - -interface RestaurantInfoParams { - restaurantId: string; -} - -const getRestaurantInfo = async ({ restaurantId }: RestaurantInfoParams) => { - const response = await axiosInstance.get(`/api/v1/${restaurantId}`); - return response; -}; - -export default getRestaurantInfo;