Skip to content

Commit 1a7cda9

Browse files
authored
Merge pull request #87 from TaskFlow-CLAP/CLAP-265
CLAP-265 404 페이지 구현 및 라우팅 설정
2 parents 9183ae8 + dfb2a4e commit 1a7cda9

File tree

9 files changed

+100
-23
lines changed

9 files changed

+100
-23
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template>
2+
<div class="flex flex-col gap-2 items-center">
3+
<span class="text-4xl font-bold text-black whitespace-pre-wrap text-center leading-tight">{{
4+
title
5+
}}</span>
6+
<span class="font-bold whitespace-pre-wrap text-body text-center">{{ content }}</span>
7+
</div>
8+
</template>
9+
10+
<script setup lang="ts">
11+
defineProps<{ title: string; content?: string }>()
12+
</script>

src/components/top-bar/TopBar.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,29 @@ import { storeToRefs } from 'pinia'
5555
import { useMemberStore } from '@/stores/member'
5656
import NotificationModal from './NotificationModal.vue'
5757
import ProfileModal from './ProfileModal.vue'
58+
import { useRoute, useRouter } from 'vue-router'
59+
import { PERMITTED_URL } from '@/constants/common'
5860
5961
const memberStore = useMemberStore()
6062
const { info } = storeToRefs(memberStore)
6163
64+
const route = useRoute()
65+
const router = useRouter()
6266
onMounted(async () => {
6367
await memberStore.updateMemberInfoWithToken()
68+
69+
const originUrl = route.path.split('/')[1]
70+
if (info.value.memberRole === 'ROLE_USER') {
71+
if (!PERMITTED_URL.ROLE_USER.includes(originUrl)) router.push('/my-request')
72+
} else if (info.value.memberRole === 'ROLE_MANAGER') {
73+
if (!PERMITTED_URL.ROLE_MANAGER.includes(originUrl)) router.push('/my-task')
74+
} else if (info.value.memberRole === 'ROLE_ADMIN') {
75+
if (!PERMITTED_URL.ROLE_ADMIN.includes(originUrl)) router.push('/member-management')
76+
} else {
77+
if (!PERMITTED_URL.UNKNOWN.includes(originUrl)) {
78+
router.push('/login')
79+
}
80+
}
6481
})
6582
6683
const isSideOpen = ref(false)

src/constants/common.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,34 @@ export const COLOR_LIST = [
3737
{ borderColor: '#8B5CF6', fillColor: '#F5F3FF', colorEnum: 'PURPLE' },
3838
{ borderColor: '#A1A1AA', fillColor: '#F4F4F5', colorEnum: 'GREY' }
3939
]
40+
41+
export const PERMITTED_URL = {
42+
UNKNOWN: ['login', 'pw-change-email', 'pw-change'],
43+
ROLE_USER: ['my-request', 'task-request', 'edit-information', 'pw-check', 'pw-change'],
44+
ROLE_MANAGER: [
45+
'my-request',
46+
'task-request',
47+
'requested',
48+
'request-history',
49+
'my-task',
50+
'task-board',
51+
'team-board',
52+
'statistics',
53+
'task-detail',
54+
'edit-information',
55+
'pw-check',
56+
'pw-change'
57+
],
58+
ROLE_ADMIN: [
59+
'member-management',
60+
'edit-information',
61+
'task-management',
62+
'category-first',
63+
'category-second',
64+
'login-logs',
65+
'api-logs',
66+
'edit-information',
67+
'pw-check',
68+
'pw-change'
69+
]
70+
}

src/router/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const router = createRouter({
88
name: 'Login',
99
component: () => import('../views/LoginView.vue')
1010
},
11-
1211
{
1312
path: '/pw-change',
1413
name: 'PwChange',
@@ -111,6 +110,11 @@ const router = createRouter({
111110
path: '/statistics',
112111
name: 'Statistics',
113112
component: () => import('../views/StatisticsView.vue')
113+
},
114+
{
115+
path: '/:pathMatch(.*)*',
116+
name: 'NotFound',
117+
component: () => import('../views/NotFoundView.vue')
114118
}
115119
]
116120
})

