Skip to content

Commit

Permalink
Merge pull request #68 from Bibumhada/feat/67-수정된-API로-변경
Browse files Browse the repository at this point in the history
수정된 API 연결
  • Loading branch information
cho7778 authored Dec 25, 2023
2 parents 728d959 + 48dd393 commit 6d673de
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 39 deletions.
8 changes: 6 additions & 2 deletions src/apis/api/getPoll.tsx
Original file line number Diff line number Diff line change
@@ -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;
};

Expand Down
10 changes: 7 additions & 3 deletions src/apis/api/getResult.tsx
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/apis/api/postRandomListApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
10 changes: 5 additions & 5 deletions src/apis/api/postResuggestOneApi.tsx
Original file line number Diff line number Diff line change
@@ -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;
};

Expand Down
8 changes: 6 additions & 2 deletions src/apis/api/postRetryApi.tsx
Original file line number Diff line number Diff line change
@@ -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/resuggest/${roomId}`);
return response.data;
};

Expand Down
2 changes: 1 addition & 1 deletion src/apis/api/postVoteApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
4 changes: 2 additions & 2 deletions src/apis/query/useGetResult.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/apis/query/useGetRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/MenuCard/MenuCard.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
`;

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/MenuCard/MenuCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const MenuCard = (props: MenuCardProps) => {
<section>
<S.TitleLayout onClick={handleLinkClick}>
<S.RestaurantName>{title}</S.RestaurantName>
<S.RestaurantLink src={icon_link} />
<S.RestaurantLinkImg src={icon_link} />
</S.TitleLayout>
<S.RestaurantTagsUl>
{categories.map((category, i) => (
Expand Down
8 changes: 2 additions & 6 deletions src/pages/OverallRanking/OverallRanking.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,7 +98,6 @@ export const Distance = styled.p`
export const ButtonLayout = styled.div`
display: flex;
flex-direction: column;
height: 100%;
flex-grow: 1;
`;

Expand All @@ -115,7 +115,3 @@ export const ButtonShare = styled.button`
vertical-align: bottom;
}
`;

export const RetryButtonLayout = styled.div`
margin-top: 12px;
`;
16 changes: 7 additions & 9 deletions src/pages/OverallRanking/OverallRanking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,14 @@ function OverallRanking() {
</button>
</S.RestaurantItem>
))}
<S.ButtonLayout>
<S.ButtonShare onClick={handleModalClick}>
<img src={shareResult} alt="share result icon" />
공유하기
</S.ButtonShare>
<S.RetryButtonLayout>
<Button onClick={handleRetry}>처음부터 다시하기</Button>
</S.RetryButtonLayout>
</S.ButtonLayout>
<S.ButtonShare onClick={handleModalClick}>
<img src={shareResult} alt="share result icon" />
공유하기
</S.ButtonShare>
</S.RestaurantList>
<S.ButtonLayout>
<Button onClick={handleRetry}>처음부터 다시하기</Button>
</S.ButtonLayout>
</S.OverallRankingWrapper>
</S.Wrapper>
{/* 모달은 포탈 써서 전역으로 나중에 바꿀게요!! */}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/RandomList/RandomList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const RandomList = () => {
category: 'click',
action: '투표공유하기_버튼',
label: '음식점 추천 화면',
value: roomId,
value: Number(roomId),
});
}
navigate(`/random-menu/${roomId}`);
Expand All @@ -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: '마이너스_버튼',
Expand All @@ -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;
Expand All @@ -91,7 +91,7 @@ const RandomList = () => {
label: '음식점 추천 화면',
});
if (roomId) {
retryMutate(roomId, { onSuccess: retryOnSuccess });
retryMutate({ roomId }, { onSuccess: retryOnSuccess });
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/recoil/roomIdData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { persistAtom } = recoilPersist({
storage: sessionStorage,
});

export const roomIdData = atom<number | null>({
export const roomIdData = atom<string | null>({
key: 'roomIdData',
default: null,
effects_UNSTABLE: [persistAtom],
Expand Down

0 comments on commit 6d673de

Please sign in to comment.