@@ -6,6 +6,7 @@ import axios from "axios";
6
6
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
7
7
import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons" ;
8
8
import FadeIn from "react-fade-in" ;
9
+ import Placeholder from "./Placeholder" ;
9
10
10
11
class Help extends Component {
11
12
constructor ( props ) {
@@ -14,8 +15,10 @@ class Help extends Component {
14
15
query : "" ,
15
16
data : { } ,
16
17
currentResources : [ ] ,
18
+ loadingStatus : null ,
17
19
} ;
18
20
this . handleQuery = this . handleQuery . bind ( this ) ;
21
+ this . handleLoading = this . handleLoading . bind ( this ) ;
19
22
this . getData = this . getData . bind ( this ) ;
20
23
}
21
24
@@ -50,20 +53,25 @@ class Help extends Component {
50
53
this . setState ( { query : query } , this . getData ) ;
51
54
}
52
55
56
+ handleLoading ( ) {
57
+ this . setState ( { loadingStatus : "loading" } ) ;
58
+ }
59
+
53
60
getData ( ) {
54
61
let resources = [ ] ;
55
62
for ( const key of Object . keys ( this . state . data ) ) {
56
- if ( key === this . state . query ) {
63
+ if ( key . toLowerCase ( ) === this . state . query . toLowerCase ( ) ) {
57
64
resources . push ( { ...this . state . data [ key ] } ) ;
58
65
} else {
59
66
for ( const dist of Object . keys ( this . state . data [ key ] ) ) {
60
- if ( dist === this . state . query ) {
67
+ if ( dist . toLowerCase ( ) === this . state . query . toLowerCase ( ) ) {
61
68
resources . push ( { [ key ] : this . state . data [ key ] [ dist ] } ) ;
62
69
}
63
70
}
64
71
}
65
72
}
66
- this . setState ( { currentResources : resources , isLoading : false } ) ;
73
+ this . setState ( { currentResources : resources } ) ;
74
+ setTimeout ( ( ) => this . setState ( { loadingStatus : "completeLoading" } ) , 1500 ) ;
67
75
}
68
76
69
77
render ( ) {
@@ -111,9 +119,23 @@ class Help extends Component {
111
119
} ) ;
112
120
return (
113
121
< 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
+ ) }
117
139
</ div >
118
140
) ;
119
141
}
0 commit comments