File tree Expand file tree Collapse file tree 1 file changed +28
-21
lines changed Expand file tree Collapse file tree 1 file changed +28
-21
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,8 @@ const APISearchDrawer: React.FC<APISearchDrawerProps> = ({
216
216
</ Card >
217
217
218
218
{ /* Context Data Tables */ }
219
- { apiSearchResults . context_data &&
219
+ { apiSearchResults &&
220
+ apiSearchResults . context_data &&
220
221
Object . entries ( apiSearchResults . context_data ) . map (
221
222
( [ key , data ] , index ) => (
222
223
< Card sx = { { marginTop : 2 } } key = { index } >
@@ -238,21 +239,23 @@ const APISearchDrawer: React.FC<APISearchDrawerProps> = ({
238
239
unmountOnExit
239
240
>
240
241
< CardContent >
241
- < TableContainer component = { Paper } >
242
- < Table size = "small" >
243
- < TableHead >
244
- < TableRow >
245
- { Object . keys ( data [ 0 ] ) . map ( ( columnName , idx ) => (
246
- < TableCell key = { idx } >
247
- { columnName . charAt ( 0 ) . toUpperCase ( ) +
248
- columnName . slice ( 1 ) }
249
- </ TableCell >
250
- ) ) }
251
- </ TableRow >
252
- </ TableHead >
253
- < TableBody >
254
- { ( data as Array < Record < string , any > > ) . map (
255
- ( row , rowIndex ) => (
242
+ { Array . isArray ( data ) && data . length > 0 ? (
243
+ < TableContainer component = { Paper } >
244
+ < Table size = "small" >
245
+ < TableHead >
246
+ < TableRow >
247
+ { Object . keys ( data [ 0 ] ) . map (
248
+ ( columnName , idx ) => (
249
+ < TableCell key = { idx } >
250
+ { columnName . charAt ( 0 ) . toUpperCase ( ) +
251
+ columnName . slice ( 1 ) }
252
+ </ TableCell >
253
+ )
254
+ ) }
255
+ </ TableRow >
256
+ </ TableHead >
257
+ < TableBody >
258
+ { data . map ( ( row , rowIndex ) => (
256
259
< TableRow key = { rowIndex } >
257
260
{ Object . values ( row ) . map (
258
261
( value , cellIndex ) => (
@@ -264,11 +267,15 @@ const APISearchDrawer: React.FC<APISearchDrawerProps> = ({
264
267
)
265
268
) }
266
269
</ TableRow >
267
- )
268
- ) }
269
- </ TableBody >
270
- </ Table >
271
- </ TableContainer >
270
+ ) ) }
271
+ </ TableBody >
272
+ </ Table >
273
+ </ TableContainer >
274
+ ) : (
275
+ < Typography variant = "body2" color = "textSecondary" >
276
+ No data available
277
+ </ Typography >
278
+ ) }
272
279
</ CardContent >
273
280
</ Collapse >
274
281
</ Card >
You can’t perform that action at this time.
0 commit comments