<x-layout bodyClass="g-sidenav-show  bg-gray-200">
  <x-navbars.sidebar_triage
    role="{{ $request->user()->role }}"
    activePage="schedules"
  ></x-navbars.sidebar_triage>

  <main
    class="main-content position-relative max-height-vh-100 h-100 border-radius-lg"
  >

    <!-- Navbar -->
    <x-navbars.navs.auth
      titlePage="schedules"
      role="{{ $request->user()->role }}"
      firstName="{{ $request->user()->name }}"
    >
    </x-navbars.navs.auth>
    <!-- End Navbar -->

    <div class="container-fluid px-md-4 px-2">
      <div class="row gx-4 mb-2">
        <div
          class="col-auto"
          style="display: none;"
        >
          <div class="avatar avatar-xl position-relative">
            <img
              class="w-100 border-radius-lg shadow-sm"
              src="{{ asset('assets') }}/img/bruce-mars.jpg"
              alt="profile_image"
            >
          </div>
        </div>
        <div class="col-auto my-auto">
          <div class="h-100">
            <h5 class="mb-1">
              {{ $schedule->name }}
            </h5>
            <p class="font-weight-normal mb-0 text-sm">
              {{ $schedule->name }}
            </p>
          </div>
        </div>
      </div>

      <div class="card card-plain h-100">
        <div class="card-header p-3 pb-0">
          <div class="row mb-4">
            <div class="col-md-6 d-flex align-items-center">
              <h6
                class="align-center mb-3"
                style="margin-bottom: 0 !important;"
              >
                View Schedule Information
              </h6>
            </div>

            <div class="col-md-6 d-flex align-items-center">
              <form
                action="/schedules/{{ $schedule->id }}"
                method="POST"
              >

                <a
                  class="btn btn-secondary btn-sm"
                  href="/schedules/{{ $schedule->id }}/edit"
                  style="margin-bottom: 0;"
                >
                  <span class="btn-text">edit</span>
                </a>

                @csrf
                @method('DELETE')
                <button
                  class="btn btn-danger btn-sm"
                  style="margin-bottom: 0;"
                >
                  <span class="btn-text">delete</span>
                </button>

              </form>
            </div>
          </div>
        </div>

        <div
          class="card-body p-3 pb-0"
          style="background-color: white;"
        >
          <div class="row">

            <div class="col-md-6 mb-3">
              <label class="form-label">Start time (Y-m-d)</label>
              <input
                class="form-control border border-2 p-2"
                id="startTime"
                name="startTime"
                type="text"
                value="{{ old('startTime', $schedule->startTime) }}"
                disabled
              />

              @error('startTime')
                <p class='text-danger inputerror'>{{ $message }} </p>
              @enderror
            </div>

            <div class="col-md-6 mb-3">
              <label class="form-label">End time (Y-m-d)</label>
              <input
                class="form-control border border-2 p-2"
                id="endTime"
                name="endTime"
                type="text"
                value="{{ old('endTime', $schedule->endTime) }}"
                disabled
              />

              @error('endTime')
                <p class='text-danger inputerror'>{{ $message }} </p>
              @enderror
            </div>

            <div class="col-md-6 mb-3">
              <label class="form-label">Classroom :</label>
              @if ($schedule->classRooms[0]->deleted == 'true')
                <input
                  class="form-control border border-2 p-2"
                  id="class_room_id"
                  name="endTime"
                  type="text"
                  value="{{ $schedule->classRooms[0]->classRoomTitle }} (deleted)"
                  disabled
                />
              @else
                <input
                  class="form-control border border-2 p-2"
                  id="class_room_id"
                  name="endTime"
                  type="text"
                  value="{{ $schedule->classRooms[0]->classRoomTitle }}"
                  disabled
                />
              @endif

              @error('classRoom')
                <p class='text-danger inputerror'>{{ $message }} </p>
              @enderror
            </div>

            <div class="col-md-6 mb-3">
              <label class="form-label">Subject :</label>

              @if ($schedule->subjects[0]->deleted == 'true')
                <input
                  class="form-control border border-2 p-2"
                  id="class_room_id"
                  name="endTime"
                  type="text"
                  value="{{ $schedule->subjects[0]->subjectTitle }} (deleted)"
                  disabled
                />
              @else
                <input
                  class="form-control border border-2 p-2"
                  id="class_room_id"
                  name="endTime"
                  type="text"
                  value="{{ $schedule->subjects[0]->subjectTitle }}"
                  disabled
                />
              @endif

              @error('subject_id')
                <p class='text-danger inputerror'>{{ $message }} </p>
              @enderror
            </div>

            <div class="col-md-full mb-3">
              <label class="form-label">Name</label>
              <input
                class="form-control border border-2 p-2"
                name="subject"
                type="text"
                value="{{ $schedule->subject }}"
                disabled
              >

              @error('subject')
                <p class='text-danger inputerror'>{{ $message }} </p>
              @enderror
            </div>

            <div class="col-md-12 mb-3">
              <label for="floatingTextarea2">Description :</label>
              <textarea
                class="form-control border border-2 p-2"
                id="floatingTextarea2"
                name="description"
                placeholder="schedule description"
                rows="4"
                cols="50"
                disabled
              />{{ old('description', $schedule->description) }}</textarea>

              @error('description')
                <p class='text-danger inputerror'>{{ $message }}</p>
              @enderror
            </div>

          </div>
        </div>

        <div
          class="card-footer d-flex"
          style="background-color: white;"
        >
          <a
            class="btn btn-secondary btn-sm font-weight-normal my-auto"
            href="/schedules"
            style="display: flex; flex-direction: row; justify-content: center; align-items: center; gap: 1rem;"
          >
            <i
              class="fas fa-arrow-left"
              style="font-size: 1rem;"
            ></i> Back
          </a>
        </div>

      </div>
    </div>
  </main>

</x-layout>
