add today view route and template

This commit is contained in:
Yisroel Baum 2026-04-26 21:24:35 +03:00
parent 0b4d7238af
commit bfacb5b62c
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 60 additions and 1 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@ vendor/
node_modules/
data/*.json
.direnv/
cypress/screenshots/
cypress/videos/

View file

@ -38,6 +38,16 @@ class ViewController
return $response;
}
public function today(Response $response): Response
{
$html = file_get_contents(
__DIR__ . '/../../views/templates/today.php'
);
$response->getBody()->write($html);
return $response;
}
public function login(Response $response): Response
{
$html = file_get_contents(

View file

@ -27,6 +27,7 @@ $app->post('/api/auth/register', [AuthController::class, 'register']);
// Authenticated routes (any logged-in user)
$app->group('', function (RouteCollectorProxy $group) {
$group->get('/home', [ViewController::class, 'home']);
$group->get('/today', [ViewController::class, 'today']);
$group->post('/api/auth/logout', [AuthController::class, 'logout']);
$group->get('/api/auth/me', [AuthController::class, 'me']);

33
public/js/today.js Normal file
View file

@ -0,0 +1,33 @@
document.addEventListener('DOMContentLoaded', () => {
const scheduledNodesList = document.getElementById(
'scheduled-nodes-list'
);
function todayDateString() {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0');
const day = String(today.getDate()).padStart(2, '0');
return year + '-' + month + '-' + day;
}
async function loadScheduledNodes() {
const date = todayDateString();
const response = await fetch(
'/api/scheduled-nodes?date=' + date,
{ credentials: 'same-origin' }
);
if (!response.ok) {
return;
}
const scheduledNodes = await response.json();
scheduledNodesList.innerHTML = scheduledNodes
.map((scheduledNode) =>
'<li>' + scheduledNode.planName + ': ' +
scheduledNode.nodeTitle + '</li>'
)
.join('');
}
loadScheduledNodes();
});

13
views/templates/today.php Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Daily Goals - Today</title>
</head>
<body>
<h1>Today</h1>
<ul id="scheduled-nodes-list">
</ul>
<script src="/js/auth.js"></script>
<script src="/js/today.js"></script>
</body>
</html>