<?php

namespace Signteer\Web\Admin\Page\Setting\EmailNotification;

use Plainwork\Http\Request;
use Plainwork\Http\Redirect;
use Plainwork\DateTime\DateTimeFormatter;
use Plainwork\Ui\Html;
use Signteer\Core\Repo\SettingRepo;
use Signteer\Core\Model\SignupFieldFinder;

final class ListEmailNotificationsPage
{
    public $repo = SettingRepo::class;
    public $fieldFinder = SignupFieldFinder::class;

    public function __invoke(Request $request)
    {
        $html = new Html();

        $ret = $html->table();

        $ret->withHeadCell('head', 'label')->setContent('__Notification__');
        $ret->withHeadCell('head', 'enabled')
            ->setContent('__Status__')
            ->setWidth(2)
            ->withAttr('class', 'pw-col-align-center')
        ;

    // confirmation
        $id = 'confirm';
        $v = '__Volunteer signup email__';
        $v = $html->link('./edit', ['message' => $id], $v);
        $v2 = '__Sent to volunteers after they sign up.__';
        $v = $html->blockList($v, $v2)->setSpacing(0);
        $ret->withCell($id, 'label')->setContent($v);
        $v = $html->el('em', '__On__');
        $ret->withCell($id, 'enabled')->setContent($v)->withAttr('class', 'pw-col-align-center');

        $ret = $html->main($ret);
        $ret->title = $html->el('h1', '__Email notifications__');

        return $ret;
    }
}
