@extends('layouts.admin')

@section('content')
<div class="container-fluid">
    <div class="card">
        <div class="card-header">
            <h4 class="card-title">Edit Delivery Slot</h4>
        </div>
        <div class="card-body">
            <form action="{{ route('admin.delivery.slots.update', $item) }}" method="POST">
                @csrf
                @method('PUT')
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Day of Week</label>
                            <select name="day_of_week" class="form-select" required>
                                <option value="">Select Day</option>
                                <option value="Monday" {{ old('day_of_week', $item->day_of_week) == 'Monday' ? 'selected' : '' }}>Monday</option>
                                <option value="Tuesday" {{ old('day_of_week', $item->day_of_week) == 'Tuesday' ? 'selected' : '' }}>Tuesday</option>
                                <option value="Wednesday" {{ old('day_of_week', $item->day_of_week) == 'Wednesday' ? 'selected' : '' }}>Wednesday</option>
                                <option value="Thursday" {{ old('day_of_week', $item->day_of_week) == 'Thursday' ? 'selected' : '' }}>Thursday</option>
                                <option value="Friday" {{ old('day_of_week', $item->day_of_week) == 'Friday' ? 'selected' : '' }}>Friday</option>
                                <option value="Saturday" {{ old('day_of_week', $item->day_of_week) == 'Saturday' ? 'selected' : '' }}>Saturday</option>
                                <option value="Sunday" {{ old('day_of_week', $item->day_of_week) == 'Sunday' ? 'selected' : '' }}>Sunday</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Start Time</label>
                            <input type="time" name="start_time" class="form-control" required 
                                   value="{{ old('start_time', $item->start_time) }}">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">End Time</label>
                            <input type="time" name="end_time" class="form-control" required 
                                   value="{{ old('end_time', $item->end_time) }}">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Max Orders</label>
                            <input type="number" name="max_orders" class="form-control" required 
                                   value="{{ old('max_orders', $item->max_orders) }}" min="1">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Additional Fee</label>
                            <input type="number" name="additional_fee" class="form-control" 
                                   value="{{ old('additional_fee', $item->additional_fee) }}" step="0.01" min="0">
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="mb-3">
                            <div class="form-check">
                                <input type="checkbox" name="is_active" class="form-check-input" 
                                       value="1" {{ $item->is_active ? 'checked' : '' }}>
                                <label class="form-check-label">Active</label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="text-end">
                    <a href="{{ route('admin.delivery.slots.index') }}" class="btn btn-secondary">Cancel</a>
                    <button type="submit" class="btn btn-primary">Update Slot</button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
