Migrate v3 data; WIP on journal items
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use BitBadger\PDODocument\{Custom, Query};
|
||||
use BitBadger\PDODocument\Mapper\DocumentMapper;
|
||||
use MyPrayerJournal\{Auth,History,Layout,Request,Table};
|
||||
|
||||
require '../../start.php';
|
||||
|
||||
Auth::requireUser(false);
|
||||
bare_head();
|
||||
|
||||
$reqs = Custom::list(
|
||||
Query::selectFromTable(Table::REQUEST) . " WHERE data->>'userId' = :userId AND data->>'$.history[0].action' <> 'Answered'",
|
||||
[':userId' => Auth::user()['sub']], new DocumentMapper(Request::class));
|
||||
|
||||
if ($reqs->hasItems()) { ?>
|
||||
<section id=journalItems class="row row-cols-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-4 g-3" hx-target=this
|
||||
hx-swap=outerHTML aria-label="Prayer Requests"><?php
|
||||
$spacer = '<span> </span>';
|
||||
foreach ($reqs->items() as /** @var Request $req */ $req) {
|
||||
$withText = array_filter($req->history, fn($hist) => isset($hist->text));
|
||||
$text = $withText[array_key_first($withText)]->text; ?>
|
||||
<div class=col>
|
||||
<div class="card h-100">
|
||||
<div class="card-header p-0 d-flex" role=toolbar><?php
|
||||
page_link("/request/edit?id=$req->id", icon('edit'),
|
||||
['class' => 'btn btn-secondary', 'title' => 'Edit Request']); ?>
|
||||
<?=$spacer?>
|
||||
<button type=button class="btn btn-secondary" title="Add Notes" data-bs-toggle=modal
|
||||
data-bs-target=#notesModal hx-get="/components/request/add-notes?id=<?=$req->id?>"
|
||||
hx-target=#notesBody hx-swap=innerHTML><?=icon('comment');?></button>
|
||||
<?=$spacer?>
|
||||
<button type=button class="btn btn-secondary" title="Snooze Request" data-bs-toggle=modal
|
||||
data-bs-target=#snoozeModal hx-get="/components/request/snooze?id=<?=$req->id?>"
|
||||
hx-target=#snoozeBody hx-swap=innerHTML><?=icon('schedule');?></button>
|
||||
<div class=flex-grow-1></div>
|
||||
<button type=button class="btn btn-success w-25" hx-patch="/request/prayed?id=<?=$req->id?>"
|
||||
title="Mark as Prayed"><?=icon('done');?></button>
|
||||
</div>
|
||||
<div class=card-body>
|
||||
<p class=request-text><?=htmlentities($text);?>
|
||||
</div>
|
||||
<div class="card-footer text-end text-muted px-1 py-0">
|
||||
<em>last activity <?=$req->history[0]->asOf?></em>
|
||||
<?php /*
|
||||
TODO: relative time
|
||||
[] [
|
||||
match req.LastPrayed with
|
||||
| Some dt -> str "last prayed "; relativeDate dt now tz
|
||||
| None -> str "last activity "; relativeDate req.AsOf now tz
|
||||
] */ ?>
|
||||
</div>
|
||||
</div>
|
||||
</div><?php
|
||||
} ?>
|
||||
</section><?php
|
||||
} else {
|
||||
Layout::noResults('No Active Requests', '/request/edit?id=new', 'Add a Request', <<<'TEXT'
|
||||
You have no requests to be shown; see the “Active” link above for snoozed or deferred requests, and
|
||||
the “Answered” link for answered requests
|
||||
TEXT);
|
||||
}
|
||||
|
||||
bare_foot();
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use MyPrayerJournal\Auth;
|
||||
|
||||
require '../start.php';
|
||||
|
||||
Auth::requireUser();
|
||||
|
||||
$user = Auth::user();
|
||||
$name = $user['first_name'] ?? 'Your';
|
||||
page_head('Welcome'); ?>
|
||||
<article class="container-fluid mt-3">
|
||||
<h2 class=pb-3><?=$name?><?=$name == 'Your' ? '' : '’s'?> Prayer Journal</h2>
|
||||
<p class="pb-3 text-center"><?php
|
||||
page_link('/request/new/edit', icon('add_box') . ' Add a Prayer Request', ['class' => 'btn btn-primary']); ?>
|
||||
<p hx-get=/components/journal-items hx-swap=outerHTML hx-trigger=load hx-target=this>
|
||||
Loading your prayer journal…
|
||||
<div id=notesModal class="modal fade" tabindex=-1 aria-labelledby=nodesModalLabel aria-hidden=true>
|
||||
<div class="modal-dialog modal-dialog-scrollable">
|
||||
<div class=modal-content>
|
||||
<div class=modal-header>
|
||||
<h5 class=modal-title id=nodesModalLabel>Add Notes to Prayer Request</h5>
|
||||
<button type=button class=btn-close data-bs-dismiss=modal aria-label=Close></button>
|
||||
</div>
|
||||
<div class=modal-body id=notesBody></div>
|
||||
<div class=modal-footer>
|
||||
<button type=button id=notesDismiss class="btn btn-secondary" data-bs-dismiss=modal>Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id=snoozeModal class="modal fade" tabindex=-1 aria-labelledby=snoozeModalLabel aria-hidden=true>
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class=modal-content>
|
||||
<div class=modal-header>
|
||||
<h5 class=modal-title id=snoozeModalLabel>Snooze Prayer Request</h5>
|
||||
<button type=button class=btn-close data-bs-dismiss=modal aria-label=Close></button>
|
||||
</div>
|
||||
<div class=modal-body id=snoozeBody></div>
|
||||
<div class=modal-footer>
|
||||
<button type=button id=snoozeDismiss class="btn btn-secondary" data-bs-dismiss=modal>Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article><?php
|
||||
page_foot();
|
||||
|
||||
@@ -7,5 +7,5 @@ require '../../../start.php';
|
||||
Auth::client()->exchange($_ENV['AUTH0_BASE_URL'] . '/user/log-on/success');
|
||||
|
||||
// TODO: get the possible redirect URL
|
||||
header('Location: /');
|
||||
header('Location: /journal');
|
||||
exit();
|
||||
|
||||
Reference in New Issue
Block a user