carlosvegap / capstone-kickoff

0 stars 0 forks source link

Refactor BackEnd Adventure for Rating Experiences #65

Closed CarLosVegga closed 2 years ago

CarLosVegga commented 2 years ago

HI everyone!

This PR includes the necessary changes to have a review request aligned with the proposed format.

In the original code I had one request for submitting a rate and I decided to keep it that way and just restructuring basic information.

For instance, what I did:

QUERIES/ADVENTURE.JS I included a query for that specific endpoint

ROUTES/ADVENTURE.JS I consume the same query according to the params passed by the UI

ROUTES/REVIEW.JS I deleted the unused endpoint

ADVENTURER.JSX I tried to choose a better name for the setter of restaurants. My idea was to use that setter, so that once I submit a review and I get a confirmation status for that request, I would edit my restaurants array and add a review field (so it would update and display this review sign instead of the review button) image

QUESTION: I was trying to have the original version where after the submission was done, it would update immediately from the Rate me button to the rated tag. My first approach was to have this derived state from the currentRestaurant, so that on every render it would check the value and then I would only need to update the information of that restaurant with my setter. However, I see that this approach is not working unless I refresh the page (by that point is being modify by external factors). My assumption up to this moment is that it is related on the queued property that the setter has (not immediate update), but I am still reflecting on what it can be. I will keep you posted if I come up with a solution, and any hint would be appreciated 😅 A (probably not so good) solution I was thinking was instead of having a derived state, creating it's own state so I could manipulate isRated 'easier'. However I believe that could lead to async problems, and that was the point of having a derived state.

CarLosVegga commented 2 years ago

Thank you for guiding me through this bug