diff --git a/src/routes/Login/Login.tsx b/src/routes/Login/Login.tsx index 5a72b1a..b33ef2c 100644 --- a/src/routes/Login/Login.tsx +++ b/src/routes/Login/Login.tsx @@ -7,8 +7,8 @@ import { NativeSyntheticEvent, TextInputChangeEventData, } from "react-native"; -import { useDispatch } from "react-redux"; -import { useState } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { useEffect, useState } from "react"; import LoginIcon from "../../icons/LoginIcon/LoginIcon"; import Button from "../../components/Button/Button"; import { useNavigation } from "@react-navigation/native"; @@ -22,15 +22,22 @@ import { unsetOnboarding, } from "../../features/redux/slices/StatusSlice/StatusSlice"; import { useToast } from "react-native-toast-notifications"; +import { RootState } from "../../features/redux/Store/Store"; export default function Login() { const navigation = useNavigation(); + const status = useSelector((state: RootState) => state.status); const dispatch = useDispatch(); const [creds, setCreds] = useState({ username: "", password: "", }); const toast = useToast(); + useEffect(() => { + if (status.logged_in) { + navigation.navigate("Home"); + } + }, []); return ( diff --git a/src/routes/SubjectsPage/SubjectsPage.tsx b/src/routes/SubjectsPage/SubjectsPage.tsx index cfee8f7..e7d5905 100644 --- a/src/routes/SubjectsPage/SubjectsPage.tsx +++ b/src/routes/SubjectsPage/SubjectsPage.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import styles from "../../styles"; -import { View, Text } from "react-native"; +import { View, Text, ActivityIndicator } from "react-native"; import { useState } from "react"; import { UserInfoReturnType, @@ -183,7 +183,17 @@ export default function SubjectsPage() { ); } } - + if (StudentInfo.isLoading || Subjects.isLoading) { + return ( + + + + + Loading... + + + ); + } return ( diff --git a/src/routes/UserInfoPage/UserInfoPage.tsx b/src/routes/UserInfoPage/UserInfoPage.tsx index 5d8a49b..129bdd4 100644 --- a/src/routes/UserInfoPage/UserInfoPage.tsx +++ b/src/routes/UserInfoPage/UserInfoPage.tsx @@ -7,6 +7,7 @@ import { NativeSyntheticEvent, TextInputChangeEventData, Pressable, + ActivityIndicator, } from "react-native"; import { useState } from "react"; import { @@ -285,7 +286,22 @@ export default function UserInfoPage() { ); } } - + if ( + StudentInfo.isLoading || + Semesters.isLoading || + yearlevel_query.isLoading || + course_query.isLoading + ) { + return ( + + + + + Loading... + + + ); + } return (