From f7d28637efdad806a9eb92a39ce8aceb567f7c1f Mon Sep 17 00:00:00 2001 From: Manu Genia Date: Fri, 31 Oct 2025 10:12:50 -0300 Subject: [PATCH 1/3] feat: use protected routes --- src/app/_layout.tsx | 61 +++++++++++++++++++++++++++++++++------------ src/app/sign-in.tsx | 6 ----- src/app/sign-up.tsx | 6 ----- 3 files changed, 45 insertions(+), 28 deletions(-) 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' }), }); From 2282b0318e9946d5a1b80851fcd3314de0f507d9 Mon Sep 17 00:00:00 2001 From: Manu Genia Date: Wed, 5 Nov 2025 17:24:43 -0300 Subject: [PATCH 2/3] fix: try to run checks --- env.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ef5c45b998edecebf1bdea1a4403575c832b16d5 Mon Sep 17 00:00:00 2001 From: Manu Genia Date: Wed, 5 Nov 2025 17:45:19 -0300 Subject: [PATCH 3/3] fix: repeated permission in type check --- .github/workflows/type-check.yml | 4 ---- 1 file changed, 4 deletions(-) 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)