Use option for req-by-ID

This commit is contained in:
2024-06-23 17:09:56 -04:00
parent a2feaff4da
commit 5beeee4819
5 changed files with 13 additions and 16 deletions

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';