File tree Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Expand file tree Collapse file tree 1 file changed +18
-15
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,23 @@ function Resources() {
21
21
22
22
const { results, count } = data ;
23
23
24
+ const renderResults = ( ) => {
25
+ if ( ! results ) return null ; // to be on safe side in case API breaks
26
+ return (
27
+ < Grid container spacing = { 1 } >
28
+ { results && results . length === 0 ? (
29
+ < Typography > No resources found</ Typography >
30
+ ) : (
31
+ results . map ( resource => (
32
+ < Grid item lg = { 3 } key = { resource . guid } >
33
+ < ResourceCard { ...resource } />
34
+ </ Grid >
35
+ ) )
36
+ ) }
37
+ </ Grid >
38
+ ) ;
39
+ } ;
40
+
24
41
return (
25
42
< Grid container spacing = { 1 } >
26
43
< Grid item lg = { 3 } >
@@ -36,21 +53,7 @@ function Resources() {
36
53
</ Typography >
37
54
) }
38
55
< br />
39
- { error ? (
40
- < div className = "errorMessage" > { error } </ div >
41
- ) : (
42
- < Grid container spacing = { 1 } >
43
- { results . length === 0 ? (
44
- < Typography > No resources found</ Typography >
45
- ) : (
46
- results . map ( resource => (
47
- < Grid item lg = { 3 } key = { resource . guid } >
48
- < ResourceCard { ...resource } />
49
- </ Grid >
50
- ) )
51
- ) }
52
- </ Grid >
53
- ) }
56
+ { error ? < div className = "errorMessage" > { error } </ div > : renderResults ( ) }
54
57
</ Grid >
55
58
</ Grid >
56
59
) ;
You can’t perform that action at this time.
0 commit comments