Files
ilycats/resources/views/pages/users/index.blade.php
T

39 lines
3.7 KiB
PHP

<x-app-layout>
<div class="space-y-6 pb-8">
<div class="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
<div><h2 class="text-2xl font-bold text-slate-900">Manajemen pengguna</h2><p class="mt-1 text-sm text-slate-500">Kelola akses, status akun, WhatsApp, dan kata sandi pengguna.</p></div>
@can('check-access', ['users', 'create'])
<a href="{{ route('admin.users.create') }}" class="rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-indigo-700"><i class="fas fa-user-plus mr-2"></i>Tambah pengguna</a>
@endcan
</div>
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-slate-200 text-sm">
<thead class="bg-slate-50 text-left text-xs font-semibold text-slate-500"><tr><th class="px-5 py-3">Pengguna</th><th class="px-5 py-3">WhatsApp</th><th class="px-5 py-3">Role</th><th class="px-5 py-3">Status</th><th class="px-5 py-3 text-right">Aksi</th></tr></thead>
<tbody class="divide-y divide-slate-100">
@forelse($users as $user)
<tr class="hover:bg-slate-50">
<td class="px-5 py-4"><p class="font-semibold text-slate-900">{{ $user->name }}</p><p class="mt-0.5 text-xs text-slate-500">{{ $user->email }}</p></td>
<td class="px-5 py-4 text-slate-600">{{ $user->phone ?: '-' }}</td>
<td class="px-5 py-4"><span class="rounded-full border border-slate-200 bg-slate-50 px-2.5 py-1 text-xs font-semibold text-slate-600">{{ $user->roleModel?->name ?? $user->role ?? '-' }}</span></td>
<td class="px-5 py-4">@if($user->is_active)<span class="rounded-full border border-emerald-100 bg-emerald-50 px-2.5 py-1 text-xs font-semibold text-emerald-700">Aktif</span>@else<span class="rounded-full border border-rose-100 bg-rose-50 px-2.5 py-1 text-xs font-semibold text-rose-700">Nonaktif</span>@endif</td>
<td class="px-5 py-4"><div class="flex justify-end gap-1">
@can('check-access',['users','update'])
<a href="{{ route('admin.users.edit',$user) }}" class="rounded-lg p-2 text-slate-500 hover:bg-slate-100" title="Ubah"><i class="fas fa-pen"></i></a>
<form action="{{ route('admin.users.status',$user) }}" method="POST">@csrf @method('PATCH')<button class="rounded-lg p-2 {{ $user->is_active?'text-rose-500 hover:bg-rose-50':'text-emerald-600 hover:bg-emerald-50' }}" title="{{ $user->is_active?'Nonaktifkan':'Aktifkan' }}" {{ $user->id===auth()->id() && $user->is_active ? 'disabled' : '' }}><i class="fas {{ $user->is_active?'fa-user-slash':'fa-user-check' }}"></i></button></form>
@endcan
@can('check-access',['users','delete'])
<form action="{{ route('admin.users.destroy',$user) }}" method="POST" onsubmit="return confirm('Hapus user ini?')">@csrf @method('DELETE')<button class="rounded-lg p-2 text-rose-500 hover:bg-rose-50" title="Hapus"><i class="fas fa-trash"></i></button></form>
@endcan
</div></td>
</tr>
@empty<tr><td colspan="5" class="px-5 py-10 text-center text-slate-500">Belum ada pengguna.</td></tr>@endforelse
</tbody>
</table>
</div>
<div class="border-t border-slate-200 p-4">{{ $users->links() }}</div>
</div>
</div>
</x-app-layout>