@extends('frontend.layout.dash')

@section('content')
    @include('frontend.components.accordion')

    <div class="card mp-20">
        <h2 class="title">{{ $title }}</h2>
        <div class="table-header">
            <form method="GET" action="{{ route('user.log.account-orders') }}" class="table-search-form">
                <div class="table-search">
                    <input type="text" name="search" class="search-input" placeholder="Search by order ID..." value="{{ $search ?? '' }}">
                    <i class="ti ti-search"></i>
                </div>
                <button type="submit" class="btn btn-secondary search-btn">Search</button>
            </form>
        </div>
        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>Order ID</th>
                        <th>Amount</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($orders as $order)
                        <tr>
                            <td>{{ $order->created_at?->format('Y-m-d H:i') }}</td>
                            <td>#{{ $order->id }}</td>
                            <td>{{ $currency ?? '' }}{{ number_format($order->total_amount, 2) }}</td>
                            <td><a href="{{ route('user.log.account-orders.detail', ['id' => $order->id]) }}" class="btn btn-sm btn-primary">View credentials</a></td>
                        </tr>
                    @empty
                        <tr><td colspan="4" class="text-center">No account orders yet.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
        @if($orders->hasPages())
            {{ $orders->links('vendor.pagination.default') }}
        @endif
    </div>
@endsection
