Udate: form validation success

parent 496dc27f
......@@ -7,6 +7,7 @@ import { homeStack } from "./Navigations/homeStack";
import { AuthStack } from "./Navigations/AuthStack";
import { FontAwesome } from '@expo/vector-icons';
import { AboutUs } from './screen/AboutUs';
// import MainTabScreen from './screen/MainTabScreen';
const Drawer = createDrawerNavigator();
......@@ -19,6 +20,7 @@ export default function App() {
<Drawer.Navigator initialRouteName="Authntications">
<Drawer.Screen name="Authentications" component={AuthStack} />
<Drawer.Screen name="Agripreneurs" component={homeStack} />
{/* <Drawer.Screen name="MainTab" component={MainTabScreen} /> */}
<Drawer.Screen name="About Us" component={AboutUs} />
</Drawer.Navigator>
</NavigationContainer>
......
......@@ -1120,6 +1120,15 @@
"to-fast-properties": "^2.0.0"
}
},
"@callstack/react-theme-provider": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/@callstack/react-theme-provider/-/react-theme-provider-3.0.6.tgz",
"integrity": "sha512-wwKMXfmklfogpalNZT0W+jh76BIquiYUiQHOaPmt/PCyCEP/E6rP+e7Uie6mBZrfkea9WJYJ+mus6r+45JAEhg==",
"requires": {
"deepmerge": "^3.2.0",
"hoist-non-react-statics": "^3.3.0"
}
},
"@cnakazawa/watch": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz",
......@@ -2203,6 +2212,19 @@
"react-native-iphone-x-helper": "^1.3.0"
}
},
"@react-navigation/elements": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.1.0.tgz",
"integrity": "sha512-jZncciZPGuoP6B6f+Wpf6MYSSYy86B2HJDbFTCtT5xZV0w6V9GgCeqvSTOEAxifZrmKl8uDxsr0GrIxgQE8NxA=="
},
"@react-navigation/material-bottom-tabs": {
"version": "6.0.5",
"resolved": "https://registry.npmjs.org/@react-navigation/material-bottom-tabs/-/material-bottom-tabs-6.0.5.tgz",
"integrity": "sha512-u1vEH4Sxs3vofaS08jNcY9305OAsRQQPVZMfa2dsBTAaxEhH/nDotATmKngZoXiMm269bc/8LUUkHKL5/v9xvQ==",
"requires": {
"@react-navigation/elements": "^1.1.0"
}
},
"@react-navigation/native": {
"version": "5.9.4",
"resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-5.9.4.tgz",
......@@ -2280,6 +2302,11 @@
"@types/istanbul-lib-report": "*"
}
},
"@types/lodash": {
"version": "4.14.173",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.173.tgz",
"integrity": "sha512-vv0CAYoaEjCw/mLy96GBTnRoZrSxkGE0BKzKimdR8P3OzrNYNvBgtW7p055A+E8C31vXNUhWKoFCbhq7gbyhFg=="
},
"@types/node": {
"version": "15.12.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-15.12.2.tgz",
......@@ -6142,6 +6169,11 @@
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==",
"optional": true
},
"nanoclone": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/nanoclone/-/nanoclone-0.2.1.tgz",
"integrity": "sha512-wynEP02LmIbLpcYw8uBKpcfF6dmg2vcpKqxeH5UcoKEYdExslsdUA4ugFauuaeYdTB76ez6gJW8XAZ6CgkXYxA=="
},
"nanoid": {
"version": "3.1.23",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz",
......@@ -6797,6 +6829,11 @@
}
}
},
"property-expr": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/property-expr/-/property-expr-2.0.4.tgz",
"integrity": "sha512-sFPkHQjVKheDNnPvotjQmm3KD3uk1fWKUN7CrpdbwmUx3CrG3QiM8QpTSimvig5vTXmTvjz7+TDvXOI9+4rkcg=="
},
"pseudomap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
......@@ -7244,6 +7281,16 @@
"resolved": "https://registry.npmjs.org/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz",
"integrity": "sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg=="
},
"react-native-paper": {
"version": "4.9.2",
"resolved": "https://registry.npmjs.org/react-native-paper/-/react-native-paper-4.9.2.tgz",
"integrity": "sha512-J7FRsd0YblQawtuj9I46F//apZHadsCKk6jWpc6njFTYdgUeCdkR8KgEto7cp2WxbcGNELx7KGwPQ4zAgX746A==",
"requires": {
"@callstack/react-theme-provider": "^3.0.6",
"color": "^3.1.2",
"react-native-iphone-x-helper": "^1.3.1"
}
},
"react-native-reanimated": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-2.1.0.tgz",
......@@ -7296,6 +7343,96 @@
"resolved": "https://registry.npmjs.org/react-native-screens/-/react-native-screens-3.0.0.tgz",
"integrity": "sha512-35II5oxTaVp3OP8y0eLPOPpQkxG4fRKQ+dL1YSE1we5kCZFOU0l/Rn0T79HbyUu1LPwUZr6lZupPs0ULnRyMuQ=="
},
"react-native-vector-icons": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-8.1.0.tgz",
"integrity": "sha512-sHIdBB6Y0dHaot2fMXgy5J/hhCn5YuyN7SKDNFgPzL8KA1oF2/v7mgYMavnK7LIIs2dJoGnDANKf61dsU+TZlg==",
"requires": {
"lodash.frompairs": "^4.0.1",
"lodash.isequal": "^4.5.0",
"lodash.isstring": "^4.0.1",
"lodash.omit": "^4.5.0",
"lodash.pick": "^4.4.0",
"lodash.template": "^4.5.0",
"prop-types": "^15.7.2",
"yargs": "^16.1.1"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"requires": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^7.0.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"strip-ansi": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
"requires": {
"ansi-regex": "^5.0.0"
}
},
"wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"requires": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
}
},
"y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="
},
"yargs": {
"version": "16.2.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
"integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
"requires": {
"cliui": "^7.0.2",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.0",
"y18n": "^5.0.5",
"yargs-parser": "^20.2.2"
}
},
"yargs-parser": {
"version": "20.2.9",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w=="
}
}
},
"react-native-web": {
"version": "0.13.18",
"resolved": "https://registry.npmjs.org/react-native-web/-/react-native-web-0.13.18.tgz",
......@@ -8256,6 +8393,11 @@
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
},
"toposort": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/toposort/-/toposort-2.0.2.tgz",
"integrity": "sha1-riF2gXXRVZ1IvvNUILL0li8JwzA="
},
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
......@@ -8768,6 +8910,20 @@
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="
},
"yup": {
"version": "0.32.9",
"resolved": "https://registry.npmjs.org/yup/-/yup-0.32.9.tgz",
"integrity": "sha512-Ci1qN+i2H0XpY7syDQ0k5zKQ/DoxO0LzPg8PAR/X4Mpj6DqaeCoIYEEjDJwhArh3Fa7GWbQQVDZKeXYlSH4JMg==",
"requires": {
"@babel/runtime": "^7.10.5",
"@types/lodash": "^4.14.165",
"lodash": "^4.17.20",
"lodash-es": "^4.17.15",
"nanoclone": "^0.2.1",
"property-expr": "^2.0.4",
"toposort": "^2.0.2"
}
}
}
}
......@@ -3,6 +3,7 @@
// Import React and Component
import React from 'react';
// import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View, Text, TouchableOpacity, ImageBackground } from "react-native";
import ImageSliderz from "react-native-image-slideshow";
import {
......
import React, { useState, useEffect } from 'react';
import { StyleSheet, Button, TextInput, View, Text, TouchableOpacity, ImageBackground } from 'react-native';
import axios from 'axios'
import { ScrollView } from "react-native-gesture-handler";
import { FontAwesome } from "@expo/vector-icons";
......
......@@ -12,55 +12,79 @@ import { FontAwesome } from "@expo/vector-icons";
import { FontAwesome5 } from "@expo/vector-icons";
import { Entypo } from "@expo/vector-icons";
import { Ionicons } from "@expo/vector-icons";
import { AntDesign } from '@expo/vector-icons';
export function PriceScreen({ navigation, data }) {
return (
<View style={styles.container}>
{/* <ImageBackground source={require('../assets/agri.jpg')} style={styles.images}>
const [details, setDetails] = useState({
email: "",
earns: "",
district: "",
isValidUser: true,
isValidearns: true,
isValiddistrict: true,
check_textinputChange: false
});
<View style={styles.inContainer}>
<View ><Text style={styles.heading}>User Profile</Text></View>
<View style={styles.iconStyle}>
<FontAwesome
name="user-circle"
size={70}
color="black"
/>
</View>
<View>
<TextInput
style={styles.input}
multiline
placeholder='Name'
/>
<TextInput
style={styles.input}
multiline
placeholder='Earns'
/>
<TextInput
style={styles.input}
multiline
placeholder='District'
// onChangeText={props.handleChange('password')}
// value={navigation.getParams('District')}
/>
<TouchableOpacity style = {styles.buttonSub} title="Sign Up" >
<Text style={styles.buttonText}>Save Details</Text>
</TouchableOpacity>
<Text style={styles.texts}>You Have earned 5% Discount</Text>
</View>
</View>
</ImageBackground> */}
const textInputChange = (val) => {
if( val.trim().length >= 4) {
setDetails({
...details,
email: val,
check_textInputChange: true,
isValidUser: true
});
}
else {
setDetails({
...details,
email: val,
check_textInputChange: false,
isValidUser: false
});
}
}
const handleEarnsChanged = (val) => {
if( val.trim().length <= 7) {
setDetails({
...details,
earns: val,
isValidearns: true
});
}
else {
setDetails({
...details,
earns: val,
isValidearns: false
});
}
}
const handleDistrictChanged = (val) => {
if( val.trim().length >= 4) {
setDetails({
...details,
district: val,
isValiddistrict: true
});
}
else {
setDetails({
...details,
district: val,
isValiddistrict: false
});
}
}
<ImageBackground
return (
<View style={styles.container}>
<ImageBackground
source={require("../assets/signin1.jpg")}
style={styles.images}
>
......@@ -68,6 +92,9 @@ export function PriceScreen({ navigation, data }) {
<TouchableOpacity>
<FontAwesome5 name="user-edit" size={30} color="black" />
</TouchableOpacity>
<TouchableOpacity>
<AntDesign name="logout" size={30} color="black" />
</TouchableOpacity>
</View>
<View style={styles.secondContainer}>
<View style={styles.SectionStyle}>
......@@ -93,12 +120,12 @@ export function PriceScreen({ navigation, data }) {
<Entypo name="user" size={30} color="white" />
<TextInput
style={styles.input1}
// onChangeText={(UserEmail) =>
// setUserEmail(UserEmail)
// }
onChangeText={(val) =>
textInputChange(val)
}
placeholder="Enter Email" //dummy@abc.com
placeholderTextColor="#8b9cb5"
// keyboardType="email-address"
keyboardType="email-address"
// onSubmitEditing={() =>
// passwordInputRef.current &&
// passwordInputRef.current.focus()
......@@ -106,6 +133,9 @@ export function PriceScreen({ navigation, data }) {
blurOnSubmit={false}
/>
</View>
{ details.isValidUser ? null :
<Text style={styles.errorMsg}>Email must be 4 characters long</Text>
}
</View>
<View style={styles.SectionStyle}>
......@@ -113,9 +143,9 @@ export function PriceScreen({ navigation, data }) {
<FontAwesome name="money" size={30} color="white" />
<TextInput
style={styles.input1}
// onChangeText={(UserPassword) =>
// setUserPassword(UserPassword)
// }
onChangeText={(val) =>
handleEarnsChanged(val)
}
placeholder="Enter Earns" //12345
placeholderTextColor="#8b9cb5"
// ref={passwordInputRef}
......@@ -124,15 +154,18 @@ export function PriceScreen({ navigation, data }) {
secureTextEntry={true}
/>
</View>
{ details.isValidearns ? null :
<Text style={styles.errorMsg}>Email must be 4 characters long</Text>
}
</View>
<View style={styles.SectionStyle}>
<View style={styles.textinputicon}>
<Entypo name="location-pin" size={30} color="white" />
<TextInput
style={styles.input1}
// onChangeText={(UserPassword) =>
// setUserPassword(UserPassword)
// }
onChangeText={(val) =>
handleDistrictChanged(val)
}
placeholder="Enter District" //12345
placeholderTextColor="#8b9cb5"
// ref={passwordInputRef}
......@@ -141,6 +174,9 @@ export function PriceScreen({ navigation, data }) {
secureTextEntry={true}
/>
</View>
{ details.isValiddistrict ? null :
<Text style={styles.errorMsg}>Email must be 4 characters long</Text>
}
</View>
<View style={styles.buttons}>
<TouchableOpacity
......@@ -256,5 +292,11 @@ const styles = StyleSheet.create({
},
editUSer: {
alignSelf: "flex-end",
flexDirection: "row",
},
errorMsg:{
color: 'black',
fontSize: 14,
alignSelf:"center"
}
});
This diff is collapsed.
......@@ -4,32 +4,87 @@ import { Formik } from 'formik';
import { Entypo } from '@expo/vector-icons';
import { MaterialIcons } from '@expo/vector-icons';
import { Ionicons } from '@expo/vector-icons';
import axios from 'axios'
import axios from 'axios';
import * as yup from 'yup';
const reviewSchema = yup.object({
name: yup.string().required().min(2),
email: yup.string().required().min(2),
password: yup.string().required().min(2),
district: yup.string().required().min(2)
})
export function SignUp({ navigation }) {
// const [submit, setSubmit] = useEffect();
// function handleSubmit()
// {
// useEffect(() => {
// axios.post('http://192.168.8.126:5000/users', {
// district: values.district,
// email: values.email,
// name: values.name,
// password: values.password,
// })
// .then(function (response){
// console.log(response + "logged")
// // return response;
// })
// .catch(function(error){
// console.log(error)
// })
// })
// }
return (
<View style={styles.container}>
<ImageBackground source={require('../assets/signup11.jpg')} style={styles.images}>
<Formik
initialValues={{ name: '', email: '', password: '', district: '' }}
onSubmit={(values) => {
validationSchema={reviewSchema}
onSubmit={(values, actions) => {
// console.log(values);
axios.post('http://127.0.0.1:5000/users', {
name: values.name,
email: values.email,
password: values.password,
district: values.district
// actions.submitForm();
const valuesToBeSent = JSON.stringify({
"name": values.name,
"email": values.email,
"password": values.password,
"district": values.district,
})
axios.post('http://192.168.8.126:5000/users', valuesToBeSent)
// axios.get('http://192.168.8.126:5000/getUsers')
.then(function (response){
console.log(response)
// return response;
})
.catch(function(error){
console.log(error)
})
}}
actions.resetForm();
// useEffect(() => {
// axios.post('http://192.168.8.126:5000/users', {
// district: values.district,
// email: values.email,
// name: values.name,
// password: values.password,
// })
// .then(function (response){
// console.log(response + "logged")
// // return response;
// })
// .catch(function(error){
// console.log(error)
// })
// })
}}
>
{({handleChange, handleSubmit, values}) => (
{(props) => (
<View>
<Text style={styles.heading}> Sign Up </Text>
......@@ -44,10 +99,11 @@ export function SignUp({ navigation }) {
<TextInput
style={styles.input}
placeholder='Name'
onChangeText={handleChange('name')}
value={values.name}
onChangeText={props.handleChange('name')}
value={props.values.name}
/>
</View>
<Text style={styles.errorText}>{props.errors.name}</Text>
</View>
<View style={styles.container}>
......@@ -56,10 +112,12 @@ export function SignUp({ navigation }) {
<TextInput
style={styles.input}
placeholder='Email'
onChangeText={handleChange('email')}
value={values.email}
onChangeText={props.handleChange('email')}
value={props.values.email}
/>
</View>
<Text style={styles.errorText}>{props.errors.email}</Text>
</View>
......@@ -70,10 +128,12 @@ export function SignUp({ navigation }) {
style={styles.input}
multiline
placeholder='Password'
onChangeText={handleChange('password')}
value={values.password}
onChangeText={props.handleChange('password')}
value={props.values.password}
/>
</View>
<Text style={styles.errorText}>{props.errors.password}</Text>
</View>
......@@ -83,14 +143,16 @@ export function SignUp({ navigation }) {
<TextInput
style={styles.input}
placeholder='District'
onChangeText={handleChange('district')}
value={values.district}
onChangeText={props.handleChange('district')}
value={props.values.district}
/>
</View>
<Text style={styles.errorText}>{props.errors.district}</Text>
</View>
<View>
<TouchableOpacity style={styles.buttonSub} title="Sign Up" onPress={handleSubmit} >
<TouchableOpacity style={styles.buttonSub} title="Sign Up" onPress={props.handleSubmit} >
<Text style={styles.buttonText}>Sign Up</Text>
</TouchableOpacity>
</View>
......@@ -132,7 +194,7 @@ const styles = StyleSheet.create({
color: '#333',
padding: 10,
width: "100%",
justifyContent: 'flex-start',
// justifyContent: 'flex-start',
alignContent: 'stretch',
},
buttonSub: {
......@@ -160,5 +222,9 @@ const styles = StyleSheet.create({
},
container: {
},
},
errorText:{
color:"black",
alignSelf:"center"
}
});
\ No newline at end of file
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