e835bab7df
- Vues admin/utilisateurs : route() utilisait $user sans clé nommée ;
Laravel ne résout pas automatiquement un modèle vers un paramètre
{utilisateur} (nom non-anglais) — remplacé par ['utilisateur' => $user]
dans edit.blade.php, index.blade.php et UserController::store()
- Carte : ajout de position:relative + z-index:0 sur #carte-map pour
créer un contexte d'empilement qui confine les z-indexes internes de
Leaflet (≤800) et laisse le menu (z-index:40) s'afficher par-dessus
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
187 lines
12 KiB
PHP
187 lines
12 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-xl font-semibold text-gray-800 dark:text-gray-200">Gestion des utilisateurs</h2>
|
|
<div class="flex items-center gap-3">
|
|
<a href="{{ route('admin.utilisateurs.create') }}"
|
|
class="flex items-center gap-1.5 px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700 transition-colors">
|
|
+ Nouvel utilisateur
|
|
</a>
|
|
<a href="{{ route('admin.utilisateurs.import') }}"
|
|
class="flex items-center gap-1.5 px-4 py-2 border border-gray-300 dark:border-gray-600 text-sm text-gray-700 dark:text-gray-300 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
|
|
</svg>
|
|
Importer CSV
|
|
</a>
|
|
<a href="{{ route('admin.utilisateurs.export', request()->only(['role', 'status', 'q'])) }}"
|
|
class="flex items-center gap-1.5 px-4 py-2 border border-gray-300 dark:border-gray-600 text-sm text-gray-700 dark:text-gray-300 rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4 4m0 0l4 4m-4-4h12"/>
|
|
</svg>
|
|
Exporter CSV
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</x-slot>
|
|
|
|
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
|
|
|
@if(session('success'))
|
|
<div class="p-4 bg-green-50 dark:bg-green-900/30 border border-green-200 dark:border-green-700 text-green-800 dark:text-green-200 text-sm rounded-md">
|
|
{{ session('success') }}
|
|
</div>
|
|
@endif
|
|
@if(session('error'))
|
|
<div class="p-4 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-700 text-red-800 dark:text-red-200 text-sm rounded-md">
|
|
{{ session('error') }}
|
|
</div>
|
|
@endif
|
|
|
|
{{-- Filtres --}}
|
|
@php $hasFilters = request()->anyFilled(['role', 'q', 'status']); @endphp
|
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg p-5">
|
|
<form method="GET" action="{{ route('admin.utilisateurs.index') }}"
|
|
class="flex flex-wrap items-end gap-4">
|
|
<div class="flex-1 min-w-[180px]">
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Recherche</label>
|
|
<input type="text" name="q" value="{{ request('q') }}"
|
|
placeholder="Nom ou e-mail…"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm
|
|
focus:border-indigo-500 focus:ring-indigo-500">
|
|
</div>
|
|
|
|
<div class="w-44">
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Rôle</label>
|
|
<select name="role"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm
|
|
focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">— Tous —</option>
|
|
@foreach(\App\Enums\UserRole::cases() as $r)
|
|
<option value="{{ $r->value }}" {{ request('role') === $r->value ? 'selected' : '' }}>
|
|
{{ $r->label() }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<div class="w-40">
|
|
<label class="block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1">Statut</label>
|
|
<select name="status"
|
|
class="block w-full rounded-md border-gray-300 dark:border-gray-600 shadow-sm text-sm
|
|
focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">— Tous —</option>
|
|
<option value="active" {{ request('status') === 'active' ? 'selected' : '' }}>Actifs</option>
|
|
<option value="inactive" {{ request('status') === 'inactive' ? 'selected' : '' }}>Inactifs</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3">
|
|
<button type="submit"
|
|
class="px-5 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700">
|
|
Filtrer
|
|
</button>
|
|
@if($hasFilters)
|
|
<a href="{{ route('admin.utilisateurs.index') }}"
|
|
class="px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm rounded-md hover:bg-gray-50 dark:hover:bg-gray-700">
|
|
Effacer
|
|
</a>
|
|
@endif
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
{{-- Tableau --}}
|
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg overflow-hidden">
|
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700 text-sm">
|
|
<thead class="bg-gray-50 dark:bg-gray-700">
|
|
<tr>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Nom</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">E-mail</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Rôle</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Sections</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Sources</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase">Inscrit le</th>
|
|
<th class="px-6 py-3"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
|
|
@forelse($users as $user)
|
|
@php
|
|
$roleColors = [
|
|
'admin' => 'bg-red-100 dark:bg-red-900/50 text-red-700',
|
|
'section_manager' => 'bg-blue-100 dark:bg-blue-900/50 text-blue-700',
|
|
'member' => 'bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400',
|
|
];
|
|
$color = $roleColors[$user->role->value] ?? 'bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400';
|
|
@endphp
|
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700 {{ ! $user->is_active ? 'opacity-60' : '' }}">
|
|
<td class="px-6 py-4 font-medium text-gray-900 dark:text-white">
|
|
{{ $user->name }}
|
|
@if($user->id === auth()->id())
|
|
<span class="ml-1 text-xs text-gray-400 dark:text-gray-500">(vous)</span>
|
|
@endif
|
|
@if(! $user->is_active)
|
|
<span class="ml-2 inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-red-100 dark:bg-red-900/50 text-red-600">
|
|
Inactif
|
|
</span>
|
|
@endif
|
|
</td>
|
|
<td class="px-6 py-4 text-gray-500 dark:text-gray-400">{{ $user->email }}</td>
|
|
<td class="px-6 py-4">
|
|
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium {{ $color }}">
|
|
{{ $user->role->label() }}
|
|
</span>
|
|
</td>
|
|
<td class="px-6 py-4 text-gray-500 dark:text-gray-400">
|
|
{{ $user->sections->isNotEmpty() ? $user->sections->pluck('nom')->join(', ') : '—' }}
|
|
</td>
|
|
<td class="px-6 py-4 text-gray-500 dark:text-gray-400">{{ $user->sources_assignees_count ?: '—' }}</td>
|
|
<td class="px-6 py-4 text-gray-500 dark:text-gray-400 whitespace-nowrap">
|
|
{{ $user->created_at->format('d/m/Y') }}
|
|
</td>
|
|
<td class="px-6 py-4 text-right space-x-3">
|
|
<a href="{{ route('admin.utilisateurs.edit', ['utilisateur' => $user]) }}"
|
|
class="text-indigo-600 hover:underline text-sm">Modifier</a>
|
|
@if($user->id !== auth()->id())
|
|
<form method="POST"
|
|
action="{{ route('admin.utilisateurs.toggle-active', ['utilisateur' => $user]) }}"
|
|
class="inline" x-data
|
|
@submit.prevent="if(confirm('{{ $user->is_active ? 'Désactiver' : 'Activer' }} ce compte ?')) $el.submit()">
|
|
@csrf
|
|
<button type="submit"
|
|
class="text-sm {{ $user->is_active ? 'text-orange-500 hover:text-orange-700' : 'text-green-600 hover:text-green-700' }}">
|
|
{{ $user->is_active ? 'Désactiver' : 'Activer' }}
|
|
</button>
|
|
</form>
|
|
<form method="POST"
|
|
action="{{ route('admin.utilisateurs.destroy', ['utilisateur' => $user]) }}"
|
|
class="inline" x-data
|
|
@submit.prevent="if(confirm('Supprimer définitivement {{ addslashes($user->name) }} ?')) $el.submit()">
|
|
@csrf @method('DELETE')
|
|
<button type="submit" class="text-sm text-red-500 hover:text-red-700">
|
|
Supprimer
|
|
</button>
|
|
</form>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="7" class="px-6 py-10 text-center text-gray-400 dark:text-gray-500">
|
|
Aucun utilisateur trouvé.
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
@if($users->hasPages())
|
|
<div class="px-6 py-4 border-t">{{ $users->links() }}</div>
|
|
@endif
|
|
</div>
|
|
|
|
</div>
|
|
</x-app-layout>
|