carlosvegap / capstone-kickoff

0 stars 0 forks source link

find active and inactive preferences of an experience #69

Closed CarLosVegga closed 1 year ago

CarLosVegga commented 1 year ago

Hi everyone!

Some context of my PR:

Previously I had an endpoint for each active and inactive preferences. I decided to merge those two into a single one.

I found a bug while dealing with this PR. It seems like I was creating an Experience until the user firsts uploads the data (which at the beginning made sense). However, my form to create an experience is next to the select preferences to be rated by adventurers. image

So, if the user didn't follow the expected user flow (first submit your experience information and then modify your preferred feedback) the second form would simply die (because it looks for your activePreferences array, which is instantiated to be null once you submit your experience info!)

I decided to take an approach like the one I followed with the UserPreference: instantiate it once the user signs up. That is why I modified visitor.jsx

However, on the Adventurer side that killed the rendering of restaurants. Since now I am creating an experience with no data, and my algorithm finds the distance of your current location and that one registered in the db, it was calling a nonexistent value. To solve that, I simply added a continue if there is no address on routes/adventure.js I think I should implement later on a better checking method. So far the way I structured it, it can't upload a preference through the UI if a mandatory field is not complete, so for this delivery I think I will leave it that way.

I also modified the update router request on routes/adventure.js, but I will refactor that as my next step. The reason behind that is that I noticed I was repeating over and over the toast method. Most of the time I would call it twice, once for success and another for error, and I was repeating the error messages in most of the cases. To avoid that, I decided it would be also a good idea to have a module control it. So, if I ever want to make a general change like the display time, I can easily do so.

Thanks for any comments on this!