130 lines
6.6 KiB
PHP
130 lines
6.6 KiB
PHP
@php
|
|
$user = auth()->user();
|
|
$hasNav = (bool) $user?->role;
|
|
$isAdmin = $hasNav && $user->hasRole('admin');
|
|
$org = $user?->tenant?->name ?? config('signature.default_tenant.name');
|
|
$roleLabel = ['superadmin' => 'Super-administrateur', 'admin' => 'Administrateur', 'editor' => 'Éditeur'][$user?->role] ?? 'Agent';
|
|
$initials = $user ? mb_strtoupper(collect(preg_split('/[\s\-]+/u', trim($user->name)))->filter()->take(2)->map(fn ($w) => mb_substr($w, 0, 1))->join('')) : '';
|
|
// Version des fichiers statiques = date de modification : le navigateur recharge après chaque mise à jour.
|
|
$asset = fn (string $path) => asset($path).'?v='.(@filemtime(public_path($path)) ?: '1');
|
|
$nav = fn (string $route, string $pattern, string $icon, string $label) => compact('route', 'pattern', 'icon', 'label');
|
|
$links = $hasNav ? array_filter([
|
|
['group' => null, 'items' => [$nav('admin.dashboard', 'admin.dashboard', 'layout-dashboard', 'Tableau de bord')]],
|
|
['group' => 'Contenu', 'items' => [
|
|
$nav('admin.templates.index', 'admin.templates.*', 'file-code', 'Templates'),
|
|
$nav('admin.images.index', 'admin.images.*', 'images', 'Images'),
|
|
$nav('admin.campaigns.index', 'admin.campaigns.*', 'megaphone', 'Campagnes'),
|
|
]],
|
|
['group' => 'Diffusion', 'items' => array_values(array_filter([
|
|
$isAdmin ? $nav('admin.assignments.index', 'admin.assignments.*', 'users', 'Affectations') : null,
|
|
$isAdmin ? $nav('admin.fields.index', 'admin.fields.*', 'sliders-horizontal', 'Champs agents') : null,
|
|
$nav('admin.agents.index', 'admin.agents.*', 'contact', 'Agents'),
|
|
]))],
|
|
]) : [];
|
|
@endphp
|
|
<!doctype html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
<title>@yield('title', 'Signatures')</title>
|
|
<script>document.documentElement.classList.add('js');</script>
|
|
<link rel="preload" href="{{ asset('fonts/atkinson-next.woff2') }}" as="font" type="font/woff2" crossorigin>
|
|
<link rel="stylesheet" href="{{ $asset('css/app.css') }}">
|
|
</head>
|
|
<body>
|
|
<a class="skip" href="#main">Aller au contenu</a>
|
|
<div @class(['app', 'app--nav' => $hasNav])>
|
|
@auth
|
|
@if ($hasNav)
|
|
<aside class="sidebar">
|
|
<a class="brand" href="{{ route('admin.dashboard') }}">
|
|
<span class="brand-name">Signatures</span>
|
|
<svg class="brand-stroke" viewBox="0 0 104 12" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true">
|
|
<path d="M2 8c9-6 15-6 20-1s9 4 14-1 10-5 15 0 9 4 14 0 11-5 17-1 12 4 20-1"/>
|
|
</svg>
|
|
<span class="brand-org">{{ $org }}</span>
|
|
</a>
|
|
<nav class="nav" aria-label="Navigation principale">
|
|
@foreach ($links as $section)
|
|
@if ($section['group'])<p class="nav-group">{{ $section['group'] }}</p>@endif
|
|
@foreach ($section['items'] as $item)
|
|
<a href="{{ route($item['route']) }}" @class(['nav-link', 'active' => request()->routeIs($item['pattern'])])
|
|
@if (request()->routeIs($item['pattern'])) aria-current="page" @endif>
|
|
<x-icon :name="$item['icon']" />{{ $item['label'] }}
|
|
</a>
|
|
@endforeach
|
|
@endforeach
|
|
</nav>
|
|
<div class="sidebar-foot">
|
|
<a href="{{ route('portal.home') }}" @class(['nav-link', 'active' => request()->routeIs('portal.*')])>
|
|
<x-icon name="signature" />Ma signature
|
|
</a>
|
|
<div class="user">
|
|
<span class="avatar" aria-hidden="true">{{ $initials }}</span>
|
|
<span>
|
|
<span class="user-name">{{ $user->name }}</span>
|
|
<span class="user-role">{{ $roleLabel }}</span>
|
|
</span>
|
|
<form method="post" action="{{ route('logout') }}">@csrf
|
|
<button class="icon-btn" type="submit" title="Se déconnecter" aria-label="Se déconnecter"><x-icon name="log-out" /></button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
@else
|
|
<header class="topbar">
|
|
<a class="brand" href="{{ route('portal.home') }}"><span class="brand-name">Signatures</span></a>
|
|
<span class="muted" style="color:inherit">{{ $org }}</span>
|
|
<div class="user">
|
|
<span class="avatar" aria-hidden="true">{{ $initials }}</span>
|
|
<span class="user-name">{{ $user->name }}</span>
|
|
<form method="post" action="{{ route('logout') }}">@csrf
|
|
<button class="icon-btn" type="submit" title="Se déconnecter" aria-label="Se déconnecter"><x-icon name="log-out" /></button>
|
|
</form>
|
|
</div>
|
|
</header>
|
|
@endif
|
|
@endauth
|
|
|
|
<div class="content">
|
|
<main id="main">
|
|
@if (session('status'))
|
|
<div class="toasts">
|
|
<div class="toast" role="status" data-toast>
|
|
<x-icon name="circle-check" />
|
|
<span>{{ session('status') }}</span>
|
|
<button class="icon-btn" type="button" data-dismiss aria-label="Fermer"><x-icon name="x" :size="16" /></button>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
@if ($errors->any())
|
|
<div class="alert errors" role="alert">
|
|
<x-icon name="triangle-alert" />
|
|
<div>@foreach ($errors->all() as $error)<div>{{ $error }}</div>@endforeach</div>
|
|
</div>
|
|
@endif
|
|
@yield('content')
|
|
</main>
|
|
</div>
|
|
</div>
|
|
|
|
<dialog class="dialog" id="confirm-dialog" aria-labelledby="confirm-title">
|
|
<form method="dialog">
|
|
<div class="dialog-body">
|
|
<h2 id="confirm-title">Confirmer l'action</h2>
|
|
<p data-message></p>
|
|
</div>
|
|
<div class="dialog-actions">
|
|
<button class="btn secondary" value="cancel" autofocus>Annuler</button>
|
|
<button class="btn" value="ok" data-ok>Confirmer</button>
|
|
</div>
|
|
</form>
|
|
</dialog>
|
|
|
|
<script src="{{ $asset('js/app.js') }}" defer></script>
|
|
@stack('scripts')
|
|
</body>
|
|
</html>
|