File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -2,5 +2,4 @@ import React from "react"
22export  default { 
33    text_loading : < i  className = "fa fa-spinner fa-pulse" > </ i > , 
44    section_loading : < div  className = "p-5" >  < i  className = "fa fa-spinner fa-pulse" > </ i >  Loading...</ div > , 
5-     search_icon  : < i  class = "fa fa-search"  aria-hidden = "true" > </ i > 
65} 
Original file line number Diff line number Diff line change 11import  React ,  {  useState  }  from  "react" ; 
22import  { ReactComponent  as  GitStatsLogo }  from  '../Images/logo.svg' ; 
3- import  Loader  from  "../Components/Extras/Loader"  ; 
3+ import  DataProvider  from  "../Data-provider/index"  
44
55function  Header ( )  { 
6+     var  users  =  [ ] 
67    let  [ dayStatus ,  setTheme ]  =  useState ( true ) ; 
78    let  [ imageUrl ,  setImageUrl ]  =  useState ( "img/sun.png" ) ; 
89    const  [ searchString ,  setSearchString ]  =  useState ( "" ) 
@@ -19,8 +20,10 @@ function Header() {
1920        setTheme ( ! dayStatus ) ; 
2021    } ; 
2122
22-     function  search ( ) { 
23-        window . location . href  =  searchString 
23+    async  function  search ( event ) { 
24+     setSearchString ( event . target . value ) 
25+     let  res  =  await  DataProvider . getSearchUsers ( event . target . value ) 
26+     let  users  =  res . map ( item  =>  console . log ( item ) ) 
2427    } 
2528
2629    return  ( 
@@ -52,10 +55,12 @@ function Header() {
5255                                        className = "search" 
5356                                        placeholder = "Search..." 
5457                                        value = { searchString } 
55-                                         onChange = { ( event )   =>   setSearchString ( event . target . value ) } 
58+                                         onChange = { search } 
5659                                    /> 
5760                                  { /* Search icon */ } 
58-                                     < button  className = "search-icon"  onClick = { search } > { Loader . search_icon } </ button > 
61+                                   < div  className = "Search-result" > 
62+                                     
63+                                   </ div > 
5964                                </ a > 
6065                            </ li > 
6166                            < li > 
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ async function getRepositoryInfo(username, id) {
2525  return  repository_data 
2626} ; 
2727
28+ //Search  
29+ async  function  getSearchUsers ( username ) { 
30+ let  response  =  await  axios . get ( `https://api.github.com/search/users?q=${ username }  ) ; 
31+ return  response . data . items 
32+ } 
33+ 
2834//Network CALL For Pinned Repository 
2935async  function  getPinnedRepo ( username )  { 
3036  let  response  =  await  axios . get ( `${ API_BASE_URL } ${ username }  ) ; 
@@ -263,5 +269,6 @@ export default {
263269  languageGraphCaclulations, 
264270  toReadableBytes, 
265271  advancedRepoAnalysis, 
266-   repoBarGraphCalculation
272+   repoBarGraphCalculation, 
273+   getSearchUsers
267274} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments