@extends('layouts.app')

@section('title', 'Shops')

@section('content')


    <div class="row">
        <div class="col-12">
            <div class="card">

                <div class="card-body">
               		<div class="d-flex justify-content-between align-items-center mb-3">
			<h6 class="card-title mb-0">Add Shop</h6>
 <div>
                        <a href="{{ route('shops.create') }}" class="btn btn-primary">
                            <i class="fas fa-plus"></i> Add Shop
                        </a>
                    </div>
                </div>

                    <div class="table-responsive">
                        <table class="table table-striped table-centered mb-0">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Name</th>
                                    <th>Phone</th>
                                    <th>Email</th>
                                    <th>City</th>
                                    <th>Account Code</th>
                                    <th>Status</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($shops as $shop)
                                <tr>
                                    <td>{{ $shop->id }}</td>
                                    <td>{{ $shop->name }}</td>
                                    <td>{{ $shop->phone ?? '-' }}</td>
                                    <td>{{ $shop->email ?? '-' }}</td>
                                    <td>{{ $shop->city ?? '-' }}</td>
                                    <td>{{ $shop->code ?? '-' }}</td>
                                    <td>
                                        <form action="{{ route('shops.toggle-active', $shop) }}" method="post" class="d-inline">
                                            @csrf
                                            @method('patch')
                                            <input type="hidden" name="is_active" value="{{ $shop->is_active ? 0 : 1 }}">
                                            <button type="submit" class="btn btn-sm {{ $shop->is_active ? 'btn-success' : 'btn-secondary' }}">
                                                {{ $shop->is_active ? 'Active' : 'Inactive' }}
                                            </button>
                                        </form>
                                    </td>
                                    <td>
                                        <a href="{{ route('shops.edit', $shop) }}" class="btn btn-sm btn-warning">Edit</a>
                                    </td>
                                </tr>
                                @empty
                                <tr>
                                    <td colspan="7" class="text-center">No shops found</td>
                                </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>
                    <div class="mt-3">
                        {{ $shops->links() }}
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


