Skip to content

Commit

Permalink
fix(fe): admin role doesn't have to update studentId and major (#2022)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimin9038 authored Aug 27, 2024
1 parent f4606a0 commit 1991b1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions apps/frontend/app/(main)/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default function Page() {
currentPassword: '',
newPassword: '',
confirmPassword: '',
realName: defaultProfileValues.userProfile.realName,
realName: defaultProfileValues.userProfile?.realName ?? '',
studentId: defaultProfileValues.studentId
}
})
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -458,7 +458,9 @@ export default function Page() {
<label className="-mb-4 text-xs">Name</label>
<Input
placeholder={
isLoading ? 'Loading...' : defaultProfileValues.userProfile.realName
isLoading
? 'Loading...'
: defaultProfileValues.userProfile?.realName
}
{...register('realName')}
className={`${realName && (errors.realName ? 'border-red-500' : 'border-primary')} placeholder:text-neutral-300 focus-visible:ring-0`}
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/components/auth/HeaderAuthPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export default function HeaderAuthPanel({
useEffect(() => {
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)
}
Expand Down

0 comments on commit 1991b1b

Please sign in to comment.