mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Improved drawer logout and activation page
This commit is contained in:
parent
13a24ef87a
commit
877da5123a
2 changed files with 29 additions and 17 deletions
|
@ -48,7 +48,8 @@ export default function CustomDrawerContent(props: {}) {
|
||||||
color={colors.blue_2}
|
color={colors.blue_2}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
dispatch(await clear());
|
dispatch(await clear());
|
||||||
AsyncStorage.clear();
|
await AsyncStorage.clear();
|
||||||
|
navigation.navigate("Home");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LogoutIcon size={32} />
|
<LogoutIcon size={32} />
|
||||||
|
@ -90,7 +91,7 @@ export default function CustomDrawerContent(props: {}) {
|
||||||
color={colors.blue_2}
|
color={colors.blue_2}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
dispatch(clear());
|
dispatch(clear());
|
||||||
navigation.navigate("Login");
|
navigation.navigate("Register");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SignupIcon size={32} />
|
<SignupIcon size={32} />
|
||||||
|
|
|
@ -2,9 +2,10 @@ import * as React from "react";
|
||||||
import styles, { colors } from "../../styles";
|
import styles, { colors } from "../../styles";
|
||||||
import { View, Text, ActivityIndicator } from "react-native";
|
import { View, Text, ActivityIndicator } from "react-native";
|
||||||
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||||
import { useRoute } from "@react-navigation/native";
|
import { useNavigation, useRoute } from "@react-navigation/native";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { UserActivate } from "../../components/Api/Api";
|
import { UserActivate } from "../../components/Api/Api";
|
||||||
|
import { RootDrawerParamList } from "../../interfaces/Interfaces";
|
||||||
|
|
||||||
interface ActivationRouteParams {
|
interface ActivationRouteParams {
|
||||||
uid?: string;
|
uid?: string;
|
||||||
|
@ -14,16 +15,25 @@ interface ActivationRouteParams {
|
||||||
export default function Activation() {
|
export default function Activation() {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { uid, token } = (route.params as ActivationRouteParams) || "";
|
const { uid, token } = (route.params as ActivationRouteParams) || "";
|
||||||
|
const navigation = useNavigation<RootDrawerParamList>();
|
||||||
const [state, setState] = useState(
|
const [state, setState] = useState(
|
||||||
"Activating with UID " + uid + " and Token " + token
|
"Activating with UID " + uid + " and Token " + token
|
||||||
);
|
);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
async function activate() {
|
async function activate() {
|
||||||
if (await UserActivate({ uid: String(uid), token: String(token) })) {
|
let result = await UserActivate({
|
||||||
|
uid: String(uid),
|
||||||
|
token: String(token),
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setState("Activation successful!");
|
setState("Activation successful!");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
setTimeout(() => {
|
||||||
|
navigation.navigate("Login");
|
||||||
|
}, 2000);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setState("Activation unsuccessful\nPlease contact support");
|
setState("Activation unsuccessful\nPlease contact support");
|
||||||
|
@ -31,9 +41,9 @@ export default function Activation() {
|
||||||
}
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
|
||||||
activate();
|
activate();
|
||||||
}, []);
|
}, [uid, token]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainer>
|
<AnimatedContainer>
|
||||||
|
@ -54,6 +64,7 @@ export default function Activation() {
|
||||||
color={colors.blue_1}
|
color={colors.blue_1}
|
||||||
/>
|
/>
|
||||||
<Text style={styles.text_white_medium}>{state}</Text>
|
<Text style={styles.text_white_medium}>{state}</Text>
|
||||||
|
<Text style={styles.text_white_tiny}>{uid + "\n" + token}</Text>
|
||||||
</AnimatedContainer>
|
</AnimatedContainer>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue