@@ -10,6 +10,7 @@ class Help extends Component {
10
10
this . state = {
11
11
query : "" ,
12
12
data : { } ,
13
+ currentResources : [ ] ,
13
14
} ;
14
15
this . handleQuery = this . handleQuery . bind ( this ) ;
15
16
this . getData = this . getData . bind ( this ) ;
@@ -47,33 +48,63 @@ class Help extends Component {
47
48
}
48
49
49
50
getData ( ) {
50
- let resources = { } ;
51
- let locationType ;
51
+ let resources = [ ] ;
52
52
for ( const key of Object . keys ( this . state . data ) ) {
53
53
if ( key === this . state . query ) {
54
- resources = this . state . data [ key ] ;
55
- locationType = "multiple" ;
54
+ resources . push ( { ...this . state . data [ key ] } ) ;
56
55
} else {
57
56
for ( const dist of Object . keys ( this . state . data [ key ] ) ) {
58
57
if ( dist === this . state . query ) {
59
- resources = this . state . data [ key ] [ dist ] ;
60
- locationType = "single" ;
58
+ resources . push ( { [ key ] : this . state . data [ key ] [ dist ] } ) ;
61
59
}
62
60
}
63
61
}
64
62
}
65
- this . setState ( { currentResources : resources , locationType : locationType } ) ;
63
+ this . setState ( { currentResources : resources } ) ;
66
64
}
67
65
68
66
render ( ) {
67
+ const res = this . state . currentResources . map ( ( object ) => {
68
+ for ( const key in object ) {
69
+ if ( object . hasOwnProperty ( key ) ) {
70
+ for ( const key2 in object [ key ] ) {
71
+ if ( object [ key ] . hasOwnProperty ( key2 ) ) {
72
+ const result = object [ key ] [ key2 ] . map ( ( resource ) => (
73
+ < div >
74
+ < h3 > { resource . category } </ h3 >
75
+ < p > Organization: { resource . nameoftheorganisation } </ p >
76
+ < a href = { resource . contact } > Link</ a >
77
+ < p > Contact: { resource . phonenumber } </ p >
78
+ </ div >
79
+ ) ) ;
80
+ return result ;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ return null ;
86
+ } ) ;
69
87
return (
70
88
< div >
71
89
< h1 > Help Page</ h1 >
72
90
< p > For Help Please Contact</ p >
73
91
< Form handleQuery = { this . handleQuery } />
92
+ { res }
74
93
</ div >
75
94
) ;
76
95
}
77
96
}
78
97
79
98
export default withStyles ( styles ) ( Help ) ;
99
+
100
+ // 0:
101
+ // Gangtok:
102
+ // CoVID-19 Testing Lab: Array(1)
103
+ // 0:
104
+ // category: "CoVID-19 Testing Lab"
105
+ // city: "Gangtok"
106
+ // contact: "https://covid.icmr.org.in/index.php/testing-labs-deatails#"
107
+ // descriptionandorserviceprovided: "Collection Site Only"
108
+ // nameoftheorganisation: "Sir Thutob Namgyal Memorial (STNM)"
109
+ // phonenumber: "9845562399"
110
+ // state: "Sikkim"
0 commit comments