frontend client for gemstone. decentralised workplace app
1import { Loading } from "@/components/primitives/Loading";
2import { useOAuthValue } from "@/providers/OAuthProvider";
3import { Redirect } from "expo-router";
4import type { ReactNode } from "react";
5import { View } from "react-native";
6
7export const SessionGate = ({ children }: { children: ReactNode }) => {
8 const { isLoading, session } = useOAuthValue();
9 if (isLoading) {
10 return (
11 <View
12 style={{
13 flex: 1,
14 justifyContent: "center",
15 alignItems: "center",
16 }}
17 >
18 <Loading />
19 </View>
20 );
21 }
22
23 if (!session) {
24 return <Redirect href="/login" />;
25 }
26
27 return <>{children}</>;
28};