1- import React , { ChangeEvent , useEffect , useState } from "react" ;
2- import { Box , Button , Card , Checkbox , Collapse , Divider , FormControlLabel , FormGroup , IconButton , Stack , TextField , ToggleButton , ToggleButtonGroup , Typography } from "@mui/material" ;
1+ import React , { ChangeEvent , useEffect , useMemo , useState } from "react" ;
2+ import { Box , Button , Card , Checkbox , Collapse , Divider , FormControlLabel , FormGroup , IconButton , LinearProgress , Stack , TextField , ToggleButton , ToggleButtonGroup , Typography } from "@mui/material" ;
33import { gql } from "@apollo/client" ;
44import { useLazyQuery } from "@apollo/client/react" ;
55import { useLocation , useNavigate , useParams } from "react-router-dom" ;
@@ -141,8 +141,11 @@ export default function AdminHistoryPage() {
141141 navigate ( `/admin/history` , { replace : true } ) ;
142142 } ;
143143
144- const showClearButton =
145- startDateString || stopDateString || search . includes ( "q=" ) ;
144+ const showClearButton = startDateString || stopDateString || search . includes ( "q=" ) ;
145+
146+ const logs = useMemo ( ( ) => {
147+ return queryResult . data ? queryResult . data . auditLogs : undefined ;
148+ } , [ queryResult . data , queryResult . data ?. auditLogs ] )
146149
147150 return (
148151 < Box margin = "25px" >
@@ -259,27 +262,23 @@ export default function AdminHistoryPage() {
259262 </ Stack >
260263 </ Collapse >
261264 </ Card >
262- < RequestWrapper2
263- result = { queryResult }
264- render = { ( data ) => {
265- if ( data . auditLogs . length === 0 ) {
266- return (
267- < Typography
268- variant = "body1"
269- sx = { {
270- fontStyle : "italic" ,
271- color : "grey.700" ,
272- mx : "auto" ,
273- my : 8 ,
274- } }
275- >
276- No results.
277- </ Typography >
278- ) ;
279- }
280- return (
281- < Stack divider = { < Divider flexItem /> } mt = { 4 } spacing = { 0.75 } >
282- { data . auditLogs . map ( ( log : any ) => (
265+ {
266+ logs === undefined
267+ ? < LinearProgress />
268+ : ( logs . length === 0 )
269+ ? < Typography
270+ variant = "body1"
271+ sx = { {
272+ fontStyle : "italic" ,
273+ color : "grey.700" ,
274+ mx : "auto" ,
275+ my : 8 ,
276+ } }
277+ >
278+ No results.
279+ </ Typography >
280+ : < Stack divider = { < Divider flexItem /> } mt = { 4 } spacing = { 0.75 } >
281+ { logs . map ( ( log : any ) => (
283282 < AuditLogRow
284283 key = { log . id }
285284 dateTime = { log . dateTime }
@@ -290,9 +289,7 @@ export default function AdminHistoryPage() {
290289 ) ) }
291290 < Typography variant = "body2" > This page is limitted to 100 logs. Consider narrowing your search criteria.</ Typography >
292291 </ Stack >
293- ) ;
294- } }
295- />
292+ }
296293
297294 < ManualRoomSignInModal modalOpen = { manualSignInModal } setModalOpen = { setManualSignInModal } />
298295 </ Box >
0 commit comments