@extends('admin.layout')

@section('title', 'Services')

@section('body')
<div class="shell">
    @include('admin.partials.sidebar')
    <main class="main">
        <div class="top">
            <h1>Services</h1>
            @include('admin.partials.logout')
        </div>
        @if (session('status')) <div class="status">{{ session('status') }}</div> @endif
        <section class="panel">
            <h2>Add Service</h2>
            <form method="post" action="{{ route('admin.services.store') }}" class="form-grid">
                @csrf
                <div><label>Category</label><select name="category_id">@foreach($categories as $cat)<option value="{{ $cat->id }}">{{ $cat->name }}</option>@endforeach</select></div>
                <div><label>Name</label><input name="name" required></div>
                <div><label>Type</label><select name="service_type"><option value="task">Task</option><option value="hourly">Hourly</option><option value="express">Express</option><option value="recurring_bundle">Recurring</option></select></div>
                <div><label>Duration minutes</label><input type="number" name="default_duration_minutes" value="60" min="15" required></div>
                <div><label>Price</label><input type="number" step="0.01" name="price" value="199" min="0" required></div>
                <div><button type="submit">Add</button></div>
            </form>
        </section>
        <table>
            <tr><th>Name</th><th>Category</th><th>Type</th><th>Duration</th><th>Starting Price</th><th>Status</th></tr>
            @foreach ($services as $row)
                <tr><td>{{ $row->name }}</td><td>{{ $row->category_name }}</td><td>{{ $row->service_type }}</td><td>{{ $row->default_duration_minutes }}</td><td>{{ $row->starting_price }}</td><td>{{ $row->status }}</td></tr>
            @endforeach
        </table>
        {{ $services->links() }}
    </main>
</div>
@endsection
