diff --git a/apps/desktop/src/renderer/components/accounts/account-not-found.tsx b/apps/desktop/src/renderer/components/accounts/account-not-found.tsx new file mode 100644 index 00000000..914a9539 --- /dev/null +++ b/apps/desktop/src/renderer/components/accounts/account-not-found.tsx @@ -0,0 +1,100 @@ +import React from 'react'; +import { Mail } from 'lucide-react'; +import { useNavigate } from 'react-router-dom'; + +import { Avatar } from '@/renderer/components/avatars/avatar'; +import { Button } from '@/renderer/components/ui/button'; +import { useQuery } from '@/renderer/hooks/use-query'; +import { AccountContext } from '@/renderer/contexts/account'; + +export const AccountNotFound = () => { + const navigate = useNavigate(); + const { data } = useQuery({ + type: 'account_list', + }); + + const accounts = data ?? []; + return ( +
+
+

404

+
+
+
+
+

+ You have been logged out or your login has expired +

+ {accounts.length > 0 ? ( + +

+ Continue with one of your existing accounts +

+
+ {accounts.map((account) => ( + {}, + openLogout: () => {}, + }} + > +
navigate(`/${account.id}`)} + > + +
+ + {account.name} + + + {account.email} + +
+
+
+ ))} +
+
+

+ Or login with your email +

+ +
+ ) : ( + +

+ You need to login to continue +

+ +
+ )} +
+
+
+
+ ); +}; diff --git a/apps/desktop/src/renderer/components/accounts/account.tsx b/apps/desktop/src/renderer/components/accounts/account.tsx index 45e020e1..2ad5839e 100644 --- a/apps/desktop/src/renderer/components/accounts/account.tsx +++ b/apps/desktop/src/renderer/components/accounts/account.tsx @@ -4,6 +4,7 @@ import { Outlet, useNavigate, useParams } from 'react-router-dom'; import { AccountLogout } from '@/renderer/components/accounts/account-logout'; import { AccountSettingsDialog } from '@/renderer/components/accounts/account-settings-dialog'; import { AccountContext } from '@/renderer/contexts/account'; +import { AccountNotFound } from '@/renderer/components/accounts/account-not-found'; import { useQuery } from '@/renderer/hooks/use-query'; export const Account = () => { @@ -13,7 +14,7 @@ export const Account = () => { const [openSettings, setOpenSettings] = React.useState(false); const [openLogout, setOpenLogout] = React.useState(false); - const { data } = useQuery( + const { data, isPending } = useQuery( { type: 'account_get', accountId: accountId ?? '', @@ -23,8 +24,12 @@ export const Account = () => { } ); - if (!accountId || !data) { - return

Account not found

; + if (!accountId || isPending) { + return null; + } + + if (!data) { + return ; } const account = data;