diff --git a/frontend/src/pages/candidate/Profile.tsx b/frontend/src/pages/candidate/Profile.tsx index 363676c..8058780 100644 --- a/frontend/src/pages/candidate/Profile.tsx +++ b/frontend/src/pages/candidate/Profile.tsx @@ -184,13 +184,32 @@ const CandidateProfile: React.FC = (props: BackstoryPageProp // Handle profile image upload const handleImageUpload = async (e: React.ChangeEvent) => { - if (e.target.files && e.target.files[0]) { - if (await apiClient.uploadCandidateProfile(e.target.files[0])) { + if (!e.target.files || !e.target.files[0]) { + return; + } + + try { + console.log('Uploading profile image:', e.target.files[0]); + const success = await apiClient.uploadCandidateProfile(e.target.files[0]); + if (success) { setProfileImage(URL.createObjectURL(e.target.files[0])); candidate.profileImage = 'profile.' + e.target.files[0].name.replace(/^.*\./, ''); console.log(`Set profile image to: ${candidate.profileImage}`); updateUserData(candidate); + } else { + setSnackbar({ + open: true, + message: 'Failed to upload profile image. Please try again.', + severity: 'error' + }); } + } catch (error) { + console.error('Error uploading profile image:', error); + setSnackbar({ + open: true, + message: 'Failed to upload profile image. Please try again.', + severity: 'error' + }); } };