Update: login

parent 50f8c0e6
import React from "react"; import React from "react";
import { createStackNavigator } from "@react-navigation/stack"; import { createStackNavigator } from "@react-navigation/stack";
import { Ionicons } from "@expo/vector-icons"; import { Ionicons } from "@expo/vector-icons";
import { MaterialIcons } from '@expo/vector-icons';
import { SignIn } from "../screen/SignIn"; import { SignIn } from "../screen/SignIn";
import { SignUp } from "../screen/SignUp"; import { SignUp } from "../screen/SignUp";
import { HomeScreen } from "../screen/HomeScreen"; import { HomeScreen } from "../screen/HomeScreen";
...@@ -30,6 +30,14 @@ export function AuthStack({ navigation }) { ...@@ -30,6 +30,14 @@ export function AuthStack({ navigation }) {
); );
}, },
headerLeftContainerStyle: { paddingLeft: 10 }, headerLeftContainerStyle: { paddingLeft: 10 },
headerRight: () => {
return (
<MaterialIcons name="logout"
size={30}
color="black"
/>
);
},
}} }}
/> />
<Stack.Screen <Stack.Screen
...@@ -38,6 +46,14 @@ export function AuthStack({ navigation }) { ...@@ -38,6 +46,14 @@ export function AuthStack({ navigation }) {
options={{ options={{
title: "Sign Up Page", title: "Sign Up Page",
headerTitleAlign: "center", headerTitleAlign: "center",
headerRight: () => {
return (
<MaterialIcons name="logout"
size={30}
color="black"
/>
);
},
}} }}
/> />
<Stack.Screen <Stack.Screen
...@@ -46,6 +62,14 @@ export function AuthStack({ navigation }) { ...@@ -46,6 +62,14 @@ export function AuthStack({ navigation }) {
options={{ options={{
title: "Agripreneurs", title: "Agripreneurs",
headerTitleAlign: "center", headerTitleAlign: "center",
headerRight: () => {
return (
<MaterialIcons name="logout"
size={30}
color="black"
/>
);
},
}} }}
/> />
<Stack.Screen <Stack.Screen
...@@ -54,6 +78,14 @@ export function AuthStack({ navigation }) { ...@@ -54,6 +78,14 @@ export function AuthStack({ navigation }) {
options={{ options={{
title: "Leaderboard Page", title: "Leaderboard Page",
headerTitleAlign: "center", headerTitleAlign: "center",
headerRight: () => {
return (
<MaterialIcons name="logout"
size={30}
color="black"
/>
);
},
}} }}
/> />
<Stack.Screen <Stack.Screen
...@@ -62,6 +94,14 @@ export function AuthStack({ navigation }) { ...@@ -62,6 +94,14 @@ export function AuthStack({ navigation }) {
options={{ options={{
title: "Discounted/Price Page", title: "Discounted/Price Page",
headerTitleAlign: "center", headerTitleAlign: "center",
headerRight: () => {
return (
<MaterialIcons name="logout"
size={30}
color="black"
/>
);
},
}} }}
/> />
<Stack.Screen <Stack.Screen
...@@ -70,6 +110,14 @@ export function AuthStack({ navigation }) { ...@@ -70,6 +110,14 @@ export function AuthStack({ navigation }) {
options={{ options={{
title: "Gamification Page", title: "Gamification Page",
headerTitleAlign: "center", headerTitleAlign: "center",
headerRight: () => {
return (
<MaterialIcons name="logout"
size={30}
color="black"
/>
);
},
}} }}
/> />
<Stack.Screen <Stack.Screen
......
...@@ -92,9 +92,6 @@ export function PriceScreen({ navigation, data }) { ...@@ -92,9 +92,6 @@ export function PriceScreen({ navigation, data }) {
<TouchableOpacity> <TouchableOpacity>
<FontAwesome5 name="user-edit" size={30} color="black" /> <FontAwesome5 name="user-edit" size={30} color="black" />
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity>
<AntDesign name="logout" size={30} color="black" />
</TouchableOpacity>
</View> </View>
<View style={styles.secondContainer}> <View style={styles.secondContainer}>
<View style={styles.SectionStyle}> <View style={styles.SectionStyle}>
......
...@@ -23,7 +23,7 @@ export function SignIn({ navigation }) { ...@@ -23,7 +23,7 @@ export function SignIn({ navigation }) {
}); });
const textInputChange = (val) => { const textInputChange = (val) => {
if (val.trim().length >= 4) { if (val.trim().length >= 4 && val.includes('@')) {
setData({ setData({
...data, ...data,
email: val, email: val,
...@@ -41,7 +41,7 @@ export function SignIn({ navigation }) { ...@@ -41,7 +41,7 @@ export function SignIn({ navigation }) {
}; };
const handlePasswordChange = (val) => { const handlePasswordChange = (val) => {
if (val.trim().length >= 3) { if (val.trim().length >= 4) {
setData({ setData({
...data, ...data,
password: val, password: val,
...@@ -93,7 +93,7 @@ export function SignIn({ navigation }) { ...@@ -93,7 +93,7 @@ export function SignIn({ navigation }) {
</View> </View>
{data.isValidUser ? null : ( {data.isValidUser ? null : (
<Text style={styles.errorMsg}> <Text style={styles.errorMsg}>
Email must be 4 characters long Email must be 4 characters long and iclude @
</Text> </Text>
)} )}
</View> </View>
...@@ -114,7 +114,7 @@ export function SignIn({ navigation }) { ...@@ -114,7 +114,7 @@ export function SignIn({ navigation }) {
</View> </View>
{data.isValidPassword ? null : ( {data.isValidPassword ? null : (
<Text style={styles.errorMsg}> <Text style={styles.errorMsg}>
Password must be 6 characters long. Password must be minimum 4 characters long.
</Text> </Text>
)} )}
</View> </View>
...@@ -123,8 +123,6 @@ export function SignIn({ navigation }) { ...@@ -123,8 +123,6 @@ export function SignIn({ navigation }) {
style={styles.buttonSub} style={styles.buttonSub}
activeOpacity={0.5} activeOpacity={0.5}
onPress={() => onPress={() =>
axios.post("http://192.168.8.126:5000/login", form) axios.post("http://192.168.8.126:5000/login", form)
.then(function (response) { .then(function (response) {
const stngobj = JSON.stringify(response.data) const stngobj = JSON.stringify(response.data)
...@@ -135,6 +133,7 @@ export function SignIn({ navigation }) { ...@@ -135,6 +133,7 @@ export function SignIn({ navigation }) {
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
alert("Login failed")
}) })
} }
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment