Use option for req-by-ID

This commit is contained in:
danieljsummers committed 2024-06-23 17:09:56 -04:00
1 parent a2feaff4da
commit 5beeee4819
5 files changed
+13 -16

No files matched your search

+4 -5
View File
@@ -13,14 +13,13 @@ $isNew = $_GET['id'] == 'new';
$req = match ($isNew) {
true => new Request('new'),
false => Request::byId($_GET['id'])
false => Request::byId($_GET['id'])->getOrCall(not_found(...))
};
if (!$req) not_found();
$cancelLink = match (true) {
str_ends_with($_SERVER['HTTP_REFERER'] ?? '', 'active.php') => '/requests/active',
str_ends_with($_SERVER['HTTP_REFERER'] ?? '', 'snoozed.php') => '/requests/snoozed',
default => '/journal'
str_ends_with($_SERVER['HTTP_REFERER'] ?? '', 'active') => '/requests/active',
str_ends_with($_SERVER['HTTP_REFERER'] ?? '', 'snoozed') => '/requests/snoozed',
default => '/journal'
};
$action = $_GET['id'] == 'new' ? 'Add' : 'Edit';
+1 -2
View File
@@ -26,8 +26,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
see_other('/journal');
case 'PATCH':
$req = Request::byId($_PATCH['requestId']);
if (!$req) not_found();
$req = Request::byId($_PATCH['requestId'])->getOrCall(not_found(...));
$patch = [];
// update recurrence if changed
if ($recurrence != $req->recurrence) {