@extends('layouts.test')

@section('content')
<div class="container">
    <div class="row">
        <!-- Left Section - Chauffeur List -->
        <div class="col-md-6">
           
            <h2>
                <a href="http://localhost:8000/billets" class="back-icon">⬅</a> Liste Des Véhicules
            </h2>
            <div class="card">
                <div class="card-body">
                    <!-- Chauffeur List Pagination -->
                    <!-- Replace the following with your actual chauffeur data -->
                    <ul class="list-group">
    @foreach($chauffeurs as $chauffeur)
        <li class="list-group-item">
            <div style="display: flex; align-items: center; justify-content: space-between;">
                <div style="display: flex; align-items: center;">
                    <!-- <img src="{{ asset($chauffeur->profile_image) }}" alt="Logo" style="margin-right: 10px;"> -->
                    <div>
                        <p>{{ $chauffeur->name }}</p>
                        <!-- <p>{{ $chauffeur->telephone }}</p>
                        <p>{{ $chauffeur->address }}</p>
                        <p>{{ $chauffeur->email }}</p> -->
                    </div>
                </div>
                <form id="deleteForm" action="{{ route('chauffeurs.confirm-delete', $chauffeur->id) }}" method="post">
                    @csrf
                    @method('delete')
                    <button type="button" class="btn btn-danger" onclick="confirmDelete()"><i class="fa fa-trash" aria-hidden="true"></i></button>
                </form>
            </div>
        </li>
    @endforeach
</ul>


                    <!-- Pagination Links -->
                    {{ $chauffeurs->links() }}
                </div>
            </div>
        </div>

        <!-- Right Section - Add Chauffeur Form -->
        <div class="col-md-6">
            <h2>Ajouter Un Nouveau Véhicule</h2>
            <div class="card">
                <div class="card-body">
                    <!-- Add Chauffeur Form -->
                    <form action="{{ route('chauffeurs.store') }}" method="post" enctype="multipart/form-data">
                        @csrf
                        
                        <input type="text" name="name" placeholder="Matricule Véhicule" class="form-control">
                        <!-- <input type="email" name="email" placeholder="Email" class="form-control">
                        <input type="tel" name="telephone" placeholder="Telephone" class="form-control">
                        <textarea name="address" placeholder="Address" class="form-control"></textarea>
                        <input type="file" name="profile_image" class="form-control"> -->
                       <BR>
                        <button type="submit" class="btn btn-primary">Ajouter</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
        function confirmDelete() {
            var result = confirm("Are you sure you want to delete?");
            if (result) {
                document.getElementById('deleteForm').submit();
            }
        }
    </script>
@endsection
