Skip to content

Commit

Permalink
added election details view
Browse files Browse the repository at this point in the history
  • Loading branch information
TimTJoe committed Aug 19, 2024
1 parent c0b878f commit 44282c1
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 38 deletions.
38 changes: 22 additions & 16 deletions routes/elections-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,37 @@ router.get("/", function handler(req, res) {
if (error) console.error(error);
data.parties = parties;
if (data.length !== 0) {
res.render("elections.ejs", {path: "elections", data });
res.render("elections.ejs", { path: "elections", data });
}
});
});
router.get("/create", function handler(req, res) {
res.send("create elections");
});

router.get("/:electionID/parties", (req, res) => {
router.get("/:electionID", function handler(req, res) {
let data = {};
db.all("SELECT * FROM parties", function (err, parties) {
data.parties = parties;
if (err) console.error(err);
res.render("elections/parties.ejs", { data });
});
let { electionID } = req.params;
data.electionID = electionID;
res.render("election-details.ejs", { path: "elections", data });
});

router.get("/:electionID/candidates", (req, res) => {
let data = {};
res.render("elections/candidates.ejs", { data });
});
// router.get("/:electionID/parties", (req, res) => {
// let data = {};
// db.all("SELECT * FROM parties", function (err, parties) {
// data.parties = parties;
// if (err) console.error(err);
// res.render("elections/parties.ejs", { data });
// });
// });

router.get("/:electionID/voters", (req, res) => {
let data = {};
res.render("elections/voters.ejs", { data });
});
// router.get("/:electionID/candidates", (req, res) => {
// let data = {};
// res.render("elections/candidates.ejs", { data });
// });

// router.get("/:electionID/voters", (req, res) => {
// let data = {};
// res.render("elections/voters.ejs", { data });
// });

module.exports = router;
45 changes: 45 additions & 0 deletions views/election-details.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<%- include("./partials/head") %>
<%- include("./partials/navigation") %>
<div class="layout">
<%- include("./partials/sidebar") %>
<div class="content ">
<header class="container-medium center-align">
<h1 class="huge no-margin" id="election-name">Block A General Elections</h1>
<small class="margin-bottom">4day 10hrs 33mins 12sec to go</small>
<span class="large muted no-margin">Aug 25, 2024 &middot; 10 Candidates &middot; 1234
Voters</span>
</header>
<nav class="row margin-top border-bottom" id="tabs">
<button class="tab active">Candidates</button>
<button class="tab">Voters</button>
<button class="tab">Parties</button>
<button class="mini crimson move-right margin-right ">Vote Now</button>
</nav>
<div class="grid padding">
<a href="/candidates/1234567" class="row border padding black hover-elevate">
<img src="/images/sample.png" alt="" class="round small">
<span class="max margin-left">
<h6 class="large no-margin">John D. Doe </h6>
<p class="small ">Candidate</p>
<small class="smaller muted"> Party Name &middot; Position</small>
</span>
</a>
<a href="/users/2" class="row border padding black hover-elevate">
<img src="/images/sample.png" alt="" class="round small">
<span class="max margin-left">
<h6 class="large no-margin">John D. Doe </h6>
<p class="small ">Voter</p>
<small class="smaller muted"> 25 years old &middot; No Affiliation</small>
</span>
</a>
<a href="/parties/12345678" class="border row padding black hover-elevate tiny-radius">
<img class="small" src="/images/up.png" alt="" />
<span class="column margin-left">
<h3 class="large no-margin"> Unity Party</h3>
<small class="muted"> 0 Candidates &middot; 0 Elections Won </small>
</span>
</a>

</div

</div>
23 changes: 16 additions & 7 deletions views/elections.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@
<small class="margin-bottom">4day 10hrs 33mins 12sec to go</small>
<span class="large muted no-margin">Aug 25, 2024 &middot; 10 Candidates &middot; 1234 Voters</span>
<nav class="row margin-top border-bottom" id="tabs">
<button class="tab active">Parties</button>
<button class="tab active">Candidates</button>
<button class="tab">Voters</button>
<button class="tab">Candidates</button>
<button class="mini move-right margin-right">Vote Now</button>
<button class="tab">Parties</button>
<button class="mini crimson move-right margin-right ">Vote Now</button>
</nav>
</div>
<div class="grid padding">
<section class="row border padding">
<a href="/candidates/1234567" class="row border padding black hover-elevate">
<img src="/images/sample.png" alt="" class="round small">
<span class="max margin-left">
<h3 class="large no-margin">The Part Name Here</h3>
<small class="row around">10 Candidates &middot; 0 Election won</small>
<h6 class="large no-margin">John D. Doe </h6>
<p class="small ">Candidate</p>
<small class="smaller muted"> Party Name &middot; Position</small>
</span>
</section>
</a>
<a href="/parties/12345678" class="border row padding black hover-elevate tiny-radius">
<img class="small" src="/images/up.png" alt="" />
<span class="column margin-left">
<h3 class="large no-margin"> Unity Party</h3>
<small class="muted"> 0 Candidates &middot; 0 Elections Won </small>
</span>
</a>

</div>
</div>
</div>
Expand Down
19 changes: 10 additions & 9 deletions views/users-profile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@
<%}%>
<nav class="row margin-top border-bottom" id="tabs">
<button class="tab active">Elections</button>
<button class="tab">Affiliation</button>
</nav>
<div class="grid padding">
<section class="border padding">
<a href="/elections/12345" class="border padding black hover-elevate">
<h6 class="small bold">Block A General Elections</h6>
<small class="small">Aug 25, 2024 &middot; <em class="success">Voted</em></small>
</section>
<section class="border padding">
<small class="small">10 Candidates &middot; Aug 25, 2024 &middot; <em class="success">Voted</em></small>
</a>
<a href="/elections/12345" class="border padding black hover-elevate">
<h6 class="small bold">Block A General Elections</h6>
<small class="small">Aug 25, 2024 &middot; <em class="success">Voted</em></small>
</section>
<section class="border padding">
<small class="small">10 Candidates &middot; Aug 25, 2024 &middot; <em class="success">Voted</em></small>
</a>
<a href="/elections/12345" class="border padding black hover-elevate">
<h6 class="small bold">Block A General Elections</h6>
<small class="small">Aug 25, 2024 &middot; <em class="success">Voted</em></small>
</section>
<small class="small">10 Candidates &middot; Aug 25, 2024 &middot; <em class="success">Voted</em></small>
</a>
</div>
</div>
</div>
13 changes: 7 additions & 6 deletions views/voters.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@
<div class="grid padding">
<% if(data.voters) { %>
<% data.voters.reverse().map(function each(voter){ %>
<section class="row border padding">
<a href="/users/<%= voter.id %>" class="row border padding black hover-elevate">
<img src="/uploads/<%= voter.photo %>" alt="" class="round small">
<span class="max margin-left">
<a href="/users/<%= voter.id %>" class="large black no-margin">
<h6 class="large no-margin">
<%= voter.first_name %>
<%= voter.middle_name %>
<%= voter.last_name %>
</a>
<small class="row">
<%= voter.DOB %> &middot; <p class="success"> 2x Voted </p>
</h6>
<p class="small ">Candidate</p>
<small class="smaller muted">
<%= voter.DOB %> &middot; No Affiliation
</small>
</span>
</section>
</a>
<% }) %>
<% } %>
</div>
Expand Down

0 comments on commit 44282c1

Please sign in to comment.