Skip to content

Slice 3 (Module 03): Slot deletion with booked guard #22

Description

@mGasiorek998

What to build

Let a doctor delete their own free slots with a per-row delete button on /doctor/slots. Slots in booked status must not be deletable — both the API and the UI enforce this so a doctor can never silently cancel a confirmed appointment.

  • Fill in doctorContract with deleteSlot.
  • DELETE /doctors/{doctorId}/slots/{slotId} behind requireAuth() + requireRole(['doctor']) plus an ownership check: 403 if doctorId ≠ JWT sub.
  • Returns 204 on successful deletion; 404 SLOT_NOT_FOUND if the slot does not exist; 409 SLOT_BOOKED if its status is booked.
  • Structured INFO log on every successful deletion (acting doctor id, slot id).
  • Per-row delete button on /doctor/slots: hidden or disabled-with-tooltip ("Booked slots cannot be deleted") for booked rows; on success removes the row from the list (TanStack Query invalidation).

Acceptance criteria

  • DELETE /doctors/{doctorId}/slots/{slotId} removes a free slot owned by the caller and returns 204.
  • DELETE … on a slot with status booked returns 409 SLOT_BOOKED and leaves the row in place.
  • DELETE … where doctorId does not match the calling user returns 403 (cross-doctor tampering blocked).
  • DELETE … for a non-existent slot returns 404 SLOT_NOT_FOUND.
  • DELETE … returns 401 without JWT and 403 with a patient JWT.
  • The delete button on /doctor/slots is disabled (or absent) for booked slots and removes the row on success.
  • pnpm verify exits 0.

User stories covered

Blocked by

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:2Priority 2sliceVertical tracer-bullet slice

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions