mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Added working activation page
This commit is contained in:
parent
e52aca41cc
commit
92b8ce0e4e
1 changed files with 38 additions and 6 deletions
|
@ -3,6 +3,8 @@ import styles, { colors } from "../../styles";
|
|||
import { View, Text, ActivityIndicator } from "react-native";
|
||||
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||
import { useRoute } from "@react-navigation/native";
|
||||
import { useEffect, useState } from "react";
|
||||
import { UserActivate } from "../../components/Api/Api";
|
||||
|
||||
interface ActivationRouteParams {
|
||||
uid?: string;
|
||||
|
@ -11,17 +13,47 @@ interface ActivationRouteParams {
|
|||
|
||||
export default function Activation() {
|
||||
const route = useRoute();
|
||||
const { uid, token } = route.params as ActivationRouteParams;
|
||||
const { uid, token } = (route.params as ActivationRouteParams) || "";
|
||||
|
||||
const [state, setState] = useState(
|
||||
"Activating with UID " + uid + " and Token " + token
|
||||
);
|
||||
const [loading, setLoading] = useState(true);
|
||||
async function activate() {
|
||||
if (await UserActivate({ uid: String(uid), token: String(token) })) {
|
||||
setTimeout(() => {
|
||||
setState("Activation successful!");
|
||||
}, 1000);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
setState("Activation unsuccessful\nPlease contact support");
|
||||
}, 1000);
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
useEffect(() => {
|
||||
activate();
|
||||
}, []);
|
||||
return (
|
||||
<View style={styles.background}>
|
||||
<AnimatedContainer>
|
||||
<View
|
||||
style={{
|
||||
paddingVertical: 4,
|
||||
marginBottom: 16,
|
||||
borderRadius: 4,
|
||||
width: "90%",
|
||||
backgroundColor: colors.blue_1,
|
||||
}}
|
||||
/>
|
||||
<Text style={styles.text_white_large}>Activation</Text>
|
||||
<View style={{ paddingVertical: 8 }} />
|
||||
<ActivityIndicator size={96} color={colors.blue_1} />
|
||||
<Text style={styles.text_white_medium}>
|
||||
Activating {uid ? `with UID: ${uid}` : ""}{" "}
|
||||
{token ? `and Token: ${token}` : ""}
|
||||
</Text>
|
||||
<ActivityIndicator
|
||||
animating={loading}
|
||||
size={96}
|
||||
color={colors.blue_1}
|
||||
/>
|
||||
<Text style={styles.text_white_medium}>{state}</Text>
|
||||
</AnimatedContainer>
|
||||
</View>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue