@extends('layouts.app')

@section('title', 'Edit Ruangan')
@section('page_title', 'Edit Data Ruangan')
@section('page_pretitle', 'Master Ruangan')

@section('page_actions')
  <a class="btn" href="{{ route('rooms.index') }}">
    <i class="ti ti-arrow-left me-1"></i>
    Kembali
  </a>
@endsection

@section('content')
  <div class="card">
    <div class="card-header">
      <div>
        <h3 class="card-title">{{ $room->nama_ruangan }}</h3>
        <p class="card-subtitle">{{ $room->kode_qr }}</p>
      </div>
    </div>
    <form action="{{ route('rooms.update', $room) }}" method="POST">
      @csrf
      @method('PUT')
      <div class="card-body">
        <div class="row g-3">
          <div class="col-md-6">
            <label class="form-label">Nama Ruangan</label>
            <input class="form-control" name="name" value="{{ old('name', $room->nama_ruangan) }}" required>
          </div>
          <div class="col-md-3">
            <label class="form-label">Kode Ruangan</label>
            <input class="form-control" name="code" value="{{ old('code', $room->kode_ruangan) }}" required>
          </div>
          <div class="col-md-3">
            <label class="form-label">Lantai</label>
            <input class="form-control" name="floor" value="{{ old('floor', $room->lantai) }}">
          </div>
          <div class="col-md-6">
            <label class="form-label">Penanggung Jawab</label>
            <input class="form-control" name="responsible_person" value="{{ old('responsible_person', $room->penanggung_jawab) }}">
          </div>
          <div class="col-md-3">
            <label class="form-label">Status</label>
            <select class="form-select" name="status">
              <option value="active" @selected(old('status', $room->status_ruangan) === 'active')>Aktif</option>
              <option value="inactive" @selected(old('status', $room->status_ruangan) === 'inactive')>Nonaktif</option>
            </select>
          </div>
        </div>
      </div>
      <div class="card-footer text-end">
        <button class="btn btn-primary" type="submit">
          <i class="ti ti-device-floppy me-1"></i>
          Update Ruangan
        </button>
      </div>
    </form>
  </div>
@endsection
