Skip to content

Commit

Permalink
fix: solve profile bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shishirbychapur authored and Daviancold committed Oct 6, 2024
1 parent ae45630 commit 21208d7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/components/account/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { useState } from 'react'
function Profile() {
const { data: session, update } = useSession()
const defaultUsername = session?.user.username ?? ''
const [formValues, setFormValues] = useState({ ...initialFormValues, username: defaultUsername })
const [formValues, setFormValues] = useState({
...initialFormValues,
username: defaultUsername,
proficiency: session?.user.proficiency as Proficiency,
})
const [formErrors, setFormErrors] = useState({ ...initialFormValues, proficiency: '' })
const [isDialogOpen, toggleDialogOpen] = useState(false)
const [isFormSubmit, setIsFormSubmit] = useState(false)
Expand Down Expand Up @@ -41,7 +45,10 @@ function Profile() {
username: response.username ?? '',
proficiency: proficiency,
})
update({ ...session, user: { ...session?.user, username: response.username, role: response.role } })
update({
...session,
user: { ...session?.user, username: response.username, proficiency: proficiency },
})
toast.success('Profile has been updated successfully.')
}
} catch (error) {
Expand Down

0 comments on commit 21208d7

Please sign in to comment.