-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.js
109 lines (105 loc) · 2.65 KB
/
login.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React, { useState } from "react";
import { StyleSheet, Text, View, TextInput, Button } from "react-native";
import { StatusBar } from "expo-status-bar";
import axios from "axios";
export default function Login({ navigation }) {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const loginVerification = () => {
axios
.post("http://10.0.2.2:3000/getClinic", {
email: email,
password: password,
})
.then((response) => {
if (email == "" || password == "") {
alert("Please enter your email and password");
} else if (response.data.length == 0) {
alert("Invalid Email/Password.");
} else if (password != response.data[0]["password"]) {
alert("Invalid Email/Password.");
} else {
alert("Welcome, " + response.data[0]["name"]);
navigation.navigate("Clinic", { email: email });
}
})
.catch((error) => {
console.log(error);
});
};
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.heading}>My Clinic</Text>
</View>
<View style={styles.body}>
<Text>Email</Text>
<TextInput
style={styles.input}
keyboardType="email-address"
value={email}
onChangeText={(text) => {
setEmail(text);
}}
/>
<Text>Password</Text>
<TextInput
style={styles.input}
secureTextEntry
value={password}
onChangeText={(text) => {
setPassword(text);
}}
/>
<View style={styles.buttonContainer}>
<Button title="Login" onPress={loginVerification} />
</View>
<View style={styles.buttonContainer}>
<Button
color="#999"
title="Registration"
onPress={() => navigation.navigate("Registration")}
/>
</View>
</View>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
},
header: {
flex: 1,
},
body: {
flex: 3,
color: "white",
//alignItems: 'center',
},
heading: {
marginTop: 50,
marginBottom: 50,
fontWeight: "bold",
fontSize: 36,
color: "#6eb9fa",
borderColor: "black",
},
input: {
borderWidth: 1,
borderColor: "#6eb9fa",
padding: 8,
margin: 10,
width: 250,
height: 40,
marginBottom: 20,
},
buttonContainer: {
marginTop: 10,
backgroundColor: "black",
},
});