<x-layouts.dashboard title="My Requests">
    @php($oneTimeClient = auth()->user()->client_type === 'one_time')
    <form class="form-card" method="post" enctype="multipart/form-data" action="{{ route('client.requests.store') }}">
        @csrf
        <div class="form-grid">
            <div class="field">
                <label>{{ $oneTimeClient ? 'Order Type' : 'Request Type' }}</label>
                <select name="request_type" required>
                    @foreach ($oneTimeClient ? ['one_time_order', 'revision'] : ['social_post', 'ad_poster', 'logo', 'banner', 'reel_cover', 'website', 'revision'] as $type)
                        <option value="{{ $type }}">{{ str($type)->headline() }}</option>
                    @endforeach
                </select>
            </div>
            <div class="field">
                <label>Service</label>
                <select name="service_id">
                    <option value="">Select service</option>
                    @foreach ($services as $service)
                        <option value="{{ $service->id }}">{{ $service->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="field"><label>Deadline</label><input type="date" name="deadline"></div>
            <div class="field full-field"><label>Title</label><input name="title" required></div>
            <div class="field full-field"><label>Details</label><textarea name="details"></textarea></div>
            <div class="field full-field"><label>File / Image</label><input type="file" name="file_path"></div>
        </div>
        <p><button class="btn">{{ $oneTimeClient ? 'Submit New Order' : 'New Request' }}</button></p>
    </form>
    <div class="table-card"><table><thead><tr><th>Request</th><th>Type</th><th>Service</th><th>Deadline</th><th>Status</th></tr></thead><tbody>
        @forelse ($requests as $request)
            <tr>
                <td>{{ $request->title }}</td>
                <td>{{ str($request->request_type)->headline() }}</td>
                <td>{{ $request->service->name ?? '-' }}</td>
                <td>{{ optional($request->deadline)->format('Y-m-d') }}</td>
                <td><span class="badge">{{ $request->status }}</span></td>
            </tr>
        @empty
            <tr><td colspan="5">No requests yet. Submit your first order above.</td></tr>
        @endforelse
    </tbody></table></div>
</x-layouts.dashboard>
