# Per-Room Schedule with Day Tabs — Design

Date: 2026-09-16
Status: Approved

## Goal

On the room page (`/berita/{id}`, "Jadwal Ruangan" tab), let students view the
room's schedule for any weekday (Senin–Jumat) instead of only today, using a
day-tab switcher styled like the one on `/jadwal-hari-ini`.

## Decisions

- Location: existing "Jadwal Ruangan" tab on the room page (no new route; the
  dead `/jadwal/{id}` route is out of scope).
- Presentation: keep the existing list-style DataTable (Jam, Dosen, Kelas,
  Mata Kuliah) and add day tabs above it.
- Interaction: server-side links (`?hari=<day>#jadwal`) like `jadwal-hari-ini`.
- Reservations (`tidak tetap`, status=1) appear only on the **today** tab —
  they are bound to specific dates, not weekdays.
- Green "ongoing class" row highlight applies only when viewing today.

## Data Flow

1. `GET /berita/{id}?hari=Senin#jadwal` — `BeritaController::index` reads
   `hari` (validated against Senin/Selasa/Rabu/Kamis/Jumat, default = today
   in Asia/Jakarta) and passes it to `JadwalRuanganDataTable` alongside the
   existing `kelas_id`.
2. The DataTable's `html()` builds its AJAX URL with both `kelas_id` and
   `hari`; the AJAX request carries them to the `data.jadwal` endpoint.
3. `JadwalRuanganDataTable::query()` filters:
   - `tipe_jadwal = 'tetap'` AND `hari = <selectedDay>`
   - OR (only when `selectedDay === today`): `tipe_jadwal = 'tidak tetap'`
     AND `status = 1` AND `hari` (date) = today — current behavior unchanged.
   - Order by `jam_masuk` as today.

## UI

- Day tab bar above the schedule table inside the Jadwal tab panel, reusing
  the `jadwal-hari-ini` tab styles (`border-b`, active = red underline +
  bold red text). Links use `request()->fullUrlWithQuery(['hari' => $day])`
  plus the `#jadwal` fragment so the Alpine tab selection is preserved after
  reload (the page's tab init reads `window.location.hash`).
- The tab matching today gets a small marker (e.g. dot) so users can spot it.
- Empty state ("Tidak ada jadwal ...") continues to come from DataTables'
  zero-records message; a short line is added above the table when viewing a
  non-today day so the reservation rule is understandable.

## Highlight Rule

`setRowClass`'s `!bg-green/15` (currently running class) is applied only when
`selectedDay === today`; other days render plain rows. The reservasi
`row-reservasi` merge (drawCallback) keeps working for the today tab.

## Out of Scope

- Fixing or removing the dead `/jadwal/{id}` route.
- Showing reservations under non-today weekday tabs.
- Grid-style per-room view.

## Testing / Verification

- Unit-ish script: instantiate `JadwalRuanganDataTable` with `kelas_id` +
  `hari` for each weekday and confirm row counts/day filtering against the
  DB; confirm reservations only appear for today's day param.
- Render `app.berita.index` with a room that has schedules; confirm the tab
  bar markup, active tab, hash-preservation in URLs, and the today marker.
