diff --git a/apps/web/src/pages/AuthCallback.tsx b/apps/web/src/pages/AuthCallback.tsx new file mode 100644 index 00000000..1476342f --- /dev/null +++ b/apps/web/src/pages/AuthCallback.tsx @@ -0,0 +1,17 @@ +import { useEffect } from 'react'; +import { useNavigate } from 'react-router'; + +export default function AuthCallbackPage() { + const navigate = useNavigate(); + + useEffect(() => { + const timer = window.setTimeout(() => navigate('/', { replace: true }), 300); + return () => window.clearTimeout(timer); + }, [navigate]); + + return ( +
+ 로그인 처리 중... +
+ ); +} diff --git a/apps/web/src/pages/HomePage.tsx b/apps/web/src/pages/HomePage.tsx new file mode 100644 index 00000000..e7d8874a --- /dev/null +++ b/apps/web/src/pages/HomePage.tsx @@ -0,0 +1,255 @@ +import { Link } from 'react-router'; +import { mapApiMatchToMatchDetail } from '../api/mappers'; +import { useMatches, useMe } from '../api/hooks'; +import { DEFAULT_COMMUNITY_ID } from '../config'; + +function StatusBadge({ status }: { status: string }) { + const styles: Record = { + 모집중: '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 ( + + {status} + + ); +} + +function MapBadge({ map }: { map: string }) { + return ( + + {map} + + ); +} + +function getStatusLabel(status: string) { + switch (status) { + case 'recruiting': + return '모집중'; + case 'team-built': + return '팀빌딩'; + case 'in-progress': + return '진행중'; + case 'finished': + return '종료'; + default: + return status; + } +} + +export default function HomePage() { + const upcomingMatchesQuery = useMatches({ limit: 20 }, DEFAULT_COMMUNITY_ID); + const finishedMatchesQuery = useMatches( + { status: 'finished', limit: 10 }, + DEFAULT_COMMUNITY_ID, + ); + const meQuery = useMe(); + + if (!DEFAULT_COMMUNITY_ID) { + return ( +
+
+ `apps/web/.env.development`의 `VITE_DEFAULT_COMMUNITY_ID`를 먼저 설정해주세요. +
+
+ ); + } + + if (upcomingMatchesQuery.isLoading || finishedMatchesQuery.isLoading) { + return ( +
+ 매치 목록을 불러오는 중... +
+ ); + } + + if (upcomingMatchesQuery.error || finishedMatchesQuery.error) { + return ( +
+ + 매치 목록을 불러오지 못했습니다. + +
+ ); + } + + const upcomingMatches = + upcomingMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? []; + const finishedMatches = + finishedMatchesQuery.data?.map(mapApiMatchToMatchDetail) ?? []; + const nextMatch = upcomingMatches[0]; + const upcomingCards = nextMatch ? upcomingMatches.slice(1) : upcomingMatches; + const currentUser = + meQuery.data?.memberships.find( + (membership) => membership.community?._id === DEFAULT_COMMUNITY_ID, + )?.user ?? null; + const canManage = currentUser?.role === 'owner' || currentUser?.role === 'admin'; + + return ( +
+
+
+

+ 다음 내전 +

+
+ {canManage && ( + + 내전 관리 + + )} + + 내전 전적 보기 + +
+
+ + {nextMatch ? ( + +
+
+
+
+
+

+ {nextMatch.title} +

+ +
+

+ {nextMatch.description} +

+
+ {nextMatch.date} {nextMatch.time} + | + + {nextMatch.participants.length}/{nextMatch.maxParticipants}명 + + | + +
+
+
+ + 상세 보기 + +
+
+
+
+ + ) : ( +
+ 아직 등록된 내전이 없습니다. +
+ )} +
+ +
+

+ 예정된 내전 +

+
+ {upcomingCards.length > 0 ? ( + upcomingCards.map((match) => ( + +
+
+

+ {match.title} +

+ +
+
+
{match.date} {match.time}
+
+ {match.participants.length}/{match.maxParticipants}명 +
+
+
+ +
+
+ + )) + ) : ( +
+ 예정된 추가 매치가 없습니다. +
+ )} +
+
+ +
+

+ 지난 내전 기록 +

+
+ + + + + + + + + + + + {finishedMatches.length > 0 ? ( + finishedMatches.map((match) => ( + + + + + + + + )) + ) : ( + + + + )} + +
날짜내전맵참가결과
+ {match.date} + + + {match.title} + + + + + {match.participants.length}명 + + {match.result?.winner ? `${match.result.winner} 승리` : '-'} +
+ 아직 종료된 내전 기록이 없습니다. +
+
+
+
+ ); +} diff --git a/apps/web/src/pages/Login.tsx b/apps/web/src/pages/Login.tsx new file mode 100644 index 00000000..7bbca0e1 --- /dev/null +++ b/apps/web/src/pages/Login.tsx @@ -0,0 +1,47 @@ +import { useMsal } from "@azure/msal-react"; +import { + isMsalConfigured, + MSAL_API_SCOPE, + msalInstance, +} from "../lib/auth/msal.config"; + +function LoginButton() { + const { instance } = useMsal(); + + return ( + + ); +} + +export default function LoginPage() { + return ( +
+
+

로그인

+

+ Entra ID 계정으로 LOLYMPUS 정보를 불러옵니다. +

+
+ {isMsalConfigured && msalInstance ? ( + + ) : ( +
+ MSAL 환경변수 설정이 필요합니다. +
+ )} +
+
+
+ ); +}