chore(web): limit upcoming match cards
This commit is contained in:
1 parent
7b636ee793
commit
a896342429
1 file changed
+11
-2
@@ -3,6 +3,9 @@ import { mapApiMatchToMatchDetail } from '../api/mappers';
|
|||||||
import { useMatches, useMe } from '../api/hooks';
|
import { useMatches, useMe } from '../api/hooks';
|
||||||
import { DEFAULT_COMMUNITY_ID } from '../config';
|
import { DEFAULT_COMMUNITY_ID } from '../config';
|
||||||
|
|
||||||
|
const UPCOMING_GRID_MATCH_LIMIT = 3;
|
||||||
|
const UPCOMING_MATCH_LIST_LIMIT = UPCOMING_GRID_MATCH_LIMIT + 1;
|
||||||
|
|
||||||
function StatusBadge({ status }: { status: string }) {
|
function StatusBadge({ status }: { status: string }) {
|
||||||
const styles: Record<string, string> = {
|
const styles: Record<string, string> = {
|
||||||
모집중: 'bg-green-500/15 text-green-500 border-green-500/20',
|
모집중: 'bg-green-500/15 text-green-500 border-green-500/20',
|
||||||
@@ -44,7 +47,10 @@ function getStatusLabel(status: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
const upcomingMatchesQuery = useMatches({ limit: 20 }, DEFAULT_COMMUNITY_ID);
|
const upcomingMatchesQuery = useMatches(
|
||||||
|
{ limit: UPCOMING_MATCH_LIST_LIMIT },
|
||||||
|
DEFAULT_COMMUNITY_ID,
|
||||||
|
);
|
||||||
const finishedMatchesQuery = useMatches(
|
const finishedMatchesQuery = useMatches(
|
||||||
{ status: 'finished', limit: 10 },
|
{ status: 'finished', limit: 10 },
|
||||||
DEFAULT_COMMUNITY_ID,
|
DEFAULT_COMMUNITY_ID,
|
||||||
@@ -84,7 +90,10 @@ export default function HomePage() {
|
|||||||
const finishedMatches =
|
const finishedMatches =
|
||||||
finishedMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? [];
|
finishedMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? [];
|
||||||
const nextMatch = upcomingMatches[0];
|
const nextMatch = upcomingMatches[0];
|
||||||
const upcomingCards = nextMatch ? upcomingMatches.slice(1) : upcomingMatches;
|
const upcomingCards = (nextMatch
|
||||||
|
? upcomingMatches.slice(1)
|
||||||
|
: upcomingMatches
|
||||||
|
).slice(0, UPCOMING_GRID_MATCH_LIMIT);
|
||||||
const currentUser =
|
const currentUser =
|
||||||
meQuery.data?.memberships.find(
|
meQuery.data?.memberships.find(
|
||||||
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
|
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
|
||||||
|
|||||||
Reference in new issue
Block a user