forked from AdaGold/trek
-
Notifications
You must be signed in to change notification settings - Fork 47
goeun / edges / trek trek trek #39
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
goeunpark
wants to merge
6
commits into
Ada-C10:master
Choose a base branch
from
goeunpark: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
6 commits
Select commit
Hold shift + click to select a range
70b7cd1
add files, html and css basics
goeunpark a1d1a3b
can make post request to show all trips
goeunpark 5b9e9a2
skeleton loadTripDetails takes in tripID
goeunpark a1abf64
wave 2
goeunpark aae4c8b
add id and css to wave 2
goeunpark 59b8004
wave 3
goeunpark 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,75 @@ | ||
| *{ | ||
| list-style: none; | ||
| font-family: 'Roboto Mono', monospace; | ||
| } | ||
|
|
||
| h1, h2, h4{ | ||
| font-family: 'Roboto Slab', serif; | ||
| } | ||
| body{ | ||
| background-color: rgb(240, 235, 237); | ||
| margin: 50px; | ||
| } | ||
|
|
||
| main{ | ||
| display: grid; | ||
| grid-template-columns: 2fr 4fr 1fr; | ||
| } | ||
|
|
||
| #hidden{ | ||
| visibility: hidden; | ||
| } | ||
|
|
||
| .current-trips > *{ | ||
| margin: 20px; | ||
| } | ||
|
|
||
| .reservation{ | ||
|
|
||
| } | ||
|
|
||
| #trip-detail{ | ||
| grid-columns: 2 / 3; | ||
| } | ||
|
|
||
| .reservation{ | ||
| grid-columns: 2 / 3; | ||
| } | ||
|
|
||
| .btn{ | ||
| margin-top: 10px; | ||
| } | ||
|
|
||
| .detail-container{ | ||
| background-color: rgba(191, 163, 176, 0.31); | ||
| margin-left: 20px; | ||
| margin-right: 30px; | ||
| padding: 30px; | ||
| } | ||
|
|
||
| #name{ | ||
| font-size: 2.5rem; | ||
| padding-bottom: 5px; | ||
| } | ||
|
|
||
| #continent{ | ||
| font-size: 2rem; | ||
| padding-bottom: 5px; | ||
| } | ||
|
|
||
| #about{ | ||
| padding-bottom: 10px; | ||
| } | ||
| #weeks{ | ||
| border-top: 1px solid rgba(167, 162, 168, 0.61); | ||
| padding-top: 10px; | ||
| } | ||
|
|
||
| #trip-list li{ | ||
| padding: 3px; | ||
| } | ||
|
|
||
| #trip-list li:hover{ | ||
| background-color: rgb(219, 193, 204); | ||
| font-style: italic; | ||
| } |
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,54 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en" dir="ltr"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>trek trek trek</title> | ||
|
|
||
| <script src="https://code.jquery.com/jquery-3.3.1.js"></script> | ||
| <script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
| <link href="https://fonts.googleapis.com/css?family=Roboto+Mono:300|Roboto+Slab" rel="stylesheet"> | ||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
| <link rel="stylesheet" href="index.css"> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <nav> | ||
| <h1>🚗 Trek outta here!</h1> | ||
| </nav> | ||
| </header> | ||
|
|
||
| <main> | ||
| <section class="current-trips"> | ||
| <button type="button" class="btn btn-light" id="load">Where to?</button> | ||
| <ul id="trip-list"></ul> | ||
| </section> | ||
|
|
||
| <section id="trip-detail"> | ||
| </section> | ||
|
|
||
| <section class="reservation" id="hidden"> | ||
| <h4>Make a reservation for this trip</h4> | ||
| <form id="reservation-form"> | ||
| <div> | ||
| <label for="name">Your name</label> | ||
| <input type="text" name="name" /> | ||
| </div> | ||
|
|
||
| <div> | ||
| <label for="name">Email</label> | ||
| <input type="text" name="email" /> | ||
| </div> | ||
|
|
||
| <div> | ||
| <label for="name">Trip ID</label> | ||
| <input type="number" name="trip_id" /> | ||
| </div> | ||
|
|
||
| <input type="submit" name="add-trip" value="Add Trip" class="btn btn-light"/> | ||
| </form> | ||
| </section> | ||
| </main> | ||
|
|
||
| <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,95 @@ | ||
| const TRIPS = 'https://trektravel.herokuapp.com/trips'; | ||
|
|
||
| const reportStatus = (message) => { | ||
| $('#status-message').html(message); | ||
| }; | ||
|
|
||
| const reportError = (message, errors) => { | ||
| let content = `<p>${message}</p>` | ||
| content += "<ul>"; | ||
| for (const field in errors) { | ||
| for (const problem of errors[field]) { | ||
| content += `<li>${field}: ${problem}</li>`; | ||
| } | ||
| } | ||
| content += "</ul>"; | ||
| reportStatus(content); | ||
| }; | ||
|
|
||
| const createReservation = (event => { | ||
| event.preventDefault(); | ||
|
|
||
| const reservationData = { | ||
| name: $('input[name="name"]').val(), | ||
| email: $('input[name="email"]').val(), | ||
| trip_id: $('input[name="trip_id"]').val() | ||
| }; | ||
| console.log(reservationData) | ||
|
|
||
| axios.post(`${TRIPS}/${reservationData.trip_id}/reservations`, reservationData) | ||
| .then((response) => { | ||
| reportStatus(`Successfully added a reservation with ID ${response.data.id}`) | ||
| }) | ||
| .catch((error) => { | ||
| reportStatus(`Encountered an error: ${error.message}`); | ||
| }) | ||
|
|
||
| }); | ||
|
|
||
| const loadTrips = () => { | ||
| reportStatus("* ~ * loading trips ~ * ~") | ||
| const tripList = $('#trip-list'); | ||
| tripList.empty(); | ||
|
|
||
| axios.get(TRIPS) | ||
| .then((response) => { | ||
| reportStatus(`Successfully loaded trips!`) | ||
|
|
||
| response.data.forEach((trip) => { | ||
| tripList.append(`<li id="${trip.id}">${trip.name}</li>`); | ||
| }); | ||
| }) | ||
| .catch((error) => { | ||
| reportError(error); | ||
| console.log('something went wrong'); | ||
| }); | ||
| }; | ||
|
|
||
| const loadTripDetails = (tripId) => { | ||
|
|
||
| const tripDetails = () => { | ||
| const detail = $('#trip-detail'); | ||
| detail.empty(); | ||
| axios.get(`${TRIPS}/${tripId}`) | ||
| .then((response) => { | ||
| reportStatus(`Successfully loaded detail of trip!`); | ||
|
|
||
| detail.append(`<div class='detail-container'> | ||
| <h2>Trip ${response.data.id} Details</h2> | ||
| <li id="name">${response.data.name}</li> | ||
| <li id="continent">${response.data.continent}</li> | ||
| <li id="about">${response.data.about}</li> | ||
| <li id="weeks"><b>Weeks:</b> ${response.data.weeks}</li> | ||
| <li id="cost"><b>Cost:</b> $${response.data.cost}</li> | ||
| </div>`); | ||
| }) | ||
| .catch((error) => { | ||
| reportError(error); | ||
| console.log('something went wrong :c'); | ||
| }); | ||
| }; | ||
|
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. You should also do something here to set the form field value to the trip id. |
||
| return tripDetails(); | ||
| }; | ||
|
|
||
|
|
||
| $(document).ready(() => { | ||
| $('#load').click(loadTrips); | ||
|
|
||
| $('ul').on('click', 'li', function(){ | ||
| const tripId = $(this).attr('id'); | ||
| loadTripDetails(tripId); | ||
| $('#hidden').css('visibility', 'visible'); | ||
| }); | ||
|
|
||
| $('#reservation-form').submit(createReservation); | ||
| }); | ||
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 convert this into a number.