@@ -39,11 +39,13 @@ import {
3939 Business ,
4040 CheckCircle ,
4141 InsertDriveFile ,
42+ Delete ,
4243} from "@mui/icons-material"
4344import { connectToGitHub , initiateGitHubOAuth , fetchRepoLanguages , handleGitHubOAuth } from "../handlers/githubAuth"
4445import api from "../serverApi"
4546import LinkedinJobs from "../components/LinkedinJobs"
4647import { motion } from "framer-motion"
48+ import { getUserAuth } from "../handlers/userAuth"
4749
4850const roles = [
4951 "Software Engineer" ,
@@ -72,7 +74,7 @@ const skillsList = [
7274]
7375
7476const MainDashboard : React . FC = ( ) => {
75- const theme = useTheme ( )
77+ const theme = useTheme ( ) ;
7678 const [ aboutMe , setAboutMe ] = useState ( ( ) => localStorage . getItem ( "aboutMe" ) || "" )
7779 const [ skills , setSkills ] = useState < string [ ] > ( ( ) => JSON . parse ( localStorage . getItem ( "skills" ) || "[]" ) )
7880 const [ newSkill , setNewSkill ] = useState ( "" )
@@ -87,6 +89,9 @@ const MainDashboard: React.FC = () => {
8789 const [ roleMatch , setRoleMatch ] = useState < string > ( "" )
8890 const [ resumeFileName , setResumeFileName ] = useState < string > ( "" )
8991
92+ // Profile image state
93+ const [ image , setImage ] = useState < string | null > ( null )
94+
9095 // Skills toggle
9196 const [ showAllSkills , setShowAllSkills ] = useState ( false )
9297 const SKILL_DISPLAY_LIMIT = 4
@@ -186,6 +191,22 @@ const MainDashboard: React.FC = () => {
186191 }
187192 }
188193
194+ useEffect ( ( ) => {
195+ const fetchProfileImage = async ( ) => {
196+ try {
197+ const response = await api . get ( `/resource/image/${ getUserAuth ( ) . imageFilename } ` , {
198+ responseType : 'blob' ,
199+ } ) ;
200+ const imageUrl = URL . createObjectURL ( response . data as Blob ) ;
201+ setImage ( imageUrl ) ;
202+ } catch ( error ) {
203+ console . log ( 'Error fetching profile image.' ) ;
204+ setImage ( null ) ;
205+ }
206+ } ;
207+ getUserAuth ( ) . imageFilename && fetchProfileImage ( ) ;
208+ } , [ ] ) ;
209+
189210 // Upload & parse resume
190211 const handleResumeUpload = async ( e : React . ChangeEvent < HTMLInputElement > ) => {
191212
@@ -267,6 +288,10 @@ const MainDashboard: React.FC = () => {
267288
268289 const profileCompletion = calculateProfileCompletion ( )
269290
291+ const handleRemoveAllSkills = ( ) => {
292+ setSkills ( [ ] ) ;
293+ } ;
294+
270295 return (
271296 < Box sx = { { minHeight : "100vh" , py : 4 } } >
272297 < Container maxWidth = "xl" >
@@ -357,7 +382,7 @@ const MainDashboard: React.FC = () => {
357382 { /* Upload Section */ }
358383 < Box sx = { { display : "flex" , justifyContent : "space-between" , alignItems : "center" , mb : 3 } } >
359384 < Box sx = { { display : "flex" , alignItems : "center" } } >
360- < Avatar
385+ { ! image ? < Avatar
361386 sx = { {
362387 bgcolor : alpha ( theme . palette . primary . main , 0.1 ) ,
363388 color : theme . palette . primary . main ,
@@ -367,7 +392,10 @@ const MainDashboard: React.FC = () => {
367392 } }
368393 >
369394 < PersonIcon sx = { { fontSize : 28 } } />
370- </ Avatar >
395+ </ Avatar > :
396+ < Avatar src = { image } alt = "Profile" style = { { width : 56 , height : 56 , marginTop : '16px' , objectFit : 'cover' , margin :7 } } />
397+
398+ }
371399 < Box >
372400 < Typography variant = "h5" fontWeight = { 700 } sx = { { mb : 0.5 } } >
373401 About Me
@@ -463,6 +491,7 @@ const MainDashboard: React.FC = () => {
463491 border : `1px solid ${ alpha ( theme . palette . divider , 0.1 ) } ` ,
464492 boxShadow : `0 8px 32px ${ alpha ( theme . palette . common . black , 0.1 ) } ` ,
465493 transition : "all 0.3s ease" ,
494+ position : 'relative' , // Add position relative
466495 "&:hover" : {
467496 transform : "translateY(-4px)" ,
468497 boxShadow : `0 12px 48px ${ alpha ( theme . palette . common . black , 0.15 ) } ` ,
@@ -491,7 +520,11 @@ const MainDashboard: React.FC = () => {
491520 </ Typography >
492521 </ Box >
493522 </ Box >
494-
523+ < Tooltip title = "Remove all skills" arrow >
524+ < Button size = "small" onClick = { handleRemoveAllSkills } sx = { { mb : 2 , position : 'absolute' , top : 8 , right : 8 } } >
525+ < Delete />
526+ </ Button >
527+ </ Tooltip >
495528 < Stack direction = "row" spacing = { 1 } sx = { { flexWrap : "wrap" , mb : 2 , gap : 1 } } >
496529 { ( showAllSkills ? skills : skills . slice ( 0 , SKILL_DISPLAY_LIMIT ) ) . map ( ( skill , index ) => (
497530 < Chip
0 commit comments