@extends('layouts.app')

@section('content')
    <div class="container-fluid p-4">
        <div class="card shadow-sm p-3">
            <h4 class="fw-bold" style="color: #063986;">Data Customer</h4>
            <div class="d-flex justify-content-between align-items-center mb-3">
                <!-- Tombol Tambah Data -->
                <a href="{{ route('admin.createcustomer') }}" class="btn text-white"
                    style="background: linear-gradient(135deg, #8AC0DF, #48499B); border: none;">
                    <i class="bi bi-plus-circle"></i> Tambah Data
                </a>

                <!-- Form Pencarian -->
                <form method="GET" action="{{ route('admin.customer') }}" class="d-flex">
                    <input type="text" name="search" class="form-control form-control-sm me-2"
                        placeholder="Cari customer..." value="{{ request()->search }}" style="max-width: 200px;">
                    <button type="submit" class="btn btn-outline-secondary btn-sm">Cari</button>
                </form>
            </div>

            <!-- Tabel Data Customer -->
            <div class="table-responsive">
                <table class="table table-bordered text-center">
                    <thead class="table-primary">
                        <tr>
                            <th>No</th>
                            <th>Nama</th>
                            <th>Email</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($users as $index => $user)
                            <tr>
                                <td>{{ $index + 1 }}</td>
                                <td>{{ $user->name }}</td>
                                <td>{{ $user->email }}</td>
                                <td>
                                    <a href="{{ route('admin.editcustomer', ['id_user' => $user->id_user]) }}" class="text-primary">
                                        <i class="bi bi-pencil-square"></i>
                                    </a>
                                    <a href="{{ route('admin.deletecustomer', ['id_user' => $user->id_user]) }}" class="text-danger" 
                                        onclick="return confirm('Apakah Anda yakin ingin menghapus user ini?');">
                                        <i class="bi bi-trash-fill"></i>
                                    </a>
                                </td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>            

        </div>
    </div>
@endsection
