1- import React , { useState } from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import { ListItemIcon } from '../../base' ;
33import { useTheme } from '../../theme' ;
44import CollapsibleSection from './CollapsibleSection' ;
@@ -16,15 +16,35 @@ const TechnologySection: React.FC<TechnologySectionProps> = ({
1616 technologies
1717} ) => {
1818 const [ openTechnologies , setOpenTechnologies ] = useState ( true ) ;
19-
19+ const [ validTechnologies , setValidTechnologies ] = useState < string [ ] > ( [ ] ) ;
2020 const theme = useTheme ( ) ;
2121
22+ useEffect ( ( ) => {
23+ // Function to check if SVG exists
24+ const validateTechnologies = async ( ) => {
25+ const validTechs = await Promise . all (
26+ technologies . map ( async ( tech ) => {
27+ const svg_path = `/${ technologySVGPath } /${ tech . toLowerCase ( ) } /${ technologySVGSubpath } /${ tech . toLowerCase ( ) } -color.svg` ;
28+ try {
29+ const response = await fetch ( svg_path ) ;
30+ return response . ok ? tech : null ;
31+ } catch {
32+ return null ;
33+ }
34+ } )
35+ ) ;
36+ setValidTechnologies ( validTechs . filter ( ( tech ) : tech is string => tech !== null ) ) ;
37+ } ;
38+
39+ validateTechnologies ( ) ;
40+ } , [ technologies , technologySVGPath , technologySVGSubpath ] ) ;
41+
2242 const renderTechnologyItem = ( item : string , index : number ) => {
2343 const svg_path = `${ technologySVGPath } /${ item . toLowerCase ( ) } /${ technologySVGSubpath } /${ item . toLowerCase ( ) } -color.svg` ;
2444 return (
2545 < LabelDiv key = { index } >
2646 < ListItemIcon sx = { { minWidth : '1.5rem' , marginRight : 1 } } >
27- < img height = "24px" width = "24px" src = { `/${ svg_path } ` } alt = "technology icon" />
47+ < img height = "24px" width = "24px" src = { `/${ svg_path } ` } alt = { ` ${ item } icon` } />
2848 </ ListItemIcon >
2949 { item }
3050 </ LabelDiv >
@@ -46,7 +66,7 @@ const TechnologySection: React.FC<TechnologySectionProps> = ({
4666 title = "TECHNOLOGY"
4767 isOpen = { openTechnologies }
4868 onToggle = { ( ) => setOpenTechnologies ( ( prev ) => ! prev ) }
49- items = { technologies }
69+ items = { validTechnologies }
5070 renderItem = { renderTechnologyItem }
5171 emptyState = { 'No technologies assigned to this design' }
5272 tooltip = { 'Technologies used in this design' }
0 commit comments