@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">My Winnings</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">
                        @if(isset($error))
                            <div class="alert alert-danger">{{ $error }}</div>
                        @endif
                        @if(session('error'))
                            <div class="alert alert-danger">{{ session('error') }}</div>
                        @endif

                        @if($winnings->count() > 0)
                            <div class="table-responsive">
                                <table class="table table-vcenter card-table">
                                    <thead>
                                        <tr>
                                            <th>Item #</th>
                                            <th>Description</th>
                                            <th>Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach($winnings as $winning)
                                            <tr>
                                                <td>{{ $winning->items->item_assigned_num }}</td>
                                                <td>{{ $winning->items->item_desc }}</td>
                                                <td>${{ number_format($winning->winning_cost, 2) }}</td>
                                            </tr>
                                        @endforeach
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <th colspan="2" class="text-end">Total:</th>
                                            <th>${{ number_format($total_cost, 2) }}</th>
                                        </tr>
                                    </tfoot>
                                </table>
                            </div>

                            @if(!$is_checked_out)
                                <div class="text-end mt-4">
                                    <a href="{{ route('north.checkout', ['bidder_id' => $bidder->idbidders]) }}" class="btn btn-success btn-lg">Pay Now with Credit Card</a>
                                </div>
                            @else
                                <div class="alert alert-success text-center mt-4">
                                    <strong>Checked Out!</strong> Your payment has been processed.
                                </div>
                            @endif
                        @else
                            <p>No winning bids found for this bidder number.</p>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
@push('js')
@endpush
