Skip to content

Commit fff168f

Browse files
committed
♻️ [fix] : 회원정보 수정 정상화(유효성 검증)
1 parent 79b1c06 commit fff168f

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/api/admin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ export const getMemberDetailAdmin = async (id: string) => {
4646
}
4747

4848
export const updateMemberAdmin = async (id: string, data: UserUpdateValue) => {
49-
const response = await axiosInstance.post(`api/managements/members/${id}`, data)
49+
const response = await axiosInstance.patch(`api/managements/members/${id}`, data)
5050
return response.data
5151
}

src/components/user-manage/UserUpdate.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</ModalView>
99
<RequestTaskInput
1010
v-model="userRegistrationForm.name"
11+
:is-invalidate="isInvalidate"
1112
:placeholderText="'회원의 이름을 입력해주세요'"
1213
:labelName="'이름'" />
1314
<RequestTaskInput
@@ -113,8 +114,23 @@ const handleCancel = async () => {
113114
router.back()
114115
}
115116
117+
const usernameRegex = /^[a-z]{3,10}\.[a-z]{1,5}$/
118+
const emailRegex = /^@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/
119+
116120
const handleSubmit = async () => {
117121
try {
122+
if (!userRegistrationForm.value.name) {
123+
isInvalidate.value = 'nameEmpty'
124+
return
125+
}
126+
if (!usernameRegex.test(userRegistrationForm.value.nickname)) {
127+
isInvalidate.value = 'wrongNickname'
128+
return
129+
}
130+
if (!emailRegex.test(userRegistrationForm.value.email)) {
131+
isInvalidate.value = 'wrongEmail'
132+
return
133+
}
118134
if (typeof userId.value === 'string') {
119135
const userData = {
120136
role: RoleTypeMapping[userRegistrationForm.value.role],
@@ -123,6 +139,7 @@ const handleSubmit = async () => {
123139
departmentId: userRegistrationForm.value.departmentId,
124140
departmentRole: userRegistrationForm.value.departmentRole
125141
}
142+
126143
await updateMemberAdmin(userId.value, userData)
127144
isModalVisible.value = true
128145
}

0 commit comments

Comments
 (0)