diff --git a/db_app/src/components/Plan.js b/db_app/src/components/Plan.js index 13118b2..cc7dd8f 100644 --- a/db_app/src/components/Plan.js +++ b/db_app/src/components/Plan.js @@ -87,9 +87,7 @@ function weekStart(){ const net_id = ReactSession.get("net_id"); //to set nutritional goal for the week -const [goalInput, setGoalInput] = useReducer( - (state, newState) => ({ ...state, ...newState }), - { +const [goalInput, setGoalInput] = useState({ total_cal: "", total_fat: "", total_sat_fat: "", @@ -104,12 +102,18 @@ const [goalInput, setGoalInput] = useReducer( } ); +const{total_cal, total_fat, total_sat_fat, total_trans_fat, total_carbs, total_fiber, + total_sugar, total_protein, total_sodium, total_potassium, total_cholesterol} = goalInput -const handleSubmit = evt => { - let data = {goalInput} +const changeGoalHandler = evt =>{ + setGoalInput({...goalInput, [evt.target.name]: [evt.target.value] }) +} + +const submitGoalHandler = evt => { + evt.preventDefault(); Axios.post() -} +}; return ( @@ -140,74 +144,107 @@ const handleSubmit = evt => {

  Your Plan

   Goal for the week of:

-
+