v1#42
Conversation
|
so for the user id i set the local storage test email manually because my google Oauth does not work and i cant test completely in a user setting, so please verify if this works. Thank you! |
| <Router> | ||
| <Routes> | ||
| <Route path='/' element={<Home/>} /> | ||
| <Route path='/activities' element={<Activities/>} /> |
There was a problem hiding this comment.
Shouldn't be needed since everything is in the preferences route.
| <Routes> | ||
| <Route path='/' element={<Home/>} /> | ||
| <Route path='/activities' element={<Activities/>} /> | ||
| <Route path='/recommendation' element={<Recommendation/>}/> |
There was a problem hiding this comment.
Will need to make it /recommendation:group_id like the others so we can pass through useParams().
There was a problem hiding this comment.
Additionally let's make it plural recommendations to be consistent with the other pages. Together /recommendations/:group_id
|
|
||
|
|
||
| navigate('/'); | ||
| navigate('/recommendation'); |
There was a problem hiding this comment.
Then this can be changed to /recommendation/${group_id}
There was a problem hiding this comment.
Additionally, let's make it plural recommendations to be consistent with the other pages.
|
Couldn't test the actual recommendation returns but I trust that it works fine as you showed. The flow of the routes seems fine barring the missing url parameters. I noticed the extra links on the home page, which I'm guessing are there just from testing? But some link to routes that ultimately shouldn't exist (i.e., any of the individual preference components). |
pabloj2001
left a comment
There was a problem hiding this comment.
Good job on this page! I have a number of comments but they should all be quick fixes. I noticed that during merging with main you might've overridden some of the API files, we'll need to remove those changes by resetting the branch to a previous commit, merging with main again while ensuring the overriding doesn't happen again, and then applying the latest changes again. We can do it together later.
|
|
||
|
|
||
| navigate('/'); | ||
| navigate('/recommendation'); |
There was a problem hiding this comment.
Additionally, let's make it plural recommendations to be consistent with the other pages.
| import { GoogleOAuthProvider } from '@react-oauth/google'; | ||
| import './index.css'; | ||
|
|
||
| const apiKey ="AIzaSyABQ4Pci5rnkud1UShQlNtU7iGG7waWghU" |
There was a problem hiding this comment.
apiKey needs to be removed and turned to an environment variable.
| if (apiKey) { | ||
| // If API key is available, dynamically load Google Maps API | ||
| const script = document.createElement('script'); | ||
| script.src = `https://maps.googleapis.com/maps/api/js?key=AIzaSyABQ4Pci5rnkud1UShQlNtU7iGG7waWghU&libraries=places`; | ||
| script.async = true; | ||
| script.defer = true; | ||
|
|
||
| script.onload = renderApp; // Render the app once the Google Maps API script has loaded | ||
|
|
||
| document.head.appendChild(script); |
There was a problem hiding this comment.
I'm a little confused as to why we're using 2 different methods to load the Google Maps API throughout the app. Couldn't we have reused the same method we used for location preferences? Let's leave it for now though for the sake of time.
| }; | ||
|
|
||
| // Perform an API request to save the vote | ||
| fetch(import.meta.env.VITE_SERVER + `groups/${group_id}/votes`, { |
There was a problem hiding this comment.
Let's end all the API calls with a slash / for consistency and compatibility.
| rec_id: { | ||
| recommendation_id: selectedRecommendation.id, | ||
| selected_time: selectedTime, | ||
| }, | ||
| user_id: userdata, | ||
| group_id: group_id, |
There was a problem hiding this comment.
rec_id is just the id of the recommendation, so selectedRecommendation.id, and user_id should be userdata.user_id. We don't need to pass the group_id since it's given in the URL. I had forgotten about the time in the Votes model, thanks for noticing, we will need to make a new field for it in the API model. Overall I think we only need rec_id, selected_time, and user_id.
| }) | ||
| .then((response) => response.json()) | ||
| .then((json) => { | ||
| setRecommendations(json); |
There was a problem hiding this comment.
When parsing the json recommendations, I'm afraid it doesn't parse recursively, so the times json array doesn't get parsed to an array and remains as a string. For this reason, we'll have to manually parse all the times fields.
json.map((rec) => {
rec.times = JSON.parse(rec.times);
});
Something like this before setting the recommendations should do it.
| <Routes> | ||
| <Route path='/' element={<Home/>} /> | ||
| <Route path='/activities' element={<Activities/>} /> | ||
| <Route path='/recommendation' element={<Recommendation/>}/> |
There was a problem hiding this comment.
Additionally let's make it plural recommendations to be consistent with the other pages. Together /recommendations/:group_id






No description provided.