@extends('layouts.layout-user')
@section('content')
<table id="table-register" class="table table-bordered table-hover">
    <thead>
        <tr>
            <th colspan="8">
                <h2 style="display: inline-block; margin-right: 10px;">Data Users</h2>
                <span style="margin:1%; float: right;"></span>
                <form class="w-72" action="{{route('user.index')}}" method="GET">
                    <div class="input-group input-group-merge" style="max-width: 300px">
                        <span class="input-group-text" id="basic-addon-search31"><i class="fa fa-search"></i></span>
                        <input name="search" class="form-control" placeholder="Search..." aria-label="Search..." aria-describedby="basic-addon-search31"></input>
                    </div>
                </form>
                <a href="{{ route('user.create') }}" class="btn btn-primary btn-delete" style="float: left; margin-top:1%;">Buat User</a>
            </th>
        </tr>
        <tr style="background-color: #155dfa;">
            <th style="color: white; text-align: center; padding: 10px;">No</th>
            <th style="color: white; text-align: center; padding: 10px;">Nama</th>
            <th style="color: white; text-align: center; padding: 10px;">Email</th>
            <th style="color: white; text-align: center; padding: 10px;">Role</th>
            <th style="text-align: center; color: white; padding: 10px;">Action</th>
        </tr>


    </thead>
    <!-- Isi tabel -->
    <tbody>
        @php
            $i=1;
        @endphp
        @if($users->count() >0)
            @foreach ($users as $user)
            <tr>
                <td>{{ $i++ }}</td>
                <td>{{$user->name}}</td>
                <td>{{$user->email}}</td>
                <td>{{$user->role}}</td>
                <td>
                    <div style="display: flex; justify-content: center;">
                        {{-- <a href="{{ url('/beranda/group/{{$group->id}}/edit') }}" class="btn btn-primary" style="margin-left: 10px; background-color: rgb(0, 106, 255);">Update</a> --}}
                        <a href="{{ route('user.edit', ['id' => $user->id]) }}" class="btn  btn-delete" style=" background-color: rgb(0, 106, 255); color: #fff; border: none; border-radius: 4px; cursor: pointer; ">Update</a>
                        <div style="width: 20px;"></div> <!-- Separator -->
                        <a href="{{ route('user.destroy', ['id' => $user->id]) }}" class="btn  btn-delete" style=" background-color: #e04f4f; color: #fff; border: none; border-radius: 4px; cursor: pointer;">Delete</a>
                    </div>
                </td>
            </tr>
            @endforeach
            <!-- Tambahkan baris sesuai data yang ada -->
        @else
            <tr>
                <td class="text-center" colspan="4">User not found</td>
            </tr>
        @endif
    </tbody>
</table>
@endsection