src/views/LoginView.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<template>
22
<div class="max-w-400">
33
<div class="py-16">
4-
<div class="text-4xl font-bold text-center">
5-
<p class="pb-2">TaskFlow</p>
6-
<p class="pb-2">로그인</p>
7-
</div>
8-
<p class="text-center font-bold text-body">아이디와 비밀번호를 입력해주세요</p>
4+
<TitleContainer
5+
:title="'TaskFlow\n로그인'"
6+
content="아이디와 비밀번호를 입력해주세요" />
97
</div>
108
<form
119
@submit.prevent="handleLogin"
@@ -48,6 +46,7 @@
4846
import { ref } from 'vue'
4947
import { useRouter } from 'vue-router'
5048
import { postLogin } from '@/api/auth'
49+
import TitleContainer from '@/components/common/TitleContainer.vue'
5150
5251
const router = useRouter()
5352

src/views/NotFoundView.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div class="max-w-400 h-screen flex flex-col justify-center items-center gap-16">
3+
<TitleContainer
4+
title="404 Error"
5+
:content="'요청하신 페이지는\n없는 페이지입니다'" />
6+
<button
7+
class="button-large-primary"
8+
@click="router.back()">
9+
이전으로
10+
</button>
11+
</div>
12+
</template>
13+
14+
<script setup lang="ts">
15+
import TitleContainer from '@/components/common/TitleContainer.vue'
16+
import { useRouter } from 'vue-router'
17+
18+
const router = useRouter()
19+
</script>

src/views/PwChange.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
<template #body> 다시 로그인 해주세요 </template>
99
</ModalView>
1010
<div class="py-16">
11-
<div class="text-4xl font-bold text-center">
12-
<p class="pb-2">비밀번호</p>
13-
<p class="pb-2">재설정</p>
14-
</div>
15-
<p class="text-center font-bold text-body">초기 비밀번호를 변경해주세요</p>
11+
<TitleContainer
12+
:title="'비밀번호\n재설정'"
13+
content="초기 비밀번호를 변경해주세요" />
1614
</div>
1715
<form
1816
@submit.prevent="handleChange"
@@ -50,6 +48,7 @@ import { ref } from 'vue'
5048
import { useRouter } from 'vue-router'
5149
import ModalView from '../components/ModalView.vue'
5250
import { patchPassword } from '@/api/auth'
51+
import TitleContainer from '@/components/common/TitleContainer.vue'
5352
5453
const newPw = ref('')
5554
const checkPw = ref('')

src/views/PwChangeEmail.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
<template #body> 이메일을 확인해주세요 </template>
99
</ModalView>
1010
<div class="py-16">
11-
<div class="text-4xl font-bold text-center">
12-
<p class="pb-2">비밀번호</p>
13-
<p class="pb-2">재설정</p>
14-
</div>
15-
<p class="text-center font-bold text-body">가입된 아이디와 이메일을 입력해주세요</p>
11+
<TitleContainer
12+
:title="'비밀번호\n재설정'"
13+
content="가입된 아이디와 이메일을 입력해주세요" />
1614
</div>
1715
<form
1816
@submit.prevent="handleCheck"
@@ -67,6 +65,7 @@
6765
import { ref } from 'vue'
6866
import router from '../router/index'
6967
import ModalView from '../components/ModalView.vue'
68+
import TitleContainer from '@/components/common/TitleContainer.vue'
7069
7170
const id = ref('')
7271
const email = ref('')

src/views/PwCheck.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<template>
22
<div class="max-w-400">
33
<div class="py-16">
4-
<div class="text-4xl font-bold text-center">
5-
<p class="pb-2">비밀번호</p>
6-
<p class="pb-2">재설정</p>
7-
</div>
8-
<p class="text-center font-semibold text-body">
9-
비밀번호 재설정을 위해<br />현재 비밀번호를 입력해주세요
10-
</p>
4+
<TitleContainer
5+
:title="'비밀번호\n재설정'"
6+
content="비밀번호 재설정을 위해\n현재 비밀번호를 입력해주세요" />
117
</div>
128
<form
139
@submit.prevent="handleCheck"
@@ -36,6 +32,7 @@
3632
<script setup lang="ts">
3733
import { ref } from 'vue'
3834
import router from '../router/index'
35+
import TitleContainer from '@/components/common/TitleContainer.vue'
3936
4037
const pw = ref('')
4138

0 commit comments

Comments
 (0)