Skip to content

Commit

Permalink
feat: Add notifications and jobs page handlers for settings and heade…
Browse files Browse the repository at this point in the history
…r components
  • Loading branch information
wajeht committed Aug 14, 2024
1 parent 4f3998f commit 09e905a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 21 deletions.
16 changes: 12 additions & 4 deletions src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ export function getSettingsPageHandler(req: Request, res: Response) {
});
}

// GET /profile
export function getProfilePageHandler(req: Request, res: Response) {
return res.render('profile.html', {
path: '/profile',
// GET /notifications
export function getNotificationsPageHandler(req: Request, res: Response) {
return res.render('settings.html', {
path: '/notifications',
layout: '../layouts/auth.html',
});
}

// GET /jobs
export function getJobsPageHandler(req: Request, res: Response) {
return res.render('jobs.html', {
path: '/jobs',
layout: '../layouts/auth.html',
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import {
postNotificationHandler,
getHomePageHandler,
getAppsPageHandler,
getJobsPageHandler,
getNotificationsPageHandler,
postCreateAppHandler,
getNewAppChannelPageHandler,
getAppPageHandler,
getTermsOfServicePageHandler,
getSettingsPageHandler,
getProfilePageHandler,
getLogoutHandler,
getCreateNewAppPageHandler,
getAppNotificationsPageHandler,
Expand Down Expand Up @@ -45,7 +46,9 @@ router.get('/apps/:id/notifications', catchAsyncErrorMiddleware(getAppNotificati

router.get('/settings', catchAsyncErrorMiddleware(getSettingsPageHandler));

router.get('/profile', catchAsyncErrorMiddleware(getProfilePageHandler));
router.get('/jobs', catchAsyncErrorMiddleware(getJobsPageHandler));

router.get('/notifications', catchAsyncErrorMiddleware(getNotificationsPageHandler));

router.get('/logout', catchAsyncErrorMiddleware(getLogoutHandler));

Expand Down
9 changes: 4 additions & 5 deletions src/views/components/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ <h1><a href="/">Notify</a></h1>

<nav style="display: flex; justify-content: space-between; align-items: center;">
<div style="display: flex; align-items: center; gap: 10px;">
<a style="font-weight: <%= path === '/apps' ? 'bold' : 'normal' %>;" href="/apps">Apps</a>
<a style="font-weight: <%= path === '/jobs' ? 'bold' : 'normal' %>;" href="/jobs">Jobs</a>
<a style="font-weight: <%= path === '/notifications' ? 'bold' : 'normal' %>;" href="/notifications">Notifications</a>
<a style="font-weight: <%= path === '/apps' ? 'bold' : 'normal' %>; text-decoration: <%= path === '/apps' ? 'underline' : 'none' %>;" href="/apps">Apps</a>
<a style="font-weight: <%= path === '/jobs' ? 'bold' : 'normal' %>; text-decoration: <%= path === '/jobs' ? 'underline' : 'none' %>;" href="/jobs">Jobs</a>
<a style="font-weight: <%= path === '/notifications' ? 'bold' : 'normal' %>; text-decoration: <%= path === '/notifications' ? 'underline' : 'none' %>;" href="/notifications">Notifications</a>
</div>

<div style="display: flex; align-items: center; gap: 10px;">
<a style="font-weight: <%= path === '/profile' ? 'bold' : 'normal' %>;" href="/profile">Profile</a>
<a style="font-weight: <%= path === '/settings' ? 'bold' : 'normal' %>;" href="/settings">Settings</a>
<a style="font-weight: <%= path === '/settings' ? 'bold' : 'normal' %>; text-decoration: <%= path === '/settings' ? 'underline' : 'none' %>;" href="/settings">Settings</a>
<a href="/logout">Logout</a>
</div>
</nav>
Expand Down
10 changes: 5 additions & 5 deletions src/views/layouts/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
<html lang="en">
<%- include('../components/head.html') %>

<body style="display: flex; flex-direction: column; gap: 10px; min-height: 100vh;">
<body style="display: flex; flex-direction: column; gap: 20px; min-height: 100vh;">
<%- include('../components/header.html') %>

<main style="flex: 1; display: flex; flex-direction: column; gap: 10px;">
<h2 >Apps / <%= app.id %></h2>
<h2>Apps / <%= app.id %></h2>

<div style="display: grid; grid-template-columns: 20% 80%;">
<aside style="display: inline-block;">
<div style="display: flex; flex-direction: column; gap: 5px">
<a style="font-weight: <%= path === `/apps/${app.id}` ? 'bold' : 'normal' %>;" href="/apps/<%= app.id %>">App</a>
<a style="font-weight: <%= /\/apps\/.*\/channels/.test(path) ? 'bold' : 'normal' %>;" href="/apps/<%= app.id %>/channels">Channels</a>
<a style="font-weight: <%= /\/apps\/.*\/notifications/.test(path) ? 'bold' : 'normal' %>;" href="/apps/<%= app.id %>/notifications">Notifications</a>
<a style="font-weight: <%= path === `/apps/${app.id}` ? 'bold' : 'normal' %>; text-decoration: <%= path === `/apps/${app.id}` ? 'underline' : 'none' %>;" href="/apps/<%= app.id %>">App</a>
<a style="font-weight: <%= /\/apps\/.*\/channels/.test(path) ? 'bold' : 'normal' %>; text-decoration: <%= /\/apps\/.*\/channels/.test(path) ? 'underline' : 'none' %>;" href="/apps/<%= app.id %>/channels">Channels</a>
<a style="font-weight: <%= /\/apps\/.*\/notifications/.test(path) ? 'bold' : 'normal' %>; text-decoration: <%= /\/apps\/.*\/notifications/.test(path) ? 'underline' : 'none' %>;" href="/apps/<%= app.id %>/notifications">Notifications</a>
</div>
</aside>

Expand Down
2 changes: 1 addition & 1 deletion src/views/layouts/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<%- include('../components/head.html') %>

<body style="display: flex; flex-direction: column; gap: 10px; min-height: 100vh;">
<body style="display: flex; flex-direction: column; gap: 20px; min-height: 100vh;">
<%- include('../components/header.html') %>

<main style="flex: 1;">
Expand Down
4 changes: 4 additions & 0 deletions src/views/pages/jobs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<h2>Jobs</h2>
<p>jobs</p>
</div>
4 changes: 4 additions & 0 deletions src/views/pages/notifications.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<h2>Notifications</h2>
<p>notifications</p>
</div>
4 changes: 0 additions & 4 deletions src/views/pages/profile.html

This file was deleted.

0 comments on commit 09e905a

Please sign in to comment.