Skip to content

Commit

Permalink
Merge pull request #2 from plum-king/feature#3-display-goal
Browse files Browse the repository at this point in the history
#6 [Feat] display goal
  • Loading branch information
plum-king authored Dec 14, 2022
2 parents 1d5b459 + 5a0398c commit c6f406d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
14 changes: 11 additions & 3 deletions controllers/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
const express = require("express");
const router = express.Router();
const pool = require("../db.js");

router.get("/", (req, res) => {
router.get("/", async (req, res) => {
const title = "main";
if (req.session.user) {
const nickname = req.session.user["nickname"];
res.render("main", {title: title, nickname: nickname});
const goal_list = await pool.query(`SELECT * FROM goal`);
res.render("main", {
title: title,
nickname: nickname,
goal_list: goal_list[0],
});
} else {
res.render("loginMain", {title: title});
res.render("login", {
title: title,
});
}
});

Expand Down
17 changes: 0 additions & 17 deletions views/loginMain.ejs

This file was deleted.

6 changes: 6 additions & 0 deletions views/main.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
<p>
<%= nickname %>
<a href="/logout">로그아웃</a>
<% for (let i = 0; i < goal_list.length; i++) { %>
<div class="goal_list">
<b> <%= goal_list[i].goal_user %> : </b> <%= goal_list[i].goal_content %> <br />
</div>
<!-- &emsp;&emsp; -->
<% } %>
</p>
</body>
</html>

0 comments on commit c6f406d

Please sign in to comment.