diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml index a881fa16c..b07947235 100644 --- a/.github/workflows/type-check.yml +++ b/.github/workflows/type-check.yml @@ -22,10 +22,6 @@ permissions: contents: read pull-requests: write -permissions: - contents: read - pull-requests: write - jobs: type-check: name: Type Check (tsc) diff --git a/env.js b/env.js index 29bea2ec5..abd00d493 100644 --- a/env.js +++ b/env.js @@ -79,7 +79,7 @@ require('dotenv').config({ * for example: if the APP_ENV is staging, the bundle id will be com.rootstrap.staging */ -// TODO: Replace these values with your own +// TODO: Replace these values with your own values const BUNDLE_ID = 'com.rootstrap'; // ios bundle id const PACKAGE = 'com.rootstrap'; // android package name diff --git a/src/app/_layout.tsx b/src/app/_layout.tsx index b56ec01ec..44d758149 100644 --- a/src/app/_layout.tsx +++ b/src/app/_layout.tsx @@ -14,8 +14,8 @@ import { KeyboardProvider } from 'react-native-keyboard-controller'; import { APIProvider } from '@/api'; import interceptors from '@/api/common/interceptors'; -import { AuthProvider } from '@/components/providers/auth'; -import { hydrateAuth, loadSelectedTheme } from '@/lib'; +import { AuthProvider, useAuth } from '@/components/providers/auth'; +import { hydrateAuth, loadSelectedTheme, useIsFirstTime } from '@/lib'; import { useThemeConfig } from '@/lib/use-theme-config'; export { ErrorBoundary } from 'expo-router'; @@ -35,36 +35,65 @@ SplashScreen.setOptions({ fade: true, }); -export default function RootLayout() { +function GuardedStack() { + const { isAuthenticated } = useAuth(); const { t } = useTranslation(); + const [isFirstTime] = useIsFirstTime(); + return ( - - - + + - + + + + + + + - - + + + + + + ); +} + +export default function RootLayout() { + return ( + + ); } -function Providers({ children }: { children: React.ReactNode }) { +function RouterContent() { + const { ready } = useAuth(); + + if (!ready) { + return ; + } + + return ; +} + +function Providers({ children }: Readonly<{ children: React.ReactNode }>) { const theme = useThemeConfig(); + return ( { - router.push('/'); - }, onError: (error) => showMessage({ message: error.message, type: 'danger' }), }); diff --git a/src/app/sign-up.tsx b/src/app/sign-up.tsx index 22f7f1ab8..dd8daf857 100644 --- a/src/app/sign-up.tsx +++ b/src/app/sign-up.tsx @@ -1,4 +1,3 @@ -import { useRouter } from 'expo-router'; import React from 'react'; import { showMessage } from 'react-native-flash-message'; @@ -8,12 +7,7 @@ import { SignUpForm } from '@/components/sign-up-form'; import { FocusAwareStatusBar } from '@/components/ui'; export default function SignIn() { - const router = useRouter(); - const { mutate: signUp, isPending } = useSignUp({ - onSuccess: () => { - router.push('/'); - }, onError: (error) => showMessage({ message: error.message, type: 'danger' }), });