Skip to content

Commit 8160db4

Browse files
committed
feat: add instructions dialog to form
1 parent a1e080d commit 8160db4

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

packages/instrument-renderer/src/components/FormContent/FormContent.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { Form, Heading } from '@douglasneuroinformatics/libui/components';
1+
import { Button, Dialog, Form, Heading } from '@douglasneuroinformatics/libui/components';
2+
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
23
import type { AnyUnilingualFormInstrument, FormInstrument } from '@opendatacapture/runtime-core';
4+
import { InfoIcon } from 'lucide-react';
35
import type { Promisable } from 'type-fest';
46

57
export type FormContentProps = {
@@ -8,9 +10,33 @@ export type FormContentProps = {
810
};
911

1012
export const FormContent = ({ instrument, onSubmit }: FormContentProps) => {
13+
const { t } = useTranslation();
14+
const instructions = instrument.clientDetails?.instructions ?? instrument.details.instructions;
1115
return (
1216
<div className="space-y-6">
13-
<Heading variant="h4">{instrument.details.title}</Heading>
17+
<div className="flex gap-2">
18+
<Heading variant="h4">{instrument.clientDetails?.title ?? instrument.details.title}</Heading>
19+
<Dialog>
20+
<Dialog.Trigger asChild>
21+
<Button disabled={!instructions?.length} size="icon" variant="ghost">
22+
<InfoIcon />
23+
</Button>
24+
</Dialog.Trigger>
25+
<Dialog.Content className="sm:max-w-[425px]">
26+
<Dialog.Header>
27+
<Dialog.Title>
28+
{t({
29+
en: 'Instructions',
30+
fr: 'Instructions'
31+
})}
32+
</Dialog.Title>
33+
</Dialog.Header>
34+
<Dialog.Body className="py-2">
35+
<p className="text-muted-foreground text-sm">{instructions?.join(', ')}</p>
36+
</Dialog.Body>
37+
</Dialog.Content>
38+
</Dialog>
39+
</div>
1440
<Form
1541
preventResetValuesOnReset
1642
content={instrument.content}

0 commit comments

Comments
 (0)