alittlebroken / recipefinder-client

0 stars 0 forks source link

issue when adding recipes to a cookbook one after the other #121

Closed alittlebroken closed 8 months ago

alittlebroken commented 8 months ago

If you add one recipe to a cookbook and then add another the modal displays the last cookbook selected.

However if you leave it as is and then click on add, it is not added at all unless you actually change the cookbook in the drop down

alittlebroken commented 8 months ago

The server log shows

"POST /cookbooks/NaN/recipe HTTP/1.1" 500 104 "http://localhost:3000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"

it looks like selecting an entry in the drop down sets the value, as we did not do this it sends a blank string which when we parse converts to NaN as seen in the url above

alittlebroken commented 8 months ago

Issue being caused by the ReciepList Component not resetting the select elements state each time it is called to add a new cookbook.

Added a new prop to the component to set the selected cookbooks state and set it to be reset back to default each time the end user clicks on Add