forked from AdaGold/trek
-
Notifications
You must be signed in to change notification settings - Fork 42
Hannah Cameron - Trek - Octos #35
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
Open
hannahlcameron
wants to merge
9
commits into
Ada-C9:master
Choose a base branch
from
hannahlcameron:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1c276e0
started project - added in empty files
hannahlcameron 81ac185
added in framework for loadTrips; added in load trips button
hannahlcameron 26a2ef0
passing wave one - clicking button shows list of trips
hannahlcameron 7047978
added in user messaging
hannahlcameron 2894f4f
working on loadClickedTrip functionality
hannahlcameron 3326e4c
finished loadclickedtrip function - displaying all info for selected …
hannahlcameron c31d958
added in scaffolding for reserveTrip function
hannahlcameron 9abe322
filled in reserveTrip funcionality, added in clearing of forms each time
hannahlcameron 2fe5184
added in CSS
hannahlcameron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| body { | ||
| background-color: rgb(140, 213, 90); | ||
| font-family: 'Scada', sans-serif; | ||
| } | ||
|
|
||
| header { | ||
| border-bottom: solid; | ||
| } | ||
|
|
||
| main { | ||
| min-height: 80vh; | ||
| display: flex; | ||
| flex-flow: wrap row; | ||
| justify-content: space-around; | ||
| } | ||
|
|
||
|
|
||
| footer { | ||
| border-top: solid; | ||
| } | ||
|
|
||
| section { | ||
| max-height: 80vh; | ||
| width: 45vw; | ||
| overflow: scroll; | ||
| padding: .5em | ||
| } | ||
|
|
||
| .button { | ||
| background-color: rgb(140, 213, 90); | ||
| color: rgb(0, 0, 0); | ||
| border: 2px solid rgb(0, 0, 0); | ||
| } | ||
|
|
||
| #selected-trip{ | ||
| max-height: 55vh; | ||
| overflow: scroll; | ||
| } | ||
|
|
||
| #trip-booking{ | ||
| max-height: 25vh; | ||
| overflow: scroll; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en" dir="ltr"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>TREK</title> | ||
| <link href="https://fonts.googleapis.com/css?family=Scada" rel="stylesheet"> | ||
| <link rel="stylesheet" type="text/css" href="index.css"> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h4>Welcome to Trek - The new tech start up that's bound to disrupt the industry!</h4> | ||
| <section id="user-message"></section> | ||
| </header> | ||
|
|
||
| <main> | ||
| <section> | ||
| <button id="trips-button" class="button">View All Trips</button> | ||
| <ul id="trips-list"></ul> | ||
| </section> | ||
| <section> | ||
| <article id="selected-trip"></article> | ||
| <article id="trip-booking"></article> | ||
| </section> | ||
| </main> | ||
| <footer> | ||
| <p>Hannah Cameron, 2018</p> | ||
| </footer> | ||
| <script | ||
| src="https://code.jquery.com/jquery-3.3.1.js"></script> | ||
| <script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
| <script type="text/javascript" src="index.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| const URL = "https://ada-backtrek-api.herokuapp.com/trips" | ||
|
|
||
| const userMessage = (message) => { | ||
| $('#user-message').html(message) | ||
| } | ||
|
|
||
| const loadTrips = function loadTrips() { | ||
| const tripList = $('#trips-list'); | ||
| tripList.empty(); | ||
| userMessage('Loading in trips..') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semi-colons on all of your |
||
| axios.get(URL) | ||
| .then((response) => { | ||
| const tripCollection = response.data | ||
| // console.log(response); | ||
| tripCollection.forEach((trip) => { | ||
| console.log(trip); | ||
| tripList.append(`<li id="${trip.id}">${trip.name}</li>`) | ||
| }); | ||
| userMessage(`Showing ${tripCollection.length} amazing trips to choose from!`) | ||
| }) | ||
| .catch((error) => { | ||
| userMessage(`Hrmm.. something has gone wrong: ${error.message}`) | ||
| console.log(error); | ||
| }); | ||
| }; | ||
|
|
||
| const loadClickedTrip = function loadClickedTrip(trip) { | ||
| // id, name, continent, about, category, weeks and cost | ||
| $('#selected-trip').empty(); | ||
| console.log(trip); | ||
| axios.get(URL + `/${trip.id}`) | ||
| .then((response) => { | ||
| console.log(response); | ||
| const selectedTrip = response.data | ||
| $('#selected-trip').append('<h4 id="trip-table">Trip Information</h4>'); | ||
| $('#trip-table').append(`<p>Trip Name: ${selectedTrip.name}</p>`) | ||
| $('#trip-table').append(`<p>Trip ID: ${selectedTrip.id}</p>`) | ||
| $('#trip-table').append(`<p>Continent: ${selectedTrip.continent}</p>`) | ||
| $('#trip-table').append(`<p>Category: ${selectedTrip.category}</p>`) | ||
| $('#trip-table').append(`<p>Duration: ${selectedTrip.weeks}</p>`) | ||
| $('#trip-table').append(`<p>Cost: $${selectedTrip.cost}</p>`) | ||
| $('#trip-table').append(`<p>Description: ${selectedTrip.about}</p>`) | ||
|
|
||
| // Load form | ||
| buildForm(selectedTrip) | ||
| }) | ||
| .catch((error) => { | ||
| userMessage(`Hrmm.. something has gone wrong loading this trip! ${error.message}`) | ||
| console.log(error); | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| const buildForm = (selectedTrip) => { | ||
| $('#trip-booking').empty(); | ||
| $("#trip-booking").append('<h4>Book A Trip!</h4>') | ||
| $("#trip-booking").append( | ||
| `<form><p>Trip: ${selectedTrip.name}</p><p>Name:<input type= "text" name="name"></p><p>Email:<input type="text" name="email"></p><input type="hidden" name="id" value="${selectedTrip.id}"><input class="button" type="submit" value="Submit"></form>` | ||
| ) | ||
| } | ||
|
|
||
| const reserveTrip = (event) => { | ||
| event.preventDefault(); | ||
| const tripID = $('form')[0][2].value | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment about what this code is doing would be good readability and reusability |
||
| const reservationData = $('form').serialize() | ||
| console.log($('form')); | ||
| console.log(tripID); | ||
| console.log(reservationData); | ||
| axios.post(URL + `/${tripID}/reservations?${reservationData}`) | ||
| .then((response) => { | ||
| console.log(response); | ||
| userMessage("Hooray! You've booked an exciting adventure!") | ||
| }) | ||
| .catch((error) => { | ||
| userMessage(`Hrmm.. something has gone wrong booking this trip! ${error.message}`) | ||
| console.log(error); | ||
| }) | ||
| $('form')[0].reset(); | ||
| } | ||
|
|
||
|
|
||
| $(document).ready (() => { | ||
| $('#trips-button').click(loadTrips); | ||
| $('#trips-list').on("click", "li", function(){ | ||
| let trip = this; | ||
| console.log(trip); | ||
| loadClickedTrip(trip); | ||
| }); | ||
| $('#trip-booking').submit(reserveTrip); | ||
|
|
||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out for little expressions like these where you're missing semi-colons