about summary refs log tree commit diff
path: root/src/screens/Signup.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-06-10 11:55:09 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-06-10 11:55:09 -0500
commitfaddda83f04b46bcdaab5c225cab696fc7a820cd (patch)
tree8a7cacb04f0a480d90a8e5dc9f9daae00f27c802 /src/screens/Signup.tsx
parent967f9fc474f2903dd2c12ef4f662ead1592ea26c (diff)
downloadvoidsky-faddda83f04b46bcdaab5c225cab696fc7a820cd.tar.zst
(WIP) Add initial API client
Diffstat (limited to 'src/screens/Signup.tsx')
-rw-r--r--src/screens/Signup.tsx50
1 files changed, 31 insertions, 19 deletions
diff --git a/src/screens/Signup.tsx b/src/screens/Signup.tsx
index bab7abc1c..1d5915d65 100644
--- a/src/screens/Signup.tsx
+++ b/src/screens/Signup.tsx
@@ -1,24 +1,36 @@
 import React from 'react'
+import {Text, Button, View, ActivityIndicator} from 'react-native'
+import {observer} from 'mobx-react-lite'
 import {Shell} from '../platform/shell'
-import {Text, Button, View} from 'react-native'
 import type {RootTabsScreenProps} from '../routes/types'
 import {useStores} from '../state'
 
-export function Signup({navigation}: RootTabsScreenProps<'Signup'>) {
-  const store = useStores()
-  return (
-    <Shell>
-      <View style={{justifyContent: 'center', alignItems: 'center'}}>
-        <Text style={{fontSize: 20, fontWeight: 'bold'}}>Create Account</Text>
-        <Button
-          title="Create new account"
-          onPress={() => store.session.setAuthed(true)}
-        />
-        <Button
-          title="Log in to an existing account"
-          onPress={() => navigation.navigate('Login')}
-        />
-      </View>
-    </Shell>
-  )
-}
+export const Signup = observer(
+  ({navigation}: RootTabsScreenProps<'Signup'>) => {
+    const store = useStores()
+    return (
+      <Shell>
+        <View style={{justifyContent: 'center', alignItems: 'center'}}>
+          <Text style={{fontSize: 20, fontWeight: 'bold'}}>Create Account</Text>
+          {store.session.uiError ?? <Text>{store.session.uiError}</Text>}
+          {store.session.uiState === 'idle' ? (
+            <>
+              <Button
+                title="Create new account"
+                onPress={() =>
+                  store.session.createTestAccount('http://localhost:1986')
+                }
+              />
+              <Button
+                title="Log in to an existing account"
+                onPress={() => navigation.navigate('Login')}
+              />
+            </>
+          ) : (
+            <ActivityIndicator />
+          )}
+        </View>
+      </Shell>
+    )
+  },
+)