Skip to content

Commit

Permalink
Fixed Bug for dashboard : Handled Layout rendering for corresponding …
Browse files Browse the repository at this point in the history
…routes (#108)
  • Loading branch information
ParasY1724 authored Oct 30, 2024
1 parent 2f6d2b7 commit dd272fd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 72 deletions.
1 change: 0 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ app.use(express.static("public"));

// Templating Engine
app.use(expressLayout);
app.set('layout', './layouts/main');
app.set('view engine', 'ejs');

// Helper for active route
Expand Down
113 changes: 43 additions & 70 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions server/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ const authMiddleware = (req, res, next) => {
* GET /
* Admin - Login Page
*/

router.use((req, res, next) => {
res.locals.layout = './layouts/admin'; // Set the layout for the response
next(); // Call the next middleware or route handler
});

router.get('/admin', restrictAuthRouteMiddleware, async (req, res) => {
try {
const locals = {
Expand Down
6 changes: 6 additions & 0 deletions server/routes/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ const transporter = require('../config/nodemailerConfig');
* GET /
* HOME
*/

router.use((req, res, next) => {
res.locals.layout = './layouts/main'; // Set the layout for the response
next(); // Call the next middleware or route handler
});

router.get('/', async (req, res) => {
try {
const locals = {
Expand Down
2 changes: 1 addition & 1 deletion views/partials/header_admin.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<header class="header">
<a href="/" class="header__logo">Admin Panel</a>
<a href="/dashboard" class="header__logo">Admin Panel</a>

<nav class="header__nav">
<ul>
Expand Down

0 comments on commit dd272fd

Please sign in to comment.