Skip to content

Commit

Permalink
Merge pull request #117 from hufs-sports-live/fix/time
Browse files Browse the repository at this point in the history
[FIX] 경기 시간의 분을 두자리로 출력
  • Loading branch information
seongminn authored Nov 30, 2023
2 parents e52cf67 + f91c8c3 commit ed01c40
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/api/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { convertObjectToQueryString } from '@/utils/queryString';
import instance from '.';

export type MatchListParams = {
sportsId?: string[];
sport_id?: string[];
status: MatchStatus;
leagueId?: string;
league_id?: string;
cursor?: number;
};

Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default function Home() {
return (
<section className="flex flex-col items-center">
<AsyncBoundary
errorFallback={() => <div>에러</div>}
errorFallback={() => <SportsList.Skeleton />}
loadingFallback={<SportsList.Skeleton />}
>
<SportsListFetcher leagueId={params.get(QUERY_PARAMS.league) || '1'}>
<SportsListFetcher leagueId={params.get('leagueId') || '39'}>
{data => (
<SportsList
selectedId={paramsObj[QUERY_PARAMS.sports] as string[]}
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/MatchCard/pieces/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export default function Label({ className }: LabelProps) {
return (
<div className={$('flex items-center justify-between text-sm', className)}>
<time>
{month}. {date}. {weekday}요일 {period} {hours}:{minutes}
{month}. {date}. {weekday}요일 {period} {hours}:
{minutes.toString().padStart(2, '0')}
</time>
<div className="text-right">
{sportsName} {gameName}
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function Sidebar({
<Link
href={{
pathname: '/',
query: { leagueId: content.leagueId },
query: { league_id: content.leagueId },
}}
className="flex items-center rounded-lg p-2 hover:bg-gray-2 dark:text-white dark:hover:bg-gray-5"
>
Expand Down
6 changes: 4 additions & 2 deletions src/components/match/CommentForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type CommentFormProps = {

const teamColor = [
'bg-cheer-left',
'bg-[#fb923c] ',
'bg-cheer-right',
'bg-[#fb923c] ',
'bg-[#22c55e]',
] as const;

Expand All @@ -25,7 +25,9 @@ export default function CommentForm({
scrollToBottom,
}: CommentFormProps) {
const [inputValue, setInputValue] = useState('');
const [selectedTeamId, setSelectedTeamId] = useState<number>(1);
const [selectedTeamId, setSelectedTeamId] = useState<number>(
matchTeams[0].gameTeamId,
);

const handleCommentSubmit = (
e: FormEvent<HTMLFormElement>,
Expand Down
2 changes: 1 addition & 1 deletion src/constants/queryParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const QUERY_PARAMS = {
league: 'league_id',
sports: 'sports_id',
sports: 'sport_id',
status: 'status',
};
2 changes: 1 addition & 1 deletion src/queries/useMatchList/Fetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function MatchListFetcher({
...props
}: MatchListFetcherProps) {
const { matchList, error, hasNextPage, fetchNextPage, isFetching } =
useMatchList(props satisfies { status: string });
useMatchList(props);

if (error) throw error;

Expand Down
10 changes: 5 additions & 5 deletions src/queries/useMatchList/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { useSuspenseInfiniteQuery } from '@tanstack/react-query';
import { getMatchList, MatchListParams } from '@/api/match';

export const useMatchList = ({
sportsId,
sport_id,
status = 'playing',
leagueId,
league_id,
}: Omit<MatchListParams, 'cursor' | 'size'>) => {
const { data, error, isFetching, hasNextPage, fetchNextPage } =
useSuspenseInfiniteQuery({
queryKey: ['match-list', sportsId, status, leagueId],
queryKey: ['match-list', sport_id, status, league_id],
queryFn: ({ pageParam }) =>
getMatchList({
sportsId,
sport_id,
status,
leagueId,
league_id,
cursor: pageParam,
}),
initialPageParam: 0,
Expand Down
19 changes: 2 additions & 17 deletions src/queries/useSportsListByLeagueId/Fetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,13 @@ type SportsListFetcherProps = {
children: (data: SportsType[]) => ReactNode;
};

const DUMMY = [
{
sportId: 1,
name: '축구',
},
{
sportId: 3,
name: '농구',
},
{
sportId: 2,
name: '롤',
},
];

export default function SportsListFetcher({
leagueId,
children,
}: SportsListFetcherProps) {
const { error } = useSportsListByLeagueId(leagueId);
const { sportsList, error } = useSportsListByLeagueId(leagueId);

if (error) throw error;

return children(DUMMY);
return children(sportsList);
}

0 comments on commit ed01c40

Please sign in to comment.