update: delete update user

parent 9bb8811a
......@@ -7,10 +7,14 @@ 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';
// 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 Tab = createMaterialBottomTabNavigator();
export default function App() {
......@@ -19,10 +23,11 @@ export default function App() {
<NavigationContainer>
<Drawer.Navigator initialRouteName="Authntications">
<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="About Us" component={AboutUs} /> */}
</Drawer.Navigator>
{/* <HomeScreen/> */}
</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 @@
// https://aboutreact.com/react-native-login-and-signup/
// Import React and Component
import React from 'react';
import React from "react";
// 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 {
AntDesign,
MaterialCommunityIcons,
Ionicons,
} from "@expo/vector-icons";
import { MaterialIcons } from '@expo/vector-icons';
// import BottomTabNavigator from '../Navigations/BottomTabNavigator'
import { MaterialIcons } from "@expo/vector-icons";
import { gamification } from "./gamification";
// import BottomTab from "../Navigations/BottomTab";
export function HomeScreen({ navigation }) {
//to diable the yellow box warning on the simulator
console.disableYellowBox = true;
return (
<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
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>
{/* <BottomTabNavigator/> */}
</ImageBackground>
</View>
</ImageBackground>
{/* <BottomTab/> */}
</View>
);
}
......@@ -96,21 +101,19 @@ const styles = StyleSheet.create({
flexDirection: "row",
marginBottom: 15,
justifyContent: "center",
borderRadius: 10
borderRadius: 10,
},
buttonText: {
color: "#000",
fontSize: 15,
marginLeft: 8
marginLeft: 8,
},
background:{
backgroundColor: '#bababa',
height: '100%'
background: {
backgroundColor: "#bababa",
height: "100%",
},
images: {
height: "100%",
justifyContent: "center",
},
images: {
height: '100%',
justifyContent: 'center'
}
});
......@@ -7,84 +7,111 @@ import {
Text,
TouchableOpacity,
ImageBackground,
Alert,
} from "react-native";
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';
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({
email: "",
earns: "",
name: "",
district: "",
isValidUser: true,
isValidearns: true,
isValiddistrict: true,
check_textinputChange: false
check_textinputChange: false,
});
const textInputChange = (val) => {
if( val.trim().length >= 4) {
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) {
...details,
name: val,
check_textInputChange: true,
isValidUser: true,
});
} else {
setDetails({
...details,
earns: val,
isValidearns: true
});
...details,
name: val,
check_textInputChange: false,
isValidUser: false,
});
}
else {
setDetails({
...details,
earns: val,
isValidearns: 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) {
if (val.trim().length >= 4) {
setDetails({
...details,
district: val,
isValiddistrict: true,
});
} else {
setDetails({
...details,
district: val,
isValiddistrict: true
});
...details,
district: val,
isValiddistrict: false,
});
}
else {
setDetails({
...details,
district: val,
isValiddistrict: false
});
}
}
};
const createTwoButtonAlert = () =>{
Alert.alert(
"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 (
<View style={styles.container}>
<ImageBackground
<ImageBackground
source={require("../assets/signin1.jpg")}
style={styles.images}
>
......@@ -117,12 +144,10 @@ export function PriceScreen({ navigation, data }) {
<Entypo name="user" size={30} color="white" />
<TextInput
style={styles.input1}
onChangeText={(val) =>
textInputChange(val)
}
placeholder="Enter Email" //dummy@abc.com
onChangeText={(val) => textInputChange(val)}
placeholder="Enter Name" //dummy@abc.com
placeholderTextColor="#8b9cb5"
keyboardType="email-address"
// keyboardType="email-address"
// onSubmitEditing={() =>
// passwordInputRef.current &&
// passwordInputRef.current.focus()
......@@ -130,9 +155,11 @@ export function PriceScreen({ navigation, data }) {
blurOnSubmit={false}
/>
</View>
{ details.isValidUser ? null :
<Text style={styles.errorMsg}>Email must be 4 characters long</Text>
}
{details.isValidUser ? null : (
<Text style={styles.errorMsg}>
Name must be 4 characters long
</Text>
)}
</View>
<View style={styles.SectionStyle}>
......@@ -140,9 +167,7 @@ export function PriceScreen({ navigation, data }) {
<FontAwesome name="money" size={30} color="white" />
<TextInput
style={styles.input1}
onChangeText={(val) =>
handleEarnsChanged(val)
}
onChangeText={(val) => handleEarnsChanged(val)}
placeholder="Enter Earns" //12345
placeholderTextColor="#8b9cb5"
// ref={passwordInputRef}
......@@ -151,18 +176,18 @@ export function PriceScreen({ navigation, data }) {
secureTextEntry={true}
/>
</View>
{ details.isValidearns ? null :
<Text style={styles.errorMsg}>Email must be 4 characters long</Text>
}
{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={(val) =>
handleDistrictChanged(val)
}
onChangeText={(val) => handleDistrictChanged(val)}
placeholder="Enter District" //12345
placeholderTextColor="#8b9cb5"
// ref={passwordInputRef}
......@@ -171,28 +196,41 @@ export function PriceScreen({ navigation, data }) {
secureTextEntry={true}
/>
</View>
{ details.isValiddistrict ? null :
<Text style={styles.errorMsg}>Email must be 4 characters long</Text>
}
{details.isValiddistrict ? null : (
<Text style={styles.errorMsg}>
Distict must be 4 characters long
</Text>
)}
</View>
<View style={styles.buttons}>
<TouchableOpacity
style={styles.buttonSub}
activeOpacity={0.5}
onPress={() => navigation.navigate("HomeScreen")}
>
<Text style={styles.buttonTextStyle}>Save Details</Text>
{/* <ImageBackground source={require('../assets/loginex.jpg')} style={styles.imagebutton}/> */}
</TouchableOpacity>
<View style={styles.saveBtn}>
<TouchableOpacity
style={styles.buttonSub}
activeOpacity={0.5}
onPress={() => axios.put("http://192.168.8.126:5000/updateUsers/<id>", form)
.then(function (response) {
const stngobj = JSON.stringify(response.data)
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',
justifyContent: 'center',
alignItems: 'center',}}>
<Text style={{color: 'black', textAlign: 'center'}}>Dont have an account</Text>
<TouchableOpacity style={styles.buttonSignUp} title="Sign Up" onPress={() => navigation.navigate('SignUp')}>
<Text style={styles.buttonText}>Sign Up</Text>
</TouchableOpacity>
</View> */}
<TouchableOpacity
style={styles.delbtn}
activeOpacity={0.5}
onPress={() => createTwoButtonAlert()}
>
<Text style={styles.buttonTextStyle}>Delete user</Text>
</TouchableOpacity>
</View>
<View>
<Text style={styles.text1}>You have earned 5% Discount</Text>
</View>
......@@ -218,11 +256,11 @@ const styles = StyleSheet.create({
backgroundColor: "white",
},
buttonSub: {
width: "80%",
width: "40%",
padding: 10,
marginTop: 30,
marginLeft: 45,
marginHorizontal: 10,
marginLeft: 30,
// marginHorizontal: 10,
backgroundColor: "#ff426e",
flexDirection: "row",
marginBottom: 20,
......@@ -291,9 +329,24 @@ const styles = StyleSheet.create({
alignSelf: "flex-end",
flexDirection: "row",
},
errorMsg:{
color: 'black',
errorMsg: {
color: "black",
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 }) {
})
.catch(function (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