Skip to content

Slice 2a (Module 03): Slot table + list-own + read-only slot management page #20

Description

@mGasiorek998

What to build

Land the doctor_slots schema and the read side of slot management: a doctor-only /doctor/slots page that lists all of their slots (free + booked) sorted ascending by start time. Creation comes in Slice 2b — this slice ships a page that shows an empty state (or seeded slots) and the API/data foundation everything else builds on.

  • Drizzle migration: create slot_status Postgres enum (free | booked); create doctor_slots table — UUID PK, doctor_id FK to users.id (ON DELETE CASCADE), starts_at and ends_at timezone-aware non-null, status defaulting to free, composite index on (doctor_id, starts_at), DB check constraint ends_at > starts_at.
  • Extend pnpm db:seed to give each seeded doctor at least one free slot so the page is non-empty for demos and so Module 04 has data to consume.
  • Fill in doctorContract with listOwnSlots.
  • GET /doctors/me/slots → 200 Array<{ id, startsAt, endsAt, status }> sorted ascending by startsAt, both free and booked, behind requireAuth() + requireRole(['doctor']).
  • New /doctor/slots route: list table with start/end (rendered in Europe/Warsaw), status badge, empty state. TanStack Router file route, beforeLoad guard that redirects patients to /patient.
  • Header row links from /doctor to /doctor/slots.

Acceptance criteria

  • Migration applied via pnpm db:push; doctor_slots exists with the composite index and check constraint; the slot_status enum has values free and booked.
  • pnpm db:seed populates at least one slot per seeded doctor and is idempotent on re-run.
  • GET /doctors/me/slots returns the calling doctor's slots sorted ascending; never includes another doctor's slots.
  • GET /doctors/me/slots returns 401 without JWT and 403 with a patient JWT.
  • /doctor/slots renders the slot list with Europe/Warsaw-formatted datetimes and a status indicator.
  • A patient JWT navigating to /doctor/slots is redirected to /patient.
  • An empty-state message renders when the doctor has no slots.
  • pnpm verify exits 0.

User stories covered

Blocked by

  • None — can start immediately

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    afkEligible for the main agent looppriority:1Priority 1 — bugs default heresliceVertical tracer-bullet slice

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions