Add cancel snooze
- Add common request validation function
This commit is contained in:
1 parent
d6e8cf66cc
commit
9421bb2035
11 files changed
+96
-83
No files matched your search
@@ -3,12 +3,8 @@
|
||||
use MyPrayerJournal\{Auth, Layout, Request};
|
||||
|
||||
require '../../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
$req = validate_request($_GET['id'], ['GET'], false);
|
||||
|
||||
Layout::bareHead(); ?>
|
||||
<form hx-post="/request/note?id=<?=$req->id?>">
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Layout, Request, UI};
|
||||
use MyPrayerJournal\{Layout, UI};
|
||||
|
||||
require '../../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
$req = validate_request($_GET['id'], ['GET'], false);
|
||||
|
||||
Layout::bareHead();?>
|
||||
<p class=text-center><strong>Prior Notes for This Request</strong><?php
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Layout, Request};
|
||||
use MyPrayerJournal\Layout;
|
||||
|
||||
require '../../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
$req = validate_request($_GET['id'], ['GET'], false);
|
||||
|
||||
Layout::bareHead(); ?>
|
||||
<form hx-patch="/request/snooze?id=<?=$req->id?>" hx-target=#journalItems hx-swap=outerHTML>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Layout, Table, UI};
|
||||
use BitBadger\PDODocument\RemoveFields;
|
||||
|
||||
require '../../../start.php';
|
||||
|
||||
$req = validate_request($_GET['id'], ['GET'], false);
|
||||
|
||||
RemoveFields::byId(Table::REQUEST, $req->id, ['snoozedUntil']);
|
||||
|
||||
// TODO: message
|
||||
Layout::bareHead();
|
||||
UI::requestItem($req);
|
||||
Layout::bareFoot();
|
||||
@@ -1,14 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, History, Layout, Note, Request, RequestAction, UI};
|
||||
use MyPrayerJournal\{History, Layout, Note, RequestAction, UI};
|
||||
|
||||
require '../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'GET') not_found();
|
||||
|
||||
Auth::requireUser();
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
$req = validate_request($_GET['id'], ['GET']);
|
||||
|
||||
$answered = $req->isAnswered() ? new DateTimeImmutable($req->history[0]->asOf) : null;
|
||||
$prayed = sizeof(array_filter($req->history, fn(History $hist) => $hist->action == RequestAction::Prayed));
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Note, Request, Table};
|
||||
use MyPrayerJournal\{Note, Table};
|
||||
use BitBadger\PDODocument\Patch;
|
||||
|
||||
require '../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'POST') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
$req = validate_request($_GET['id'], ['POST'], false);
|
||||
|
||||
array_unshift($req->notes, new Note((new DateTimeImmutable('now'))->format('c'), $_POST['notes']));
|
||||
Patch::byId(Table::REQUEST, $req->id, ['notes' => $req->notes]);
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, History, RecurrencePeriod, Request, RequestAction, Table, UI};
|
||||
use MyPrayerJournal\{History, RecurrencePeriod, RequestAction, Table, UI};
|
||||
use BitBadger\PDODocument\Patch;
|
||||
|
||||
require '../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'PATCH') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
|
||||
$req = validate_request($_GET['id'], ['PATCH'], false);
|
||||
$now = new DateTimeImmutable('now');
|
||||
|
||||
array_unshift($req->history, new History($now->format('c'), RequestAction::Prayed));
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\{Auth, Request, Table, UI};
|
||||
use MyPrayerJournal\{Table, UI};
|
||||
use BitBadger\PDODocument\Patch;
|
||||
|
||||
require '../../start.php';
|
||||
if ($_SERVER['REQUEST_METHOD'] <> 'PATCH') not_found();
|
||||
|
||||
Auth::requireUser(false);
|
||||
|
||||
$req = Request::byId($_GET['id']);
|
||||
if (!$req) not_found();
|
||||
$req = validate_request($_GET['id'], ['PATCH'], false);
|
||||
|
||||
$until = (new DateTimeImmutable($_PATCH['until'] . 'T00:00:00', new DateTimeZone($_REQUEST['time_zone'])))
|
||||
->setTimezone(new DateTimeZone('Etc/UTC'));
|
||||
|
||||
Reference in new issue
Block a user