-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from hufs-sports-live/feat/main-match-list-inf…
…inite-scroll [FEAT] 경기 리스트 무한 스크롤 구현
- Loading branch information
Showing
11 changed files
with
211 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,66 @@ | ||
import Link from 'next/link'; | ||
|
||
import { MatchCard } from '@/components/common/MatchCard'; | ||
import useIntersect from '@/hooks/useInfiniteObserver'; | ||
import { MatchListType } from '@/types/match'; | ||
|
||
type MatchListProps = { | ||
matchList: MatchListType[]; | ||
hasNextPage: boolean; | ||
fetchNextPage: () => void; | ||
isFetching: boolean; | ||
}; | ||
|
||
export default function MatchList({ | ||
matchList, | ||
}: { | ||
matchList: MatchListType[]; | ||
}) { | ||
fetchNextPage, | ||
hasNextPage, | ||
isFetching, | ||
}: MatchListProps) { | ||
const { ref } = useIntersect<HTMLDivElement>(async (entry, observer) => { | ||
if (entry.isIntersecting) { | ||
observer.unobserve(entry.target); | ||
|
||
if (hasNextPage && !isFetching) { | ||
fetchNextPage(); | ||
} | ||
} | ||
}); | ||
|
||
return ( | ||
<ul> | ||
{matchList.map(({ gameId, ...match }) => ( | ||
<li key={gameId} className="mb-14"> | ||
<Link href={`match/${gameId}`}> | ||
<MatchCard {...match} className="flex flex-col"> | ||
<MatchCard.Label className="mb-2 grid w-full grid-cols-3 border-b-2 border-b-gray-5 px-1 pb-1" /> | ||
<div className="flex h-full min-h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"> | ||
<MatchCard.Background | ||
viewBox="-13 117 120 50" | ||
width={150} | ||
height={170} | ||
className="h-[180px]" | ||
/> | ||
<> | ||
<ul> | ||
{matchList.map(({ id, ...match }) => ( | ||
<li key={id} className="mb-14"> | ||
<Link href={`match/${id}`}> | ||
<MatchCard {...match} className="flex flex-col"> | ||
<MatchCard.Label className="mb-2 grid w-full grid-cols-3 border-b-2 border-b-gray-5 px-1 pb-1" /> | ||
<div className="flex h-full min-h-[180px] items-center justify-around rounded-xl bg-gray-1 shadow-lg"> | ||
<MatchCard.Background | ||
viewBox="-13 117 120 50" | ||
width={150} | ||
height={170} | ||
className="h-[180px] fill-primary" | ||
/> | ||
|
||
<MatchCard.Team | ||
teamIndex={1} | ||
className="flex flex-col items-center" | ||
/> | ||
<MatchCard.Score teamIndex={1} /> | ||
<MatchCard.Status /> | ||
<MatchCard.Score teamIndex={2} /> | ||
<MatchCard.Team | ||
teamIndex={2} | ||
className="flex flex-col items-center" | ||
/> | ||
</div> | ||
</MatchCard> | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
<MatchCard.Team | ||
teamIndex={1} | ||
className="flex flex-col items-center" | ||
/> | ||
<MatchCard.Score teamIndex={1} /> | ||
<MatchCard.Status /> | ||
<MatchCard.Score teamIndex={2} /> | ||
<MatchCard.Team | ||
teamIndex={2} | ||
className="flex flex-col items-center" | ||
/> | ||
</div> | ||
</MatchCard> | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
<div ref={ref}></div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const QUERY_PARAMS = { | ||
league: 'league_id', | ||
sports: 'sports_id', | ||
status: 'status', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.