<x-app-layout>

    @include('jadwalbk.create')
    @include('jadwalbk.edit')
    @include('jadwalbk.delete')

    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            @if (Auth::user()->hasRole('Siswa'))
            {{ __('JADWAL BK SMK') }}
            @elseif (Auth::user()->hasRole('BK'))
            {{ __('JADWAL BK SMK') }}
            @endif
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6 text-gray-900">

                    @hasanyrole('Admin|GuruBK')
                    <button type="button" class="btn btn-outline-warning m-4" data-bs-toggle="modal" data-bs-target="#tambahModal">TAMBAH DATA</button>
                    @endhasanyrole

                    @hasanyrole('Siswa|WaliKelas')
                    <center>
                        <b>JADWAL KONSELING POLI JIWA<br>RSUD SAYANG KABUPATEN CIANJUR</b>
                        <br>
                        <br>
                    </center>
                    @endhasrole

                    <x-table :tableId="'myTable_' . uniqid()">
                        <x-slot name="header">
                            <tr class="bg-gray-400 text-center">
                                <th>NO</th>
                                <th>NAMA GURU BK</th>
                                <th>HARI</th>
                                <th>JAM</th>
                                @hasanyrole('Admin|GuruBK')
                                <th>AKSI</th>
                                @endhasanyrole
                            </tr>
                        </x-slot>
                        @php $num = 1; @endphp
                        @foreach ($jadwalbk as $data)
                        <tr class="text-center">
                            <td>{{ $num++ }}</td>
                            <td>{{ $data->guru->nama_guru }}</td>
                            <td>{{ $data->hari_mulai}} dan {{ $data->hari_selesai}}</td>
                            <td>{{ $data->jam}} - selesai</td>
                            @hasanyrole('Admin|GuruBK')
                            <td>
                                <button type="button" class="btn btn-outline-warning" data-bs-toggle="modal" data-bs-target="#exampleModal_{{ $data->id_jadwal }}"><i class="fa-solid fa-pen-to-square"></i>
                                </button>
                                <button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#hapusModal_{{ $data->id_jadwal }}"><i class="fa-solid fa-trash-can"></i>
                                </button>
                            </td>
                            @endhasanyrole
                        </tr>
                        @endforeach
                    </x-table>
                </div>
            </div>
        </div>
    </div>
</x-app-layout>