@inherits LayoutComponentBase
@using BlazorBootstrap;
@using HerramientaCASA.Model
@using Microsoft.AspNetCore.Components.Web
@inject NavigationManager Navigation
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
@inject ProtectedLocalStorage ProtectedLocalStore


<head>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" />
    <link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
    <link href="_content/Blazor.Bootstrap/Blazor.Bootstrap.bundle.scp.css" rel="stylesheet" />
    <link href="Content/Site.css?v=0.16" rel="stylesheet" />
    <link href="Content/all.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <script src="Scripts/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
    <!-- Add chart.js reference if chart components are used in your application. -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <!-- Add chartjs-plugin-datalabels.min.js reference if chart components with data label feature is used in your application. -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <!-- Add sortable.js reference if SortableList component is used in your application. -->
    <script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
    <script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
    <script src="Scripts/popper.min.js"></script>
    <script src="Scripts/all.min.js"></script>
    <script src="Scripts/Util.js"></script>
</head>

<div class="page">
    <main style="height: 100%;">
        <header class="d-none d-md-block">
            <div class="pa-header-t1">
                <div class="pa-header-row1">
                    <nav class="navbar navbar-expand-lg navbar-light fixed-top bg-light" style="background-color:white !important">
                        <div class="container-fluid">
                            <div>
                                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#topMenu" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                                    <span class="navbar-toggler-icon"></span>
                                </button>
                                <a class="navbar-brand" href="https://www.cacoa.es/">
                                    <img src="Content/Imagenes/logo_CACOA_alta.jpg" style="height: 40px" />
                                </a>
                            </div>
                            <div class="collapse navbar-collapse" id="topMenu">
                                <ul class="navbar-nav mr-auto ulMenu">
                                    <li id="liPC" class="nav-item">
                                        <NavLink class="nav-link" href="PanelControlConf">Menú</NavLink>
                                    </li>
                                    <li id="liCC" class="nav-item">
                                        <NavLink class="nav-link" href="Variables">Variables</NavLink>
                                    </li>
                                    <li id="liCS" class="nav-item">
                                        <NavLink class="nav-link" href="Enumeraciones">Enumeraciones</NavLink>
                                    </li>

                                    <li id="liCB" class="nav-item">
                                        <NavLink class="nav-link" href="FactoresCorreccion">Factores Corrección</NavLink>
                                    </li>

                                    <li id="liMS" class="nav-item">
                                        <NavLink class="nav-link" href="TipologiasConf">Tipologías</NavLink>
                                    </li>
                                    <li id="liMS" class="nav-item">
                                        <NavLink class="nav-link" href="ConvenioColectivo">Convenio Colectivo</NavLink>
                                    </li>
                                    <li id="liMS" class="nav-item">
                                        <NavLink class="nav-link" href="DocumentosUrban">Documentos URBAN</NavLink>
                                    </li>
                                    <li id="liMS" class="nav-item">
                                        <NavLink class="nav-link" href="CalculoCDCI">Calculo CD+CI</NavLink>
                                    </li>
                                </ul>
                            </div>
                            <div class="ml-auto">
                                <ul class="navbar-nav mr-auto ulMenu">
                                    <li class="nav-item">
                                        <NavLink class="nav-link headNav" href="/"> <i class="fas fa-user-slash"></i>Cerrar Sesión</NavLink>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </nav>
                </div>
            </div>
        </header>
        <div class="pagina">
            @Body
        </div>
    </main>
</div>


    @code {
        

    protected override async Task OnInitializedAsync()
    {
        var obtenerDatoAdmin = await ProtectedLocalStore.GetAsync<bool>("EsAdmin");
        var obtenerDatoId = await ProtectedLocalStore.GetAsync<int>("idUsuario");
        // Redirigir al home si no hay token y la ruta no es pública
        if (obtenerDatoId.Value == 0 || !obtenerDatoAdmin.Value)
        {
            Navigation.NavigateTo("/", true);
        }
    }
    }
