@extends('layouts.app')

@section('title', 'Edit deduction section')
@section('heading', 'Edit deduction section')

@section('content')
    <x-card>
        <form action="{{ route('superadmin.deduction-sections.update', $deductionSection) }}" method="post" class="max-w-md space-y-6">
            @csrf
            @method('PUT')
            <div>
                <label for="section_code" class="block text-sm font-medium text-slate-700">Section code <span class="text-red-500">*</span></label>
                <input type="text" name="section_code" id="section_code" value="{{ old('section_code', $deductionSection->section_code) }}" required maxlength="20" class="mt-1 w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
                @error('section_code') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror
            </div>
            <div>
                <label for="section_name" class="block text-sm font-medium text-slate-700">Section name <span class="text-red-500">*</span></label>
                <input type="text" name="section_name" id="section_name" value="{{ old('section_name', $deductionSection->section_name) }}" required maxlength="100" class="mt-1 w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
                @error('section_name') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror
            </div>
            <div>
                <label for="limit_amount" class="block text-sm font-medium text-slate-700">Limit amount</label>
                <input type="number" name="limit_amount" id="limit_amount" value="{{ old('limit_amount', $deductionSection->limit_amount) }}" step="0.01" min="0" class="mt-1 w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
                @error('limit_amount') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror
            </div>
            <div>
                <label for="description" class="block text-sm font-medium text-slate-700">Description</label>
                <textarea name="description" id="description" rows="2" class="mt-1 w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">{{ old('description', $deductionSection->description) }}</textarea>
            </div>
            <div>
                <label class="inline-flex items-center gap-2">
                    <input type="hidden" name="is_active" value="0">
                    <input type="checkbox" name="is_active" value="1" {{ old('is_active', $deductionSection->is_active) ? 'checked' : '' }} class="rounded border-slate-300 text-slate-800">
                    <span class="text-sm text-slate-700">Active</span>
                </label>
            </div>
            <div class="flex gap-3">
                <button type="submit" class="rounded-lg bg-primary px-4 py-2 text-sm font-medium text-white">Update</button>
                <a href="{{ route('superadmin.deduction-sections.index') }}" class="rounded-lg border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Cancel</a>
            </div>
        </form>
    </x-card>
@endsection
