update: pricepage discount updated

parent 2f5a1693
......@@ -8,7 +8,7 @@ import {
TouchableOpacity,
ImageBackground,
Alert,
Image
Image,
} from "react-native";
import { FontAwesome } from "@expo/vector-icons";
import { FontAwesome5 } from "@expo/vector-icons";
......@@ -24,49 +24,48 @@ export function PriceScreen({ navigation }) {
const [discount, setDiscount] = useState("");
// data, route
// const {picture} = route.params
// useEffect(() => {
// getImage(picture);
// }, []);
// const {picture} = route.params
// useEffect(() => {
// getImage(picture);
// }, []);
const fetchData = async () => {
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
const fetchData = async () => {
// const resp = await fetch("http://192.168.8.126:5000/getDetails", {method:"POST"});
axios({
method: "GET",
url: "http://192.168.8.126:5000/discount/<id>",
})
.then(function (response) {
console.log(response.data.message);
// data = response.data
setDiscount(response.data.message);
axios({
method: "GET",
url: "http://192.168.8.126:5000/discount/<id>",
})
.catch(function (error) {
console.log("axios error" + error);
});
};
useEffect(() => {
fetchData();
},[]);
.then(function (response) {
console.log(response.data.message);
// data = response.data
setDiscount(response.data.message);
})
.catch(function (error) {
console.log("axios error" + error);
});
};
function name() {
axios
}
useEffect(() => {
fetchData();
}, []);
const [image, setImage] = useState('');
//get the token and id from headers
//from the id get the
function name() {
axios;
}
const getImage = async (name) => {
console.log(name)
const q = name.split(' ').join('+')
const img = await fetch(`http://192.168.8.126:5000/getimage/${name}`)
const image = await img.json();
console.log(image)
setImage(image.previewURL)
const [image, setImage] = useState("");
//get the token and id from headers
//from the id get the
}
const getImage = async (name) => {
console.log(name);
const q = name.split(" ").join("+");
const img = await fetch(`http://192.168.8.126:5000/getimage/${name}`);
const image = await img.json();
console.log(image);
setImage(image.previewURL);
};
const [details, setDetails] = useState({
name: "",
......@@ -110,42 +109,41 @@ const getImage = async (name) => {
}
};
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("Please Insert new Data")
}) }
]
);
}
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("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);
form.append("district", details.district);
console.log(form)
console.log(form);
return (
<View style={styles.container}>
......@@ -180,10 +178,14 @@ const getImage = async (name) => {
<View style={styles.con}>
<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 style={styles.textinputicon}>
......@@ -253,18 +255,21 @@ const getImage = async (name) => {
<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")
}) }
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}>Update Details</Text>
</TouchableOpacity>
......@@ -278,13 +283,31 @@ const getImage = async (name) => {
</TouchableOpacity>
</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 style={styles.bottom}>
<BottomTab/>
<BottomTab />
</View>
</ImageBackground>
</View>
......@@ -331,17 +354,25 @@ const styles = StyleSheet.create({
text1: {
fontSize: 20,
alignSelf: "center",
marginBottom: 20,
marginTop: 15,
// marginBottom: 20,
marginTop: 10,
color: "black",
},
text2: {
fontSize: 20,
alignSelf: "center",
// marginBottom: 20,
marginTop: 15,
color: "green",
fontWeight: "bold",
},
container: {
justifyContent: "flex-start",
alignContent: "stretch",
},
secondContainer: {
justifyContent: "flex-start",
marginTop:65
marginTop: 55,
},
textinputicon: {
// flex: 1,
......@@ -359,7 +390,7 @@ const styles = StyleSheet.create({
fontSize: 15,
borderRadius: 25,
marginTop: 20,
marginBottom: 10,
marginBottom: 5,
marginLeft: 10,
marginRight: 19,
backgroundColor: "white",
......@@ -400,20 +431,20 @@ const styles = StyleSheet.create({
justifyContent: "center",
borderRadius: 8,
},
bottom:{
justifyContent:"flex-end",
marginTop:120
bottom: {
justifyContent: "flex-end",
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