@extends('layouts.admin')

@section('content')
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="page-title-box">
                <div class="page-title-right">
                    <a href="{{ route('admin.shipping.locations.create') }}" class="btn btn-primary">
                        <i class="fas fa-plus"></i> Add Location
                    </a>
                </div>
                <h4 class="page-title">Shipping Locations</h4>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-centered table-striped">
                            <thead>
                                <tr>
                                    <th>State</th>
                                    <th>City</th>
                                    <th>ZIP Code</th>
                                    <th>Status</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($locations as $location)
                                <tr>
                                    <td>{{ $location->state }}</td>
                                    <td>{{ $location->city }}</td>
                                    <td>{{ $location->zip_code }}</td>
                                    <td>
                                        <span class="badge bg-{{ $location->is_active ? 'success' : 'danger' }}">
                                            {{ $location->is_active ? 'Active' : 'Inactive' }}
                                        </span>
                                    </td>
                                    <td>
                                        <a href="{{ route('admin.shipping.locations.edit', $location) }}" 
                                           class="btn btn-sm btn-info">Edit</a>
                                        <button type="button" 
                                                class="btn btn-sm btn-danger delete-location" 
                                                data-id="{{ $location->id }}">Delete</button>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                    {{ $locations->links('pagination::bootstrap-5') }}
                </div>
            </div>
        </div>
    </div>
</div>
@endsection