@extends('layouts.app')

@section('content')
    <div class="container p-4">
        <div class="card shadow-sm p-3">
            <h4 class="fw-bold" style="color: #063986;">Edit Kamar</h4>

            <form action="{{ route('admin.updateroom', ['id_kamar' => $room->id_kamar]) }}" method="POST" enctype="multipart/form-data">
                @csrf
                
                <div class="mb-3">
                    <label class="form-label">Nomor Kamar</label>
                    <input type="text" name="room_number" class="form-control" value="{{ $room->room_number }}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">Tipe Kamar</label>
                    <input type="text" name="room_type" class="form-control" value="{{ $room->room_type }}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">Harga</label>
                    <input type="number" name="harga" class="form-control" value="{{ $room->harga }}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">Status</label>
                    <select name="status" class="form-select" required>
                        <option value="tersedia" {{ $room->status == 'tersedia' ? 'selected' : '' }}>Tersedia</option>
                        <option value="terisi" {{ $room->status == 'terisi' ? 'selected' : '' }}>Terisi</option>
                        <option value="maintenance" {{ $room->status == 'maintenance' ? 'selected' : '' }}>Maintenance</option>
                    </select>
                </div>

                <div class="mb-3">
                    <label class="form-label">Lantai</label>
                    <input type="number" name="lantai" class="form-control" value="{{ $room->lantai }}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">Fasilitas</label>
                    <textarea name="fasilitas" class="form-control" required>{{ $room->fasilitas }}</textarea>
                </div>

                <div class="mb-3">
                    <label class="form-label">Foto Kamar</label>
                    <input type="file" name="foto" class="form-control">
                    
                    @if($room->foto)
                        <div class="mt-2">
                            <img src="{{ asset('assets/admin/' . $room->foto) }}" alt="Foto Kamar" width="100" class="rounded">
                        </div>
                    @endif
                </div>

                <div class="mb-3">
                    <label class="form-label">Deskripsi</label>
                    <textarea name="deskripsi" class="form-control" required>{{ $room->deskripsi }}</textarea>
                </div>

                <button type="submit" class="btn btn-primary">Update</button>
                <a href="{{ route('admin.rooms') }}" class="btn btn-secondary">Kembali</a>
            </form>
        </div>
    </div>
@endsection
