@extends('layouts.app')

@section('title', 'Edit Company Policy')
@section('heading', 'Edit Company Policy')

@section('content')
    <x-card class="max-w-3xl">
        <form action="{{ route('company-policies.update', $companyPolicy) }}" method="POST" class="space-y-4" novalidate data-company-policy-form="edit">
            @csrf
            @method('PUT')
            <div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
                <div class="sm:col-span-2 lg:col-span-3">
                    <label class="block text-sm font-medium text-slate-700">Name <span class="text-red-500">*</span></label>
                    <input type="text" name="name" value="{{ old('name', $companyPolicy->name) }}" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2">
                    @error('name')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
                    <p data-js-error="name" class="mt-1 text-sm text-red-600 hidden"></p>
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700">Status</label>
                    <select name="status" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2 js-select2">
                        <option value="active" {{ old('status', $companyPolicy->status) === 'active' ? 'selected' : '' }}>Active</option>
                        <option value="inactive" {{ old('status', $companyPolicy->status) === 'inactive' ? 'selected' : '' }}>Inactive</option>
                    </select>
                </div>
            </div>
            <div>
                <label class="block text-sm font-medium text-slate-700">Description</label>
                <textarea name="description" rows="2" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2">{{ old('description', $companyPolicy->description) }}</textarea>
                @error('description')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
                <p data-js-error="description" class="mt-1 text-sm text-red-600 hidden"></p>
            </div>
            <div>
                <label class="block text-sm font-medium text-slate-700">Content</label>
                <textarea name="content" rows="6" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2">{{ old('content', $companyPolicy->content) }}</textarea>
                @error('content')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
                <p data-js-error="content" class="mt-1 text-sm text-red-600 hidden"></p>
            </div>
            <div class="flex gap-2">
                <button type="submit" class="rounded-lg bg-primary px-4 py-2 text-sm font-medium text-white">Update</button>
                <a href="{{ route('company-policies.index') }}" class="rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200">Cancel</a>
            </div>
        </form>
    </x-card>
@endsection

@push('scripts')
<script src="{{ asset('js/form-validation.js') }}"></script>
<script src="{{ asset('js/form-text-rules.js') }}"></script>
<script src="{{ asset('js/company-policy-form-validation.js') }}"></script>
@endpush
