Skip to content

Commit d0b3988

Browse files
committed
add login status
1 parent 2cec2d3 commit d0b3988

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

apps/playground/src/components/Header/ActionsDropdown/LoginDialog.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Dialog, Form } from '@douglasneuroinformatics/libui/components';
55
import { useNotificationsStore } from '@douglasneuroinformatics/libui/hooks';
66
import type { $LoginCredentials } from '@opendatacapture/schemas/auth';
77
import axios from 'axios';
8+
import { CheckIcon, XIcon } from 'lucide-react';
89
import { err, ok } from 'neverthrow';
910
import type { ResultAsync } from 'neverthrow';
1011
import { z } from 'zod/v4';
@@ -25,6 +26,7 @@ export type LoginDialogProps = {
2526

2627
export const LoginDialog = ({ isOpen, setIsOpen }: LoginDialogProps) => {
2728
const apiBaseUrl = useAppStore((store) => store.settings.apiBaseUrl);
29+
const isAuthorized = useAppStore((store) => !!store.auth);
2830
const updateSettings = useAppStore((store) => store.updateSettings);
2931

3032
const addNotification = useNotificationsStore((store) => store.addNotification);
@@ -68,6 +70,23 @@ export const LoginDialog = ({ isOpen, setIsOpen }: LoginDialogProps) => {
6870
Login to your Open Data Capture instance. A special access token is used that grants permissions to create
6971
instruments only. You must have permission to create instruments to use this functionality.
7072
</Dialog.Description>
73+
<div className="mt-2 flex items-center gap-1 text-sm font-medium">
74+
{isAuthorized ? (
75+
<>
76+
<div className="flex h-4 w-4 items-center justify-center rounded-full bg-green-600">
77+
<CheckIcon className="text-white" style={{ height: '12px', width: '12px' }} />
78+
</div>
79+
<span>You are already logged in</span>
80+
</>
81+
) : (
82+
<>
83+
<div className="flex h-4 w-4 items-center justify-center rounded-full bg-red-600">
84+
<XIcon className="text-white" style={{ height: '12px', width: '12px' }} />
85+
</div>
86+
<span>You are not currently logged in</span>
87+
</>
88+
)}
89+
</div>
7190
</Dialog.Header>
7291
<Dialog.Body className="grid gap-4">
7392
<Form

0 commit comments

Comments
 (0)