update: delete update user

parent 9bb8811a
...@@ -7,10 +7,14 @@ import { homeStack } from "./Navigations/homeStack"; ...@@ -7,10 +7,14 @@ import { homeStack } from "./Navigations/homeStack";
import { AuthStack } from "./Navigations/AuthStack"; import { AuthStack } from "./Navigations/AuthStack";
import { FontAwesome } from '@expo/vector-icons'; import { FontAwesome } from '@expo/vector-icons';
import { AboutUs } from './screen/AboutUs'; import { AboutUs } from './screen/AboutUs';
// import MainTabScreen from './screen/MainTabScreen'; // import {HomeScreen} from './screen/HomeScreen';
// import {HomeScreen} from './screen/HomeScreen'
// import {BottomTab} from './Navigations/BottomTab';
// import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
const Drawer = createDrawerNavigator(); const Drawer = createDrawerNavigator();
// const Tab = createMaterialBottomTabNavigator();
export default function App() { export default function App() {
...@@ -19,10 +23,11 @@ export default function App() { ...@@ -19,10 +23,11 @@ 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={BottomTab} /> */}
{/* <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>
{/* <HomeScreen/> */}
</NavigationContainer> </NavigationContainer>
); );
} }
......
// import React from 'react';
// import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
// import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
// import { HomeScreen } from "../screen/HomeScreen";
// const Tab = createMaterialBottomTabNavigator();
// export function BottomTab() {
// return (
// <Tab.Navigator
// initialRouteName="HomeScreen"
// screenOptions={{
// tabBarActiveTintColor: '#e91e63',
// }}
// >
// <Tab.Screen
// name="HomeScreen"
// component={HomeScreen}
// options={{
// tabBarLabel: 'Home',
// tabBarIcon: ({ color, size }) => (
// <MaterialCommunityIcons name="home" color={color} size={size} />
// ),
// }}
// />
// </Tab.Navigator>
// );
// }
...@@ -2,71 +2,76 @@ ...@@ -2,71 +2,76 @@
// https://aboutreact.com/react-native-login-and-signup/ // https://aboutreact.com/react-native-login-and-signup/
// Import React and Component // Import React and Component
import React from 'react'; import React from "react";
// import { StatusBar } from 'expo-status-bar'; // import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View, Text, TouchableOpacity, ImageBackground } from "react-native"; import {
StyleSheet,
View,
Text,
TouchableOpacity,
ImageBackground,
} from "react-native";
import ImageSliderz from "react-native-image-slideshow"; import ImageSliderz from "react-native-image-slideshow";
import { import {
AntDesign, AntDesign,
MaterialCommunityIcons, MaterialCommunityIcons,
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' import { gamification } from "./gamification";
// import BottomTab from "../Navigations/BottomTab";
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
console.disableYellowBox = true; console.disableYellowBox = true;
return ( return (
<View style={styles.background}> <View style={styles.background}>
<ImageBackground source={require('../assets/signin1.jpg')} style={styles.images}> <ImageBackground
source={require("../assets/signin1.jpg")}
style={styles.images}
>
<ImageSliderz
height={430}
dataSource={[
{
url: require("../assets/d.jpg"),
},
{
url: require("../assets/c.jpg"),
},
{
url: require("../assets/b.jpg"),
},
]}
/>
<View>
<TouchableOpacity
style={styles.saveExam}
onPress={() => navigation.navigate("gamification")}
>
<Ionicons name="game-controller" size={24} color="black" />
<Text style={styles.buttonText}>Gamification</Text>
</TouchableOpacity>
</View>
<View>
<TouchableOpacity
style={styles.saveExam}
onPress={() => navigation.navigate("Leaderboard")}
>
<MaterialIcons name="leaderboard" size={24} color="black" />
<Text style={styles.buttonText}>Leaderboard</Text>
</TouchableOpacity>
</View>
<Text style={styles.heading}>
AGRIPRENEURS. Agriculture solution provider.
</Text>
<Text style={styles.heading1}>Build to Empower Entrepreneurs</Text>
<Text style={styles.heading2}>All Right Reserved.</Text>
<ImageSliderz </ImageBackground>
height={430} {/* <BottomTab/> */}
dataSource={[ </View>
{
url: require("../assets/d.jpg"),
},
{
url: require("../assets/c.jpg"),
},
{
url: require("../assets/b.jpg"),
},
]}
/>
<View>
<TouchableOpacity style={styles.saveExam} onPress={() => navigation.navigate('gamification')}>
<Ionicons
name="game-controller"
size={24}
color="black"
/>
<Text style={styles.buttonText}>Gamification</Text>
</TouchableOpacity>
</View>
<View>
<TouchableOpacity style={styles.saveExam} onPress={() => navigation.navigate('Leaderboard')}>
<MaterialIcons
name="leaderboard"
size={24}
color="black" />
<Text style={styles.buttonText}>Leaderboard</Text>
</TouchableOpacity>
</View>
<Text style={styles.heading}>
AGRIPRENEURS. Agriculture solution provider.
</Text>
<Text style={styles.heading1}>
Build to Empower Entrepreneurs
</Text>
<Text style={styles.heading2}>
All Right Reserved.
</Text>
{/* <BottomTabNavigator/> */}
</ImageBackground>
</View>
); );
} }
...@@ -96,21 +101,19 @@ const styles = StyleSheet.create({ ...@@ -96,21 +101,19 @@ const styles = StyleSheet.create({
flexDirection: "row", flexDirection: "row",
marginBottom: 15, marginBottom: 15,
justifyContent: "center", justifyContent: "center",
borderRadius: 10 borderRadius: 10,
}, },
buttonText: { buttonText: {
color: "#000", color: "#000",
fontSize: 15, fontSize: 15,
marginLeft: 8 marginLeft: 8,
}, },
background:{ background: {
backgroundColor: '#bababa', backgroundColor: "#bababa",
height: '100%' height: "100%",
},
images: {
height: "100%",
justifyContent: "center",
}, },
images: {
height: '100%',
justifyContent: 'center'
}
}); });
...@@ -7,84 +7,111 @@ import { ...@@ -7,84 +7,111 @@ import {
Text, Text,
TouchableOpacity, TouchableOpacity,
ImageBackground, ImageBackground,
Alert,
} from "react-native"; } from "react-native";
import { FontAwesome } from "@expo/vector-icons"; import { FontAwesome } from "@expo/vector-icons";
import { FontAwesome5 } from "@expo/vector-icons"; import { FontAwesome5 } from "@expo/vector-icons";
import { Entypo } from "@expo/vector-icons"; import { Entypo } from "@expo/vector-icons";
import { Ionicons } from "@expo/vector-icons"; import { Ionicons } from "@expo/vector-icons";
import { AntDesign } from '@expo/vector-icons'; import { AntDesign } from "@expo/vector-icons";
import { SignIn } from "./SignIn";
export function PriceScreen({ navigation, data }) { import axios from "axios";
export function PriceScreen({ navigation, data }) {
const [details, setDetails] = useState({ const [details, setDetails] = useState({
email: "", name: "",
earns: "",
district: "", district: "",
isValidUser: true, isValidUser: true,
isValidearns: true, isValidearns: true,
isValiddistrict: true, isValiddistrict: true,
check_textinputChange: false check_textinputChange: false,
}); });
const textInputChange = (val) => { const textInputChange = (val) => {
if( val.trim().length >= 4) { if (val.trim().length >= 4) {
setDetails({ setDetails({
...details, ...details,
email: val, name: val,
check_textInputChange: true, check_textInputChange: true,
isValidUser: true isValidUser: true,
}); });
} } else {
else {
setDetails({
...details,
email: val,
check_textInputChange: false,
isValidUser: false
});
}
}
const handleEarnsChanged = (val) => {
if( val.trim().length <= 7) {
setDetails({ setDetails({
...details, ...details,
earns: val, name: val,
isValidearns: true check_textInputChange: false,
}); isValidUser: false,
});
} }
else { };
setDetails({ // const handleEarnsChanged = (val) => {
...details, // if (val.trim().length <= 7) {
earns: val, // setDetails({
isValidearns: false // ...details,
}); // earns: val,
} // isValidearns: true,
// });
} // } else {
// setDetails({
// ...details,
// earns: val,
// isValidearns: false,
// });
// }
// };
const handleDistrictChanged = (val) => { const handleDistrictChanged = (val) => {
if( val.trim().length >= 4) { if (val.trim().length >= 4) {
setDetails({
...details,
district: val,
isValiddistrict: true,
});
} else {
setDetails({ setDetails({
...details, ...details,
district: val, district: val,
isValiddistrict: true isValiddistrict: false,
}); });
} }
else { };
setDetails({
...details, const createTwoButtonAlert = () =>{
district: val, Alert.alert(
isValiddistrict: false "Delete User",
}); "Are you sure want to delete User",
} [
{
} text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel"
},
{ text: "OK", onPress: () => axios.delete("http://192.168.8.126:5000/deleteUsers/<id>")
.then(function (response) {
const stngobj = JSON.stringify(response.data)
console.log(stngobj);
alert("Successfully deleted")
navigation.navigate("SignIn")
// return response;
})
.catch(function (error) {
console.log(error);
alert("Login failed")
}) }
]
);
}
const form = new FormData ();
form.append("name", details.name)
form.append("district", details.district)
console.log(form)
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ImageBackground <ImageBackground
source={require("../assets/signin1.jpg")} source={require("../assets/signin1.jpg")}
style={styles.images} style={styles.images}
> >
...@@ -117,12 +144,10 @@ export function PriceScreen({ navigation, data }) { ...@@ -117,12 +144,10 @@ export function PriceScreen({ navigation, data }) {
<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 Name" //dummy@abc.com
}
placeholder="Enter Email" //dummy@abc.com
placeholderTextColor="#8b9cb5" placeholderTextColor="#8b9cb5"
keyboardType="email-address" // keyboardType="email-address"
// onSubmitEditing={() => // onSubmitEditing={() =>
// passwordInputRef.current && // passwordInputRef.current &&
// passwordInputRef.current.focus() // passwordInputRef.current.focus()
...@@ -130,9 +155,11 @@ export function PriceScreen({ navigation, data }) { ...@@ -130,9 +155,11 @@ export function PriceScreen({ navigation, data }) {
blurOnSubmit={false} blurOnSubmit={false}
/> />
</View> </View>
{ details.isValidUser ? null : {details.isValidUser ? null : (
<Text style={styles.errorMsg}>Email must be 4 characters long</Text> <Text style={styles.errorMsg}>
} Name must be 4 characters long
</Text>
)}
</View> </View>
<View style={styles.SectionStyle}> <View style={styles.SectionStyle}>
...@@ -140,9 +167,7 @@ export function PriceScreen({ navigation, data }) { ...@@ -140,9 +167,7 @@ export function PriceScreen({ navigation, data }) {
<FontAwesome name="money" size={30} color="white" /> <FontAwesome name="money" size={30} color="white" />
<TextInput <TextInput
style={styles.input1} style={styles.input1}
onChangeText={(val) => onChangeText={(val) => handleEarnsChanged(val)}
handleEarnsChanged(val)
}
placeholder="Enter Earns" //12345 placeholder="Enter Earns" //12345
placeholderTextColor="#8b9cb5" placeholderTextColor="#8b9cb5"
// ref={passwordInputRef} // ref={passwordInputRef}
...@@ -151,18 +176,18 @@ export function PriceScreen({ navigation, data }) { ...@@ -151,18 +176,18 @@ export function PriceScreen({ navigation, data }) {
secureTextEntry={true} secureTextEntry={true}
/> />
</View> </View>
{ details.isValidearns ? null : {details.isValidearns ? 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}>
<View style={styles.textinputicon}> <View style={styles.textinputicon}>
<Entypo name="location-pin" size={30} color="white" /> <Entypo name="location-pin" size={30} color="white" />
<TextInput <TextInput
style={styles.input1} style={styles.input1}
onChangeText={(val) => onChangeText={(val) => handleDistrictChanged(val)}
handleDistrictChanged(val)
}
placeholder="Enter District" //12345 placeholder="Enter District" //12345
placeholderTextColor="#8b9cb5" placeholderTextColor="#8b9cb5"
// ref={passwordInputRef} // ref={passwordInputRef}
...@@ -171,28 +196,41 @@ export function PriceScreen({ navigation, data }) { ...@@ -171,28 +196,41 @@ export function PriceScreen({ navigation, data }) {
secureTextEntry={true} secureTextEntry={true}
/> />
</View> </View>
{ details.isValiddistrict ? null : {details.isValiddistrict ? null : (
<Text style={styles.errorMsg}>Email must be 4 characters long</Text> <Text style={styles.errorMsg}>
} Distict must be 4 characters long
</Text>
)}
</View> </View>
<View style={styles.buttons}> <View style={styles.buttons}>
<TouchableOpacity <View style={styles.saveBtn}>
style={styles.buttonSub} <TouchableOpacity
activeOpacity={0.5} style={styles.buttonSub}
onPress={() => navigation.navigate("HomeScreen")} activeOpacity={0.5}
> onPress={() => axios.put("http://192.168.8.126:5000/updateUsers/<id>", form)
<Text style={styles.buttonTextStyle}>Save Details</Text> .then(function (response) {
{/* <ImageBackground source={require('../assets/loginex.jpg')} style={styles.imagebutton}/> */} const stngobj = JSON.stringify(response.data)
</TouchableOpacity> console.log(stngobj);
alert("Successfully Update")
// navigation.navigate("HomeScreen")
// return response;
})
.catch(function (error) {
console.log(error);
alert("update error")
}) }
>
<Text style={styles.buttonTextStyle}>Save Details</Text>
</TouchableOpacity>
{/* <View style={{flexDirection: 'row', <TouchableOpacity
justifyContent: 'center', style={styles.delbtn}
alignItems: 'center',}}> activeOpacity={0.5}
<Text style={{color: 'black', textAlign: 'center'}}>Dont have an account</Text> onPress={() => createTwoButtonAlert()}
<TouchableOpacity style={styles.buttonSignUp} title="Sign Up" onPress={() => navigation.navigate('SignUp')}> >
<Text style={styles.buttonText}>Sign Up</Text> <Text style={styles.buttonTextStyle}>Delete user</Text>
</TouchableOpacity> </TouchableOpacity>
</View> */} </View>
<View> <View>
<Text style={styles.text1}>You have earned 5% Discount</Text> <Text style={styles.text1}>You have earned 5% Discount</Text>
</View> </View>
...@@ -218,11 +256,11 @@ const styles = StyleSheet.create({ ...@@ -218,11 +256,11 @@ const styles = StyleSheet.create({
backgroundColor: "white", backgroundColor: "white",
}, },
buttonSub: { buttonSub: {
width: "80%", width: "40%",
padding: 10, padding: 10,
marginTop: 30, marginTop: 30,
marginLeft: 45, marginLeft: 30,
marginHorizontal: 10, // marginHorizontal: 10,
backgroundColor: "#ff426e", backgroundColor: "#ff426e",
flexDirection: "row", flexDirection: "row",
marginBottom: 20, marginBottom: 20,
...@@ -291,9 +329,24 @@ const styles = StyleSheet.create({ ...@@ -291,9 +329,24 @@ const styles = StyleSheet.create({
alignSelf: "flex-end", alignSelf: "flex-end",
flexDirection: "row", flexDirection: "row",
}, },
errorMsg:{ errorMsg: {
color: 'black', color: "black",
fontSize: 14, fontSize: 14,
alignSelf:"center" alignSelf: "center",
} },
saveBtn: {
flexDirection: "row",
},
delbtn: {
width: "40%",
padding: 10,
marginTop: 30,
marginLeft: 25,
// marginHorizontal: 10,
backgroundColor: "red",
flexDirection: "row",
marginBottom: 20,
justifyContent: "center",
borderRadius: 8,
},
}); });
...@@ -133,7 +133,7 @@ export function SignIn({ navigation }) { ...@@ -133,7 +133,7 @@ export function SignIn({ navigation }) {
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
alert("Login failed") alert("No User Existed")
}) })
} }
> >
......
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