Skip to content

Commit 5d1f126

Browse files
authored
Merge pull request #1279 from joshunrau/session-date
fix issue where retrospective session date is not recorded
2 parents 7ea307c + b95d747 commit 5d1f126

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

apps/web/src/components/Sidebar/Sidebar.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useState } from 'react';
2+
13
import { toBasicISOString, toLowerCase } from '@douglasneuroinformatics/libjs';
24
import { Button, Dialog, LanguageToggle, ThemeToggle } from '@douglasneuroinformatics/libui/components';
35
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
@@ -14,6 +16,8 @@ import { NavButton } from '../NavButton';
1416
import { UserDropup } from '../UserDropup';
1517

1618
export const Sidebar = () => {
19+
const [isEndSessionModalOpen, setIsEndSessionModalOpen] = useState(false);
20+
1721
const navItems = useNavItems();
1822
const currentSession = useAppStore((store) => store.currentSession);
1923
const endSession = useAppStore((store) => store.endSession);
@@ -43,7 +47,7 @@ export const Sidebar = () => {
4347
/>
4448
))}
4549
{i === navItems.length - 1 && (
46-
<Dialog>
50+
<Dialog open={isEndSessionModalOpen} onOpenChange={setIsEndSessionModalOpen}>
4751
<Dialog.Trigger asChild>
4852
<NavButton
4953
disabled={currentSession === null}
@@ -63,12 +67,19 @@ export const Sidebar = () => {
6367
className="min-w-20"
6468
onClick={() => {
6569
endSession();
66-
void navigate({ to: '/session/start-session' });
70+
void navigate({ to: '/session/start-session' }).then(() => {
71+
setIsEndSessionModalOpen(false);
72+
});
6773
}}
6874
>
6975
{t('core.yes')}
7076
</Button>
71-
<Button className="min-w-20" variant="outline">
77+
<Button
78+
className="min-w-20"
79+
type="button"
80+
variant="outline"
81+
onClick={() => setIsEndSessionModalOpen(false)}
82+
>
7283
{t('core.no')}
7384
</Button>
7485
</Dialog.Footer>

apps/web/src/routes/_app/instruments/render/$id.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const RouteComponent = () => {
3838
const handleSubmit: InstrumentSubmitHandler = async ({ data, instrumentId }) => {
3939
await axios.post('/v1/instrument-records', {
4040
data,
41-
date: new Date(),
41+
date: currentSession!.date,
4242
groupId: currentGroup?.id,
4343
instrumentId,
4444
sessionId: currentSession!.id,

apps/web/src/routes/_app/session/start-session.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,24 @@ const RouteComponent = () => {
6060
<motion.div
6161
animate={{ opacity: 1, scale: 1 }}
6262
className="flex grow"
63-
exit={{ opacity: 0, scale: 0 }}
64-
initial={{ opacity: 0, scale: 0 }}
63+
exit={{ opacity: 0, scale: 0.5 }}
64+
initial={{ opacity: 0, scale: 0.5 }}
6565
key="modal"
66+
transition={{ duration: 0.3 }}
6667
>
6768
<div className="flex grow items-center justify-center">
68-
{currentSession !== null && (
69-
<Card className="mx-auto block max-w-3xl border p-12 text-green-600 opacity-70 dark:text-green-300">
70-
<div className="flex flex-col items-center justify-center gap-y-10">
71-
<CheckCircle className="!size-20" />
72-
<p className="max-w-2xl text-center text-lg font-medium">
73-
{t({
74-
en: 'The current session must be ended before starting the form again.',
75-
fr: 'La session en cours doit être terminée avant de recommencer le formulaire.'
76-
})}
77-
</p>
78-
</div>
79-
</Card>
80-
)}
69+
<Card className="mx-auto flex max-w-2xl flex-col items-center p-12 opacity-70">
70+
<CheckCircle className="mb-3 !size-10 text-green-900 dark:text-green-500" />
71+
<h5 className="font-semibold text-green-900 dark:text-green-500">
72+
{t({ en: 'Session Successfully Started', fr: 'Session démarrée avec succès' })}
73+
</h5>
74+
<p className="text-sm text-green-700 dark:text-green-300">
75+
{t({
76+
en: 'Please note that you must end the current session before completing this form again.',
77+
fr: 'Veuillez noter que vous devez mettre fin à la session en cours avant de remplir à nouveau ce formulaire.'
78+
})}
79+
</p>
80+
</Card>
8181
</div>
8282
</motion.div>
8383
)}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "opendatacapture",
33
"type": "module",
4-
"version": "1.12.4",
4+
"version": "1.13.0",
55
"private": true,
66
"packageManager": "pnpm@10.7.0",
77
"license": "Apache-2.0",

0 commit comments

Comments
 (0)