diff --git a/src/api/match.ts b/src/api/match.ts index e341ffd..a6bb35c 100644 --- a/src/api/match.ts +++ b/src/api/match.ts @@ -4,6 +4,7 @@ import { MatchCommentType, MatchLineupType, MatchListType, + MatchStatus, MatchTimelineType, MatchType, MatchVideoType, @@ -13,20 +14,21 @@ import { convertObjectToQueryString } from '@/utils/queryString'; import instance from '.'; export type MatchListParams = { - sportsId: number | number[]; - status: 'playing' | 'scheduled' | 'finished'; - leagueId: number; - cursor: number; - size: number; + sportsId?: string[]; + status: MatchStatus; + leagueId?: string; + cursor?: number; }; -export const getMatchList = async (params: MatchListParams) => { - const queryString = convertObjectToQueryString< - keyof MatchListParams, - MatchListParams[keyof MatchListParams] - >(params); +export const getMatchList = async ( + { cursor, ...params }: MatchListParams, + size = 3, +) => { + const queryString = convertObjectToQueryString(params); - const { data } = await instance.get(`games?${queryString}`); + const { data } = await instance.get( + `games?${queryString}&cursor=${cursor || ''}&size=${size}`, + ); return data; }; diff --git a/src/app/page.tsx b/src/app/page.tsx index 7e22e3a..92f514c 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,48 +3,79 @@ import { Suspense } from 'react'; import SportsList from '@/components/league/SportsList'; +import MatchList from '@/components/match/MatchList'; +import { QUERY_PARAMS } from '@/constants/queryParams'; import useQueryParams from '@/hooks/useQueryParams'; +import MatchListFetcher from '@/queries/useMatchList/Fetcher'; import SportsListFetcher from '@/queries/useSportsListByLeagueId/Fetcher'; +import { MatchStatus } from '@/types/match'; +import { $ } from '@/utils/core'; export default function Home() { - const { appendToParams, setInParams } = useQueryParams(); + const { params, repeatIterator, appendToParams, setInParams } = + useQueryParams(); + + const paramsObj = repeatIterator( + {} as { status: MatchStatus }, + params.entries(), + ); return (
- - {data => } + + {data => ( + + )}
- {/*
+
MatchList 로딩중...
}> - - {data => } + + {({ matchList, ...props }) => ( + + )} -
*/} +
); } diff --git a/src/components/common/Icon/svg/BackgroundLogo.tsx b/src/components/common/Icon/svg/BackgroundLogo.tsx index d34a676..73a43d4 100644 --- a/src/components/common/Icon/svg/BackgroundLogo.tsx +++ b/src/components/common/Icon/svg/BackgroundLogo.tsx @@ -5,17 +5,13 @@ export const BackgroundLogo = ({ ...props }: ComponentProps<'svg'>) => { return ( - + ); diff --git a/src/components/league/SportsList/index.tsx b/src/components/league/SportsList/index.tsx index 2b10f53..4ae0775 100644 --- a/src/components/league/SportsList/index.tsx +++ b/src/components/league/SportsList/index.tsx @@ -1,23 +1,35 @@ +import { Icon } from '@/components/common/Icon'; +import { QUERY_PARAMS } from '@/constants/queryParams'; import { SportsType } from '@/types/league'; +import { $ } from '@/utils/core'; type SportsListProps = { + selectedId: string[]; sportsList: SportsType[]; onClick: (key: string, value: string) => void; }; -export default function SportsList({ sportsList, onClick }: SportsListProps) { +export default function SportsList({ + selectedId = [], + sportsList, + onClick, +}: SportsListProps) { return (