Files
mesreleves-php/resources/views/admin/utilisateurs/index.blade.php
T
yann64 c790691200 Étape 10 : interface admin (tableau de bord + gestion utilisateurs)
- DashboardController : stats globales (sources par statut, relevés, utilisateurs, activité mensuelle 6 mois)
- UserController : liste filtrée (nom/email/rôle) + édition de rôle avec protections (auto-demotion, dernier admin)
- Vue admin/dashboard : compteurs par statut cliquables, graphique barres mensuel, sources à valider, relevés récents
- Vue admin/utilisateurs : liste paginée avec sections et sources assignées, page d'édition avec radio-cards
- Dashboard principal enrichi : bloc accès admin, mes sources assignées triées par urgence, mes derniers relevés
- Navigation : ajout Tableau de bord admin et Utilisateurs dans le menu Administration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 17:21:50 +02:00

117 lines
6.3 KiB
PHP

<x-app-layout>
<x-slot name="header">
<h2 class="text-xl font-semibold text-gray-800">Gestion des utilisateurs</h2>
</x-slot>
<div class="py-8 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
{{-- Filtres --}}
@php $hasFilters = request()->anyFilled(['role', 'q']); @endphp
<div class="bg-white 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-[200px]">
<label class="block text-xs font-medium text-gray-600 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 shadow-sm text-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div class="w-52">
<label class="block text-xs font-medium text-gray-600 mb-1">Rôle</label>
<select name="role"
class="block w-full rounded-md border-gray-300 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="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 text-gray-600 text-sm rounded-md hover:bg-gray-50">
Effacer
</a>
@endif
</div>
</form>
</div>
{{-- Tableau --}}
<div class="bg-white shadow rounded-lg overflow-hidden">
<table class="min-w-full divide-y divide-gray-200 text-sm">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Nom</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">E-mail</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Rôle</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Sections</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Sources assignées</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Inscrit le</th>
<th class="px-6 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@forelse($users as $user)
@php
$roleColors = [
'admin' => 'bg-red-100 text-red-700',
'section_manager' => 'bg-blue-100 text-blue-700',
'member' => 'bg-gray-100 text-gray-600',
];
$color = $roleColors[$user->role->value] ?? 'bg-gray-100 text-gray-600';
@endphp
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 font-medium text-gray-900">
{{ $user->name }}
@if($user->id === auth()->id())
<span class="ml-1 text-xs text-gray-400">(vous)</span>
@endif
</td>
<td class="px-6 py-4 text-gray-500">{{ $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">
@if($user->sections->isNotEmpty())
{{ $user->sections->pluck('nom')->join(', ') }}
@else
@endif
</td>
<td class="px-6 py-4 text-gray-500">{{ $user->sources_assignees_count ?: '—' }}</td>
<td class="px-6 py-4 text-gray-500 whitespace-nowrap">
{{ $user->created_at->format('d/m/Y') }}
</td>
<td class="px-6 py-4 text-right">
@if($user->id !== auth()->id())
<a href="{{ route('admin.utilisateurs.edit', $user) }}"
class="text-indigo-600 hover:underline text-sm">
Modifier
</a>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="7" class="px-6 py-10 text-center text-gray-400">
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>