<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Edit {{ $grapeVariety->variety_name }}</title>
</head>
<body>
    <h1>Edit Grape Variety: {{ $grapeVariety->variety_name }}</h1>

    <form action="{{ route('grape-varieties.update', $grapeVariety) }}" method="POST">
        @csrf
        @method('PUT')

        <div>
            <label for="variety_name">Variety Name:</label>
            <input type="text" name="variety_name" id="variety_name" value="{{ old('variety_name', $grapeVariety->variety_name) }}" required>
            @error('variety_name')
                <span>{{ $message }}</span>
            @enderror
        </div>

        <div>
            <label for="wine_type">Wine Type:</label>
            <select name="wine_type" id="wine_type">
                <option value="">Select type</option>
                <option value="white" {{ old('wine_type', $grapeVariety->wine_type) == 'white' ? 'selected' : '' }}>White</option>
                <option value="red" {{ old('wine_type', $grapeVariety->wine_type) == 'red' ? 'selected' : '' }}>Red</option>
                <option value="rose" {{ old('wine_type', $grapeVariety->wine_type) == 'rose' ? 'selected' : '' }}>Rosé</option>
            </select>
            @error('wine_type')
                <span>{{ $message }}</span>
            @enderror
        </div>

        <div>
            <label for="origin">Origin:</label>
            <input type="text" name="origin" id="origin" value="{{ old('origin', $grapeVariety->origin) }}">
            @error('origin')
                <span>{{ $message }}</span>
            @enderror
        </div>

        <div>
            <label for="description">Description:</label>
            <textarea name="description" id="description">{{ old('description', $grapeVariety->description) }}</textarea>
            @error('description')
                <span>{{ $message }}</span>
            @enderror
        </div>

        <div>
            <label for="characteristics">Characteristics:</label>
            <textarea name="characteristics" id="characteristics">{{ old('characteristics', $grapeVariety->characteristics) }}</textarea>
            @error('characteristics')
                <span>{{ $message }}</span>
            @enderror
        </div>

        <div>
            <label for="image_url">Image URL:</label>
            <input type="url" name="image_url" id="image_url" value="{{ old('image_url', $grapeVariety->image_url) }}">
            @error('image_url')
                <span>{{ $message }}</span>
            @enderror
        </div>

        <button type="submit">Update</button>
        <a href="{{ route('grape-varieties.show', $grapeVariety) }}">Cancel</a>
    </form>
</body>
</html>
