Skip to content

Commit

Permalink
changed two state code label to a full label
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarieay committed Mar 2, 2022
1 parent 94b8d4a commit 197494a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 0 additions & 4 deletions controllers/campgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const geocoder = mbxGeocoding({ accessToken: mapBoxToken });
const {config, reverseGeo} = require("../tools/index");
/*
** TODO:IMPROVE ACCESSIBLITY
** AFTER NEED TO REFACTOR ASYNCS TO MIDDLEWARE
*/
module.exports.index = async (req, res) => {
const result = {};
Expand Down Expand Up @@ -94,9 +93,6 @@ module.exports.index = async (req, res) => {
}
});
await Promise.all(campPromises);
} else {
// NOTHING FOUND IN API
result.query = q;
}
// res.send(result);
res.render('campgrounds/index', {result})
Expand Down
5 changes: 4 additions & 1 deletion public/javascripts/searchMode.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const options = document.querySelectorAll('option');

const stateLabel = document.querySelector('.state-label')
let state;
const stateCode = filter;

//apply selected attribute to filtered state
for(let option of options){
if(option.getAttribute('value') == stateCode){
state = option.innerText;
option.selected = true;
break;
}
}

stateLabel.innerText = state;
4 changes: 2 additions & 2 deletions views/campgrounds/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ul>
</nav>
<% } else if(result.filter && result.results.length) {%>
<h1 class="pb-3">Showing campgrounds at <%= result.filter %> </h1>
<h1 class="pb-3" class="labelMode">Showing campgrounds at <span class="state-label"></span></h1>
<% } %>

<form action="/campgrounds" class="pb-4">
Expand Down Expand Up @@ -108,7 +108,7 @@
</div>
<% } %>
<% } else {%>
<h1 class="pt-4">Sorry, no campgrounds to show in <%= result.query %></h1>
<h1 class="pt-4">Sorry, no campgrounds to show in <span class="state-label"></span></h1>
<% } %>
<script>
const mapToken = '<%- process.env.MAPBOX_TOKEN %>';
Expand Down

0 comments on commit 197494a

Please sign in to comment.