From d6e8cf66cc236a8e15af289761899bd5a7ecbe2f Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Sat, 22 Jun 2024 22:48:31 -0400 Subject: [PATCH] Finish req list, add snoozed list --- src/MyPrayerJournal/Handlers.fs | 6 ++--- src/lib/Layout.php | 15 ++++++++++-- src/lib/Request.php | 17 ++++++++++++-- src/lib/UI.php | 41 ++++++++++++++++++--------------- src/public/requests/snoozed.php | 22 ++++++++++++++++++ 5 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 src/public/requests/snoozed.php diff --git a/src/MyPrayerJournal/Handlers.fs b/src/MyPrayerJournal/Handlers.fs index a36a389..b6b3792 100644 --- a/src/MyPrayerJournal/Handlers.fs +++ b/src/MyPrayerJournal/Handlers.fs @@ -530,7 +530,7 @@ let routes = [ routef "request/%s/add-notes" Components.addNotes // done routef "request/%s/item" Components.requestItem // not used routef "request/%s/notes" Components.notes // done - routef "request/%s/snooze" Components.snooze + routef "request/%s/snooze" Components.snooze // done ] ] GET_HEAD [ route "/docs" Home.docs ] // done @@ -547,14 +547,14 @@ let routes = [ routef "/%s/full" Request.getFull // done route "s/active" Request.active // done route "s/answered" Request.answered // done - route "s/snoozed" Request.snoozed + route "s/snoozed" Request.snoozed // done ] PATCH [ route "" Request.update // done routef "/%s/cancel-snooze" Request.cancelSnooze routef "/%s/prayed" Request.prayed // done routef "/%s/show" Request.show - routef "/%s/snooze" Request.snooze + routef "/%s/snooze" Request.snooze // done ] POST [ route "" Request.add // done diff --git a/src/lib/Layout.php b/src/lib/Layout.php index a0e90bc..11abe8a 100644 --- a/src/lib/Layout.php +++ b/src/lib/Layout.php @@ -2,6 +2,9 @@ namespace MyPrayerJournal; +use BitBadger\PDODocument\Custom; +use BitBadger\PDODocument\Mapper\ExistsMapper; + class Layout { /** @@ -72,7 +75,15 @@ class Layout * The default navigation bar, which will load the items on page load, and whenever a refresh event occurs */ public static function navBar(): void - { ?> + { + $table = Table::REQUEST; + $hasSnoozed = key_exists('user_id', $_SESSION) + ? Custom::scalar(<<>'userId' = :userId AND datetime(data->>'snoozedUntil') > datetime('now')) + SQL, [':userId' => $_SESSION['user_id']], new ExistsMapper()) + : false; ?>