Skip to content

Commit c790c8f

Browse files
alwubinWonJuneKimcoderabbitai[bot]
authored
refactor: 변경된 밸런스게임 조회 api 파라미터 수정 (#264)
* [style] : mobile typo 정의 및 Header mobile svg 추가 * [feat] : viewport 메타 태그 추가 및 미디어 쿼리 기본 스타일 적용 * [feat] : LandingPage에 사용되는 모바일 svg 추가 * [feat] : 모바일 Button 컴포넌트 구현 * [style] : 모바일 typo 추가 * [feat] : BalanceGameCategory 관련 모바일 스타일 추가 * [feat] : CategoryBox 관련 모바일 스타일 추가 * [feat] : SearchBar 모바일 스타일 추가 * [feat] : ContentsButton 모바일 스타일 추가 * [feat] : TopBanner 모바일 스타일 추가 * [feat] : 모바일 layout 정의 * [feat] : Mobile 컴포넌트 관련 svg 파일 추가 * [feat] : LandingPage 속 새로운 mobile 컴포넌트 UI 및 스토리북 구현 * [feat] : BalanceGameList 관련 모바일 스타일 추가 * [style] MobileCreateButton hover style 및 배경 색상 추가 * [feat] useIsMobile 훅 구현 및 반응형 적용 * [refactor] : 모바일 UI 컴포넌트 폴더 구조 변경 및 적용 * [feat] : DraftSaveButton 컴포넌트 UI 및 스토리북 구현 * [chore] : 모바일 UI 관련 폴더 구조 정리 및 파일 이동 * [refactor] : 스토리북 통일을 위해 Default/All로 수정 * [refactor] : 모바일 UI 스토리북 폴더 구조 수정 * [refactor] : TopBanner 모바일 dotStyling 수정 * [refactor] : 레이아웃 공백 요소의 불필요한 ARIA role 제거 및 접근성 개선 * [refactor] : 접근성 개선을 위한 aria-hidden 추가 * Update src/components/mobile/molecules/MobileCreateDropdown/MobileCreateDropdown.tsx Co-authored-by: Banana_milk <101927445+WonJuneKim@users.noreply.github.com> * [refactor] accessToken 타입 처리 개선 Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * [refactor] : 로그인 핸들러 중복 로직 제거 및 개선 Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * [style] typo 누락 스타일 추가 * [refactor] : 컴포넌트 네이밍 수정 * [refactor] : 스토리북 속 porps 일부 action 적용 * [refactor] : 컴포넌트 네이밍 수정 및 적용 * [refactor] : 로그인 핸들러 중첩 함수 오류 수정 * [refactor] : 사용자 에이전트 문자열 검사 로직 개선 * [refactor] : 사용자 에이전트 문자열 검사 로직 수정 * [refactor] : 모바일 토글 defaultItem을 통해 종속성 제거 * [refactor] : 태그 제거 및 cosole 함수 action 기능으로 수정 * [refactor] : 인코딩 처리 명시 * [feat] : storybook custom viewport를 통해 모바일 UI 스토리북 구현 * [refactor] : 수정된 props 반영 * [refactor] : 밸런스게임 조회 파라미터 '인기' 태그에 대한 수정 * [refactor] : 밸런스게임 태그 상태값 수정 및 적용 * [refactor] : 밸런스 게임에 대한 인기순/최신순 api 동시 호출 분리 * [refactor] : activeTab의 기본값을 빈 문자열에서 '인기'로 변경하고 tagName 처리 로직 수정 * [refactor] : params 타입을 GameParams로 정의 및 조건 수정 * [refactor] : enabled 옵션을 통한 조건부 데이터 패칭 로직 수정 --------- Co-authored-by: Banana_milk <101927445+WonJuneKim@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent e9de786 commit c790c8f

5 files changed

Lines changed: 40 additions & 17 deletions

File tree

src/api/game.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
BalanceGame,
55
Game,
66
GameContent,
7+
GameParams,
78
GameSet,
89
TempGame,
910
} from '@/types/game';
@@ -61,21 +62,35 @@ export const getNewGames = async () => {
6162
};
6263

