diff options
Diffstat (limited to 'ui/src/root.tsx')
-rw-r--r-- | ui/src/root.tsx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/ui/src/root.tsx b/ui/src/root.tsx index bb4b763..13b3021 100644 --- a/ui/src/root.tsx +++ b/ui/src/root.tsx @@ -1,7 +1,8 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { invoke } from '@tauri-apps/api/core'; export default function Root() { + const [existingAccounts, setExistingAccounts] = useState<any>([]) const [signedIn, setSignedIn] = useState<{serverDomain: string, username: string} | null>(null) const [accountData, setAccountData] = useState('') @@ -17,10 +18,25 @@ export default function Root() { setAccountData(JSON.parse(result)) } + useEffect(() => { + (async () => { + setExistingAccounts(await invoke('get_all_accounts')) + })() + }, []) + return ( <> {!signedIn ? ( - <button onClick={signIn}>Sign in</button> + <> + <p>Existing accounts:</p> + {existingAccounts.map(({username, server_domain}: {username: string, server_domain: string}) => ( + <> + <button key={username + server_domain} onClick={() => setSignedIn({serverDomain: server_domain, username})}>@{username}@{server_domain}</button> + <br/> + </> + ))} + <button onClick={signIn}>Add another account</button> + </> ) : (!accountData ? ( <button onClick={getSelf}>Retrieve account data</button> ):( |