@extends('layouts.admin')

@section('header', 'Edit Testimonial')

@section('content')
<div class="bg-white rounded-lg shadow">
    <div class="p-6 border-b border-gray-200">
        <h3 class="text-lg font-medium text-gray-900">Edit Testimonial Details</h3>
    </div>
    <div class="p-6">
        <form action="{{ route('admin.testimonials.update', $testimonial) }}" method="POST">
            @csrf
            @method('PUT')
            
            <div class="mb-4">
                <label for="author_name" class="block text-sm font-medium text-gray-700">Author Name</label>
                <input type="text" name="author_name" id="author_name" value="{{ old('author_name', $testimonial->author_name) }}" class="mt-1 focus:ring-teal-500 focus:border-teal-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md py-2 px-3 border" required>
            </div>

            <div class="mb-4">
                <label for="text" class="block text-sm font-medium text-gray-700">Testimonial Text</label>
                <textarea name="text" id="text" rows="4" class="mt-1 focus:ring-teal-500 focus:border-teal-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md py-2 px-3 border" required>{{ old('text', $testimonial->text) }}</textarea>
            </div>

            <div class="mb-4">
                <label for="order_index" class="block text-sm font-medium text-gray-700">Display Order</label>
                <input type="number" name="order_index" id="order_index" value="{{ old('order_index', $testimonial->order_index) }}" class="mt-1 focus:ring-teal-500 focus:border-teal-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md py-2 px-3 border">
            </div>

            <div class="mb-6 flex items-start">
                <div class="flex items-center h-5">
                    <input id="is_active" name="is_active" type="checkbox" class="focus:ring-teal-500 h-4 w-4 text-teal-600 border-gray-300 rounded" {{ $testimonial->is_active ? 'checked' : '' }}>
                </div>
                <div class="ml-3 text-sm">
                    <label for="is_active" class="font-medium text-gray-700">Active</label>
                    <p class="text-gray-500">Visible on the homepage.</p>
                </div>
            </div>

            <div class="flex justify-end">
                <a href="{{ route('admin.testimonials.index') }}" class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-teal-500 mr-3">
                    Cancel
                </a>
                <button type="submit" class="bg-teal-600 border border-transparent rounded-md shadow-sm py-2 px-4 text-sm font-medium text-white hover:bg-teal-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-teal-500">
                    Update
                </button>
            </div>
        </form>
    </div>
</div>
@endsection
