@extends('layouts.guru')
@section('content')
<x-slot name="header">
    <h2 class="font-semibold text-xl text-gray-800 leading-tight">
        {{ __('Edit Prestasi') }}
    </h2>
</x-slot>

<div class="py-12">
    <div class="max-w-2xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
            <div class="p-6">
                <h2 class="text-xl font-bold text-primary mb-4">Edit Data Prestasi</h2>
                <form action="{{ route('prestasis.update', $prestasi) }}" method="POST">
                    @csrf
                    @method('PUT')
                    <div class="mb-3">
                        <label class="font-semibold">Santri</label>
                        <select name="santri_id" class="form-control rounded" required>
                            <option value="">Pilih Santri</option>
                            @foreach($santris as $s)
                                <option value="{{ $s->id }}" {{ old('santri_id', $prestasi->santri_id)==$s->id?'selected':'' }}>{{ $s->nama }}</option>
                            @endforeach
                        </select>
                        @error('santri_id')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                    </div>
                    <div class="mb-3">
                        <label class="font-semibold">Kelas</label>
                        <select name="kelas_id" class="form-control rounded" required>
                            <option value="">Pilih Kelas</option>
                            @foreach($kelas as $k)
                                <option value="{{ $k->id }}" {{ old('kelas_id', $prestasi->kelas_id)==$k->id?'selected':'' }}>{{ $k->nama_kelas }}</option>
                            @endforeach
                        </select>
                        @error('kelas_id')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                    </div>
                    <div class="mb-3">
                        <label class="font-semibold">Nama Perlombaan</label>
                        <input type="text" name="nama_perlombaan" class="form-control rounded" value="{{ old('nama_perlombaan', $prestasi->nama_perlombaan) }}" required>
                        @error('nama_perlombaan')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                    </div>
                    <div class="mb-3">
                        <label class="font-semibold">Keterangan</label>
                        <input type="text" name="keterangan" class="form-control rounded" value="{{ old('keterangan', $prestasi->keterangan) }}">
                        @error('keterangan')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                    </div>
                    <div class="flex gap-2 mt-4">
                        <button type="submit" class="btn-primary">Update</button>
                        <a href="{{ route('prestasis.index') }}" class="btn-accent">Kembali</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection 