forked from AdaGold/trek
-
Notifications
You must be signed in to change notification settings - Fork 41
Ampers: Abinnet #36
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
Abiaina
wants to merge
12
commits into
Ada-C9:master
Choose a base branch
from
Abiaina: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
Ampers: Abinnet #36
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
69670d6
button to show all trips, display loosely follows wireframes
Abiaina cacdc2d
hard coded link for list item to show details
Abiaina b3c927d
clicking on table rows shows trip details, responsive. needs styling
Abiaina f00af14
some css done with foundation, reviewing foundation.zurb videos...mov…
Abiaina 6d65a5d
foundation is working
Abiaina 78a67fc
used foundation to make a form and show and hid rservatio and trip de…
Abiaina ec0d3da
added trip name to reservation show
Abiaina 18f0f87
added logic for reservation, fixed bug it caused in trips and trip sh…
Abiaina f3b0935
user can make a reservation based on form input, post requests appear…
Abiaina debba76
error message added
Abiaina 0fab38f
basic requirements met, needs styling
Abiaina 39b0980
added some color and updated some styling
Abiaina 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,56 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Trek</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| <!-- Compressed CSS --> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.4.3/dist/css/foundation.min.css" integrity="sha256-GSio8qamaXapM8Fq9JYdGNTvk/dgs+cMLgPeevOYEx0= sha384-wAweiGTn38CY2DSwAaEffed6iMeflc0FMiuptanbN4J+ib+342gKGpvYRWubPd/+ sha512-QHEb6jOC8SaGTmYmGU19u2FhIfeG+t/hSacIWPpDzOp5yygnthL3JwnilM7LM1dOAbJv62R+/FICfsrKUqv4Gg==" crossorigin="anonymous"> | ||
|
|
||
| </head> | ||
| <body> | ||
| <div class="grid-x grid-padding-x"> | ||
| <h1 class="small-12 medium-12 cell" id="title">Trek</h1> | ||
| <h3 class="small-12 medium-12 cell" id="userMessages"><h3> | ||
|
|
||
| <button type="button" class="button secondary" id="seetrips">See All Trips</button> | ||
| </div> | ||
|
|
||
| <div class="grid-x grid-padding-x"> | ||
| <div class="small-12 medium-6 cell"> | ||
| <div class="table-scroll"> | ||
| <table id="showtrips" class="hover"> | ||
| </table> | ||
| </div> | ||
| </div> | ||
| <div class="small-12 medium-6 cell"> | ||
| <div class="Trip"> | ||
| <table id="tripDetails"> | ||
| </table> | ||
|
|
||
| <div class="ReserveTrip"> | ||
| <h1>Reserve Trip</h1> | ||
| <form id="reservationForm"> | ||
| <div> | ||
| <label for="name">Your Name: </label> | ||
| <input type="text" name="name" id="travellerName"/> | ||
| <label for="email">Your Email: </label> | ||
| <input type="text" name="email" id="travellerEmail"/> | ||
| </div> | ||
| <div id="tripName"> | ||
| </div> | ||
| <input type="submit" name="reserve-trip" value="Reserve Trip" /> | ||
| </form> | ||
|
|
||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
|
|
||
| <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,120 @@ | ||
|
|
||
| const URL = 'https://ada-backtrek-api.herokuapp.com'; | ||
|
|
||
| const banner = $('#userMessages'); | ||
|
|
||
| const showBanner = (message) => { | ||
| banner.empty(); | ||
| banner.append(message); | ||
| } | ||
|
|
||
| const loadTrips = () => { | ||
| const tripList = $('#showtrips'); | ||
| tripList.empty(); | ||
| $('.ReserveTrip').hide(); | ||
|
|
||
| $('#tripDetails').empty(); | ||
|
|
||
| const tripParam = '/trips'; | ||
|
|
||
| showBanner('Loading Trips! Please Wait...!'); | ||
|
|
||
| axios.get(URL + tripParam) | ||
|
|
||
| .then((response) => { | ||
| console.log('Responding'); | ||
| console.log(response); | ||
|
|
||
| tripList.append(`<tr><th>All Trips</th></tr>`); | ||
|
|
||
| response.data.forEach((trip) => { | ||
| tripList.append(`<tr><td id=${trip.id}>${trip.name}</td></tr>`); | ||
| }); | ||
| showBanner('Trips Loaded'); | ||
|
|
||
| }) | ||
|
|
||
| .catch((error) => { | ||
| console.log(error); | ||
| showBanner(`Error: ${error.message }`); | ||
|
|
||
| }); | ||
|
|
||
| } | ||
|
|
||
| const reserveTrip = function reserveTrip(tripId, reservationDetails){ | ||
|
|
||
| showBanner('Loading Trip Details! Please Wait...!'); | ||
|
|
||
| axios.post(`https://ada-backtrek-api.herokuapp.com/trips/${tripId}/reservations`, reservationDetails) | ||
|
|
||
| .then((response) => { | ||
| console.log('Responding'); | ||
| showBanner('Successfully Reserved Trip'); | ||
| }) | ||
|
|
||
| .catch((error) => { | ||
| console.log(error); | ||
| showBanner(`Unable to Reserve: ${error.message }`); | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| const loadTripDetails = (id) => { | ||
| const tripDetails = $('#tripDetails'); | ||
| tripDetails.empty(); | ||
|
|
||
| const tripId = `/trips/${id}`; | ||
|
|
||
| showBanner('Loading Trip Details! Please Wait...!'); | ||
|
|
||
| axios.get(URL + tripId) | ||
|
|
||
| .then((response) => { | ||
| console.log('Responding'); | ||
| console.log(response); | ||
|
|
||
| tripDetails.append(`<tr><th>Trip Details</th></tr>`); | ||
|
|
||
| let detail = response.data; | ||
| tripDetails.append(`<tr><td>Name: ${detail.name}</td></tr>`); | ||
| tripDetails.append(`<tr><td>Trip Id: ${detail.id}</td></tr>`); | ||
| tripDetails.append(`<tr><td>Continent: ${detail.continent}</td></tr>`); | ||
| tripDetails.append(`<tr><td>Category: ${detail.category}</td></tr>`); | ||
| tripDetails.append(`<tr><td>Weeks: ${detail.weeks}</td></tr>`); | ||
| tripDetails.append(`<tr><td>Cost: $${detail.cost}</td></tr>`); | ||
| tripDetails.append(`<tr><td>${detail.about}</td></tr>`); | ||
|
|
||
| showBanner('Trip Details Loaded'); | ||
|
|
||
| $('#tripName').empty(); | ||
| $('#tripName').append(`<h5>Trip Name: ${detail.name}</h5>`); | ||
| $('.ReserveTrip').show(); | ||
| $('#reservationForm').off(); | ||
|
|
||
| $('#reservationForm').submit(function(event) { | ||
|
|
||
| let reservationDetails = { | ||
| name: $('#travellerName').val(), | ||
| email: $('#travellerEmail').val(), | ||
| }; | ||
|
|
||
| event.preventDefault(); | ||
|
|
||
| reserveTrip(detail.id, reservationDetails); | ||
| }); | ||
| }) | ||
|
|
||
| .catch((error) => { | ||
| showBanner(`Error: ${error.message }`); | ||
| }); | ||
| } | ||
|
|
||
| $(document).ready(() => { | ||
| $('#seetrips').click(loadTrips); | ||
| $('#showtrips').on( 'click', 'td', function(event) { | ||
| let id = $(this).attr('id'); | ||
| event.preventDefault(); | ||
| loadTripDetails(id); | ||
| }); | ||
| }); | ||
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 @@ | ||
| .ReserveTrip { | ||
| display: none; | ||
| } | ||
|
|
||
| #title { | ||
| background-color: green; | ||
| color: white; | ||
| text-align: center; | ||
| } | ||
|
|
||
| #userMessages { | ||
| font-size: 12pt; | ||
| font-style: italic; | ||
| color: grey; | ||
| text-align: center; | ||
| } | ||
|
|
||
| #showtrips { | ||
| background-color: #8FBC8F; | ||
| } | ||
|
|
||
| #tripDetails { | ||
| background-color: #98FB98; | ||
| } | ||
|
|
||
| .ReserveTrip { | ||
| background-color: #20B2AA; | ||
| text-align: center; | ||
| } | ||
|
|
||
| #travellerName { | ||
| padding: 1rem; | ||
| } |
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.
You should also be checking for validation errors like we did in class here.