Files
otunes/apps/mobile/app/(auth)/_layout.tsx
T

29 lines
681 B
TypeScript

import { useConvexAuth } from "@convex-dev/auth/react"
import { Redirect, Stack } from "expo-router"
import { LoadingView } from "@/components/ui/primitives"
import { useServerConfig } from "@/contexts/server-config"
export default function AuthLayout() {
const { config, isLoading: serverLoading } = useServerConfig()
const auth = useConvexAuth()
if (serverLoading) {
return <LoadingView />
}
if (!config) {
return <Redirect href="/server" />
}
if (!auth || auth.isLoading) {
return <LoadingView />
}
if (auth.isAuthenticated) {
return <Redirect href="/(app)/(tabs)/home" />
}
return <Stack screenOptions={{ headerShown: false }} />
}