11import { useTranslation } from '@douglasneuroinformatics/libui/hooks' ;
22import { ClipboardDocumentIcon , DocumentTextIcon , UserIcon , UsersIcon } from '@heroicons/react/24/solid' ;
3+ import type { Summary as SummaryType } from '@opendatacapture/schemas/summary' ;
34
4- import { LoadingFallback } from '@/components/LoadingFallback ' ;
5+ import { WithFallback } from '@/components/WithFallback ' ;
56import { useAppStore } from '@/store' ;
67
78import { StatisticCard } from '../components/StatisticCard' ;
@@ -17,46 +18,49 @@ export const Summary = () => {
1718 }
1819 } ) ;
1920
20- if ( ! summaryQuery . data ) {
21- return < LoadingFallback /> ;
22- }
23-
2421 return (
25- < div className = "body-font" >
26- < div className = "grid grid-cols-1 gap-5 text-center lg:grid-cols-2" >
27- < StatisticCard
28- icon = { < UsersIcon className = "h-12 w-12" /> }
29- label = { t ( {
30- en : 'Total Users' ,
31- fr : "Nombre d'utilisateurs"
32- } ) }
33- value = { summaryQuery . data . counts . users }
34- />
35- < StatisticCard
36- icon = { < UserIcon className = "h-12 w-12" /> }
37- label = { t ( {
38- en : 'Total Subjects' ,
39- fr : 'Nombre de clients'
40- } ) }
41- value = { summaryQuery . data . counts . subjects }
42- />
43- < StatisticCard
44- icon = { < ClipboardDocumentIcon className = "h-12 w-12" /> }
45- label = { t ( {
46- en : 'Total Instruments' ,
47- fr : "Nombre d'instruments"
48- } ) }
49- value = { summaryQuery . data . counts . instruments }
50- />
51- < StatisticCard
52- icon = { < DocumentTextIcon className = "h-12 w-12" /> }
53- label = { t ( {
54- en : 'Total Records' ,
55- fr : "Nombre d'enregistrements"
56- } ) }
57- value = { summaryQuery . data . counts . records }
58- />
59- </ div >
60- </ div >
22+ < WithFallback
23+ Component = { ( { data } : { data : SummaryType } ) => (
24+ < div className = "body-font" >
25+ < div className = "grid grid-cols-1 gap-5 text-center lg:grid-cols-2" >
26+ < StatisticCard
27+ icon = { < UsersIcon className = "h-12 w-12" /> }
28+ label = { t ( {
29+ en : 'Total Users' ,
30+ fr : "Nombre d'utilisateurs"
31+ } ) }
32+ value = { data . counts . users }
33+ />
34+ < StatisticCard
35+ icon = { < UserIcon className = "h-12 w-12" /> }
36+ label = { t ( {
37+ en : 'Total Subjects' ,
38+ fr : 'Nombre de clients'
39+ } ) }
40+ value = { data . counts . subjects }
41+ />
42+ < StatisticCard
43+ icon = { < ClipboardDocumentIcon className = "h-12 w-12" /> }
44+ label = { t ( {
45+ en : 'Total Instruments' ,
46+ fr : "Nombre d'instruments"
47+ } ) }
48+ value = { data . counts . instruments }
49+ />
50+ < StatisticCard
51+ icon = { < DocumentTextIcon className = "h-12 w-12" /> }
52+ label = { t ( {
53+ en : 'Total Records' ,
54+ fr : "Nombre d'enregistrements"
55+ } ) }
56+ value = { data . counts . records }
57+ />
58+ </ div >
59+ </ div >
60+ ) }
61+ props = { {
62+ data : summaryQuery . data
63+ } }
64+ />
6165 ) ;
6266} ;
0 commit comments