11import React , { useState , useEffect } from 'react' ;
22import Select from 'react-select' ;
3- import { AiOutlineSend } from 'react-icons/ai' ;
3+ import { AiOutlineSend , AiFillPython } from 'react-icons/ai' ;
44import { HiOutlineRefresh } from 'react-icons/hi' ;
5+ import { DiJavascript1 } from 'react-icons/di' ; // JS icon
6+ import { MdDescription } from 'react-icons/md' ; // Readme icon
7+ import { FaPython } from 'react-icons/fa' ;
8+
9+
10+
511
612const SearchBar = ( { addFileToContext } ) => {
713 const [ selectedOptions , setSelectedOptions ] = useState ( null ) ;
@@ -10,6 +16,27 @@ const SearchBar = ({ addFileToContext }) => {
1016 const [ fileStatus , setFileStatus ] = useState ( null ) ; // Add this state
1117
1218 const timetout = 1000 ;
19+ const fileIcon = ( fileType ) => {
20+ console . log ( fileType ) ;
21+ switch ( fileType ) {
22+ case 'py' :
23+ return < span className = 'text-python-blue' > < FaPython /> </ span >
24+ case 'js' :
25+ return < span className = 'text-yellow-500' > < DiJavascript1 /> </ span >
26+ case 'md' :
27+ return < span className = "text-black" > < MdDescription /> </ span >
28+ default :
29+ return null ;
30+ }
31+ } ;
32+ // Modify the option labels
33+ const formatOptionLabel = ( { value, label } ) => (
34+
35+ < div className = "flex items-center" >
36+ { fileIcon ( value . split ( '.' ) . pop ( ) ) } < span className = "ml-2" > { label } </ span >
37+ </ div >
38+
39+ ) ;
1340
1441 const handleChange = option => {
1542 setSelectedOptions ( option ) ;
@@ -156,6 +183,7 @@ const SearchBar = ({ addFileToContext }) => {
156183 styles = { customStyles }
157184 closeMenuOnSelect = { false }
158185 blurInputOnSelect = { false }
186+ formatOptionLabel = { formatOptionLabel } // Use the custom format here
159187 placeholder = 'Add File to Context'
160188 />
161189 < button className = 'text-purple-700 ml-5 text-lg' onClick = { sendFiles } >
0 commit comments