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

Ampers: Nora Peters #20

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

Ampers: Nora Peters #20

wants to merge 11 commits into from

Conversation

npeters5
Copy link

TREK

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What does it mean for code to be asynchronous? Asynchronous code is typically used on websites when performing expensive or time-consuming operations, like API calls, and it prevents the entire website from reloading, allowing the user to continue interacting and making multiple requests without having to wait for the initial request to complete executing.
Describe a piece of your code that executes asynchronously. How did this affect the way you structured it? The axios 'get' and 'post' requests in index.js are executed asynchronously. I used event.preventDefault(); to prevent the page reload as a result of various event triggers.
What kind of errors might the API give you? How did you choose to handle them? The API may respond to a post request with errors relating to validation of the incoming data (ex: "name and email must not be blank"). I handled these by displaying them at the top of the page, and using helper functions shared in class (reportStatus, reportError) to alert the user to successful or unsuccessful requests.
Do you have any recommendations on how we could improve this project for the next cohort? Again, some folks like me have trouble making the leap from the class example to this project, so maybe a few more hints/heads up as to how it DIFFERs from class would be helpful.


$('#trip-list').on('click', 'li', function(event) {
let id = Number(event.target.id);
$("section").removeClass("hidden");
Copy link

Choose a reason for hiding this comment

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

this ends up working, but it might be more specific to use a more specific selector than 'section' since you have more than one section in your HTML

axios.post((`${URL}${id}/reservations`), tripData)
.then((response) => {
clearForm();
reportStatus(`Successfully created trip reservation with ID ${response.data.trip_id}!`);
Copy link

Choose a reason for hiding this comment

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

response.data.trip_id refer to the ID of the trip, not the reservation itself. Funnily enough, the API doesn't give back a response with the reservation ID!

axios.get(URL + id)
.then((response) => {
let data = response.data;
let name = $(`<h4><strong>Name:</strong> ${data.name}</h4>`).addClass(`${id}`);
Copy link

Choose a reason for hiding this comment

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

It might make more sense to set the id attr on this element instead of adding a class, because this value represents a unique identifier rather than a styling class?

let data = response.data;
let name = $(`<h4><strong>Name:</strong> ${data.name}</h4>`).addClass(`${id}`);
let about = $(`<span><strong>Description:</strong> ${data.about.slice(0, 150)}</span>`).addClass("teaser");
let aboutFullText = $(`<span>${data.about.slice(150)}</span>`).addClass("moreinfo hidden").attr('id', 'info1');
Copy link

Choose a reason for hiding this comment

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

super neat solution, nice!

const sAmericaTrips = () => {
let url = (URL + '/continent?query=South%20America')
getTrips(url)
}
Copy link

@tildeee tildeee Jun 1, 2018

Choose a reason for hiding this comment

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

These functions all end up feeling very similar! It might make sense to refactor them such that...

const getTripsByContinent = (continentName) => {
  getTrips( encodeURI( URL + '/continent?query=' + continentName ) );
}

Then lines 167-173 could look maybe more like

$('#asia').click( (event) => getTripsByContinent('Asia') );

//LOAD all/specific trips based on url params
const getTrips = (url) => {
const tripList = $('#trip-list');
tripList.show();
Copy link

Choose a reason for hiding this comment

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

This is just a random jQuery thing that I'm not too concerned about but: Since you're calling .show() on this element, jQuery actually puts an inline style on this element for style={display: block;} ... which is fine, except that it's awkward since there's a class on this called hidden that never gets removed... so it ends up looking like this:

<ul class="trips hidden" id="trip-list" style="display: block;"> ... </ul>

It's a little awkward to read class="hidden" and at the same time see it on the page because of the inline style.

Like I said, I'm not too worried about this... unless it introduces bugs later (what if you try to select on $('.hidden')?) It might make sense to conform to one style or the other (either removing the class hidden instead of using .show(), or in $(document).ready calling $('#trip-list').hide() right at the beginning

@tildeee
Copy link

tildeee commented Jun 1, 2018

TREK

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene x
Comprehension questions x
Functionality
Click a button to list trips x
Click a trip to see trip details x
Fill out a form to reserve a spot x
Errors are reported to the user x
Styling x
Under the Hood
Trip data is retrieved using from the API x
JavaScript is well-organized and easy to read x
HTML is semantic x
Overall

Great work on this project!

The project definitely works as expected; the code looks good and the site looks good.

I love the interesting work you did on the "... Read more" part

Also, good job on the optionals!

I've left a couple of comments all on minor things; I have no red flags otherwise

Overall, good work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants