summary refs log tree commit diff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/src/root.tsx26
1 files changed, 17 insertions, 9 deletions
diff --git a/ui/src/root.tsx b/ui/src/root.tsx
index 8db8960..bc87cd9 100644
--- a/ui/src/root.tsx
+++ b/ui/src/root.tsx
@@ -2,20 +2,28 @@ import { useState } from 'react';
 import { invoke } from '@tauri-apps/api/core';
 
 export default function Root() {
-  const [rustResult, setRustResult] = useState('')
+  const [signedIn, setSignedIn] = useState(false)
+  const [accountData, setAccountData] = useState('')
 
-  async function callRust() {
-    const result : string = await invoke('greet', {name: 'ashe'})
-    setRustResult(result)
+  async function signIn() {
+    await invoke('start_account_auth', {instanceDomain: 'social.tempest.dev'})
+    setSignedIn(true)
+  }
+
+  async function getSelf() {
+    let result = await invoke('get_self') as string
+    setAccountData(JSON.parse(result))
   }
 
   return (
     <>
-      <p>Now we have React</p>
-      {rustResult
-        ? <p>Result from rust: <pre><code>{rustResult}</code></pre></p>
-        : <button onClick={callRust}>Call rust</button>
-      }
+      {!signedIn ? (
+        <button onClick={signIn}>Sign in</button>
+      ) : (!accountData ? (
+        <button onClick={getSelf}>Retrieve account data</button>
+      ):(
+        <p>Result from rust: <pre style={{whiteSpace:'pre'}}>{JSON.stringify(accountData, null, 2)}</pre></p>
+      ))}
     </>
   )
 }