From 5e8d3bc7008d29115bc520a75a9e49c00e2c270f Mon Sep 17 00:00:00 2001
From: Ashelyn Rose
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 (
<>
- Now we have React
- {rustResult
- ? Result from rust:
{rustResult}
- :
- }
+ {!signedIn ? (
+
+ ) : (!accountData ? (
+
+ ):(
+ Result from rust:
{JSON.stringify(accountData, null, 2)}
+ ))}
>
)
}
--
cgit 1.4.1