diff --git a/db_app/src/components/Plan.js b/db_app/src/components/Plan.js
index eca3322..fffc917 100644
--- a/db_app/src/components/Plan.js
+++ b/db_app/src/components/Plan.js
@@ -134,6 +134,7 @@ const submitGoalHandler = evt => {
//to add an off campus food item or meal to your weekly journal
const [offCampusInput, setOffCampusInput] = useState({
+ item_name:"",
calories: "",
fat_g: "",
sat_fat_g: "",
@@ -142,21 +143,39 @@ const submitGoalHandler = evt => {
fiber_g: "",
sugar_g: "",
protein_g: "",
- sodium_g: "",
- potassium_g: "",
- cholesterol_g: "",
+ sodium_mg: "",
+ potassium_mg: "",
+ cholesterol_mg: "",
}
);
- const { calories, fat_g, sat_fat_g, trans_fat_g, carbs_g, fiber_g,sugar_g, protein_g,
- sodium_g, potassium_g, cholesterol_g, } = offCampusInput
+ const {item_name, calories, fat_g, sat_fat_g, trans_fat_g, carbs_g, fiber_g,sugar_g, protein_g,
+ sodium_mg, potassium_mg, cholesterol_mg, } = offCampusInput
- const changeoffCampusHandler = evt => {
+ const changeOffCampusHandler = evt => {
setOffCampusInput({ ...offCampusInput, [evt.target.name]: [evt.target.value] })
}
- const submitoffCampusHandler = evt => {
+ const submitOffCampusHandler = evt => {
evt.preventDefault();
+ console.log(offCampusInput)
+ Axios.post("http://3.219.93.142:8000/api/",
+ {
+ calories: calories[0],
+ trans_fat_g: trans_fat_g[0],
+ sat_fat_g: sat_fat_g[0],
+ trans_fat_g: trans_fat_g[0],
+ carbs_g: carbs_g[0],
+ fiber_g: fiber_g[0],
+ sugar_g: sugar_g[0],
+ protein_g: protein_g[0],
+ sodium_mg: sodium_mg[0],
+ potassium_mg: potassium_mg[0],
+ cholesterol_mg: cholesterol_mg[0]
+ }).then((response) => {
+ console.log(response);
+ console.log(response.status);
+ })
};
@@ -196,17 +215,17 @@ const submitGoalHandler = evt => {
id="total_cal"
label="Calories"
name="total_cal"
+ size="small"
value={total_cal}
- size ="small"
onChange={changeGoalHandler}
/>