aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/app/dashboard/(tabs)/settings.tsx
blob: c2db2846030de80b2e49e623a1004fa864e96b65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Text, View } from "react-native";
import { Button } from "@/components/ui/Button";
import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";
import PageTitle from "@/components/ui/PageTitle";
import { useSession } from "@/lib/session";
import { api } from "@/lib/trpc";

export default function Dashboard() {
  const { logout } = useSession();

  const { data, error, isLoading } = api.users.whoami.useQuery();

  if (error?.data?.code === "UNAUTHORIZED") {
    logout();
  }

  return (
    <CustomSafeAreaView>
      <PageTitle title="Settings" />
      <View className="flex h-full w-full items-center gap-4 px-4 py-2">
        <View className="w-full rounded-lg bg-white px-4 py-2">
          <Text className="text-lg">
            {isLoading ? "Loading ..." : data?.email}
          </Text>
        </View>

        <Button className="w-full" label="Log Out" onPress={logout} />
      </View>
    </CustomSafeAreaView>
  );
}