<?php

namespace Signteer\Web\Admin;

use Plainwork\Http\Request;
use Plainwork\Ui\Html;
use Plainwork\Ui\Component\Main;

final class MainRenderer
{
    public function __invoke(Main $el, Request $request, callable $next)
    {
        $path = $request->getRequestedPath();
        if (('admin' === $path) or ('admin/' === substr($path, 0, strlen('admin/')))) {
            $html = new Html();

            $el->mainMenu
                ->add($html->link('admin/sheet', [], '__Sign-up sheets__'))
                ->add($html->link('admin/volunteer', [], '__Volunteers__'))
                // ->add($html->link('eventlog', [], '__History__'), 20)
                ->add($html->link('admin/setting', [], '__Settings__'), 80)
                ->add($html->link('admin/about', [], '__About__'), 90)
                ;
        }

        return $next($el, $request);
    }
}
