<?php
/**
 * @var $content
 * @var string $resources
 * @var string $title
 * @var \kernel\CgView $view
 */

use kernel\Theme;

\Josantonius\Session\Facades\Session::start();
//$assets = new \kernel\admin_themes\default\DefaultAdminThemeAssets($resources);
Theme::$assetsCollector->registerAsset(new \kernel\admin_themes\default\DefaultAdminThemeAssets($resources));
?>
<!doctype html>
<html lang="en">
<head>
    <title><?= $title ?></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <?= $view->getMeta() ?>

    <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">

    <?php Theme::$assetsCollector->renderCss(); ?>
    <?php Theme::$assetsCollector->renderJs(body: false); ?>
</head>
<body>

<div class="wrapper d-flex align-items-stretch">
    <nav id="sidebar">
        <div class="p-4 pt-5">
            <a href="<?= '/admin/user/profile' ?>" class="img logo rounded-circle mb-5"
               style="background-image: url(<?= \kernel\modules\user\service\UserService::getAuthUserPhoto() ?? '/resources/default_user_photo/noPhoto.png' ?>);">
            </a>
            <p>
                <a href="<?= '/admin/user/profile' ?>">
                    <?= \kernel\modules\user\service\UserService::getAuthUsername() ?>
                </a>
            </p>
            <?php \kernel\widgets\MenuWidget::create()->run(); ?>
            <div class="footer">

            </div>

        </div>
    </nav>

    <!-- Page Content  -->
    <div id="content" class="p-4 p-md-5">

        <nav class="navbar navbar-expand-lg navbar-light bg-light">
            <div class="container-fluid">

                <button type="button" id="sidebarCollapse" class="btn btn-primary">
                    <i class="fa fa-bars"></i>
                    <span class="sr-only">Toggle Menu</span>
                </button>
                <button class="btn btn-dark d-inline-block d-lg-none ml-auto" type="button" data-toggle="collapse"
                        data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <i class="fa fa-bars"></i>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul class="nav navbar-nav ml-auto">
                        <li class="nav-item active">
                            <a class="nav-link" href="/admin/logout">Выход</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">About</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Portfolio</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Contact</a>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
        <?php if (\kernel\Flash::hasMessage("error")): ?>
            <div class="alert alert-danger alert-dismissible mainAlert">
                <?= \kernel\Flash::getMessage("error"); ?>
                <button type="button" class="btn-close closeAlertBtn"></button>
            </div>
        <?php endif; ?>
        <?php if (\kernel\Flash::hasMessage("success")): ?>
            <div class="alert alert-success alert-dismissible">
                <?= \kernel\Flash::getMessage("success"); ?>
                <button type="button" class="btn-close closeAlertBtn"></button>
            </div>
        <?php endif; ?>
        <?= $content ?>
    </div>
</div>

<?php Theme::$assetsCollector->renderJs(); ?>
</body>
</html>