685 lines
24 KiB
TypeScript
685 lines
24 KiB
TypeScript
import { useState } from 'react';
|
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
import { Link } from 'react-router';
|
|
import { mapApiMatchToMatchDetail } from '../api/mappers';
|
|
import { useMatches, useMatchesPage, useMe } from '../api/hooks';
|
|
import { DEFAULT_COMMUNITY_ID } from '../config';
|
|
|
|
const UPCOMING_GRID_MATCH_LIMIT = 3;
|
|
const UPCOMING_MATCH_LIST_LIMIT = UPCOMING_GRID_MATCH_LIMIT + 1;
|
|
const HISTORY_MATCH_PAGE_SIZE = 10;
|
|
const EMPTY_SCHEDULE_TEXT = '예정된 매치가 없습니다.';
|
|
const HISTORY_TABLE_ROW_CLASS =
|
|
'h-10 border-b border-base-content/5 last:border-b-0';
|
|
|
|
function SkeletonBlock({ className }: { className: string }) {
|
|
return (
|
|
<div
|
|
aria-hidden="true"
|
|
className={`animate-pulse bg-base-content/10 ${className}`}
|
|
/>
|
|
);
|
|
}
|
|
|
|
function SkeletonText({
|
|
children,
|
|
className = '',
|
|
skeletonClassName,
|
|
}: {
|
|
children: string;
|
|
className?: string;
|
|
skeletonClassName: string;
|
|
}) {
|
|
return (
|
|
<span className={`relative block ${className}`}>
|
|
<span className="invisible">{children}</span>
|
|
<span
|
|
aria-hidden="true"
|
|
className={`absolute left-0 top-1/2 -translate-y-1/2 animate-pulse bg-base-content/10 ${skeletonClassName}`}
|
|
/>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
function SkeletonBadge({
|
|
children,
|
|
className,
|
|
}: {
|
|
children: string;
|
|
className: string;
|
|
}) {
|
|
return (
|
|
<span className={`relative ${className}`}>
|
|
<span className="invisible">{children}</span>
|
|
<span
|
|
aria-hidden="true"
|
|
className="absolute inset-0 animate-pulse bg-base-content/10"
|
|
/>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
function HistoryTableColGroup() {
|
|
return (
|
|
<colgroup>
|
|
<col className="w-[156px]" />
|
|
<col />
|
|
<col className="w-[88px]" />
|
|
<col className="w-[132px]" />
|
|
<col className="w-[72px]" />
|
|
<col className="w-[116px]" />
|
|
</colgroup>
|
|
);
|
|
}
|
|
|
|
function HistoryTableHeader() {
|
|
return (
|
|
<thead>
|
|
<tr className="bg-base-200/60 border-b border-base-content/10 text-xs uppercase tracking-wider text-base-content/40">
|
|
<th className="py-2.5 px-4 font-semibold">날짜</th>
|
|
<th className="py-2.5 px-4 font-semibold">내전</th>
|
|
<th className="py-2.5 px-4 font-semibold">상태</th>
|
|
<th className="py-2.5 px-4 font-semibold">맵</th>
|
|
<th className="py-2.5 px-4 font-semibold">참가</th>
|
|
<th className="py-2.5 px-4 font-semibold">결과</th>
|
|
</tr>
|
|
</thead>
|
|
);
|
|
}
|
|
|
|
function HistoryRecordsSkeleton({ rows = 5 }: { rows?: number }) {
|
|
const historySkeletons = Array.from({ length: rows });
|
|
|
|
return (
|
|
<>
|
|
<div className="hidden md:block border border-base-content/10 overflow-x-auto">
|
|
<table className="w-full table-fixed text-left">
|
|
<HistoryTableColGroup />
|
|
<HistoryTableHeader />
|
|
<tbody>
|
|
{historySkeletons.map((_, index) => (
|
|
<tr
|
|
key={index}
|
|
className={HISTORY_TABLE_ROW_CLASS}
|
|
>
|
|
<td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
|
|
<SkeletonText
|
|
skeletonClassName="h-[1em] w-20"
|
|
>
|
|
2026년 6월 8일 월
|
|
</SkeletonText>
|
|
</td>
|
|
<td className="py-2.5 px-4">
|
|
<SkeletonText
|
|
className="truncate text-sm font-medium"
|
|
skeletonClassName="h-[1em] w-36 max-w-full"
|
|
>
|
|
정기 내전
|
|
</SkeletonText>
|
|
</td>
|
|
<td className="py-2.5 px-4">
|
|
<SkeletonBadge className="inline-flex items-center whitespace-nowrap text-xs font-semibold px-1.5 py-0.5 border border-transparent">
|
|
팀빌딩
|
|
</SkeletonBadge>
|
|
</td>
|
|
<td className="py-2.5 px-4">
|
|
<SkeletonBadge className="inline-flex items-center whitespace-nowrap text-xs px-1.5 py-0.5 border border-transparent">
|
|
소환사의 협곡
|
|
</SkeletonBadge>
|
|
</td>
|
|
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
|
<SkeletonText
|
|
skeletonClassName="h-[1em] w-8"
|
|
>
|
|
10명
|
|
</SkeletonText>
|
|
</td>
|
|
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
|
<SkeletonText
|
|
className="truncate"
|
|
skeletonClassName="h-[1em] w-14"
|
|
>
|
|
1팀 승리
|
|
</SkeletonText>
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div className="md:hidden border border-base-content/10">
|
|
{historySkeletons.map((_, index) => (
|
|
<div
|
|
key={index}
|
|
className="border-b border-base-content/5 last:border-b-0 p-3"
|
|
>
|
|
<div className="flex items-start justify-between gap-3">
|
|
<div className="min-w-0 flex-1 space-y-2">
|
|
<SkeletonBlock className="h-3 w-28" />
|
|
<SkeletonBlock className="h-4 w-32" />
|
|
</div>
|
|
<SkeletonBlock className="h-5 w-12 shrink-0" />
|
|
</div>
|
|
<SkeletonBlock className="mt-2 h-3 w-40" />
|
|
</div>
|
|
))}
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
function HomePageSkeleton() {
|
|
const upcomingSkeletons = Array.from({ length: UPCOMING_GRID_MATCH_LIMIT });
|
|
|
|
return (
|
|
<main
|
|
className="max-w-5xl mx-auto px-4 sm:px-6"
|
|
aria-busy="true"
|
|
aria-live="polite"
|
|
>
|
|
<span className="sr-only">매치 목록을 불러오는 중...</span>
|
|
|
|
<section className="pt-8 pb-6">
|
|
<div className="flex items-center justify-between gap-3 mb-3">
|
|
<SkeletonBlock className="h-3 w-20" />
|
|
<div className="flex items-center gap-3">
|
|
<SkeletonBlock className="h-3 w-16" />
|
|
<SkeletonBlock className="h-3 w-20" />
|
|
</div>
|
|
</div>
|
|
|
|
<div className="border border-base-content/10 bg-base-200/50">
|
|
<div className="p-5 sm:p-6">
|
|
<div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4">
|
|
<div className="space-y-3 flex-1">
|
|
<div className="flex items-center gap-2.5 flex-wrap">
|
|
<SkeletonBlock className="h-7 w-52 sm:w-64" />
|
|
<SkeletonBlock className="h-5 w-12" />
|
|
</div>
|
|
<div className="space-y-2">
|
|
<SkeletonBlock className="h-4 w-full max-w-xl" />
|
|
<SkeletonBlock className="h-4 w-4/5 max-w-lg" />
|
|
</div>
|
|
<div className="flex items-center gap-3 flex-wrap pt-1">
|
|
<SkeletonBlock className="h-3 w-24" />
|
|
<SkeletonBlock className="h-3 w-12" />
|
|
<SkeletonBlock className="h-5 w-16" />
|
|
</div>
|
|
</div>
|
|
<SkeletonBlock className="h-8 w-24 sm:shrink-0" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section className="pb-6">
|
|
<SkeletonBlock className="h-3 w-24 mb-3" />
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-px bg-base-content/10 border border-base-content/10">
|
|
{upcomingSkeletons.map((_, index) => (
|
|
<div key={index} className="bg-base-100 h-full p-4 min-h-[122px]">
|
|
<div className="flex items-center justify-between mb-3 gap-3">
|
|
<SkeletonBlock className="h-4 w-28" />
|
|
<SkeletonBlock className="h-5 w-12 shrink-0" />
|
|
</div>
|
|
<div className="space-y-2">
|
|
<SkeletonBlock className="h-3 w-24" />
|
|
<SkeletonBlock className="h-3 w-12" />
|
|
</div>
|
|
<SkeletonBlock className="h-5 w-16 mt-3" />
|
|
</div>
|
|
))}
|
|
</div>
|
|
</section>
|
|
|
|
<section className="pb-12">
|
|
<SkeletonBlock className="h-3 w-24 mb-3" />
|
|
<HistoryRecordsSkeleton />
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|
|
|
|
function StatusBadge({ status }: { status: string }) {
|
|
const styles: Record<string, string> = {
|
|
모집중: 'bg-green-500/15 text-green-500 border-green-500/20',
|
|
팀빌딩: 'bg-amber-500/15 text-amber-500 border-amber-500/20',
|
|
진행중: 'bg-blue-500/15 text-blue-400 border-blue-500/20',
|
|
종료: 'bg-base-content/8 text-base-content/40 border-base-content/10',
|
|
};
|
|
|
|
return (
|
|
<span
|
|
className={`inline-flex items-center whitespace-nowrap text-xs font-semibold px-1.5 py-0.5 border ${styles[status] ?? 'bg-base-content/10 text-base-content/50 border-base-content/10'}`}
|
|
>
|
|
{status}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
function MapBadge({ map }: { map: string }) {
|
|
return (
|
|
<span className="inline-flex items-center whitespace-nowrap text-xs px-1.5 py-0.5 border border-base-content/10 text-base-content/50">
|
|
{map}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
function getStatusLabel(status: string) {
|
|
switch (status) {
|
|
case 'recruiting':
|
|
return '모집중';
|
|
case 'team-built':
|
|
return '팀빌딩';
|
|
case 'in-progress':
|
|
return '진행중';
|
|
case 'finished':
|
|
return '종료';
|
|
default:
|
|
return status;
|
|
}
|
|
}
|
|
|
|
function formatCompactDateTime(dateLike: string) {
|
|
const date = new Date(dateLike);
|
|
if (Number.isNaN(date.getTime())) return '';
|
|
|
|
const weekday = new Intl.DateTimeFormat('ko-KR', {
|
|
weekday: 'short',
|
|
}).format(date);
|
|
const hours = String(date.getHours()).padStart(2, '0');
|
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
|
|
return `${date.getMonth() + 1}/${date.getDate()} (${weekday}) ${hours}:${minutes}`;
|
|
}
|
|
|
|
function HistoryMetaText({
|
|
map,
|
|
participants,
|
|
result,
|
|
}: {
|
|
map: string;
|
|
participants: number;
|
|
result?: string;
|
|
}) {
|
|
return (
|
|
<div className="flex flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-base-content/45">
|
|
<span>{map}</span>
|
|
<span className="text-base-content/20">·</span>
|
|
<span>{participants}명</span>
|
|
{result && (
|
|
<>
|
|
<span className="text-base-content/20">·</span>
|
|
<span>{result}</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
interface HistoryPaginationProps {
|
|
page: number;
|
|
pageCount: number;
|
|
total: number;
|
|
isFetching: boolean;
|
|
onPrevious: () => void;
|
|
onNext: () => void;
|
|
}
|
|
|
|
function HistoryPagination({
|
|
page,
|
|
pageCount,
|
|
total,
|
|
isFetching,
|
|
onPrevious,
|
|
onNext,
|
|
}: HistoryPaginationProps) {
|
|
const hasPrevious = page > 1;
|
|
const hasNext = page < pageCount;
|
|
|
|
return (
|
|
<div className="flex flex-wrap items-center gap-2 text-xs text-base-content/40">
|
|
<span className="font-medium whitespace-nowrap">
|
|
총 {total}개 · {page}/{pageCount}페이지
|
|
</span>
|
|
<div className="flex items-center gap-1">
|
|
<button
|
|
type="button"
|
|
className="btn btn-ghost btn-xs px-2"
|
|
disabled={!hasPrevious || isFetching}
|
|
onClick={onPrevious}
|
|
>
|
|
<ChevronLeft className="h-3.5 w-3.5" aria-hidden="true" />
|
|
이전
|
|
</button>
|
|
<button
|
|
type="button"
|
|
className="btn btn-ghost btn-xs px-2"
|
|
disabled={!hasNext || isFetching}
|
|
onClick={onNext}
|
|
>
|
|
다음
|
|
<ChevronRight className="h-3.5 w-3.5" aria-hidden="true" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default function HomePage() {
|
|
const [timelineNow] = useState(() => new Date().toISOString());
|
|
const [historyPage, setHistoryPage] = useState(1);
|
|
const upcomingMatchesQuery = useMatches(
|
|
{
|
|
limit: UPCOMING_MATCH_LIST_LIMIT,
|
|
scheduledFrom: timelineNow,
|
|
sort: 'asc',
|
|
},
|
|
DEFAULT_COMMUNITY_ID,
|
|
);
|
|
const historyMatchesQuery = useMatchesPage(
|
|
{
|
|
limit: HISTORY_MATCH_PAGE_SIZE,
|
|
page: historyPage,
|
|
scheduledTo: timelineNow,
|
|
sort: 'desc',
|
|
},
|
|
DEFAULT_COMMUNITY_ID,
|
|
);
|
|
const meQuery = useMe();
|
|
|
|
if (!DEFAULT_COMMUNITY_ID) {
|
|
return (
|
|
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-16">
|
|
<div className="border border-amber-500/20 bg-amber-500/10 p-5 text-sm text-amber-700">
|
|
`apps/web/.env.development`의 `VITE_DEFAULT_COMMUNITY_ID`를 먼저 설정해주세요.
|
|
</div>
|
|
</main>
|
|
);
|
|
}
|
|
|
|
if (upcomingMatchesQuery.isLoading) {
|
|
return <HomePageSkeleton />;
|
|
}
|
|
|
|
if (upcomingMatchesQuery.error) {
|
|
return (
|
|
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-20 text-center">
|
|
<span className="text-sm text-red-500">
|
|
매치 목록을 불러오지 못했습니다.
|
|
</span>
|
|
</main>
|
|
);
|
|
}
|
|
|
|
const upcomingMatches =
|
|
upcomingMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? [];
|
|
const historyMatches =
|
|
historyMatchesQuery.data?.matches.map((match) => ({
|
|
...mapApiMatchToMatchDetail(match),
|
|
compactDateTime: formatCompactDateTime(match.scheduledAt),
|
|
})) ?? [];
|
|
const historyTotal = historyMatchesQuery.data?.total ?? 0;
|
|
const historyLimit =
|
|
historyMatchesQuery.data?.limit ?? HISTORY_MATCH_PAGE_SIZE;
|
|
const historyPageCount = Math.max(
|
|
1,
|
|
Math.ceil(historyTotal / historyLimit),
|
|
);
|
|
const isHistoryPageLoading =
|
|
historyMatchesQuery.isLoading ||
|
|
(historyMatchesQuery.isFetching && historyMatchesQuery.isPlaceholderData);
|
|
const hasHistoryError =
|
|
Boolean(historyMatchesQuery.error) && !historyMatchesQuery.data;
|
|
const goToPreviousHistoryPage = () =>
|
|
setHistoryPage((page) => Math.max(1, page - 1));
|
|
const goToNextHistoryPage = () => setHistoryPage((page) => page + 1);
|
|
const nextMatch = upcomingMatches[0];
|
|
const upcomingCards = (nextMatch
|
|
? upcomingMatches.slice(1)
|
|
: upcomingMatches
|
|
).slice(0, UPCOMING_GRID_MATCH_LIMIT);
|
|
const currentUser =
|
|
meQuery.data?.memberships.find(
|
|
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
|
|
)?.user ?? null;
|
|
const canManage = currentUser?.role === 'owner' || currentUser?.role === 'admin';
|
|
|
|
return (
|
|
<main className="max-w-5xl mx-auto px-4 sm:px-6">
|
|
<section className="pt-8 pb-6">
|
|
<div className="flex items-center justify-between gap-3 mb-3">
|
|
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest">
|
|
다음 내전
|
|
</h2>
|
|
<div className="flex items-center gap-3">
|
|
{canManage && (
|
|
<Link
|
|
to={`/admin/communities/${DEFAULT_COMMUNITY_ID}/matches`}
|
|
className="text-xs font-bold text-base-content/35 hover:text-primary"
|
|
>
|
|
내전 관리
|
|
</Link>
|
|
)}
|
|
<Link
|
|
to={`/communities/${DEFAULT_COMMUNITY_ID}/internal-stats`}
|
|
className="text-xs font-bold text-primary hover:underline"
|
|
>
|
|
내전 전적 보기
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
|
|
{nextMatch ? (
|
|
<Link to={`/match/${nextMatch.id}`} className="block group">
|
|
<div className="border border-base-content/10 bg-base-200/50 hover:bg-base-200 transition-colors">
|
|
<div className="p-5 sm:p-6 min-h-[150px]">
|
|
<div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4">
|
|
<div className="space-y-2.5">
|
|
<div className="flex items-center gap-2.5 flex-wrap">
|
|
<h3 className="text-xl sm:text-2xl font-bold text-base-content leading-tight">
|
|
{nextMatch.title}
|
|
</h3>
|
|
<StatusBadge status={getStatusLabel(nextMatch.status)} />
|
|
</div>
|
|
<p className="text-sm text-base-content/50 max-w-xl leading-relaxed">
|
|
{nextMatch.description}
|
|
</p>
|
|
<div className="flex items-center gap-3 text-xs text-base-content/40 flex-wrap">
|
|
<span>{nextMatch.date} {nextMatch.time}</span>
|
|
<span className="text-base-content/15">|</span>
|
|
<span className="bg-accent text-accent-content px-1.5 py-0.5 font-semibold">
|
|
{nextMatch.participants.length}/{nextMatch.maxParticipants}명
|
|
</span>
|
|
<span className="text-base-content/15">|</span>
|
|
<MapBadge map={nextMatch.map} />
|
|
</div>
|
|
</div>
|
|
<div className="sm:shrink-0">
|
|
<span className="btn btn-secondary btn-sm px-6 text-xs font-semibold">
|
|
상세 보기
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Link>
|
|
) : (
|
|
<div className="border border-base-content/10 bg-base-200/50">
|
|
<div className="p-5 sm:p-6 min-h-[150px] flex items-center justify-center text-center text-sm text-base-content/40">
|
|
{EMPTY_SCHEDULE_TEXT}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</section>
|
|
|
|
<section className="pb-6">
|
|
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
|
|
예정된 내전
|
|
</h2>
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-px bg-base-content/10 border border-base-content/10">
|
|
{upcomingCards.length > 0 ? (
|
|
upcomingCards.map((match) => (
|
|
<Link key={match.id} to={`/match/${match.id}`}>
|
|
<div className="bg-base-100 hover:bg-base-200/50 transition-colors cursor-pointer h-full p-4 min-h-[122px]">
|
|
<div className="flex items-center justify-between mb-2.5">
|
|
<h3 className="text-sm font-bold text-base-content truncate mr-2">
|
|
{match.title}
|
|
</h3>
|
|
<StatusBadge status={getStatusLabel(match.status)} />
|
|
</div>
|
|
<div className="space-y-1 text-xs text-base-content/40">
|
|
<div>{match.date} {match.time}</div>
|
|
<div>
|
|
{match.participants.length}/{match.maxParticipants}명
|
|
</div>
|
|
</div>
|
|
<div className="mt-2.5">
|
|
<MapBadge map={match.map} />
|
|
</div>
|
|
</div>
|
|
</Link>
|
|
))
|
|
) : (
|
|
<div className="bg-base-100 h-full p-4 min-h-[122px] flex items-center justify-center text-center text-sm text-base-content/35">
|
|
{EMPTY_SCHEDULE_TEXT}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</section>
|
|
|
|
<section
|
|
className="pb-12"
|
|
aria-busy={isHistoryPageLoading}
|
|
aria-live="polite"
|
|
>
|
|
<h2 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
|
|
지난 내전 기록
|
|
</h2>
|
|
{isHistoryPageLoading ? (
|
|
<HistoryRecordsSkeleton rows={HISTORY_MATCH_PAGE_SIZE} />
|
|
) : hasHistoryError ? (
|
|
<div className="border border-base-content/10 px-4 py-8 text-center text-sm text-red-500">
|
|
지난 내전 기록을 불러오지 못했습니다.
|
|
</div>
|
|
) : (
|
|
<>
|
|
{/* 데스크톱: 테이블 */}
|
|
<div className="hidden md:block border border-base-content/10 overflow-x-auto">
|
|
<table className="w-full table-fixed text-left">
|
|
<HistoryTableColGroup />
|
|
<HistoryTableHeader />
|
|
<tbody>
|
|
{historyMatches.length > 0 ? (
|
|
historyMatches.map((match) => (
|
|
<tr
|
|
key={match.id}
|
|
className={`${HISTORY_TABLE_ROW_CLASS} hover:bg-base-content/[0.02] transition-colors`}
|
|
>
|
|
<td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
|
|
{match.date}
|
|
</td>
|
|
<td className="py-2.5 px-4">
|
|
<Link
|
|
to={`/match/${match.id}`}
|
|
className="block truncate text-sm font-medium text-base-content hover:text-primary transition-colors"
|
|
>
|
|
{match.title}
|
|
</Link>
|
|
</td>
|
|
<td className="py-2.5 px-4">
|
|
<StatusBadge status={getStatusLabel(match.status)} />
|
|
</td>
|
|
<td className="py-2.5 px-4">
|
|
<MapBadge map={match.map} />
|
|
</td>
|
|
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
|
{match.participants.length}명
|
|
</td>
|
|
<td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
|
|
<span className="block truncate">
|
|
{match.result?.winner
|
|
? `${match.result.winner} 승리`
|
|
: '-'}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
))
|
|
) : (
|
|
<tr>
|
|
<td
|
|
colSpan={6}
|
|
className="py-6 px-4 text-sm text-base-content/35 text-center"
|
|
>
|
|
아직 내전 기록이 없습니다.
|
|
</td>
|
|
</tr>
|
|
)}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{/* 모바일: 카드 리스트 */}
|
|
<div className="md:hidden border border-base-content/10">
|
|
{historyMatches.length > 0 ? (
|
|
historyMatches.map((match) => {
|
|
const resultLabel = match.result?.winner
|
|
? `${match.result.winner} 승리`
|
|
: undefined;
|
|
|
|
return (
|
|
<Link
|
|
key={match.id}
|
|
to={`/match/${match.id}`}
|
|
className="block border-b border-base-content/5 last:border-b-0 p-3 hover:bg-base-content/[0.02] transition-colors"
|
|
>
|
|
<div className="flex items-start justify-between gap-3">
|
|
<div className="min-w-0 flex-1">
|
|
<div className="text-xs font-medium text-base-content/40">
|
|
{match.compactDateTime ||
|
|
`${match.date} ${match.time}`}
|
|
</div>
|
|
<div className="mt-1 text-sm font-semibold leading-snug text-base-content break-words">
|
|
{match.title}
|
|
</div>
|
|
</div>
|
|
<div className="shrink-0">
|
|
<StatusBadge
|
|
status={getStatusLabel(match.status)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div className="mt-2">
|
|
<HistoryMetaText
|
|
map={match.map}
|
|
participants={match.participants.length}
|
|
result={resultLabel}
|
|
/>
|
|
</div>
|
|
</Link>
|
|
);
|
|
})
|
|
) : (
|
|
<div className="py-6 px-4 text-sm text-base-content/35 text-center">
|
|
아직 내전 기록이 없습니다.
|
|
</div>
|
|
)}
|
|
</div>
|
|
</>
|
|
)}
|
|
{!hasHistoryError && historyTotal > 0 && (
|
|
<div className="mt-3 flex justify-end">
|
|
<HistoryPagination
|
|
page={historyPage}
|
|
pageCount={historyPageCount}
|
|
total={historyTotal}
|
|
isFetching={historyMatchesQuery.isFetching}
|
|
onPrevious={goToPreviousHistoryPage}
|
|
onNext={goToNextHistoryPage}
|
|
/>
|
|
</div>
|
|
)}
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|