integrate: login signup

parent 0a075d5b
...@@ -19,9 +19,9 @@ export default function App() { ...@@ -19,9 +19,9 @@ export default function App() {
<NavigationContainer> <NavigationContainer>
<Drawer.Navigator initialRouteName="Authntications"> <Drawer.Navigator initialRouteName="Authntications">
<Drawer.Screen name="Authentications" component={AuthStack} /> <Drawer.Screen name="Authentications" component={AuthStack} />
<Drawer.Screen name="Agripreneurs" component={homeStack} /> {/* <Drawer.Screen name="Agripreneurs" component={homeStack} /> */}
{/* <Drawer.Screen name="MainTab" component={MainTabScreen} /> */} {/* <Drawer.Screen name="MainTab" component={MainTabScreen} /> */}
<Drawer.Screen name="About Us" component={AboutUs} /> {/* <Drawer.Screen name="About Us" component={AboutUs} /> */}
</Drawer.Navigator> </Drawer.Navigator>
</NavigationContainer> </NavigationContainer>
); );
......
...@@ -5,6 +5,10 @@ import { Ionicons } from "@expo/vector-icons"; ...@@ -5,6 +5,10 @@ import { Ionicons } 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";
import { Leaderboard } from "../screen/Leaderboard";
import { PriceScreen } from "../screen/PriceScreen";
import { gamification } from "../screen/gamification";
import { AboutUs } from "../screen/AboutUs";
const Stack = createStackNavigator(); const Stack = createStackNavigator();
...@@ -44,6 +48,38 @@ export function AuthStack({ navigation }) { ...@@ -44,6 +48,38 @@ export function AuthStack({ navigation }) {
headerTitleAlign: "center", headerTitleAlign: "center",
}} }}
/> />
<Stack.Screen
name="Leaderboard"
component={Leaderboard}
options={{
title: "Leaderboard Page",
headerTitleAlign: "center",
}}
/>
<Stack.Screen
name="PriceScreen"
component={PriceScreen}
options={{
title: "Discounted/Price Page",
headerTitleAlign: "center",
}}
/>
<Stack.Screen
name="gamification"
component={gamification}
options={{
title: "Gamification Page",
headerTitleAlign: "center",
}}
/>
<Stack.Screen
name="AboutUs"
component={AboutUs}
options={{
title: "About Page",
headerTitleAlign: "center",
}}
/>
</Stack.Navigator> </Stack.Navigator>
); );
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
Ionicons, Ionicons,
} from "@expo/vector-icons"; } from "@expo/vector-icons";
import { MaterialIcons } from '@expo/vector-icons'; import { MaterialIcons } from '@expo/vector-icons';
// import BottomTabNavigator from '../Navigations/BottomTabNavigator'
export function HomeScreen({ navigation }) { export function HomeScreen({ navigation }) {
//to diable the yellow box warning on the simulator //to diable the yellow box warning on the simulator
...@@ -63,8 +64,9 @@ export function HomeScreen({ navigation }) { ...@@ -63,8 +64,9 @@ export function HomeScreen({ navigation }) {
<Text style={styles.heading2}> <Text style={styles.heading2}>
All Right Reserved. All Right Reserved.
</Text> </Text>
{/* <BottomTabNavigator/> */}
</ImageBackground> </ImageBackground>
</View> </View>
); );
} }
......
import React, {useState, useEffect} from "react"; import React, { useState, useEffect } from "react";
import { import {
StyleSheet, StyleSheet,
Button, Button,
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
} from "react-native"; } from "react-native";
import { Entypo } from "@expo/vector-icons"; import { Entypo } from "@expo/vector-icons";
import axios from "axios"; import axios from "axios";
import { State } from "react-native-gesture-handler";
export function SignIn({ navigation }) { export function SignIn({ navigation }) {
...@@ -19,46 +19,50 @@ export function SignIn({ navigation }) { ...@@ -19,46 +19,50 @@ export function SignIn({ navigation }) {
password: "", password: "",
isValidUser: true, isValidUser: true,
isValidPassword: true, isValidPassword: true,
check_textinputChange: false check_textinputChange: false,
}); });
const textInputChange = (val) => { const textInputChange = (val) => {
if( val.trim().length >= 4) { if (val.trim().length >= 4) {
setData({ setData({
...data, ...data,
username: val, email: val,
check_textInputChange: true, check_textInputChange: true,
isValidUser: true isValidUser: true,
}); });
} else {
setData({
...data,
email: val,
check_textInputChange: false,
isValidUser: false,
});
} }
else { };
setData({
...data,
username: val,
check_textInputChange: false,
isValidUser: false
});
}
}
const handlePasswordChange = (val) => { const handlePasswordChange = (val) => {
if( val.trim().length >= 6 ) { if (val.trim().length >= 3) {
setData({ setData({
...data, ...data,
password: val, password: val,
isValidPassword: true isValidPassword: true,
}); });
} else { } else {
setData({ setData({
...data, ...data,
password: val, password: val,
isValidPassword: false isValidPassword: false,
}); });
} }
} };
const form = new FormData ();
form.append("email", data.email)
form.append("password", data.password)
console.log(form)
return ( return (
<View style={styles.container}> <View style={styles.container}>
...@@ -75,9 +79,7 @@ const handlePasswordChange = (val) => { ...@@ -75,9 +79,7 @@ const handlePasswordChange = (val) => {
<Entypo name="user" size={30} color="white" /> <Entypo name="user" size={30} color="white" />
<TextInput <TextInput
style={styles.input1} style={styles.input1}
onChangeText={(val) => onChangeText={(val) => textInputChange(val)}
textInputChange(val)
}
placeholder="Enter Email" //dummy@abc.com placeholder="Enter Email" //dummy@abc.com
placeholderTextColor="#8b9cb5" placeholderTextColor="#8b9cb5"
keyboardType="email-address" keyboardType="email-address"
...@@ -89,9 +91,11 @@ const handlePasswordChange = (val) => { ...@@ -89,9 +91,11 @@ const handlePasswordChange = (val) => {
blurOnSubmit={false} blurOnSubmit={false}
/> />
</View> </View>
{ data.isValidUser ? null : {data.isValidUser ? null : (
<Text style={styles.errorMsg}>Email must be 4 characters long</Text> <Text style={styles.errorMsg}>
} Email must be 4 characters long
</Text>
)}
</View> </View>
<View style={styles.SectionStyle}> <View style={styles.SectionStyle}>
...@@ -99,9 +103,7 @@ const handlePasswordChange = (val) => { ...@@ -99,9 +103,7 @@ const handlePasswordChange = (val) => {
<Entypo name="lock" size={30} color="white" /> <Entypo name="lock" size={30} color="white" />
<TextInput <TextInput
style={styles.input1} style={styles.input1}
onChangeText={(val) => onChangeText={(val) => handlePasswordChange(val)}
handlePasswordChange(val)
}
placeholder="Enter Password" //12345 placeholder="Enter Password" //12345
placeholderTextColor="#8b9cb5" placeholderTextColor="#8b9cb5"
// ref={passwordInputRef} // ref={passwordInputRef}
...@@ -110,15 +112,31 @@ const handlePasswordChange = (val) => { ...@@ -110,15 +112,31 @@ const handlePasswordChange = (val) => {
secureTextEntry={true} secureTextEntry={true}
/> />
</View> </View>
{ data.isValidPassword ? null : {data.isValidPassword ? null : (
<Text style={styles.errorMsg}>Password must be 6 characters long.</Text> <Text style={styles.errorMsg}>
} Password must be 6 characters long.
</Text>
)}
</View> </View>
<View style={styles.buttons}> <View style={styles.buttons}>
<TouchableOpacity <TouchableOpacity
style={styles.buttonSub} style={styles.buttonSub}
activeOpacity={0.5} activeOpacity={0.5}
onPress={() => navigation.navigate("HomeScreen")} onPress={() =>
axios.post("http://192.168.8.126:5000/login", form)
.then(function (response) {
const stngobj = JSON.stringify(response.data)
console.log(stngobj + "logged");
alert("Successfully Logged in")
navigation.navigate("HomeScreen")
// return response;
})
.catch(function (error) {
console.log(error);
})
}
> >
<Text style={styles.buttonTextStyle}>LOGIN</Text> <Text style={styles.buttonTextStyle}>LOGIN</Text>
{/* <ImageBackground source={require('../assets/loginex.jpg')} style={styles.imagebutton}/> */} {/* <ImageBackground source={require('../assets/loginex.jpg')} style={styles.imagebutton}/> */}
...@@ -232,9 +250,9 @@ const styles = StyleSheet.create({ ...@@ -232,9 +250,9 @@ const styles = StyleSheet.create({
justifyContent: "center", justifyContent: "center",
borderRadius: 8, borderRadius: 8,
}, },
errorMsg:{ errorMsg: {
color: 'black', color: "black",
fontSize: 14, fontSize: 14,
alignSelf:"center" alignSelf: "center",
} },
}); });
...@@ -45,26 +45,40 @@ export function SignUp({ navigation }) { ...@@ -45,26 +45,40 @@ export function SignUp({ navigation }) {
<Formik <Formik
initialValues={{ name: '', email: '', password: '', district: '' }} initialValues={{ name: '', email: '', password: '', district: '' }}
validationSchema={reviewSchema} validationSchema={reviewSchema}
onSubmit={(values, actions) => {
// console.log(values); onSubmit= { (values, actions) => {
// console.log(actions.submitForm())
// await actions.submitForm()
console.log(values);
// actions.submitForm(); // actions.submitForm();
const valuesToBeSent = JSON.stringify({ // const valuesToBeSent = JSON.stringify({
"name": values.name, // "name": values.name,
"email": values.email, // "email": values.email,
"password": values.password, // "password": values.password,
"district": values.district, // "district": values.district,
}) // })
// console.log("")
const form = new FormData ();
form.append("name", values.name)
form.append("email", values.email)
form.append("password", values.password)
form.append("district", values.district)
axios.post('http://192.168.8.126:5000/users', valuesToBeSent) axios({
// axios.get('http://192.168.8.126:5000/getUsers') method:"POST",
url: "http://192.168.8.126:5000/users",
data: form
})
.then(function (response){ .then(function (response){
console.log(response) console.log("abc" + response)
actions.resetForm();
// return response; // return response;
}) })
.catch(function(error){ .catch(function(error){
console.log(error) console.log(error)
}) })
actions.resetForm();
// useEffect(() => { // useEffect(() => {
// axios.post('http://192.168.8.126:5000/users', { // axios.post('http://192.168.8.126:5000/users', {
......
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