From e423c9b86f4ae09d76394cd79429384af15b5c8c Mon Sep 17 00:00:00 2001 From: Ava DeCroix Date: Tue, 2 May 2023 18:03:26 -0400 Subject: [PATCH 1/3] 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); From 6c30a3e0eba453eb67735ec59dea6ee623cc97f5 Mon Sep 17 00:00:00 2001 From: Ava DeCroix Date: Tue, 2 May 2023 18:36:04 -0400 Subject: [PATCH 2/3] fixed search weirdness and eatery name works now --- db_app/src/components/LogMeals.js | 3 ++- db_app/src/components/ThisWeek.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/db_app/src/components/LogMeals.js b/db_app/src/components/LogMeals.js index 3d4a38a..280cdea 100644 --- a/db_app/src/components/LogMeals.js +++ b/db_app/src/components/LogMeals.js @@ -133,6 +133,7 @@ const changeSearchHandler = evt => { const submitSearchHandler = evt => { evt.preventDefault(); + setSearchItems([]); console.log(search_term) console.log(net_id) Axios.post("http://3.219.93.142:8000/api/menu_search", @@ -312,7 +313,7 @@ color: 'main', /> - {searchitem.eatery_id} + {searchitem.eatery_name} {searchitem.item_name} {searchitem.serving_size} diff --git a/db_app/src/components/ThisWeek.js b/db_app/src/components/ThisWeek.js index dbcdd0d..6260b22 100644 --- a/db_app/src/components/ThisWeek.js +++ b/db_app/src/components/ThisWeek.js @@ -178,7 +178,7 @@ const net_id = ReactSession.get("net_id"); //Send sums to results if it is Saturday const sendResults = () => { var day = planDay(); - if (day === 7): + if (day === 7){ Axios.post('http://3.219.93.142:8000/api/results', { net_id: ReactSession.get("net_id"), @@ -198,6 +198,7 @@ const net_id = ReactSession.get("net_id"); console.log(response); }); } +} From 2c05005ca04705fc171c90e97e64d8c70d797d77 Mon Sep 17 00:00:00 2001 From: Ava DeCroix Date: Wed, 3 May 2023 14:54:45 -0400 Subject: [PATCH 3/3] final updates --- db_app/src/components/ThisWeek.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db_app/src/components/ThisWeek.js b/db_app/src/components/ThisWeek.js index 6260b22..e2ec56e 100644 --- a/db_app/src/components/ThisWeek.js +++ b/db_app/src/components/ThisWeek.js @@ -197,7 +197,9 @@ const net_id = ReactSession.get("net_id"); ).then((response) => { console.log(response); }); + console.log("results sent"); } + } @@ -314,6 +316,8 @@ const net_id = ReactSession.get("net_id"); setColors() console.log('Colors set') console.log(planDay()) + sendResults() + }, []);