(WIP) Add initial API client

This commit is contained in:
Paul Frazee 2022-06-10 11:55:09 -05:00
parent 967f9fc474
commit faddda83f0
9 changed files with 260 additions and 27 deletions

View file

@ -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>
)
},
)