@extends('layouts.default')

@section('title', 'Müşteriler')

@section('content')
<div class="container-fluid">
    @include('admin.partials.page-header', ['actions' => new \Illuminate\Support\HtmlString('<a href="'.route('admin.clients.create').'" class="btn btn-primary">Yeni Müşteri</a>')])

    <div class="card">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-responsive-md">
                    <thead>
                    <tr>
                        <th>Firma</th>
                        <th>Yetkili</th>
                        <th>E-posta</th>
                        <th>Para Birimi</th>
                        <th>Durum</th>
                        <th class="text-end">İşlem</th>
                    </tr>
                    </thead>
                    <tbody>
                    @forelse($clients as $client)
                        <tr>
                            <td><a href="{{ route('admin.clients.show', $client) }}" class="text-black font-w600">{{ $client->company_name }}</a></td>
                            <td>{{ $client->contact_person ?: '-' }}</td>
                            <td>{{ $client->email ?: '-' }}</td>
                            <td>{{ $client->currency_code }}</td>
                            <td>@include('admin.partials.status-badge', ['status' => $client->status])</td>
                            <td class="text-end">
                                <a href="{{ route('admin.clients.edit', $client) }}" class="btn btn-xs btn-outline-primary">Düzenle</a>
                                <form action="{{ route('admin.clients.destroy', $client) }}" method="POST" class="d-inline" onsubmit="return confirm('Müşteri silinsin mi?')">
                                    @csrf @method('DELETE')
                                    <button class="btn btn-xs btn-outline-danger">Sil</button>
                                </form>
                            </td>
                        </tr>
                    @empty
                        <tr><td colspan="6" class="text-center text-muted py-5">Henüz müşteri yok.</td></tr>
                    @endforelse
                    </tbody>
                </table>
            </div>
            {{ $clients->links() }}
        </div>
    </div>
</div>
@endsection
