fix(web): localize history pagination loading

This commit is contained in:
dahyeon committed 2026-06-08 22:24:20 -07:00
1 parent aa07ec0304
commit fe7a482969
2 files changed
+197 -164

No files matched your search

+1
View File
@@ -146,6 +146,7 @@ export function useMatchesPage(
auth: 'none', auth: 'none',
}), }),
enabled: Boolean(communityId), enabled: Boolean(communityId),
placeholderData: (previousData) => previousData,
}); });
} }
+196 -164
View File
@@ -19,9 +19,74 @@ function SkeletonBlock({ className }: { className: string }) {
); );
} }
function HistoryRecordsSkeleton() {
const historySkeletons = Array.from({ length: 5 });
return (
<>
<div className="hidden md:block border border-base-content/10 overflow-x-auto">
<table className="w-full text-left">
<thead>
<tr className="bg-base-200/60 border-b border-base-content/10">
{['날짜', '내전', '상태', '맵', '참가', '결과'].map((label) => (
<th key={label} className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-10" />
</th>
))}
</tr>
</thead>
<tbody>
{historySkeletons.map((_, index) => (
<tr
key={index}
className="border-b border-base-content/5 last:border-b-0"
>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-16" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-4 w-36" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-5 w-12" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-5 w-16" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-10" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-14" />
</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() { function HomePageSkeleton() {
const upcomingSkeletons = Array.from({ length: UPCOMING_GRID_MATCH_LIMIT }); const upcomingSkeletons = Array.from({ length: UPCOMING_GRID_MATCH_LIMIT });
const historySkeletons = Array.from({ length: 5 });
return ( return (
<main <main
@@ -85,63 +150,7 @@ function HomePageSkeleton() {
<section className="pb-12"> <section className="pb-12">
<SkeletonBlock className="h-3 w-24 mb-3" /> <SkeletonBlock className="h-3 w-24 mb-3" />
<div className="hidden md:block border border-base-content/10 overflow-x-auto"> <HistoryRecordsSkeleton />
<table className="w-full text-left">
<thead>
<tr className="bg-base-200/60 border-b border-base-content/10">
{['날짜', '내전', '상태', '맵', '참가', '결과'].map((label) => (
<th key={label} className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-10" />
</th>
))}
</tr>
</thead>
<tbody>
{historySkeletons.map((_, index) => (
<tr
key={index}
className="border-b border-base-content/5 last:border-b-0"
>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-16" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-4 w-36" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-5 w-12" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-5 w-16" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-10" />
</td>
<td className="py-2.5 px-4">
<SkeletonBlock className="h-3 w-14" />
</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>
</section> </section>
</main> </main>
); );
@@ -305,11 +314,11 @@ export default function HomePage() {
); );
} }
if (upcomingMatchesQuery.isLoading || historyMatchesQuery.isLoading) { if (upcomingMatchesQuery.isLoading) {
return <HomePageSkeleton />; return <HomePageSkeleton />;
} }
if (upcomingMatchesQuery.error || historyMatchesQuery.error) { if (upcomingMatchesQuery.error) {
return ( return (
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-20 text-center"> <main className="max-w-5xl mx-auto px-4 sm:px-6 py-20 text-center">
<span className="text-sm text-red-500"> <span className="text-sm text-red-500">
@@ -329,11 +338,15 @@ export default function HomePage() {
const historyTotal = historyMatchesQuery.data?.total ?? 0; const historyTotal = historyMatchesQuery.data?.total ?? 0;
const historyLimit = const historyLimit =
historyMatchesQuery.data?.limit ?? HISTORY_MATCH_PAGE_SIZE; historyMatchesQuery.data?.limit ?? HISTORY_MATCH_PAGE_SIZE;
const historyPageFromApi = historyMatchesQuery.data?.page ?? historyPage;
const historyPageCount = Math.max( const historyPageCount = Math.max(
1, 1,
Math.ceil(historyTotal / historyLimit), Math.ceil(historyTotal / historyLimit),
); );
const isHistoryPageLoading =
historyMatchesQuery.isLoading ||
(historyMatchesQuery.isFetching && historyMatchesQuery.isPlaceholderData);
const hasHistoryError =
Boolean(historyMatchesQuery.error) && !historyMatchesQuery.data;
const goToPreviousHistoryPage = () => const goToPreviousHistoryPage = () =>
setHistoryPage((page) => Math.max(1, page - 1)); setHistoryPage((page) => Math.max(1, page - 1));
const goToNextHistoryPage = () => setHistoryPage((page) => page + 1); const goToNextHistoryPage = () => setHistoryPage((page) => page + 1);
@@ -451,116 +464,135 @@ export default function HomePage() {
</div> </div>
</section> </section>
<section className="pb-12"> <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 className="text-xs font-bold text-base-content/40 uppercase tracking-widest mb-3">
지난 내전 기록 지난 내전 기록
</h2> </h2>
{/* 데스크톱: 테이블 */} {isHistoryPageLoading ? (
<div className="hidden md:block border border-base-content/10 overflow-x-auto"> <HistoryRecordsSkeleton />
<table className="w-full text-left"> ) : hasHistoryError ? (
<thead> <div className="border border-base-content/10 px-4 py-8 text-center text-sm text-red-500">
<tr className="bg-base-200/60 border-b border-base-content/10 text-[11px] uppercase tracking-wider text-base-content/40"> 지난 내전 기록을 불러오지 못했습니다.
<th className="py-2.5 px-4 font-semibold">날짜</th> </div>
<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> <div className="hidden md:block border border-base-content/10 overflow-x-auto">
<th className="py-2.5 px-4 font-semibold">결과</th> <table className="w-full text-left">
</tr> <thead>
</thead> <tr className="bg-base-200/60 border-b border-base-content/10 text-[11px] uppercase tracking-wider text-base-content/40">
<tbody> <th className="py-2.5 px-4 font-semibold">날짜</th>
{historyMatches.length > 0 ? ( <th className="py-2.5 px-4 font-semibold">내전</th>
historyMatches.map((match) => ( <th className="py-2.5 px-4 font-semibold">상태</th>
<tr <th className="py-2.5 px-4 font-semibold">맵</th>
key={match.id} <th className="py-2.5 px-4 font-semibold">참가</th>
className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02] transition-colors" <th className="py-2.5 px-4 font-semibold">결과</th>
>
<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="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">
{match.result?.winner ? `${match.result.winner} 승리` : '-'}
</td>
</tr> </tr>
)) </thead>
) : ( <tbody>
<tr> {historyMatches.length > 0 ? (
<td historyMatches.map((match) => (
colSpan={6} <tr
className="py-6 px-4 text-sm text-base-content/35 text-center" key={match.id}
> className="border-b border-base-content/5 last:border-b-0 hover:bg-base-content/[0.02] transition-colors"
아직 내전 기록이 없습니다. >
</td> <td className="py-2.5 px-4 text-xs text-base-content/40 whitespace-nowrap">
</tr> {match.date}
)} </td>
</tbody> <td className="py-2.5 px-4">
</table> <Link
</div> to={`/match/${match.id}`}
className="text-sm font-medium text-base-content hover:text-primary transition-colors"
{/* 모바일: 카드 리스트 */} >
<div className="md:hidden border border-base-content/10"> {match.title}
{historyMatches.length > 0 ? ( </Link>
historyMatches.map((match) => { </td>
const resultLabel = match.result?.winner <td className="py-2.5 px-4">
? `${match.result.winner} 승리` <StatusBadge status={getStatusLabel(match.status)} />
: undefined; </td>
<td className="py-2.5 px-4">
return ( <MapBadge map={match.map} />
<Link </td>
key={match.id} <td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
to={`/match/${match.id}`} {match.participants.length}명
className="block border-b border-base-content/5 last:border-b-0 p-3 hover:bg-base-content/[0.02] transition-colors" </td>
> <td className="py-2.5 px-4 text-xs text-base-content/50 whitespace-nowrap">
<div className="flex items-start justify-between gap-3"> {match.result?.winner
<div className="min-w-0 flex-1"> ? `${match.result.winner} 승리`
<div className="text-[11px] font-medium text-base-content/40"> : '-'}
{match.compactDateTime || `${match.date} ${match.time}`} </td>
</div> </tr>
<div className="mt-1 text-sm font-semibold leading-snug text-base-content break-words"> ))
{match.title} ) : (
</div> <tr>
</div> <td
<div className="shrink-0"> colSpan={6}
<StatusBadge status={getStatusLabel(match.status)} /> className="py-6 px-4 text-sm text-base-content/35 text-center"
</div> >
</div> 아직 내전 기록이 없습니다.
<div className="mt-2"> </td>
<HistoryMetaText </tr>
map={match.map} )}
participants={match.participants.length} </tbody>
result={resultLabel} </table>
/>
</div>
</Link>
);
})
) : (
<div className="py-6 px-4 text-sm text-base-content/35 text-center">
아직 내전 기록이 없습니다.
</div> </div>
)}
</div> {/* 모바일: 카드 리스트 */}
{historyTotal > 0 && ( <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-[11px] 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"> <div className="mt-3 flex justify-end">
<HistoryPagination <HistoryPagination
page={historyPageFromApi} page={historyPage}
pageCount={historyPageCount} pageCount={historyPageCount}
total={historyTotal} total={historyTotal}
isFetching={historyMatchesQuery.isFetching} isFetching={historyMatchesQuery.isFetching}