diff options
| author | MohamedBassem <me@mbassem.com> | 2024-03-11 12:24:51 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-03-11 12:33:31 +0000 |
| commit | c87db85815d84ddf907d0a1d26226a2ab911181b (patch) | |
| tree | c909031a7c9b525871fc8938e98c38da4741bde9 /packages/mobile/app/dashboard.tsx | |
| parent | 999ed977a588b2c3b2055f18db4218d77882a1a1 (diff) | |
| download | karakeep-c87db85815d84ddf907d0a1d26226a2ab911181b.tar.zst | |
mobile: An ugly yet functional signin workflow
Diffstat (limited to 'packages/mobile/app/dashboard.tsx')
| -rw-r--r-- | packages/mobile/app/dashboard.tsx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/mobile/app/dashboard.tsx b/packages/mobile/app/dashboard.tsx new file mode 100644 index 00000000..8be57615 --- /dev/null +++ b/packages/mobile/app/dashboard.tsx @@ -0,0 +1,35 @@ +import { useRouter } from "expo-router"; +import { useEffect } from "react"; +import { Text, View } from "react-native"; + +import Logo from "@/components/Logo"; +import { Button } from "@/components/ui/Button"; +import useAppSettings from "@/lib/settings"; +import { api } from "@/lib/trpc"; + +export default function Main() { + const router = useRouter(); + const { settings, setSettings, isLoading } = useAppSettings(); + + useEffect(() => { + if (!isLoading && !settings.apiKey) { + router.replace("signin"); + } + }, [settings, isLoading]); + + const onLogout = () => { + setSettings({ ...settings, apiKey: undefined }); + }; + + const { data } = api.users.whoami.useQuery(); + + return ( + <View className="flex h-full items-center justify-center gap-4 px-4"> + <Logo /> + <Text className="justify-center"> + Logged in as: {isLoading ? "Loading ..." : data?.email} + </Text> + <Button label="Log Out" onPress={onLogout} /> + </View> + ); +} |