6364
export const getBestGames = async (tagName: string) => {
65+
const params: GameParams = {
66+
page: GAME_VALUE.PAGE,
67+
size: GAME_VALUE.SIZE,
68+
};
69+
70+
if (tagName !== '인기') {
71+
params.tagName = tagName;
72+
}
73+
6474
const { data } = await axiosInstance.get<GameContent[]>(
6575
`${END_POINT.BEST_GAME}`,
66-
{
67-
params: { tagName, page: GAME_VALUE.PAGE, size: GAME_VALUE.SIZE },
68-
},
76+
{ params },
6977
);
7078
return data;
7179
};
7280

7381
export const getLatestGames = async (tagName: string) => {
82+
const params: GameParams = {
83+
page: GAME_VALUE.PAGE,
84+
size: GAME_VALUE.SIZE,
85+
};
86+
87+
if (tagName !== '인기') {
88+
params.tagName = tagName;
89+
}
90+
7491
const { data } = await axiosInstance.get<GameContent[]>(
7592
`${END_POINT.LATEST_GAME}`,
76-
{
77-
params: { tagName, page: GAME_VALUE.PAGE, size: GAME_VALUE.SIZE },
78-
},
93+
{ params },
7994
);
8095
return data;
8196
};

src/hooks/api/game/useBestGameListQuery.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { useQuery } from '@tanstack/react-query';
22
import { GameContent } from '@/types/game';
33
import { getBestGames } from '@/api/game';
44

5-
export const useBestGameList = (tagName: string) => {
5+
export const useBestGameList = (tagName: string, isEnabled: boolean) => {
66
const { data: bestGames, isLoading } = useQuery<GameContent[]>({
77
queryKey: ['bestGames', tagName],
88
queryFn: () => getBestGames(tagName),
9+
enabled: isEnabled,
910
});
1011
return { bestGames, isLoading };
1112
};

src/hooks/api/game/useLatestGameListQuery.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { useQuery } from '@tanstack/react-query';
22
import { GameContent } from '@/types/game';
33
import { getLatestGames } from '@/api/game';
44

5-
export const useLatestGameList = (tagName: string) => {
5+
export const useLatestGameList = (tagName: string, isEnabled: boolean) => {
66
const { data: latestGames, isLoading } = useQuery<GameContent[]>({
77
queryKey: ['latestGames', tagName],
88
queryFn: () => getLatestGames(tagName),
9+
enabled: isEnabled,
910
});
1011
return { latestGames, isLoading };
1112
};

src/pages/LandingPage/LandingPage.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useMemo } from 'react';
1+
import React, { useState } from 'react';
22
import TopBanner from '@/components/molecules/TopBanner/TopBanner';
33
import SearchTagBar from '@/components/molecules/SearchTagBar/SearchTagBar';
44
import CategoryBox from '@/components/molecules/CategoryBox/CategoryBox';
@@ -26,15 +26,15 @@ const LandingPage = () => {
2626
'인기' | '커플' | '취향' | '월드컵'
2727
>('인기');
2828

29-
const { bestGames } = useBestGameList(activeTab);
30-
const { latestGames } = useLatestGameList(activeTab);
29+
const isBestGamesEnabled =
30+
activeTab === '인기' || selectedValue.field === 'views';
31+
const isLatestGamesEnabled =
32+
activeTab !== '인기' && selectedValue.field !== 'views';
3133

32-
const contents = useMemo(() => {
33-
if (selectedValue.field === 'views') {
34-
return bestGames || [];
35-
}
36-
return latestGames || [];
37-
}, [selectedValue, bestGames, latestGames]);
34+
const { bestGames } = useBestGameList(activeTab, isBestGamesEnabled);
35+
const { latestGames } = useLatestGameList(activeTab, isLatestGamesEnabled);
36+
37+
const contents = bestGames || latestGames || [];
3838

3939
const handleService = () => {
4040
setIsServicePreparing(true);

src/types/game.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export interface GamesPagination extends PaginationType {
5050
content: GameContent[];
5151
}
5252

53+
export interface GameParams {
54+
page: number;
55+
size: number;
56+
tagName?: string;
57+
}
58+
5359
export interface BalanceGameOption {
5460
id: number;
5561
name: string;

0 commit comments

Comments
 (0)