.
This commit is contained in:
1 parent
5af2c80cd1
commit
f7ee34da4f
78 files changed
+9016
-150
No files matched your search
@@ -8,7 +8,11 @@ import {
|
||||
type AuctionStateView,
|
||||
} from '../api/mappers';
|
||||
import { useAuctionSocket } from '../api/useAuctionSocket';
|
||||
import { DEFAULT_COMMUNITY_ID, setDevCaptainSide, useDevCaptainSide } from '../config';
|
||||
import {
|
||||
DEFAULT_COMMUNITY_ID,
|
||||
setDevCaptainSide,
|
||||
useDevCaptainSide,
|
||||
} from '../config';
|
||||
import { ApiError } from '../lib/api';
|
||||
import { positionIcon, positionLabel } from '../lib/league';
|
||||
import type { Position } from '../api/types';
|
||||
@@ -395,6 +399,10 @@ function BidLog({ bids }: { bids: AuctionStateView['bids'] }) {
|
||||
export default function AuctionPage() {
|
||||
const { id } = useParams();
|
||||
const meQuery = useMe();
|
||||
const currentUser =
|
||||
meQuery.data?.memberships.find(
|
||||
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
|
||||
)?.user ?? null;
|
||||
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
|
||||
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
|
||||
const socket = useAuctionSocket(id);
|
||||
@@ -460,8 +468,8 @@ export default function AuctionPage() {
|
||||
|
||||
const canManageAuction =
|
||||
import.meta.env.DEV ||
|
||||
meQuery.data?.user?.role === 'owner' ||
|
||||
meQuery.data?.user?.role === 'admin';
|
||||
currentUser?.role === 'owner' ||
|
||||
currentUser?.role === 'admin';
|
||||
const phaseLabel: Record<AuctionStateView['phase'], string> = {
|
||||
waiting: '경매 준비 중...',
|
||||
presenting: '다음 선수 등장',
|
||||
|
||||
@@ -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 (
|
||||
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-20 text-center">
|
||||
<span className="text-sm text-base-content/45">로그인 처리 중...</span>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { useMsal } from '@azure/msal-react';
|
||||
import {
|
||||
isMsalConfigured,
|
||||
MSAL_API_SCOPE,
|
||||
msalInstance,
|
||||
} from '../lib/auth/msal.config';
|
||||
|
||||
function LoginButton() {
|
||||
const { instance } = useMsal();
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-sm px-5"
|
||||
onClick={() => void instance.loginRedirect({ scopes: [MSAL_API_SCOPE] })}
|
||||
>
|
||||
Microsoft로 로그인
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default function LoginPage() {
|
||||
return (
|
||||
<main className="max-w-5xl mx-auto px-4 sm:px-6 py-20">
|
||||
<div className="max-w-md border border-base-content/10 bg-base-100 p-6 shadow-sm">
|
||||
<h1 className="text-xl font-bold tracking-tight">로그인</h1>
|
||||
<p className="mt-2 text-sm text-base-content/50">
|
||||
Microsoft Entra ID 계정으로 로그인하면 LOLYMPUS 멤버십을 불러옵니다.
|
||||
</p>
|
||||
<div className="mt-5">
|
||||
{isMsalConfigured && msalInstance ? (
|
||||
<LoginButton />
|
||||
) : (
|
||||
<div className="text-sm text-amber-600">
|
||||
MSAL 환경변수 설정이 필요합니다.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -281,6 +281,11 @@ export default function MatchDetailPage() {
|
||||
const authUserId = useAuthUserId();
|
||||
const matchQuery = useMatch(id, DEFAULT_COMMUNITY_ID);
|
||||
const meQuery = useMe();
|
||||
const currentUser =
|
||||
meQuery.data?.memberships.find(
|
||||
(membership) => membership.community?._id === DEFAULT_COMMUNITY_ID,
|
||||
)?.user ?? null;
|
||||
const canUseMemberActions = Boolean(currentUser || authUserId);
|
||||
const auctionQuery = useAuction(id, DEFAULT_COMMUNITY_ID);
|
||||
const [blueCaptainUserId, setBlueCaptainUserId] = useState('');
|
||||
const [redCaptainUserId, setRedCaptainUserId] = useState('');
|
||||
@@ -291,8 +296,8 @@ export default function MatchDetailPage() {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
preferredPositions:
|
||||
meQuery.data?.user?.preferredPositions.length
|
||||
? meQuery.data.user.preferredPositions.slice(0, 5)
|
||||
currentUser?.preferredPositions.length
|
||||
? currentUser.preferredPositions.slice(0, 5)
|
||||
: buildDefaultPreferredPositions(),
|
||||
}),
|
||||
}),
|
||||
@@ -376,7 +381,7 @@ export default function MatchDetailPage() {
|
||||
const match = mapApiMatchToMatchDetail(matchQuery.data);
|
||||
const si = statusBadge(match.status);
|
||||
const canManageAuction =
|
||||
meQuery.data?.user?.role === 'owner' || meQuery.data?.user?.role === 'admin';
|
||||
currentUser?.role === 'owner' || currentUser?.role === 'admin';
|
||||
const auctionNotStarted =
|
||||
auctionQuery.error instanceof ApiError && auctionQuery.error.status === 404;
|
||||
const showAuctionLink = Boolean(auctionQuery.data);
|
||||
@@ -490,7 +495,7 @@ export default function MatchDetailPage() {
|
||||
participants={match.participants}
|
||||
maxParticipants={match.maxParticipants}
|
||||
joined={match.joined}
|
||||
canJoin={Boolean(authUserId)}
|
||||
canJoin={canUseMemberActions}
|
||||
onJoin={() => joinMatchMutation.mutate()}
|
||||
isJoining={joinMatchMutation.isPending}
|
||||
/>
|
||||
@@ -551,9 +556,9 @@ export default function MatchDetailPage() {
|
||||
>
|
||||
{startAuctionMutation.isPending ? '시작 중...' : '경매 시작'}
|
||||
</button>
|
||||
{!authUserId && (
|
||||
{!canUseMemberActions && (
|
||||
<span className="text-xs text-amber-600">
|
||||
Dev Auth에 owner/admin User ID를 먼저 입력해주세요.
|
||||
로그인 또는 Dev Auth에 owner/admin User ID를 먼저 입력해주세요.
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user