From 3ff9daf124a2bcf7c1676705c585e4b3b049c9c5 Mon Sep 17 00:00:00 2001 From: jiyeon Date: Thu, 6 Feb 2025 17:15:53 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20[refactor]=20:=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=9C=84=EC=B9=98=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.ts | 7 ++++++- src/api/user.ts | 6 ------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/api/common.ts b/src/api/common.ts index 73c05ae7..38499909 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -1,4 +1,9 @@ -import { axiosInstance } from '../utils/axios' +import { axiosInstance, formDataAxiosInstance } from '../utils/axios' + +export const patchEditInfo = async (formdata: FormData) => { + const response = await formDataAxiosInstance.patch('/api/members/info', formdata) + return response.data +} export const getNotification = async (pageNum: number, sizeNum: number) => { const response = await axiosInstance.get(`/api/notifications?page=${pageNum}&size=${sizeNum}`) diff --git a/src/api/user.ts b/src/api/user.ts index 4b6d2eaf..0315d6e2 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,13 +1,7 @@ import type { Status } from '@/types/common' -import type { userInfo } from '@/types/user' import type { RequestApprovePostTypes } from '@/types/manager' import { axiosInstance, formDataAxiosInstance } from '@/utils/axios' -export const patchEditInfo = async (formdata: userInfo, image: File) => { - const response = await formDataAxiosInstance.post('/api/tasks', formdata, image) - return response.data -} - export const postTaskRequest = async (formdata: FormData) => { const response = await formDataAxiosInstance.post('/api/tasks', formdata) return response.data From 7bd4ec3f14f504edd998857d358a9f98f9baea9f Mon Sep 17 00:00:00 2001 From: jiyeon Date: Thu, 6 Feb 2025 18:05:58 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E2=9C=A8=20=20[feat]=20:=20=ED=94=8C?= =?UTF-8?q?=EB=9E=AB=ED=8F=BC=20=EC=95=8C=EB=A6=BC=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?api=20=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditInformation.vue | 62 +++++++++++++++++------------- src/stores/member.ts | 24 ++++++------ src/types/auth.ts | 5 +++ src/types/user.ts | 7 ---- 4 files changed, 53 insertions(+), 45 deletions(-) diff --git a/src/components/EditInformation.vue b/src/components/EditInformation.vue index 17e774de..bb726881 100644 --- a/src/components/EditInformation.vue +++ b/src/components/EditInformation.vue @@ -55,17 +55,17 @@

알림 수신 여부

+ :isChecked="info.notificationSettingInfo.agit" /> + :isChecked="info.notificationSettingInfo.kakaoWork" /> + :isChecked="info.notificationSettingInfo.email" />
@@ -94,8 +94,7 @@ import FormCheckbox from './common/FormCheckbox.vue' const router = useRouter() import { useMemberStore } from '@/stores/member' import { storeToRefs } from 'pinia' -import { patchEditInfo } from '@/api/user' -import +import { patchEditInfo } from '@/api/common' const memberStore = useMemberStore() const { info } = storeToRefs(memberStore) @@ -105,20 +104,6 @@ const previewUrl = ref(null) const isModalVisible = ref(false) -const memberForm = ref({ - isAgitChecked: false, - isKakaoWorkChecked: false, - isEmailChecked: false -}) - -const formData = new FormData() - -const requestData: any = { - name: info.value.memberName, - agitNotification: memberForm.value.isAgitChecked, - emailNotification: memberForm.value.isEmailChecked, - kakaoWorkNotification: memberForm.value.isKakaoWorkChecked -} const handleCancel = () => { router.back() } @@ -136,9 +121,34 @@ const handleFileUpload = (event: Event) => { } } -const handleSubmit = () => { - isModalVisible.value = true - console.log(requestData) - patchEditInfo(requestData, selectedFile.value) +const handleSubmit = async () => { + const formData = new FormData() + const memberInfo = { + name: info.value.memberName, + agitNotification: info.value.notificationSettingInfo.agit, + emailNotification: info.value.notificationSettingInfo.email, + kakaoWorkNotification: info.value.notificationSettingInfo.kakaoWork + } + + const jsonMemberInfo = JSON.stringify(memberInfo) + const newBlob = new Blob([jsonMemberInfo], { type: 'application/json' }) + + formData.append('memberInfo', newBlob) + + if (selectedFile.value) { + formData.append('profileImage', selectedFile.value) + } + + try { + console.log(formData) + patchEditInfo(formData) + await memberStore.updateMemberInfoWithToken() + console.log('memberInfo.agitNotification', memberInfo.agitNotification) + console.log('memberInfo.emailNotification', memberInfo.emailNotification) + console.log('memberInfo.kakaoWorkNotification', memberInfo.kakaoWorkNotification) + isModalVisible.value = true + } catch (error) { + console.error('요청 실패:', error) + } } diff --git a/src/stores/member.ts b/src/stores/member.ts index f4e45b13..57cb0b4e 100644 --- a/src/stores/member.ts +++ b/src/stores/member.ts @@ -13,7 +13,12 @@ export const useMemberStore = defineStore('memberInfo', () => { memberStatus: '', email: '', departmentName: '', - departmentRole: '' + departmentRole: '', + notificationSettingInfo: { + agit: false, + email: false, + kakaoWork: false + } }) const refreshToken = ref(Cookies.get('refreshToken') || '') @@ -35,22 +40,17 @@ export const useMemberStore = defineStore('memberInfo', () => { memberRole: responseData.role || '', memberStatus: responseData.memberStatus || '', departmentName: responseData.departmentName || '', - departmentRole: responseData.departmentRole || '' + departmentRole: responseData.departmentRole || '', + notificationSettingInfo: { + agit: responseData.notificationSettingInfo.agit, + email: responseData.notificationSettingInfo.email, + kakaoWork: responseData.notificationSettingInfo.kakaoWork + } } console.log('Updated member info:', info.value) } function logout() { - info.value = { - memberName: '', - nickname: '', - imageUrl: '', - memberRole: '', - memberStatus: '', - email: '', - departmentName: '', - departmentRole: '' - } isLogined.value = false Cookies.remove('accessToken') Cookies.remove('refreshToken') diff --git a/src/types/auth.ts b/src/types/auth.ts index 3e91977d..73529c59 100644 --- a/src/types/auth.ts +++ b/src/types/auth.ts @@ -7,6 +7,11 @@ export interface User { memberStatus: string departmentName: string departmentRole: string + notificationSettingInfo: { + agit: boolean + email: boolean + kakaoWork: boolean + } } export interface loginDataTypes { diff --git a/src/types/user.ts b/src/types/user.ts index 01241965..14a699f4 100644 --- a/src/types/user.ts +++ b/src/types/user.ts @@ -1,13 +1,6 @@ import type { LabelDataTypes, Status } from './common' import type { ManagerTypes } from './manager' -export interface userInfo { - name: string - agitNotification: boolean - emailNotification: boolean - kakaoWorkNotification: boolean -} - export interface MyRequestListData { taskId: number taskCode: string From e559c4cc0b1e91092c4691f47a589ff3f7ab46cd Mon Sep 17 00:00:00 2001 From: jiyeon Date: Thu, 6 Feb 2025 19:13:42 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20[refactor]=20:=20?= =?UTF-8?q?=EC=BD=98=EC=86=94=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EC=83=88=EB=A1=9C?= =?UTF-8?q?=EA=B3=A0=EC=B9=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditInformation.vue | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/EditInformation.vue b/src/components/EditInformation.vue index bb726881..239b7b3e 100644 --- a/src/components/EditInformation.vue +++ b/src/components/EditInformation.vue @@ -141,12 +141,9 @@ const handleSubmit = async () => { try { console.log(formData) - patchEditInfo(formData) - await memberStore.updateMemberInfoWithToken() - console.log('memberInfo.agitNotification', memberInfo.agitNotification) - console.log('memberInfo.emailNotification', memberInfo.emailNotification) - console.log('memberInfo.kakaoWorkNotification', memberInfo.kakaoWorkNotification) + await patchEditInfo(formData) isModalVisible.value = true + await memberStore.updateMemberInfoWithToken() } catch (error) { console.error('요청 실패:', error) } From e16bd564f5327e52f06835d7904ce7ea61b35bde Mon Sep 17 00:00:00 2001 From: jiyeon Date: Thu, 6 Feb 2025 19:17:31 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20[refactor]=20:=20conso?= =?UTF-8?q?le.log=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.ts | 2 -- src/components/EditInformation.vue | 1 - src/components/top-bar/NotificationModal.vue | 1 - src/stores/member.ts | 2 -- 4 files changed, 6 deletions(-) diff --git a/src/api/common.ts b/src/api/common.ts index 38499909..c318e696 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -13,13 +13,11 @@ export const getNotification = async (pageNum: number, sizeNum: number) => { export const patchNotificationRead = async (notificationId: number) => { const response = await axiosInstance.patch(`/api/notification/${notificationId}`) - console.log(notificationId) return response.data } export const getNotifiCount = async () => { const response = await axiosInstance.get(`/api/notifications/count`) - console.log(response.data) return response.data } diff --git a/src/components/EditInformation.vue b/src/components/EditInformation.vue index 239b7b3e..f7284788 100644 --- a/src/components/EditInformation.vue +++ b/src/components/EditInformation.vue @@ -140,7 +140,6 @@ const handleSubmit = async () => { } try { - console.log(formData) await patchEditInfo(formData) isModalVisible.value = true await memberStore.updateMemberInfoWithToken() diff --git a/src/components/top-bar/NotificationModal.vue b/src/components/top-bar/NotificationModal.vue index 9027748c..02e83f48 100644 --- a/src/components/top-bar/NotificationModal.vue +++ b/src/components/top-bar/NotificationModal.vue @@ -85,7 +85,6 @@ const hasNext = ref(true) const loadMoreNotifications = async ($state: any) => { try { const response = await getNotification(page.value, pageSize) - console.log(response) if (response.isFirst) { notifications.value = response.content diff --git a/src/stores/member.ts b/src/stores/member.ts index 57cb0b4e..d0914b48 100644 --- a/src/stores/member.ts +++ b/src/stores/member.ts @@ -26,7 +26,6 @@ export const useMemberStore = defineStore('memberInfo', () => { async function updateMemberInfoWithToken() { const response = await axiosInstance.get('/api/members/info') - console.log('API Response:', response.data) updateMemberInfo(response.data) isLogined.value = true } @@ -47,7 +46,6 @@ export const useMemberStore = defineStore('memberInfo', () => { kakaoWork: responseData.notificationSettingInfo.kakaoWork } } - console.log('Updated member info:', info.value) } function logout() { From a9070124335a05e92233f9e514e61700b4f97cf9 Mon Sep 17 00:00:00 2001 From: jiyeon Date: Thu, 6 Feb 2025 19:27:42 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20[refactor]=20:=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=ED=82=A4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditInformation.vue | 8 ++++---- src/components/top-bar/SideBar.vue | 8 ++++---- src/components/top-bar/TopBar.vue | 12 ++++++------ src/stores/member.ts | 16 ++++++++-------- src/types/auth.ts | 6 +++--- src/views/LoginView.vue | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/components/EditInformation.vue b/src/components/EditInformation.vue index f7284788..c913ef9a 100644 --- a/src/components/EditInformation.vue +++ b/src/components/EditInformation.vue @@ -10,8 +10,8 @@

프로필 사진

프로필 이미지 @@ -33,7 +33,7 @@ + v-model="info.name" />

아이디

@@ -124,7 +124,7 @@ const handleFileUpload = (event: Event) => { const handleSubmit = async () => { const formData = new FormData() const memberInfo = { - name: info.value.memberName, + name: info.value.name, agitNotification: info.value.notificationSettingInfo.agit, emailNotification: info.value.notificationSettingInfo.email, kakaoWorkNotification: info.value.notificationSettingInfo.kakaoWork diff --git a/src/components/top-bar/SideBar.vue b/src/components/top-bar/SideBar.vue index 7ba44dde..69b1e411 100644 --- a/src/components/top-bar/SideBar.vue +++ b/src/components/top-bar/SideBar.vue @@ -40,9 +40,9 @@
프로필 이미지
info.value.memberRole) -const name = computed(() => info.value.memberName) +const role = computed(() => info.value.role) +const name = computed(() => info.value.name) const nickname = computed(() => info.value.nickname) const filteredMenu = computed(() => { diff --git a/src/components/top-bar/TopBar.vue b/src/components/top-bar/TopBar.vue index f761b739..4576347f 100644 --- a/src/components/top-bar/TopBar.vue +++ b/src/components/top-bar/TopBar.vue @@ -29,9 +29,9 @@ type="button" @click="toggleProfile"> 프로필 이미지
{ } const originUrl = route.path.split('/')[1] - if (info.value.memberRole === 'ROLE_USER') { + if (info.value.role === 'ROLE_USER') { if (!PERMITTED_URL.ROLE_USER.includes(originUrl)) router.push('/my-request') - } else if (info.value.memberRole === 'ROLE_MANAGER') { + } else if (info.value.role === 'ROLE_MANAGER') { if (!PERMITTED_URL.ROLE_MANAGER.includes(originUrl)) router.push('/my-task') - } else if (info.value.memberRole === 'ROLE_ADMIN') { + } else if (info.value.role === 'ROLE_ADMIN') { if (!PERMITTED_URL.ROLE_ADMIN.includes(originUrl)) router.push('/member-management') } else { if (!PERMITTED_URL.UNKNOWN.includes(originUrl)) { @@ -121,7 +121,7 @@ watch(isLogined, newValue => { watch( () => info.value, async newInfo => { - if (newInfo.memberName && isLogined) { + if (newInfo.name && isLogined) { await fetchNotificationCount() } }, diff --git a/src/stores/member.ts b/src/stores/member.ts index d0914b48..3c164ea2 100644 --- a/src/stores/member.ts +++ b/src/stores/member.ts @@ -6,10 +6,10 @@ import Cookies from 'js-cookie' export const useMemberStore = defineStore('memberInfo', () => { const info = ref({ - memberName: '', + name: '', nickname: '', - imageUrl: '', - memberRole: '', + profileImageUrl: '', + role: '', memberStatus: '', email: '', departmentName: '', @@ -30,13 +30,13 @@ export const useMemberStore = defineStore('memberInfo', () => { isLogined.value = true } - function updateMemberInfo(responseData: any) { + function updateMemberInfo(responseData: User) { info.value = { - memberName: responseData.name || '', - nickname: responseData.nicknanme || '', + name: responseData.name || '', + nickname: responseData.nickname || '', email: responseData.email || '', - imageUrl: responseData.profileImageUrl || '', - memberRole: responseData.role || '', + profileImageUrl: responseData.profileImageUrl || '', + role: responseData.role || '', memberStatus: responseData.memberStatus || '', departmentName: responseData.departmentName || '', departmentRole: responseData.departmentRole || '', diff --git a/src/types/auth.ts b/src/types/auth.ts index 73529c59..43a1407d 100644 --- a/src/types/auth.ts +++ b/src/types/auth.ts @@ -1,9 +1,9 @@ export interface User { - memberName: string + name: string nickname: string email: string - imageUrl: string - memberRole: string + profileImageUrl: string + role: string memberStatus: string departmentName: string departmentRole: string diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index 0654f0b8..a5617ef9 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -62,7 +62,7 @@ const handleLogin = async () => { const sessionId = '000' const res = await postLogin(loginData, sessionId) if (res) { - switch (res.memberInfo.memberRole) { + switch (res.memberInfo.role) { case 'ROLE_ADMIN': router.push('/member-management') break