forked from JamshedK/HackUTA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
56 lines (53 loc) · 1.88 KB
/
App.js
File metadata and controls
56 lines (53 loc) · 1.88 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import LoginPage from "./components/Login";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { NavigationContainer } from "@react-navigation/native";
import SignUpPage from "./components/Signup";
import ChatbotPage from "./components/Chatbot";
import HomePage from "./components/HomePage";
import { useState, useEffect } from "react";
import { supabase } from "./supabase";
import ProfilePage from "./components/Profile";
import TipsAndTricksPage from "./components/TipsTricks";
import MaintenanceSchedulePage from "./components/MaintenanceSchedule";
import MaintenanceHistoryPage from "./components/MaintenanceHistory";
const Stack = createNativeStackNavigator();
export default function App() {
const [initialRoute, setInitialRoute] = useState("Login");
useEffect(() => {
checkAuth();
}, []);
const checkAuth = async () => {
try {
const user = supabase.auth.user();
console.log("Current user: ", user);
if (user) {
setInitialRoute("HomePage");
}
} catch (error) {
console.log(error);
}
};
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName={initialRoute}
screenOptions={{ headerShown: false }}
>
<Stack.Screen name="Login" component={LoginPage} />
<Stack.Screen name="SignUp" component={SignUpPage} />
<Stack.Screen name="Chatbot" component={ChatbotPage} />
<Stack.Screen name="HomePage" component={HomePage} />
<Stack.Screen name="Profile" component={ProfilePage} />
<Stack.Screen name="TipsTricks" component={TipsAndTricksPage} />
<Stack.Screen
name="MaintenanceSchedule"
component={MaintenanceSchedulePage}
/>
<Stack.Screen
name="MaintenanceHistory"
component={MaintenanceHistoryPage}
/>
</Stack.Navigator>
</NavigationContainer>
);
}