<?php declare(strict_types=1);

use BitBadger\PDODocument\Patch;
use MyPrayerJournal\Table;
use MyPrayerJournal\UI\Component;

require '../../start.php';

$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'));
Patch::byId(Table::REQUEST, $req->id, ['snoozedUntil' => $until->format('c')]);

// TODO: message

hide_modal('snooze');
Component::journal();