mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Added loading pages inidcators to subject and user info page and redirect login page to homepage if user is already logged in
This commit is contained in:
parent
6e63f86805
commit
369a00a0b3
3 changed files with 38 additions and 5 deletions
|
@ -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<RootDrawerParamList>();
|
||||
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 (
|
||||
<View style={styles.background}>
|
||||
<AnimatedContainer>
|
||||
|
|
|
@ -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 (
|
||||
<View style={styles.background}>
|
||||
<AnimatedContainerNoScroll>
|
||||
<View style={{ paddingVertical: 8 }} />
|
||||
<ActivityIndicator size={96} color={colors.secondary_1} />
|
||||
<Text style={styles.text_white_medium}>Loading...</Text>
|
||||
</AnimatedContainerNoScroll>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.background}>
|
||||
<AnimatedContainerNoScroll>
|
||||
|
|
|
@ -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 (
|
||||
<View style={styles.background}>
|
||||
<AnimatedContainerNoScroll>
|
||||
<View style={{ paddingVertical: 8 }} />
|
||||
<ActivityIndicator size={96} color={colors.secondary_1} />
|
||||
<Text style={styles.text_white_medium}>Loading...</Text>
|
||||
</AnimatedContainerNoScroll>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={styles.background}>
|
||||
<AnimatedContainerNoScroll>
|
||||
|
|
Loading…
Reference in a new issue