@@ -5,7 +5,7 @@ import { useEffect } from "react";
55
66export function ProfileUpdateComponent ( ) {
77 const [ file , setFile ] = useState ( null ) ;
8- const [ firstName , setFirstName ] = useState ( "" ) ;
8+ const [ username , setUserName ] = useState ( "" ) ;
99 const [ about , setAbout ] = useState ( ) ;
1010 const fileInputRef = useRef ( null ) ;
1111 const [ profile_pic , setProfilePic ] = useState ( undefined ) ;
@@ -14,11 +14,11 @@ export function ProfileUpdateComponent() {
1414 try {
1515 const response = await axiosInstance . get ( "/user/data/" ) ;
1616 const fetchedProfilePic = response . data . profile_pic ;
17- const fetchedName = response . data . first_name ;
17+ const fetchedName = response . data . username ;
1818 const fetchedAbout = response . data . about ;
1919 setProfilePic ( fetchedProfilePic ) ;
2020 setAbout ( fetchedAbout ) ;
21- setFirstName ( fetchedName ) ;
21+ setUserName ( fetchedName ) ;
2222 } catch ( error ) {
2323 console . error ( "Error fetching user:" , error ) ;
2424 }
@@ -42,7 +42,7 @@ export function ProfileUpdateComponent() {
4242 const handleSave = ( ) => {
4343 const formData = new FormData ( ) ;
4444 formData . append ( "profile_pic" , file ) ;
45- formData . append ( "first_name " , firstName ) ;
45+ formData . append ( "username " , username ) ;
4646 formData . append ( "about" , about ) ;
4747
4848 ApiUpdateUserProfile ( formData ) ;
@@ -62,16 +62,9 @@ export function ProfileUpdateComponent() {
6262 ref = { fileInputRef }
6363 />
6464 </ label >
65- < div
66- className = "avatar w-32 h-32 cursor-pointer hover:blur"
67- onClick = { handleImageUpload }
68- >
65+ < div className = "avatar w-32 h-32 cursor-pointer hover:blur" onClick = { handleImageUpload } >
6966 { file ? (
70- < img
71- src = { URL . createObjectURL ( file ) }
72- alt = "Profile"
73- className = "rounded-full"
74- />
67+ < img src = { URL . createObjectURL ( file ) } alt = "Profile" className = "rounded-full" />
7568 ) : (
7669 < >
7770 < img src = { profile_pic } alt = "Default" className = "rounded-full" />
@@ -96,13 +89,13 @@ export function ProfileUpdateComponent() {
9689
9790 { /* Full Name Field */ }
9891 < div className = "w-96" >
99- < label className = "block mb-2 text-gray-600" > First Name </ label >
92+ < label className = "block mb-2 text-gray-600" > username </ label >
10093 < input
10194 type = "text"
102- placeholder = "Enter your first name "
95+ placeholder = "Enter your username "
10396 className = "input w-full"
104- value = { firstName }
105- onChange = { ( e ) => setFirstName ( e . target . value ) }
97+ value = { username }
98+ onChange = { ( e ) => setUserName ( e . target . value ) }
10699 />
107100 </ div >
108101
0 commit comments