Skip to content

Commit

Permalink
fixed minor login bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarieay committed Mar 9, 2022
1 parent 7ddc765 commit 037eb83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions controllers/campgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const mapBoxToken = process.env.MAPBOX_TOKEN;
const axios = require("axios");
const geocoder = mbxGeocoding({ accessToken: mapBoxToken });
const {config, reverseGeo} = require("../tools/index");

/*
** TODO:IMPROVE ACCESSIBLITY
*/
module.exports.index = async (req, res) => {
const result = {};
result.results = [];
Expand Down Expand Up @@ -92,6 +94,7 @@ module.exports.index = async (req, res) => {
});
await Promise.all(campPromises);
}
// res.send(result);
res.render('campgrounds/index', {result})
}

Expand Down Expand Up @@ -170,8 +173,8 @@ module.exports.showUserCampgrounds = async (req, res) => {
}
});
result.results = user.campgrounds;
result.userMode = true;
res.render('campgrounds/index', {result});
result.mode = true;
res.render('campgrounds/index', {result})
}

module.exports.showCampground = async (req, res) => {
Expand Down
8 changes: 4 additions & 4 deletions views/campgrounds/index.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% layout('layouts/boilerplate') %>
<div id="cluster-map" class="border border-dark"></div>

<% if(result.results.length && !result.filter && !result.userMode) {%>
<% if(result.results.length && !result.filter && !result.mode) {%>
<h1 class="title">All Campgrounds</h1>
<nav aria-label="Campgrounds navigation pages" class="fw-bold">
<ul class="pagination pagination-sm d-flex justify-content-center">
Expand All @@ -14,7 +14,7 @@
<li class="page-item next-btn align-self-center"><a class="page-link page-next" href="">Next</a></li>
</ul>
</nav>
<% } else if(result.userMode && !result.filter) {%>
<% } else if(result.mode && !result.filter) {%>
<% if(result.results.length) {%>
<h1 class="pb-3 labelMode">Your Campground</h1>
<% } else {%>
Expand All @@ -24,7 +24,7 @@
<h1 class="pb-3 labelMode">Showing campgrounds at <span class="state-label"></span></h1>
<% } %>
<% if(!result.userMode) {%>
<% if(!result.mode) {%>
<form action="/campgrounds" class="pb-4">
<select class="form-select theme-target" name="q" aria-label="Default select example" onchange="this.form.submit()">
<option selected disabled aria-disabled="true">Select a state</option>
Expand Down Expand Up @@ -115,7 +115,7 @@
</div>
</div>
<% } %>
<% } else if(!result.results.length && !result.filter && !result.userMode){%>
<% } else if(!result.results.length && !result.filter && !result.mode){%>
<h1 class="pt-4">Sorry, no campgrounds to show in <span class="state-label"></span></h1>
<% } %>
<script>
Expand Down

0 comments on commit 037eb83

Please sign in to comment.