@extends('layouts.app')

@section('title', 'Manajemen Pengguna')

@section('content')
<div class="card">
    <div class="card-header">
        <h3 class="card-title">Daftar Pengguna Sistem</h3>
        <div class="card-tools"><a href="{{ route('pengguna.create') }}" class="btn btn-primary btn-sm">Tambah User</a></div>
    </div>
    <div class="card-body">
        <table class="table table-bordered table-striped datatables">
            <thead>
                <tr>
                    <th>Nama</th>
                    <th>Email</th>
                    <th>NIM (Mhs)</th>
                    <th>Role</th>
                    <th>Aksi</th>
                </tr>
            </thead>
            <tbody>
                @foreach($users as $user)
                <tr>
                    <td>{{ $user->name }}</td>
                    <td>{{ $user->email }}</td>
                    <td>{{ $user->nim ?? '-' }}</td>
                    <td><span class="badge badge-primary">{{ $user->role }}</span></td>
                    <td>
                        <a href="{{ route('pengguna.edit', $user->id) }}" class="btn btn-warning btn-sm">Edit</a>
                        <form action="{{ route('pengguna.destroy', $user->id) }}" method="POST" style="display:inline">
                            @csrf @method('DELETE')
                            <button class="btn btn-danger btn-sm" onclick="return confirm('Hapus user?')">Hapus</button>
                        </form>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>
@endsection
