Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more information to restaurant cards, including website, phone number, and reviews. #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aivey65
Copy link
Collaborator

@aivey65 aivey65 commented Aug 3, 2020

Add more information to restaurant cards, including website, phone number, and reviews.

This is just a draft until #35 is merged. After that, it will be rebased.

Addresses issues #11 & #8

Changes

  • Add images for restaurants using Google's place photos api.
  • Add website, phone number, reviews, and a link to each restaurant's listing on Google for each restaurant card using Google's place details api.
  • Make some styling changes and allow each card to expand/contract to show reviews and the listing link. This will save space on the page.

Attached

  • Image of what the search page looks like with more information. One restaurant card is highlighted and expanded to show reviews.
  • The structure of each restaurant card after adding all the new HTML elements.

Screenshot 2020-08-03 at 9 02 15 AM


Screenshot 2020-08-03 at 9 31 00 AM

@aivey65 aivey65 added the post mvp Things to work on after the MVP has been completed label Aug 3, 2020
@aivey65 aivey65 self-assigned this Aug 3, 2020
@@ -316,7 +356,7 @@ app.get(
);

app.get(`${PREFIX_API}/geocode`, async (request, response) => {
const address = encodeAddress(request.query.address);
const address = encodeForURL(request.query.address);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between encodeAddress and encodeForURL? Is it just a function you created to format the address?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name to be a bit broader. It encodes any string to be used in URLs, not just addresses. I use this function in more than one api now, so I made the name fit its purpose better.

Comment on lines 138 to 142
let messageText =
restaurantResponse.data === "ZERO_RESULTS"
? "We could not find any restaurants. Check to make sure you are using the correct address."
: "Something went wrong when searching for restaurants.";
restaurantErrorMessage.appendChild(document.createTextNode(messageText));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ved made some changes to the places API that may affect this. I suggest you rebase and run through it when he merges avoid any future issues

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw. I already plan to wait for his changes and rebase.

let image = document.createElement("img");
image.src =
"https://maps.googleapis.com/maps/api/place/photo?photoreference=" +
restaurant.photos[0].photo_reference +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: making this in such a way that its easier to understand it's coming from the place search response. Maybe placing it in a descriptive variable name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

for (restaurant of allRestaurants.results) {
//Get additional details for every restaurant using that restaurant's place id.
let placeDetailsResponse = await (
await fetch(
Copy link
Contributor

@vedantroy vedantroy Aug 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 notes:

  1. This will wait for each place details response to finish sequentially, which will be quite slow. It would be nice to parallelize the place details requests. However, since we're so close to the deadline, we might not have the time.

  2. I think it would make sense to do the place details requests on the server and pass the information back to the client. It would probably be easier to parallelize on the server too, since the ordering of the restaurants that aren't returned doesn't matter when you're on the server, but, on the client we need to know which place details data corresponds to which HTML element.

)
).json();

let additionalDetails =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General note: I think it makes sense to prefer const by default. So all variables should be const, and if, you need to re-assign something, use let. This seems better because const variables tell the user that "this value doesn't change", which makes it easier to read/debug code. When I see a let, I assume that the value is going to be re-assigned later.

I would go through this PR and change all lets to const, if the variable declared with let is not being re-assigned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@aivey65 aivey65 closed this Aug 6, 2020
@aivey65 aivey65 reopened this Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
post mvp Things to work on after the MVP has been completed
Projects
None yet
3 participants