From 1991b1bba62b2bf7f44c3659a8b0270401809465 Mon Sep 17 00:00:00 2001 From: jimin9038 Date: Tue, 27 Aug 2024 22:24:06 +0900 Subject: [PATCH] fix(fe): admin role doesn't have to update studentId and major (#2022) --- apps/frontend/app/(main)/settings/page.tsx | 10 ++++++---- apps/frontend/components/auth/HeaderAuthPanel.tsx | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/frontend/app/(main)/settings/page.tsx b/apps/frontend/app/(main)/settings/page.tsx index 2239f27898..e20b7c6366 100644 --- a/apps/frontend/app/(main)/settings/page.tsx +++ b/apps/frontend/app/(main)/settings/page.tsx @@ -134,7 +134,7 @@ export default function Page() { currentPassword: '', newPassword: '', confirmPassword: '', - realName: defaultProfileValues.userProfile.realName, + realName: defaultProfileValues.userProfile?.realName ?? '', studentId: defaultProfileValues.studentId } }) @@ -217,7 +217,7 @@ export default function Page() { try { // 필요 없는 필드 제외 (defaultProfileValues와 값이 같은 것들은 제외) const updatePayload: UpdatePayload = {} - if (data.realName !== defaultProfileValues.userProfile.realName) { + if (data.realName !== defaultProfileValues.userProfile?.realName) { updatePayload.realName = data.realName } if (majorValue !== defaultProfileValues.major) { @@ -252,7 +252,7 @@ export default function Page() { return () => { // submit 되기위해, watch로 확인되는 값이 default값과 같으면 setValue를 통해서 defaultProfileValues로 변경 if (realName === '') { - setValue('realName', defaultProfileValues.userProfile.realName) + setValue('realName', defaultProfileValues.userProfile?.realName) } if (majorValue === defaultProfileValues.major) { setMajorValue(defaultProfileValues.major) @@ -458,7 +458,9 @@ export default function Page() { { const checkIfNeedsUpdate = async () => { const userResponse = await fetcherWithAuth.get('user') - const user: { studentId: string; major: string } = + const user: { role: string; studentId: string; major: string } = await userResponse.json() const updateNeeded = - user.studentId === '0000000000' || - user.major === 'Department Information Unavailable / 학과 정보 없음' + user.role === 'User' && + (user.studentId === '0000000000' || user.major === 'none') setNeedsUpdate(updateNeeded) }