diff --git a/src/app/rummikube/[id]/page.tsx b/src/app/rummikube/[id]/page.tsx new file mode 100644 index 0000000..6a7a2fc --- /dev/null +++ b/src/app/rummikube/[id]/page.tsx @@ -0,0 +1,160 @@ +'use client'; + +import { useRef, useState } from 'react'; + +import AsyncBoundary from '@/components/common/AsyncBoundary'; +import Loader from '@/components/common/Loader'; +import CommentForm from '@/components/match/CommentForm'; +import CommentList from '@/components/match/CommentList'; +import Lineup from '@/components/match/LineupList'; +import Panel from '@/components/match/Panel'; +import RecordList from '@/components/match/RecordList'; +import Video from '@/components/match/Video'; +import Cheer from '@/components/rummikub/Cheer'; +import RummiKubMatchBanner from '@/components/rummikub/MatchBanner'; +import useSocket from '@/hooks/useSocket'; +import MatchByIdFetcher from '@/queries/useMatchById/Fetcher'; +import MatchCheerByIdFetcher from '@/queries/useMatchCheerById/Fetcher'; +import MatchCommentFetcher from '@/queries/useMatchCommentById/Fetcher'; +import MatchLineupFetcher from '@/queries/useMatchLineupById/Fetcher'; +import MatchTimelineFetcher from '@/queries/useMatchTimelineById/Fetcher'; +import MatchVideoFetcher from '@/queries/useMatchVideoById/Fetcher'; +import useSaveCommentMutation from '@/queries/useSaveCommentMutation/query'; +import { MatchCommentType } from '@/types/match'; + +export default function Rummikute({ params }: { params: { id: string } }) { + const [comments, setComments] = useState([]); + + const handleSocketMessage = (comment: MatchCommentType) => { + if (comment) { + setComments(prev => [...prev, comment]); + } + }; + + const { connect } = useSocket({ + url: 'wss://api.hufstreaming.site/ws', + destination: `/topic/games/${params.id}`, + callback: handleSocketMessage, + }); + + connect(); + + const { mutate } = useSaveCommentMutation(); + const options = [ + { label: '라인업' }, + { label: '응원댓글' }, + { label: '경기영상' }, + { label: '타임라인' }, + ]; + + const scrollRef = useRef(null); + const scrollToBottom = () => { + if (!scrollRef.current) return; + + (scrollRef.current as HTMLDivElement).scrollIntoView(); + }; + + return ( +
+ ( + + )} + loadingFallback={} + > + + {data => } + + + + } + loadingFallback={} + > + + {data => } + + + + {({ selected }) => ( + <> + {selected === '라인업' && ( + } + loadingFallback={} + > + + {([firstTeam, secondTeam]) => ( +
+ + +
+ )} +
+
+ )} + {selected === '타임라인' && ( + } + loadingFallback={} + > + + {([firstHalf, secondHalf]) => ( +
+ + +
+ )} +
+
+ )} + {selected === '응원댓글' && ( + ( + + )} + loadingFallback={} + > + + {({ commentList, matchTeams, ...data }) => ( +
+
    + + +
  • +
+ +
+ )} +
+
+ )} + {selected === '경기영상' && ( + } + loadingFallback={} + > + + {data => ( +
+
+ )} +
+
+ )} + + )} +
+
+ ); +} diff --git a/src/components/match/MatchList/index.tsx b/src/components/match/MatchList/index.tsx index 411c5fc..c0e58bd 100644 --- a/src/components/match/MatchList/index.tsx +++ b/src/components/match/MatchList/index.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/navigation'; import { FallbackProps } from '@/components/common/ErrorBoundary'; import { MatchCard } from '@/components/common/MatchCard'; +import RummiKubMatchItem from '@/components/rummikub/MatchItem'; import { COMMON_ERROR_MESSAGE, MATCH_LIST_API_ERROR_MESSAGE, @@ -37,34 +38,48 @@ export default function MatchList({ return ( <>