.
This commit is contained in:
1 parent
c00545f281
commit
c5d296d403
2 files changed
+48
-2
No files matched your search
@@ -278,6 +278,7 @@ export function useTournamentCodeStats(
|
|||||||
export function useTournamentCodes(
|
export function useTournamentCodes(
|
||||||
options: { state?: TournamentCodeState; limit?: number },
|
options: { state?: TournamentCodeState; limit?: number },
|
||||||
communityId = DEFAULT_COMMUNITY_ID,
|
communityId = DEFAULT_COMMUNITY_ID,
|
||||||
|
enabled = true,
|
||||||
) {
|
) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
@@ -295,8 +296,9 @@ export function useTournamentCodes(
|
|||||||
`/communities/${communityId}/tournament-codes${queryString ? `?${queryString}` : ''}`,
|
`/communities/${communityId}/tournament-codes${queryString ? `?${queryString}` : ''}`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
enabled: Boolean(communityId),
|
enabled: Boolean(communityId && enabled),
|
||||||
refetchInterval: 30_000,
|
refetchInterval: enabled ? 30_000 : false,
|
||||||
|
retry: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,10 +73,18 @@ export default function TournamentCodesPage() {
|
|||||||
(membership) => membership.community?._id === communityId,
|
(membership) => membership.community?._id === communityId,
|
||||||
)?.user ?? null;
|
)?.user ?? null;
|
||||||
const canManage = currentUser?.role === 'owner' || currentUser?.role === 'admin';
|
const canManage = currentUser?.role === 'owner' || currentUser?.role === 'admin';
|
||||||
|
const manageableMemberships =
|
||||||
|
meQuery.data?.memberships.filter((membership) => {
|
||||||
|
const role = membership.user.role;
|
||||||
|
return Boolean(
|
||||||
|
membership.community && (role === 'owner' || role === 'admin'),
|
||||||
|
);
|
||||||
|
}) ?? [];
|
||||||
const statsQuery = useTournamentCodeStats(communityId, canManage);
|
const statsQuery = useTournamentCodeStats(communityId, canManage);
|
||||||
const listQuery = useTournamentCodes(
|
const listQuery = useTournamentCodes(
|
||||||
{ state: stateFilter || undefined, limit: 200 },
|
{ state: stateFilter || undefined, limit: 200 },
|
||||||
communityId,
|
communityId,
|
||||||
|
canManage,
|
||||||
);
|
);
|
||||||
const uploadMutation = useBulkUploadTournamentCodes(communityId);
|
const uploadMutation = useBulkUploadTournamentCodes(communityId);
|
||||||
const restoreMutation = useRestoreTournamentCode(communityId);
|
const restoreMutation = useRestoreTournamentCode(communityId);
|
||||||
@@ -125,6 +133,29 @@ export default function TournamentCodesPage() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!communityId) {
|
||||||
|
return (
|
||||||
|
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
|
||||||
|
<h1 className="text-lg font-bold">커뮤니티 설정이 필요합니다</h1>
|
||||||
|
<p className="mt-2 text-sm text-base-content/40">
|
||||||
|
`VITE_DEFAULT_COMMUNITY_ID`를 설정하거나 올바른 커뮤니티 경로로
|
||||||
|
접속해주세요.
|
||||||
|
</p>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meQuery.isPending) {
|
||||||
|
return (
|
||||||
|
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
|
||||||
|
<h1 className="text-lg font-bold">권한 확인 중...</h1>
|
||||||
|
<p className="mt-2 text-sm text-base-content/40">
|
||||||
|
로그인한 계정의 커뮤니티 권한을 확인하고 있습니다.
|
||||||
|
</p>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!canManage) {
|
if (!canManage) {
|
||||||
return (
|
return (
|
||||||
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
|
<main className="max-w-5xl mx-auto px-4 py-20 text-center">
|
||||||
@@ -132,6 +163,19 @@ export default function TournamentCodesPage() {
|
|||||||
<p className="mt-2 text-sm text-base-content/40">
|
<p className="mt-2 text-sm text-base-content/40">
|
||||||
토너먼트 코드 풀은 owner/admin만 관리할 수 있습니다.
|
토너먼트 코드 풀은 owner/admin만 관리할 수 있습니다.
|
||||||
</p>
|
</p>
|
||||||
|
{manageableMemberships.length > 0 && (
|
||||||
|
<div className="mt-5 flex flex-wrap justify-center gap-2">
|
||||||
|
{manageableMemberships.map((membership) => (
|
||||||
|
<Link
|
||||||
|
key={membership.community?._id ?? membership.user._id}
|
||||||
|
to={`/admin/communities/${membership.community?._id}/tournament-codes`}
|
||||||
|
className="btn btn-primary btn-sm px-4 text-xs"
|
||||||
|
>
|
||||||
|
{membership.community?.name ?? '관리 가능한 커뮤니티'}로 이동
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user