Skip to content

Commit db0ef6e

Browse files
committed
feat: show core applications only to leads and above
1 parent c074dde commit db0ef6e

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { ReactNode } from 'react'
2+
3+
import ApiCodeGuard from '@/components/auth/ApiCodeGuard'
4+
5+
export default function DashboardCoreApplicationsLayout({ children }: { children: ReactNode }) {
6+
return (
7+
<ApiCodeGuard requiredRole="LEAD" nextOverride="/dashboard/core-applications">
8+
{children}
9+
</ApiCodeGuard>
10+
)
11+
}

src/app/dashboard/page.tsx

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,56 @@
1+
'use client'
2+
13
import Link from 'next/link'
24

5+
import { useAuth } from '@/hooks/useAuth'
6+
37
const DASHBOARD_LINKS = [
48
{
59
href: '/dashboard/users',
610
title: 'Users',
7-
description: '유저 권한, 팀, 계정 상태를 확인하고 수정합니다.'
11+
description: '유저 권한, 팀, 계정 상태를 확인하고 수정합니다.',
12+
minRoleRank: 2
813
},
914
{
1015
href: '/dashboard/members',
1116
title: 'Members',
12-
description: '신입 멤버 지원서와 회비 납부 상태를 확인합니다.'
17+
description: '신입 멤버 지원서와 회비 납부 상태를 확인합니다.',
18+
minRoleRank: 2
1319
},
1420
{
1521
href: '/dashboard/core-applications',
1622
title: 'Core 지원서',
17-
description: '코어 지원서를 열람하고 합격/불합격을 처리합니다.'
23+
description: '코어 지원서를 열람하고 합격/불합격을 처리합니다.',
24+
minRoleRank: 3
1825
},
1926
{
2027
href: '/dashboard/mbti',
2128
title: 'MBTI',
22-
description: 'MBTI 결과 조회와 팀 매칭을 진행합니다.'
29+
description: 'MBTI 결과 조회와 팀 매칭을 진행합니다.',
30+
minRoleRank: 2
2331
},
2432
{
2533
href: '/dashboard/memo',
2634
title: 'Memo 발송',
27-
description: '신입생 알림 신청 대상에게 안내 메시지를 발송합니다.'
35+
description: '신입생 알림 신청 대상에게 안내 메시지를 발송합니다.',
36+
minRoleRank: 2
2837
}
2938
] as const
3039

40+
const ROLE_RANK: Record<string, number> = {
41+
GUEST: 0,
42+
MEMBER: 1,
43+
CORE: 2,
44+
LEAD: 3,
45+
ORGANIZER: 4,
46+
ADMIN: 5
47+
}
48+
3149
export default function DashboardIndexPage() {
50+
const { user } = useAuth()
51+
const myRoleRank = ROLE_RANK[user?.userRole ?? 'GUEST'] ?? 0
52+
const visibleLinks = DASHBOARD_LINKS.filter((item) => myRoleRank >= item.minRoleRank)
53+
3254
return (
3355
<main className="min-h-screen bg-black px-6 py-10 text-white pc:px-10">
3456
<div className="mx-auto w-full max-w-[1280px] space-y-8">
@@ -41,7 +63,7 @@ export default function DashboardIndexPage() {
4163
</div>
4264

4365
<div className="grid gap-4 pc:grid-cols-2">
44-
{DASHBOARD_LINKS.map((item) => (
66+
{visibleLinks.map((item) => (
4567
<Link
4668
key={item.href}
4769
href={item.href}

0 commit comments

Comments
 (0)