forked from AdaGold/trek
-
Notifications
You must be signed in to change notification settings - Fork 47
Jackie F - Wreck #23
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
jfahmy
wants to merge
5
commits into
Ada-C10:master
Choose a base branch
from
jfahmy: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
Jackie F - Wreck #23
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
047a3f3
add basic grid layout and click event for get call for all trips
jfahmy 22dede9
show details for clicked trip displaying on page
jfahmy a64c8ab
post working for book escape form
jfahmy 98ea169
adjust css grid and button styling
jfahmy 292ca09
delete extra images from project, clean up some uneeded css lines
jfahmy 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
| .container { | ||
| display: grid; | ||
| grid-gap: 25px; | ||
| grid-template-areas: | ||
| "header header" | ||
| "content details" | ||
| "content details" | ||
| "content book" | ||
| "content book" | ||
| "content book"; | ||
| } | ||
|
|
||
| header { | ||
| background-color: grey; | ||
| background: rgb(204, 204, 204); /* Fallback for older browsers without RGBA-support */ | ||
| background: rgba(204, 204, 204, 0.5); | ||
| grid-area: header; | ||
| padding-bottom: 2%; | ||
| color: white; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| .book { | ||
| background-color: white; | ||
| background: rgb(204, 204, 204); /* Fallback for older browsers without RGBA-support */ | ||
| background: rgba(204, 204, 204, 0.5); | ||
| grid-area: book; | ||
| color: white; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| .content { | ||
| background-color: white; | ||
| background: rgb(204, 204, 204); /* Fallback for older browsers without RGBA-support */ | ||
| background: rgba(204, 204, 204, 0.5); | ||
| grid-area: content; | ||
| color: white; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| .details { | ||
| background-color: white; | ||
| background: rgb(204, 204, 204); /* Fallback for older browsers without RGBA-support */ | ||
| background: rgba(204, 204, 204, 0.5); | ||
| grid-area: details; | ||
| color: white; | ||
| border-radius: 5px; | ||
| } | ||
|
|
||
| ul { | ||
| list-style: none; | ||
| } | ||
|
|
||
| #escape-list { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| padding: 8%; | ||
| } | ||
|
|
||
| body { | ||
| background: url(./assets/fire2.jpg); | ||
| background-repeat: no-repeat; | ||
| background-size: cover; | ||
| margin: 4%; | ||
| padding-top: 2%; | ||
| } | ||
|
|
||
| header h1 { | ||
| padding: 2%; | ||
| padding-left: 5%; | ||
| font-size: 80px !important; | ||
| font-family: 'Black Ops One', cursive !important; | ||
| padding-bottom: 0%; | ||
| } | ||
|
|
||
| .form-info { | ||
| padding:4%; | ||
| } | ||
|
|
||
| #load { | ||
| margin: 5%; | ||
| background-color:#cc3300; | ||
| font-size: 2em; | ||
| } | ||
|
|
||
| input[name="book-escape"] { | ||
| background-color:#cc3300; | ||
| float: right; | ||
| } | ||
|
|
||
| .detail-list { | ||
| padding: 5%; | ||
| margin-right: 5%; | ||
| } |
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,61 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en" dir="ltr"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Trek Project</title> | ||
| <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> | ||
| <link rel="stylesheet" href="index.css"> | ||
| <link rel="stylesheet" | ||
| href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | ||
| integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" | ||
| crossorigin="anonymous"> | ||
| <link href="https://fonts.googleapis.com/css?family=Black+Ops+One" rel="stylesheet"> | ||
| </head> | ||
| <body> | ||
| <main class="container"> | ||
| <header> | ||
| <h1>Wreck</h1> | ||
| </header> | ||
|
|
||
| <section class="content"> | ||
| <button id="load" class="btn btn-primary"> View Escape Options </button> | ||
| <ul id="escape-list"></ul> | ||
| </section> | ||
|
|
||
| <article class="details hidden"> | ||
| <ul class="detail-list"> | ||
| </ul> | ||
| </article> | ||
|
|
||
| <section class="book hidden"> | ||
| <section class="form-info"> | ||
| <h1>Book getaway: </h1> | ||
| <section id="status-message"></section> | ||
| <form id="escape-form"> | ||
| <div class="form-group"> | ||
| <label for="name">Name:</label> | ||
| <input type="text" name="name" class="form-control"/> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label for="email">Email:</label> | ||
| <input type="text" name="email" class="form-control" /> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label for="escape">Escape: </label> | ||
| <input type="text" name="escape" class="form-control" /> | ||
| </div> | ||
|
|
||
| <input type="hidden" name="id" value=""> | ||
|
|
||
| <input type="submit" name="book-escape" value="Book Escape" class="btn btn-primary"/> | ||
| </form> | ||
| </section> | ||
| </section> | ||
| </main> | ||
| </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,124 @@ | ||
| $(document).ready( function() { | ||
|
|
||
| // error handling | ||
| const printError = (error) => { | ||
| if (error.response.data && error.response.data.errors) { | ||
| // User our new helper method | ||
| reportError( | ||
| `Encountered an error: ${error.message}`, | ||
| error.response.data.errors | ||
| ); | ||
| } else { | ||
| reportStatus(`Encountered an error: ${error.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 reportStatus = (message) => { | ||
| $('#status-message').html(message); | ||
| }; | ||
|
|
||
|
|
||
| // load index of all trips/escapes | ||
| const loadEscapes = () => { | ||
|
|
||
| const getUrl = "https://trektravel.herokuapp.com/trips" | ||
| const escapeList = $('#escape-list'); | ||
|
|
||
| axios.get(getUrl) | ||
| .then((response) => { | ||
| escapeList.prepend(`<h2>Quick! Get out of here! </h2>`); | ||
| response.data.forEach((escape) => { | ||
| const $tripItem = $(`<li>${escape.name}</li>`); | ||
|
|
||
| // creating an event related to each trip after adding it to our index list | ||
| $tripItem.click(() => { | ||
| axios.get(getUrl + '/' + escape.id) | ||
| .then((response) => { | ||
| showDetailLink(response) | ||
| }) | ||
| .catch((error) => { | ||
| printError(error) | ||
| }); | ||
| }) | ||
|
|
||
| escapeList.append($tripItem); | ||
| }) | ||
| $( "#load" ).remove(); | ||
| }) | ||
| .catch((error) => { | ||
| console.log(error); | ||
| }); | ||
| } | ||
|
|
||
| const showDetailLink = (response) => { | ||
| let escape = response.data | ||
| $('.detail-list').empty() | ||
| $('.detail-list').prepend(`<h1>${escape.name}</h1>`) | ||
|
|
||
| $('.detail-list').append(`<li><b>Continent:</b> ${escape.continent}</li> | ||
| <li><b>Category:</b> ${escape.category}</li> | ||
| <li><b>Weeks:</b> ${escape.weeks}</li> | ||
| <li><b>Cost:</b> ${escape.cost}</li> | ||
| <li><b>About:</b> ${escape.about}</li>`) | ||
| // console.log($('input[name="escape"]')) | ||
| $('input[name="escape"]').val(`${escape.name}`) | ||
| $('input[name="id"]').val(`${escape.id}`) | ||
| $('.hidden').removeClass("hidden") | ||
| } | ||
|
|
||
|
|
||
| // happens when form submit is executed, creates object literal from form fields | ||
| const readFormData = () => { | ||
| const formData = {}; | ||
| const name = $(`input[name="name"]`).val(); | ||
| formData['name'] = name ? name : undefined; | ||
| const email = $(`input[name="email"]`).val(); | ||
| formData['email'] = email ? email : undefined; | ||
| const escape = $(`input[name="escape"]`).val(); | ||
| formData['escape'] = escape ? escape : undefined; | ||
| const id = $(`input[name="id"]`).val(); | ||
| formData['id'] = id ? id : undefined; | ||
| return formData; | ||
| }; | ||
|
|
||
|
|
||
| const bookEscape = () => { | ||
| //keeps page from refreshing on the submit (default behavior reloads page) | ||
| event.preventDefault(); | ||
|
|
||
| const bookingInfo = readFormData() | ||
| //clears out form data | ||
| $( '#escape-form' ).each(function(){ | ||
| this.reset(); | ||
| }); | ||
|
|
||
| // build url needed to execute post request | ||
| const postUrl = `https://trektravel.herokuapp.com/trips/${bookingInfo.id}/reservations` | ||
| axios.post(postUrl, bookingInfo) | ||
| .then((response) => { | ||
| reportStatus('Successfully booked!'); | ||
| }) | ||
| .catch((error) => { | ||
| printError(error) | ||
| }); | ||
| } | ||
|
|
||
| // event to load all escapes | ||
| $('#load').click(loadEscapes); | ||
|
|
||
| // creates submit event for the escape booking form | ||
| $('input[name="book-escape"]').click(bookEscape) | ||
|
|
||
| }); | ||
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.
CSS is preventing this message from being visible for network issues (because the trip registration isn't visible).