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 { 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 { useRoute } from "@react-navigation/native";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { UserActivate } from "../../components/Api/Api";
|
||||||
|
|
||||||
interface ActivationRouteParams {
|
interface ActivationRouteParams {
|
||||||
uid?: string;
|
uid?: string;
|
||||||
|
@ -11,17 +13,47 @@ 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 [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 (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainer>
|
<AnimatedContainer>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
paddingVertical: 4,
|
||||||
|
marginBottom: 16,
|
||||||
|
borderRadius: 4,
|
||||||
|
width: "90%",
|
||||||
|
backgroundColor: colors.blue_1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Text style={styles.text_white_large}>Activation</Text>
|
<Text style={styles.text_white_large}>Activation</Text>
|
||||||
<View style={{ paddingVertical: 8 }} />
|
<View style={{ paddingVertical: 8 }} />
|
||||||
<ActivityIndicator size={96} color={colors.blue_1} />
|
<ActivityIndicator
|
||||||
<Text style={styles.text_white_medium}>
|
animating={loading}
|
||||||
Activating {uid ? `with UID: ${uid}` : ""}{" "}
|
size={96}
|
||||||
{token ? `and Token: ${token}` : ""}
|
color={colors.blue_1}
|
||||||
</Text>
|
/>
|
||||||
|
<Text style={styles.text_white_medium}>{state}</Text>
|
||||||
</AnimatedContainer>
|
</AnimatedContainer>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue