From 5e8d3bc7008d29115bc520a75a9e49c00e2c270f Mon Sep 17 00:00:00 2001
From: Ashelyn Rose <git@ashen.earth>
Date: Sun, 16 Feb 2025 15:18:09 -0700
Subject: Can now sign in and fetch account data

---
 ui/src/root.tsx | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

(limited to 'ui/src/root.tsx')

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>
+      ))}
     </>
   )
 }
-- 
cgit 1.4.1

