<?php
/** @var \lim\req $_req */
$nav = $_view["nav"];

$navItems = $nav->getItems();
$activeItem = $nav->getActiveItem();
$activeSubItem = $nav->getActiveSubItem();
$breadcrumbs = $nav->getAllBreadcrumbs();
$breadcrumbs[array_keys($breadcrumbs)[0]] = "Startseite";
?>

<nav class="navbar fixed-top navbar-expand-lg" role="navigation">
    <div class="container"> 
        <a class="navbar-brand" href="<?= $_con->getLink();?>">
            <img src="<?= $_con->getLink(["assets", "images" ,"logo.svg"]);?>" width="133" height="48" class="logo-nav" alt="2bgood Logo">
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar2bgood" aria-controls="navbar2bgood" aria-expanded="false"
            aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>
        <div class="collapse navbar-collapse" id="navbar2bgood">
            <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                <?php foreach ($navItems as $name => $item) { ?>
                    <?php if (!empty($item["subItems"])) { ?>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle<?= $name == $activeItem ? " active" : "" ?>" href="#" role="button" data-bs-toggle="dropdown"
                                aria-expanded="false"><?= $item["label"]; ?></a>
                            <ul class="dropdown-menu">
                                <?php foreach ($item["subItems"] as $subName => $subItem) { ?>
                                <li>
                                    <a class="dropdown-item <?=  $name == $activeItem && $subName == $activeSubItem ? " active" : "" ?>"
                                        href="<?= $subItem["link"] ?>"><?= $subItem["label"]; ?></a>
                                </li>
                                <?php } ?>
                            </ul>
                        </li>
                    <?php } else { ?>
                        <li class="nav-item"> <a class="nav-link<?= $name == $activeItem ? " active" : "" ?>" href="<?= $item["link"]; ?>"><?= $item["label"]; ?></a> </li>
                    <?php } ?>
                <?php } ?>

                <li class="nav-item">
                    <a href="<?= $_con->getLink(["interview"]); ?>" class="btn sm btn-primary score ico right ms-0 ms-lg-4">
                        Score <span class="small-menu-remove"><?= $_con->interviewExists ? "aktualisieren" : "erstellen"; ?></span><span class="icon"></span>
                    </a>
                </li>

            </ul>
        </div>
    </div>
</nav>
<nav class="d-none d-lg-block" style="--bs-breadcrumb-divider: '»';" aria-label="breadcrumb">
    <div class="container">
        <ol class="breadcrumb txt-small">
            <?php foreach ($breadcrumbs as $link => $label) { ?>
                <li class="breadcrumb-item<?= array_key_last($breadcrumbs) == $link ? " active" : ""; ?>" aria-current="page">
                    <a href="<?= $link;?>"><?= $label;?></a>
                </li>
            <?php } ?>
        </ol>
    </div>
</nav>