From e423c9b86f4ae09d76394cd79429384af15b5c8c Mon Sep 17 00:00:00 2001 From: Ava DeCroix Date: Tue, 2 May 2023 18:03:26 -0400 Subject: [PATCH] function to send results to plan --- db_app/src/components/ThisWeek.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/db_app/src/components/ThisWeek.js b/db_app/src/components/ThisWeek.js index 3a666ee..dbcdd0d 100644 --- a/db_app/src/components/ThisWeek.js +++ b/db_app/src/components/ThisWeek.js @@ -175,6 +175,33 @@ const net_id = ReactSession.get("net_id"); }); } + //Send sums to results if it is Saturday + const sendResults = () => { + var day = planDay(); + if (day === 7): + Axios.post('http://3.219.93.142:8000/api/results', + { + net_id: ReactSession.get("net_id"), + week_date: weekStart(), + total_cal: Number(sum.total_cal), + total_fat: Number(sum.total_fat), + total_sat_fat: Number(sum.total_sat_fat), + total_trans_fat: Number(sum.total_trans_fat), + total_carbs: Number(sum.total_carbs), + total_fiber: Number(sum.total_fiber), + total_sugar: Number(sum.total_sugar), + total_protein: Number(sum.total_protein), + total_sodium: Number(sum.total_sodium), + total_potassium: Number(sum.total_potassium), + total_cholesterol: Number(sum.total_cholesterol),} + ).then((response) => { + console.log(response); + }); + } + + + + //Set color variables for chips const [cals, setCals] = useState(false);