-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPwChangeEmail.vue
More file actions
105 lines (98 loc) · 2.99 KB
/
PwChangeEmail.vue
File metadata and controls
105 lines (98 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<template>
<div class="max-w-400">
<ModalView
:isOpen="isModalVisible"
type="successType"
@close="closeModal">
<template #header> 인증 번호가 전송되었습니다 </template>
<template #body> 이메일을 확인해주세요 </template>
</ModalView>
<ModalView
:isOpen="isFailModalVisible"
type="failType"
@close="closeFailModal">
<template #header> {{ messageHeader }} </template>
<template #body> {{ messageBody }}</template>
</ModalView>
<div class="py-16">
<TitleContainer
:title="'비밀번호\n재설정'"
content="가입된 이메일과 이름을 입력해주세요" />
</div>
<form
@submit.prevent="handleCheck"
class="mb-2">
<div class="mb-6">
<input
type="email"
id="email"
v-model="email"
placeholder="이메일 입력해주세요"
required
class="input-box" />
</div>
<div class="relative mb-8">
<input
type="text"
id="name"
v-model="name"
placeholder="이름을 입력해주세요"
required
class="input-box" />
</div>
<button
type="submit"
class="button-large-primary">
확인
</button>
</form>
<div class="flex w-full justify-center"></div>
</div>
</template>
<script setup lang="ts">
import { postPasswordEmailSend } from '@/api/auth'
import TitleContainer from '@/components/common/TitleContainer.vue'
import axios from 'axios'
import { ref } from 'vue'
import router from '../router/index'
import ModalView from '@/components/common/ModalView.vue'
const messageHeader = ref('')
const messageBody = ref('')
const isModalVisible = ref(false)
const isFailModalVisible = ref(false)
const name = ref('')
const email = ref('')
const closeModal = () => {
isModalVisible.value = !isModalVisible.value
router.replace('/login')
}
const closeFailModal = () => {
isFailModalVisible.value = !isFailModalVisible.value
}
const handleCheck = async () => {
try {
await postPasswordEmailSend(name.value, email.value)
isModalVisible.value = !isModalVisible.value
} catch (error) {
if (axios.isAxiosError(error)) {
switch (error?.response?.status) {
case 404:
isFailModalVisible.value = !isFailModalVisible.value
messageHeader.value = '일치하는 정보가 없습니다'
messageBody.value = '이메일과 이름을 다시 확인해 주세요'
break
case 500:
isFailModalVisible.value = !isFailModalVisible.value
messageHeader.value = '서버에 문제가 발생했습니다'
messageBody.value = '잠시후 다시 이용해주세요'
break
default:
isFailModalVisible.value = !isFailModalVisible.value
messageHeader.value = '문제가 발생했습니다'
messageBody.value = '잠시후 다시 이용해주세요'
break
}
}
}
}
</script>