@extends('tablar::page')

@section('content')
<div class="page-header d-print-none">
    <div class="container-xl">
        <div class="row g-2 align-items-center">
            <div class="col">
                <h2 class="page-title">Checkout</h2>
            </div>
        </div>
    </div>
</div>
<div class="page-body">
    <div class="container-xl">
        <div class="row row-cards">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <form method="POST" action="/checkout" class="row g-3">
                            {{ csrf_field() }}
                            <input type="hidden" name="bidder_num" value="{{ $bidder->idbidders }}">
                            
                            <h3 class="mb-3">Winning Items for {{ $bidder->bidder_fname }} {{ $bidder->bidder_lname }}</h3>
                            <ul class="list-group mb-4">
                                @foreach($winnings as $item)
                                    <li class="list-group-item d-flex justify-content-between align-items-center">
                                        {{ $item->items->item_desc }}
                                        <span class="badge bg-primary rounded-pill">${{ number_format($item->winning_cost, 2) }}</span>
                                    </li>
                                @endforeach
                            </ul>

                            <div class="col-md-4">
                                <label for="payment_method" class="form-label">Payment Method</label>
                                <select name="payment_method" id="payment_method" class="form-select" required>
                                    @foreach($paymentMethods as $pm)
                                        <option value="{{ $pm->pm_id }}">{{ $pm->pm_name }}</option>
                                    @endforeach
                                </select>
                            </div>
                            
                            <div class="col-12">
                                <button type="submit" class="btn btn-success">Complete Checkout</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
@include('components.tomselect')
@push('js')
@endpush
