@extends('admin::layouts.master')

@section('title', 'Edit Weekly Special')

@section('content')
    <h1 class="text-2xl font-bold mb-6">Edit Weekly Special</h1>
    <div class="bg-white rounded-lg shadow p-6 max-w-lg">
        <form method="POST" action="{{ route('admin.weekly-specials.update', $weeklySpecial->id) }}">
            @csrf
            @method('PUT')
            <div class="mb-4">
                <label for="name" class="block text-sm font-medium text-gray-700 mb-1">Name</label>
                <input type="text" name="name" id="name" value="{{ old('name', $weeklySpecial->name) }}" required
                    class="w-full border border-gray-300 rounded px-3 py-2">
            </div>
            <div class="mb-4">
                <label for="slug" class="block text-sm font-medium text-gray-700 mb-1">Slug</label>
                <input type="text" name="slug" id="slug" value="{{ old('slug', $weeklySpecial->slug) }}" required
                    class="w-full border border-gray-300 rounded px-3 py-2">
            </div>
            <div class="mb-4">
                <label for="description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
                <textarea name="description" id="description" rows="2"
                    class="w-full border border-gray-300 rounded px-3 py-2">{{ old('description', $weeklySpecial->description) }}</textarea>
            </div>
            <div class="grid grid-cols-2 gap-4 mb-4">
                <div>
                    <label for="max_discount" class="block text-sm font-medium text-gray-700 mb-1">Max Discount %</label>
                    <input type="number" step="0.01" name="max_discount" id="max_discount" value="{{ old('max_discount', $weeklySpecial->max_discount) }}"
                        class="w-full border border-gray-300 rounded px-3 py-2">
                </div>
                <div>
                    <label for="icon" class="block text-sm font-medium text-gray-700 mb-1">Icon</label>
                    <input type="text" name="icon" id="icon" value="{{ old('icon', $weeklySpecial->icon) }}"
                        class="w-full border border-gray-300 rounded px-3 py-2">
                </div>
            </div>
            <div class="mb-4">
                <label for="banner_url" class="block text-sm font-medium text-gray-700 mb-1">Banner URL</label>
                <input type="text" name="banner_url" id="banner_url" value="{{ old('banner_url', $weeklySpecial->banner_url) }}"
                    class="w-full border border-gray-300 rounded px-3 py-2">
            </div>
            <div class="grid grid-cols-2 gap-4 mb-4">
                <div>
                    <label for="starts_at" class="block text-sm font-medium text-gray-700 mb-1">Starts At</label>
                    <input type="date" name="starts_at" id="starts_at" value="{{ old('starts_at', $weeklySpecial->starts_at) }}" required
                        class="w-full border border-gray-300 rounded px-3 py-2">
                </div>
                <div>
                    <label for="ends_at" class="block text-sm font-medium text-gray-700 mb-1">Ends At</label>
                    <input type="date" name="ends_at" id="ends_at" value="{{ old('ends_at', $weeklySpecial->ends_at) }}" required
                        class="w-full border border-gray-300 rounded px-3 py-2">
                </div>
            </div>
            <div class="mb-4">
                <label class="flex items-center gap-2">
                    <input type="checkbox" name="is_active" value="1" {{ old('is_active', $weeklySpecial->is_active) ? 'checked' : '' }}>
                    <span class="text-sm">Active</span>
                </label>
            </div>
            <div class="flex gap-4">
                <button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">Update</button>
                <a href="{{ route('admin.weekly-specials.index') }}" class="bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600">Cancel</a>
            </div>
        </form>
    </div>
@endsection
