Files
termanager2/resources/views/livewire/settings/users-index.blade.php

102 lines
5.8 KiB
PHP

<div class="space-y-6">
<div>
<h1 class="text-2xl font-bold text-gray-900">Utenti</h1>
<p class="text-sm text-gray-500 mt-1">Crea utenti e assegna i permessi applicativi.</p>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4">Nuovo utente</h2>
<form wire:submit="createUser" class="space-y-5">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="name" class="block text-sm font-medium text-gray-700">Nome *</label>
<input wire:model="name" id="name" type="text" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
@error('name') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
</div>
<div>
<label for="email" class="block text-sm font-medium text-gray-700">Email *</label>
<input wire:model="email" id="email" type="email" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
@error('email') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700">Password *</label>
<input wire:model="password" id="password" type="password" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
@error('password') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
</div>
<div>
<label for="password_confirmation" class="block text-sm font-medium text-gray-700">Conferma Password *</label>
<input wire:model="password_confirmation" id="password_confirmation" type="password" class="mt-1 block w-full rounded-lg border-gray-300 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 text-sm">
</div>
</div>
<div>
<p class="block text-sm font-medium text-gray-700 mb-2">Permessi utente</p>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2">
@foreach($availablePermissions as $permission)
<label class="flex items-center gap-2 rounded border border-gray-200 px-3 py-2 text-sm text-gray-700 hover:bg-gray-50">
<input wire:model="selectedPermissions" type="checkbox" value="{{ $permission }}" class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
<span>{{ $permission }}</span>
</label>
@endforeach
</div>
@error('selectedPermissions.*') <p class="text-red-500 text-xs mt-1">{{ $message }}</p> @enderror
</div>
<div>
<button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 transition">Crea Utente</button>
</div>
</form>
</div>
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4">Utenti esistenti</h2>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200 text-sm">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-2 text-left font-medium text-gray-600">Nome</th>
<th class="px-4 py-2 text-left font-medium text-gray-600">Email</th>
<th class="px-4 py-2 text-left font-medium text-gray-600">Ruoli</th>
<th class="px-4 py-2 text-left font-medium text-gray-600">Permessi diretti</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($users as $user)
<tr>
<td class="px-4 py-2 text-gray-900">{{ $user->name }}</td>
<td class="px-4 py-2 text-gray-700">{{ $user->email }}</td>
<td class="px-4 py-2">
<div class="flex flex-wrap gap-1">
@forelse($user->roles as $role)
<span class="inline-flex items-center rounded-full bg-indigo-50 px-2 py-0.5 text-xs font-medium text-indigo-700">{{ $role->name }}</span>
@empty
<span class="text-xs text-gray-400">-</span>
@endforelse
</div>
</td>
<td class="px-4 py-2">
<div class="flex flex-wrap gap-1">
@forelse($user->permissions as $permission)
<span class="inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-700">{{ $permission->name }}</span>
@empty
<span class="text-xs text-gray-400">-</span>
@endforelse
</div>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="px-4 py-6 text-center text-gray-400">Nessun utente trovato</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>