Added registration functionality

This commit is contained in:
keannu125 2023-04-16 13:52:19 +08:00
parent c3fe00f8f5
commit b1c26ba992

View file

@ -1,15 +1,17 @@
import * as React from 'react'; import * as React from "react";
import {View, Text, TextInput} from 'react-native'; import { View, Text, TextInput } from "react-native";
import styles from '../../styles'; import styles from "../../styles";
import Background from '../../Components/Background/Background'; import Background from "../../Components/Background/Background";
import { SafeAreaView } from 'react-native-safe-area-context'; import { SafeAreaView } from "react-native-safe-area-context";
import { useState } from "react"; import { useState } from "react";
import { TouchableOpacity } from "react-native"; import { TouchableOpacity } from "react-native";
import { UserRegister } from "../../Components/Api/Api";
export default function Register() { export default function Register() {
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [email, setEmail] = useState(""); const [email, setEmail] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [feedback, setFeedback] = useState("");
return ( return (
<Background> <Background>
@ -45,12 +47,26 @@ export default function Register() {
value={password} value={password}
/> />
</View> </View>
<TouchableOpacity style={styles.registerbtn}> <TouchableOpacity
onPress={async () => {
setUsername("");
setPassword("");
console.log("heh");
if (await UserRegister({ username, email, password })) {
setFeedback(
"Registration success. Please check your email address for activation"
);
} else {
setFeedback("Invalid credentials specified");
}
}}
style={styles.registerbtn}
>
<Text style={styles.registertext}>REGISTER</Text> <Text style={styles.registertext}>REGISTER</Text>
</TouchableOpacity> </TouchableOpacity>
<Text style={styles.registertext}>{feedback}</Text>
</View> </View>
</SafeAreaView> </SafeAreaView>
</Background> </Background>
); );
} }