Skip to content

Commit 0f29b89

Browse files
authored
Merge pull request #1176 from joshunrau/dev
replace AlertDialog with regular Dialog
2 parents 7e8c07a + 6b44aba commit 0f29b89

File tree

6 files changed

+64
-65
lines changed

6 files changed

+64
-65
lines changed
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AlertDialog, Button } from '@douglasneuroinformatics/libui/components';
1+
import { Button, Dialog } from '@douglasneuroinformatics/libui/components';
22

33
import { useAppStore } from '@/store';
44

@@ -11,13 +11,13 @@ export type DeleteFileDialogProps = {
1111
export const DeleteFileDialog = ({ filename, isOpen, setIsOpen }: DeleteFileDialogProps) => {
1212
const deleteFile = useAppStore((store) => store.deleteFile);
1313
return filename ? (
14-
<AlertDialog open={isOpen} onOpenChange={setIsOpen}>
15-
<AlertDialog.Content>
16-
<AlertDialog.Header>
17-
<AlertDialog.Title>{`Are you sure you want to delete "${filename}"?`}</AlertDialog.Title>
18-
<AlertDialog.Description>Once deleted, this file cannot be restored</AlertDialog.Description>
19-
</AlertDialog.Header>
20-
<AlertDialog.Footer>
14+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
15+
<Dialog.Content>
16+
<Dialog.Header>
17+
<Dialog.Title>{`Are you sure you want to delete "${filename}"?`}</Dialog.Title>
18+
<Dialog.Description>Once deleted, this file cannot be restored</Dialog.Description>
19+
</Dialog.Header>
20+
<Dialog.Footer>
2121
<Button
2222
variant="danger"
2323
onClick={() => {
@@ -27,9 +27,11 @@ export const DeleteFileDialog = ({ filename, isOpen, setIsOpen }: DeleteFileDial
2727
>
2828
Delete
2929
</Button>
30-
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
31-
</AlertDialog.Footer>
32-
</AlertDialog.Content>
33-
</AlertDialog>
30+
<Button type="button" variant="outline" onClick={() => setIsOpen(false)}>
31+
Cancel
32+
</Button>
33+
</Dialog.Footer>
34+
</Dialog.Content>
35+
</Dialog>
3436
) : null;
3537
};
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AlertDialog, Button } from '@douglasneuroinformatics/libui/components';
1+
import { Button, Dialog } from '@douglasneuroinformatics/libui/components';
22
import { useNotificationsStore } from '@douglasneuroinformatics/libui/hooks';
33

44
import { useAppStore } from '@/store';
@@ -14,13 +14,13 @@ export const DeleteInstrumentDialog = ({ isOpen, setIsOpen }: DeleteInstrumentDi
1414
const selectedInstrument = useAppStore((store) => store.selectedInstrument);
1515

1616
return (
17-
<AlertDialog open={isOpen} onOpenChange={setIsOpen}>
18-
<AlertDialog.Content>
19-
<AlertDialog.Header>
20-
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
21-
<AlertDialog.Description>This instrument will be deleted from local storage.</AlertDialog.Description>
22-
</AlertDialog.Header>
23-
<AlertDialog.Footer>
17+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
18+
<Dialog.Content>
19+
<Dialog.Header>
20+
<Dialog.Title>Are you absolutely sure?</Dialog.Title>
21+
<Dialog.Description>This instrument will be deleted from local storage.</Dialog.Description>
22+
</Dialog.Header>
23+
<Dialog.Footer>
2424
<Button
2525
variant="danger"
2626
onClick={() => {
@@ -31,9 +31,11 @@ export const DeleteInstrumentDialog = ({ isOpen, setIsOpen }: DeleteInstrumentDi
3131
>
3232
Delete
3333
</Button>
34-
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
35-
</AlertDialog.Footer>
36-
</AlertDialog.Content>
37-
</AlertDialog>
34+
<Button type="button" variant="outline" onClick={() => setIsOpen(false)}>
35+
Cancel
36+
</Button>
37+
</Dialog.Footer>
38+
</Dialog.Content>
39+
</Dialog>
3840
);
3941
};
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AlertDialog, Button } from '@douglasneuroinformatics/libui/components';
1+
import { Button, Dialog } from '@douglasneuroinformatics/libui/components';
22
import { useNotificationsStore } from '@douglasneuroinformatics/libui/hooks';
33

44
import { useAppStore } from '@/store';
@@ -14,16 +14,16 @@ export const RestoreDefaultsDialog = ({ isOpen, setIsOpen }: RestoreDefaultsDial
1414
const resetSettings = useAppStore((store) => store.resetSettings);
1515

1616
return (
17-
<AlertDialog open={isOpen} onOpenChange={setIsOpen}>
18-
<AlertDialog.Content>
19-
<AlertDialog.Header>
20-
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
21-
<AlertDialog.Description>
17+
<Dialog open={isOpen} onOpenChange={setIsOpen}>
18+
<Dialog.Content>
19+
<Dialog.Header>
20+
<Dialog.Title>Are you absolutely sure?</Dialog.Title>
21+
<Dialog.Description>
2222
This action will <span className="font-bold uppercase">delete all user-defined instruments</span> in local
2323
storage and restore the default configuration.
24-
</AlertDialog.Description>
25-
</AlertDialog.Header>
26-
<AlertDialog.Footer>
24+
</Dialog.Description>
25+
</Dialog.Header>
26+
<Dialog.Footer>
2727
<Button
2828
variant="danger"
2929
onClick={() => {
@@ -35,9 +35,11 @@ export const RestoreDefaultsDialog = ({ isOpen, setIsOpen }: RestoreDefaultsDial
3535
>
3636
Reset
3737
</Button>
38-
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
39-
</AlertDialog.Footer>
40-
</AlertDialog.Content>
41-
</AlertDialog>
38+
<Button type="button" variant="outline" onClick={() => setIsOpen(false)}>
39+
Cancel
40+
</Button>
41+
</Dialog.Footer>
42+
</Dialog.Content>
43+
</Dialog>
4244
);
4345
};

apps/web/src/components/UserDropup/UserDropup.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ export const UserDropup = () => {
8383
</DropdownMenu.Item>
8484
<DropdownMenu.Item
8585
className="gap-2 hover:bg-slate-700 hover:text-slate-100 focus:bg-slate-700 focus:text-slate-100 focus:ring-0"
86-
onClick={() => {
87-
logout();
88-
void navigate({ reloadDocument: true, to: '/auth/login' });
89-
}}
86+
onClick={logout}
9087
>
9188
<LogOutIcon />
9289
{t({
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import { AlertDialog } from '@douglasneuroinformatics/libui/components';
3+
import { Button, Dialog } from '@douglasneuroinformatics/libui/components';
44
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
55

66
import { useAppStore } from '@/store';
@@ -14,30 +14,32 @@ export const DisclaimerProvider: React.FC<{ children: React.ReactElement }> = ({
1414
return (
1515
<React.Fragment>
1616
{children}
17-
<AlertDialog open={!isDisclaimerAccepted}>
18-
<AlertDialog.Content onOpenAutoFocus={(event) => event.preventDefault()}>
19-
<AlertDialog.Header>
20-
<AlertDialog.Title>
17+
<Dialog open={!isDisclaimerAccepted}>
18+
<Dialog.Content onOpenAutoFocus={(event) => event.preventDefault()}>
19+
<Dialog.Header>
20+
<Dialog.Title>
2121
{t({
2222
en: 'Disclaimer',
2323
fr: 'Avis'
2424
})}
25-
</AlertDialog.Title>
26-
<AlertDialog.Description>
25+
</Dialog.Title>
26+
<Dialog.Description>
2727
{t({
2828
en: 'This platform is not an Electronic Health Record. Our terms of service prohibit using this platform as the primary mechanism to store clinical data.',
2929
fr: "Cette plateforme n'est pas un dossier médical électronique. Nos conditions de service interdisent l'utilisation de cette plateforme comme principal mécanisme de stockage des données cliniques."
3030
})}
31-
</AlertDialog.Description>
32-
</AlertDialog.Header>
33-
<AlertDialog.Footer>
34-
<AlertDialog.Action onClick={() => setIsDisclaimerAccepted(true)}>
31+
</Dialog.Description>
32+
</Dialog.Header>
33+
<Dialog.Footer>
34+
<Button type="button" onClick={() => setIsDisclaimerAccepted(true)}>
3535
{t({ en: 'Accept', fr: 'Accepter' })}
36-
</AlertDialog.Action>
37-
<AlertDialog.Cancel onClick={logout}>{t({ en: 'Decline', fr: 'Refuser' })}</AlertDialog.Cancel>
38-
</AlertDialog.Footer>
39-
</AlertDialog.Content>
40-
</AlertDialog>
36+
</Button>
37+
<Button type="button" variant="outline" onClick={logout}>
38+
{t({ en: 'Decline', fr: 'Refuser' })}
39+
</Button>
40+
</Dialog.Footer>
41+
</Dialog.Content>
42+
</Dialog>
4143
</React.Fragment>
4244
);
4345
};

apps/web/src/store/slices/auth.slice.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { jwtDecode } from 'jwt-decode';
55

66
import type { AuthSlice, SliceCreator } from '../types';
77

8-
export const createAuthSlice: SliceCreator<AuthSlice> = (set, get) => ({
8+
export const createAuthSlice: SliceCreator<AuthSlice> = (set) => ({
99
accessToken: null,
1010
changeGroup: (group) => {
1111
set({ currentGroup: group, currentSession: null });
@@ -22,12 +22,6 @@ export const createAuthSlice: SliceCreator<AuthSlice> = (set, get) => ({
2222
});
2323
},
2424
logout: () => {
25-
get().endSession();
26-
set((state) => {
27-
state.accessToken = null;
28-
state.currentGroup = null;
29-
state.currentUser = null;
30-
state.isDisclaimerAccepted = false;
31-
});
25+
window.location.reload();
3226
}
3327
});

0 commit comments

Comments
 (0)