Skip to content

Commit e3e5f6e

Browse files
committed
feat: add interactive box to display records for each instrument
1 parent e809baa commit e3e5f6e

File tree

1 file changed

+58
-13
lines changed

1 file changed

+58
-13
lines changed

apps/web/src/routes/_app/dashboard.tsx

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const RouteComponent = () => {
2626
const navigate = useNavigate();
2727
const [isLookupOpen, setIsLookupOpen] = useState(false);
2828
const [isUserLookupOpen, setIsUserLookupOpen] = useState(false);
29+
const [isRecordLookupOpen, setIsRecordLookupOpen] = useState(false);
2930
const instrumentInfoQuery = useInstrumentInfoQuery();
3031
const userInfoQuery = useUsersQuery();
3132

@@ -223,7 +224,7 @@ const RouteComponent = () => {
223224
</Dialog>
224225
</div>
225226
<button
226-
className="group transform transition-all duration-300 hover:scale-105"
227+
className="group flex transform transition-all duration-300 hover:scale-105"
227228
data-testid="statistic-subjects"
228229
onClick={() => {
229230
void navigate({
@@ -232,6 +233,7 @@ const RouteComponent = () => {
232233
}}
233234
>
234235
<StatisticCard
236+
className="grow"
235237
icon={
236238
<UserIcon className="h-12 w-12 text-emerald-600 transition-transform duration-300 group-hover:scale-110 dark:text-emerald-400" />
237239
}
@@ -277,7 +279,7 @@ const RouteComponent = () => {
277279
fr: 'Titre'
278280
})}
279281
</p>{' '}
280-
<p>{t({ en: 'Kind' })}</p>
282+
<p>{t({ en: 'Kind', fr: 'Genre' })}</p>
281283
</div>
282284
{instrumentInfo?.map((instrument, i) => {
283285
return (
@@ -301,19 +303,62 @@ const RouteComponent = () => {
301303
</Dialog>
302304
</div>
303305
<div
304-
className="group transform transition-all duration-300 hover:scale-105"
306+
className="group flex transform transition-all duration-300 hover:scale-105"
305307
data-testid="statistic-records"
306308
>
307-
<StatisticCard
308-
icon={
309-
<DocumentTextIcon className="h-12 w-12 text-purple-600 transition-transform duration-300 group-hover:scale-110 dark:text-purple-400" />
310-
}
311-
label={t({
312-
en: 'Total Records',
313-
fr: "Nombre d'enregistrements"
314-
})}
315-
value={summaryQuery.data.counts.records}
316-
/>
309+
<Dialog open={isRecordLookupOpen} onOpenChange={setIsRecordLookupOpen}>
310+
<Dialog.Trigger className="grow">
311+
<StatisticCard
312+
icon={
313+
<DocumentTextIcon className="h-12 w-12 text-purple-600 transition-transform duration-300 group-hover:scale-110 dark:text-purple-400" />
314+
}
315+
label={t({
316+
en: 'Total Records',
317+
fr: "Nombre d'enregistrements"
318+
})}
319+
value={summaryQuery.data.counts.records}
320+
/>
321+
</Dialog.Trigger>
322+
<Dialog.Content data-spotlight-type="subject-lookup-modal" data-testid="datahub-subject-lookup-dialog">
323+
<Dialog.Header>
324+
<Dialog.Title>
325+
{t({
326+
en: 'Number of Records',
327+
fr: "Nombre d'enregistrements"
328+
})}
329+
</Dialog.Title>
330+
</Dialog.Header>
331+
<ul className="flex flex-col gap-5">
332+
<AnimatePresence mode="popLayout">
333+
<div className="flex justify-between gap-4 font-bold">
334+
<p>
335+
{t({
336+
en: 'Title',
337+
fr: 'Titre'
338+
})}
339+
</p>{' '}
340+
<p>{t({ en: 'Number', fr: 'Numero' })}</p>
341+
</div>
342+
{recordCounter?.map((instrument, i) => {
343+
return (
344+
<motion.li
345+
layout
346+
animate={{ opacity: 1, y: 0 }}
347+
exit={{ opacity: 0 }}
348+
initial={{ opacity: 0 }}
349+
key={instrument.instrumentTitle}
350+
transition={{ bounce: 0.2, delay: 0.15 * i, duration: 1.5, type: 'spring' }}
351+
>
352+
<div className="flex justify-between gap-4">
353+
<p>{instrument.instrumentTitle}</p> <p>{instrument.count}</p>
354+
</div>
355+
</motion.li>
356+
);
357+
})}
358+
</AnimatePresence>
359+
</ul>
360+
</Dialog.Content>
361+
</Dialog>
317362
</div>
318363
</div>
319364
</div>

0 commit comments

Comments
 (0)