@@ -6,6 +6,7 @@ import axios from "axios";
66import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
77import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons" ;
88import FadeIn from "react-fade-in" ;
9+ import Placeholder from "./Placeholder" ;
910
1011class Help extends Component {
1112 constructor ( props ) {
@@ -14,8 +15,10 @@ class Help extends Component {
1415 query : "" ,
1516 data : { } ,
1617 currentResources : [ ] ,
18+ loadingStatus : null ,
1719 } ;
1820 this . handleQuery = this . handleQuery . bind ( this ) ;
21+ this . handleLoading = this . handleLoading . bind ( this ) ;
1922 this . getData = this . getData . bind ( this ) ;
2023 }
2124
@@ -50,20 +53,25 @@ class Help extends Component {
5053 this . setState ( { query : query } , this . getData ) ;
5154 }
5255
56+ handleLoading ( ) {
57+ this . setState ( { loadingStatus : "loading" } ) ;
58+ }
59+
5360 getData ( ) {
5461 let resources = [ ] ;
5562 for ( const key of Object . keys ( this . state . data ) ) {
56- if ( key === this . state . query ) {
63+ if ( key . toLowerCase ( ) === this . state . query . toLowerCase ( ) ) {
5764 resources . push ( { ...this . state . data [ key ] } ) ;
5865 } else {
5966 for ( const dist of Object . keys ( this . state . data [ key ] ) ) {
60- if ( dist === this . state . query ) {
67+ if ( dist . toLowerCase ( ) === this . state . query . toLowerCase ( ) ) {
6168 resources . push ( { [ key ] : this . state . data [ key ] [ dist ] } ) ;
6269 }
6370 }
6471 }
6572 }
66- this . setState ( { currentResources : resources , isLoading : false } ) ;
73+ this . setState ( { currentResources : resources } ) ;
74+ setTimeout ( ( ) => this . setState ( { loadingStatus : "completeLoading" } ) , 1500 ) ;
6775 }
6876
6977 render ( ) {
@@ -111,9 +119,23 @@ class Help extends Component {
111119 } ) ;
112120 return (
113121 < div className = { classes . help } >
114- < h1 className = { classes . mainHeading } > Help Page</ h1 >
115- < Form handleQuery = { this . handleQuery } />
116- < div className = { classes . container } > { res } </ div >
122+ < h1 className = { classes . mainHeading } >
123+ Search for Essentials and Services
124+ </ h1 >
125+ < Form
126+ handleQuery = { this . handleQuery }
127+ handleLoading = { this . handleLoading }
128+ />
129+ { this . state . loadingStatus === "loading" && (
130+ < div className = { classes . container } >
131+ < Placeholder />
132+ < Placeholder />
133+ < Placeholder />
134+ </ div >
135+ ) }
136+ { this . state . loadingStatus === "completeLoading" && (
137+ < div className = { classes . container } > { res } </ div >
138+ ) }
117139 </ div >
118140 ) ;
119141 }
0 commit comments