update: pricepage discount updated

parent 2f5a1693
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
TouchableOpacity, TouchableOpacity,
ImageBackground, ImageBackground,
Alert, Alert,
Image Image,
} 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";
...@@ -24,12 +24,12 @@ export function PriceScreen({ navigation }) { ...@@ -24,12 +24,12 @@ export function PriceScreen({ navigation }) {
const [discount, setDiscount] = useState(""); const [discount, setDiscount] = useState("");
// data, route // data, route
// const {picture} = route.params // const {picture} = route.params
// useEffect(() => { // useEffect(() => {
// getImage(picture); // getImage(picture);
// }, []); // }, []);
const fetchData = async () => { const fetchData = async () => {
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"}); // const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
axios({ axios({
...@@ -44,29 +44,28 @@ const fetchData = async () => { ...@@ -44,29 +44,28 @@ const fetchData = async () => {
.catch(function (error) { .catch(function (error) {
console.log("axios error" + error); console.log("axios error" + error);
}); });
}; };
useEffect(() => { useEffect(() => {
fetchData(); fetchData();
},[]); }, []);
function name() { function name() {
axios axios;
} }
const [image, setImage] = useState(''); const [image, setImage] = useState("");
//get the token and id from headers //get the token and id from headers
//from the id get the //from the id get the
const getImage = async (name) => { const getImage = async (name) => {
console.log(name) console.log(name);
const q = name.split(' ').join('+') const q = name.split(" ").join("+");
const img = await fetch(`http://192.168.8.126:5000/getimage/${name}`) const img = await fetch(`http://192.168.8.126:5000/getimage/${name}`);
const image = await img.json(); const image = await img.json();
console.log(image) console.log(image);
setImage(image.previewURL) setImage(image.previewURL);
};
}
const [details, setDetails] = useState({ const [details, setDetails] = useState({
name: "", name: "",
...@@ -110,42 +109,41 @@ const getImage = async (name) => { ...@@ -110,42 +109,41 @@ const getImage = async (name) => {
} }
}; };
const createTwoButtonAlert = () =>{ const createTwoButtonAlert = () => {
Alert.alert( Alert.alert("Delete User", "Are you sure want to delete User", [
"Delete User",
"Are you sure want to delete User",
[
{ {
text: "Cancel", text: "Cancel",
onPress: () => console.log("Cancel Pressed"), onPress: () => console.log("Cancel Pressed"),
style: "cancel" style: "cancel",
}, },
{ text: "OK", onPress: () => axios.delete("http://192.168.8.126:5000/deleteUsers/<id>") {
text: "OK",
onPress: () =>
axios
.delete("http://192.168.8.126:5000/deleteUsers/<id>")
.then(function (response) { .then(function (response) {
const stngobj = JSON.stringify(response.data) const stngobj = JSON.stringify(response.data);
console.log(stngobj); console.log(stngobj);
alert("Successfully deleted") alert("Successfully deleted");
navigation.navigate("SignIn") navigation.navigate("SignIn");
// return response; // return response;
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
alert("Please Insert new Data") alert("Please Insert new Data");
}) } }),
] },
); ]);
} };
function dbDetails(){ function dbDetails() {}
} const form = new FormData();
const form = new FormData (); form.append("name", details.name);
form.append("district", details.district);
form.append("name", details.name) console.log(form);
form.append("district", details.district)
console.log(form)
return ( return (
<View style={styles.container}> <View style={styles.container}>
...@@ -180,10 +178,14 @@ const getImage = async (name) => { ...@@ -180,10 +178,14 @@ const getImage = async (name) => {
<View style={styles.con}> <View style={styles.con}>
<Text> <Text>
{ {
<Image source={{uri: `http://192.168.8.126:5000/getimage/${name}`}} style={{ width: 200, height: 200 }} /> <Image
source={{
uri: `http://192.168.8.126:5000/getimage/${name}`,
}}
style={{ width: 200, height: 200 }}
/>
} }
</Text> </Text>
</View> </View>
<View style={styles.textinputicon}> <View style={styles.textinputicon}>
...@@ -253,18 +255,21 @@ const getImage = async (name) => { ...@@ -253,18 +255,21 @@ const getImage = async (name) => {
<TouchableOpacity <TouchableOpacity
style={styles.buttonSub} style={styles.buttonSub}
activeOpacity={0.5} activeOpacity={0.5}
onPress={() => axios.put("http://192.168.8.126:5000/updateUsers/<id>", form) onPress={() =>
axios
.put("http://192.168.8.126:5000/updateUsers/<id>", form)
.then(function (response) { .then(function (response) {
const stngobj = JSON.stringify(response.data) const stngobj = JSON.stringify(response.data);
console.log(stngobj); console.log(stngobj);
alert("Successfully Update") alert("Successfully Update");
// navigation.navigate("HomeScreen") // navigation.navigate("HomeScreen")
// return response; // return response;
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
alert("update error") alert("update error");
}) } })
}
> >
<Text style={styles.buttonTextStyle}>Update Details</Text> <Text style={styles.buttonTextStyle}>Update Details</Text>
</TouchableOpacity> </TouchableOpacity>
...@@ -278,13 +283,31 @@ const getImage = async (name) => { ...@@ -278,13 +283,31 @@ const getImage = async (name) => {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View> <View>
<Text style={styles.text1}>You have earned {discount}% Discount</Text> {discount == 10 ? (
<Text style={styles.text2}>EXCELLENT!!</Text>
) : discount == 9 ? (
<Text style={styles.text2}>SUPERB!!</Text>
) : discount == 8 ? (
<Text style={styles.text2}>BEST WORK!!</Text>
) : discount == 7 ? (
<Text style={styles.text2}>NICE JOB!!</Text>
) : discount == 6 ? (
<Text style={styles.text2}>GOOD!!</Text>
) : discount == 5 ? (
<Text style={styles.text2}>GOOD KEEP GOING!!</Text>
) : discount <= 4 ? (
<Text style={styles.text2}>GOOD! TRY HARDER!!</Text>
) : (
<Text style={styles.text2}>NO DISCOUNT</Text>
)}
<Text style={styles.text1}>
You have earned {discount}% Discount
</Text>
</View> </View>
</View> </View>
</View> </View>
<View style={styles.bottom}> <View style={styles.bottom}>
<BottomTab/> <BottomTab />
</View> </View>
</ImageBackground> </ImageBackground>
</View> </View>
...@@ -331,17 +354,25 @@ const styles = StyleSheet.create({ ...@@ -331,17 +354,25 @@ const styles = StyleSheet.create({
text1: { text1: {
fontSize: 20, fontSize: 20,
alignSelf: "center", alignSelf: "center",
marginBottom: 20, // marginBottom: 20,
marginTop: 15, marginTop: 10,
color: "black", color: "black",
}, },
text2: {
fontSize: 20,
alignSelf: "center",
// marginBottom: 20,
marginTop: 15,
color: "green",
fontWeight: "bold",
},
container: { container: {
justifyContent: "flex-start", justifyContent: "flex-start",
alignContent: "stretch", alignContent: "stretch",
}, },
secondContainer: { secondContainer: {
justifyContent: "flex-start", justifyContent: "flex-start",
marginTop:65 marginTop: 55,
}, },
textinputicon: { textinputicon: {
// flex: 1, // flex: 1,
...@@ -359,7 +390,7 @@ const styles = StyleSheet.create({ ...@@ -359,7 +390,7 @@ const styles = StyleSheet.create({
fontSize: 15, fontSize: 15,
borderRadius: 25, borderRadius: 25,
marginTop: 20, marginTop: 20,
marginBottom: 10, marginBottom: 5,
marginLeft: 10, marginLeft: 10,
marginRight: 19, marginRight: 19,
backgroundColor: "white", backgroundColor: "white",
...@@ -400,20 +431,20 @@ const styles = StyleSheet.create({ ...@@ -400,20 +431,20 @@ const styles = StyleSheet.create({
justifyContent: "center", justifyContent: "center",
borderRadius: 8, borderRadius: 8,
}, },
bottom:{ bottom: {
justifyContent:"flex-end", justifyContent: "flex-end",
marginTop:120 marginTop: 120,
},
con: {
elevation: 2,
height: 100,
width: 100,
backgroundColor: "#efefef",
position: "relative",
borderRadius: 999,
overflow: "hidden",
justifyContent: "center",
alignItems: "center",
alignSelf: "center",
}, },
con:{
elevation:2,
height:100,
width:100,
backgroundColor:'#efefef',
position:'relative',
borderRadius:999,
overflow:'hidden',
justifyContent:"center",
alignItems:"center",
alignSelf:"center"
},
}); });
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