diff --git a/public/javascripts/index.js b/public/javascripts/index.js index b5bbed1..bc53f29 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -1,3 +1,4 @@ + window.addEventListener("load", (event)=>{ console.log("hello from javascript!") @@ -37,8 +38,23 @@ window.addEventListener("load", (event)=>{ } + const reviewContainer = document.querySelector('.review-container') + const rateBtn = document.querySelector('.rate-btn') + rateBtn.addEventListener('click', e => { + // e.preventDefault() + reviewContainer.classList.add(localStorage.classname) + localStorage.classname = 'hidden' + }) + }); +// console.log(review) +// if (review) { +// reviewContainer.classList.add('hidden') +// } else { +// reviewContainer.classList.remove('hidden') +// } +// let review = false // Listen to the text inside of areaThing, ONCE it exists // Set your text in your put request to the new thing area thINg diff --git a/public/stylesheets/details.css b/public/stylesheets/details.css index 6df39b5..5744dfe 100644 --- a/public/stylesheets/details.css +++ b/public/stylesheets/details.css @@ -247,3 +247,7 @@ textarea { height: 100px; border-radius: 5px; } + +.hidden { + visibility: hidden; +} \ No newline at end of file diff --git a/views/trail-detail.pug b/views/trail-detail.pug index 9ebe966..1a5e710 100644 --- a/views/trail-detail.pug +++ b/views/trail-detail.pug @@ -53,24 +53,25 @@ block content p(class=`name`)= trail.name img(src=`../trails/trail-${trail.id}.jpg` alt=`${trail.name}` class=`trail-image-${trail.id}`) p(class=`details`)= trail.description - div(class='btn-container') - form(action="/trailList" method="post" id="demo" class="demo") - button(type="submit" class="add-btn hi") Add to TrailList - div(class="review-container") - form(action=`/trail/${trail.id}` method="post" class="") - textarea(name="text" placeholder="Write a review!" class="review-input") - button(type="submit" class="rate-btn hi") Submit - div(class="list-reviews") - each review in reviews - div(class="review") - p(class="review-username")= `User: ${review.User.username}` - div - p(id=`text-${review.id}` class="review-text")= `${review.text}` - p(class="review-date")= `Reviewed at: ${review.createdAt}` - if (review.User.id === user.id) - button(type="submit" id=`${review.id}` class="edit-btn hi") Edit Review - form(action=`/trail/${trail.id}/delete` method="post" class="") - button(type="submit" class="delete-btn hi") Delete Review + if (user) + div(class='btn-container') + form(action="/trailList" method="post" id="demo" class="demo") + button(type="submit" class="add-btn hi") Add to TrailList + div(class="review-container") + form(action=`/trail/${trail.id}` method="post" class="") + textarea(name="text" placeholder="Write a review!" class="review-input") + button(type="submit" class="rate-btn hi") Submit + div(class="list-reviews") + each review in reviews + div(class="review") + p(class="review-username")= `User: ${review.User.username}` + div + p(id=`text-${review.id}` class="review-text")= `${review.text}` + p(class="review-date")= `Reviewed at: ${review.createdAt}` + if (review.User.id === user.id) + button(type="submit" id=`${review.id}` class="edit-btn hi") Edit Review + form(action=`/trail/${trail.id}/delete` method="post" class="") + button(type="submit" class="delete-btn hi") Delete Review //- input(type="hidden" class="edit-input") //- if (review.User.id === review.userId)