Skip to content

Feature/coordinator availability UI - #153

Merged
martin0024 merged 1 commit into
developfrom
feature/coordinator-availability-ui
Sep 26, 2026
Merged

martin0024 merged 1 commit into
developfrom
feature/coordinator-availability-ui

Conversation

@martin0024

@martin0024 martin0024 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130

Summary

Adds an Availability page where coordinators set when they're available for private lessons: weekly hours, time zone, date overrides and a preview
of the next few weeks. UI only. It builds on the backend from #119 / #124, plus one new read action.

Changes

Page & navigation

  • New /availability page (app/(authenticated)/availability), using the same Suspense + async content pattern as children/page.tsx.
  • Only coordinators can open it. Admins and regular users are redirected to /.
  • Availability sidebar link, shown to coordinators only.

Editor (components/availability/)

Takes a coordinatorId prop, so the admin issue ("Admin — edit any coordinator's availabilities") can reuse it.

  • Weekly hours: add, edit or remove time windows for each weekday. Each window repeats every week or every other week (with a start date).
  • Time zone: picker in the Weekly hours card, saved together with the hours.
  • Inline validation: overlapping windows, an end time before the start time, and a missing start date for every-other-week are flagged on the
    window itself, and Save is disabled. Any error from the server is shown in the card footer.
  • Date overrides: a date picker dialog to set custom hours or a day off for one date, pre-filled with that day's usual hours. It lists upcoming
    overrides, including days off, with edit and remove.
  • Preview: a 4-week calendar combining weekly hours and overrides. It marks overrides and days off and pages forward 4 weeks at a time.
  • How bookable slots work: explains that each window is cut into back-to-back slots of the lesson's length and that leftover time can't be booked.
    Each window shows a hint like "3 × 60-min slots · last 30 min not bookable", based on the coordinator's active private lessons.
  • The UI notes that changes only affect future bookings. Lessons already booked are never modified, since only the availability tables are written.

Backend

  • New read action listCoordinatorAvailabilityOverrides({ coordinatorId, from }), which returns upcoming overrides including days off (windows: []).
    It uses the same permission checks as the other availability actions.
  • The overlap check moved from app/private-lessons/schema.ts into lib/availability.ts (toMinutes, windowsConflict), so the server and the UI
    apply the same rule.
  • lib/availability-editor.ts holds the page's pure helpers: time formatting, slot splitting, per-window validation, time zone labels and building the
    preview grid.

Tests

  • __tests__/coordinator-availability-actions.test.ts: 5 new tests for listCoordinatorAvailabilityOverrides (returns days off, admin access, blocks
    regular users and other coordinators, rejects invalid dates).
  • __tests__/availability-editor.test.ts: tests for formatting, slot splitting, validation (including every-other-week windows that overlap only on
    alternate weeks), date and time zone helpers, and the preview grid.
  • registrations-view.test.tsx fails the same way on develop; that's unrelated to this PR.
01-overview

@martin0024
martin0024 changed the base branch from main to develop September 26, 2026 19:15
@martin0024
martin0024 merged commit fd8f19a into develop Sep 26, 2026
@martin0024
martin0024 deleted the feature/coordinator-availability-ui branch September 26, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue]: Coordinator UI to set their availabilities

2 participants