@extends('admin.layouts.app')
@section('title', 'Top Sellers')
@section('content')
<div class="action-bar">
    <span>{{ $topSellers->total() }} top sellers</span>
    <a href="{{ route('admin.top-sellers.create') }}" class="btn btn-primary">+ New Top Seller</a>
</div>
<div class="card">
    <table>
        <tr><th>Image</th><th>Title</th><th>Price</th><th>Order</th><th>Active</th><th>Actions</th></tr>
        @foreach($topSellers as $item)
        <tr>
            <td>@if($item->image)<img src="{{ asset('storage/'.$item->image) }}" class="product-img" alt="">@else—@endif</td>
            <td><strong>{{ $item->title }}</strong></td>
            <td>{{ $item->price > 0 ? '$'.number_format($item->price,2) : '—' }}</td>
            <td>{{ $item->order }}</td>
            <td>{!! $item->is_active ? '<span style="color:#6fcf97">Yes</span>' : '<span style="color:#e74c3c">No</span>' !!}</td>
            <td class="inline-flex">
                <a href="{{ route('admin.top-sellers.edit', $item) }}" class="btn btn-primary btn-sm">Edit</a>
                <form action="{{ route('admin.top-sellers.destroy', $item) }}" method="POST" onsubmit="return confirm('Delete?')">
                    @csrf @method('DELETE')
                    <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                </form>
            </td>
        </tr>
        @endforeach
    </table>
    <div class="pagination">{{ $topSellers->links() }}</div>
</div>
@endsection
