From 21208d7e4ac4826b63e4bdc38aba1ddf3704342b Mon Sep 17 00:00:00 2001 From: shishirbychapur Date: Mon, 7 Oct 2024 02:13:35 +0800 Subject: [PATCH] fix: solve profile bug --- frontend/components/account/Profile.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/components/account/Profile.tsx b/frontend/components/account/Profile.tsx index ebcf1d8156..b17c4c1f17 100644 --- a/frontend/components/account/Profile.tsx +++ b/frontend/components/account/Profile.tsx @@ -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) @@ -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) {