Skip to content

feat(timeslots): confirm-and-message flow for timeslot deletion#98

Merged
choden-dev merged 1 commit into
mainfrom
feat/timeslot-delete-confirm-message
Jul 14, 2026
Merged

feat(timeslots): confirm-and-message flow for timeslot deletion#98
choden-dev merged 1 commit into
mainfrom
feat/timeslot-delete-confirm-message

Conversation

@choden-dev

Copy link
Copy Markdown
Owner

Summary

Builds on the timeslot-deletion notification (#97) to give admins control over the message customers receive. Instead of an automatic, generic email on delete, deleting a timeslot now goes through a deliberate confirmation flow where the admin can write a personalised message.

Behaviour

  • On the Timeslot edit view, a "Delete timeslot & notify customers" button opens a confirmation modal.
  • The modal shows how many orders will be notified and a textarea pre-filled with an editable default apology (mentioning the slot's date/time). The admin can tweak, replace, or clear it.
  • On confirm, an admin API route:
    1. clears each affected order's pickupTimeslot so the customer can re-book,
    2. emails every booked customer (including the admin's note as an "A note from us" section),
    3. deletes the timeslot.
  • The admin is redirected back to the timeslots list with a summary of how many customers were notified.

Changes

  • collections/Timeslots.ts: removed the automatic afterDelete notification hook; registered DeleteTimeslotButton via admin.components.edit.beforeDocumentControls.
  • components/admin/DeleteTimeslotButton.tsx (new): client component with confirmation modal, affected-order count, and editable message box.
  • app/api/admin/timeslots/[id]/delete/route.ts (new): admin-authenticated GET (affected count + label) and POST (clear references, notify, delete).
  • lib/email.ts: sendTimeslotDeletedEmail now accepts an optional customMessage.
  • lib/templates/timeslotDeleted.pug: renders the admin's message as a highlighted "A note from us" section (falls back to the standard apology when empty). No em dashes.
  • app/(payload)/admin/importMap.js: registered the new component.

Notes

  • Because the auto afterDelete hook was removed, notification now happens only through this new button. Payload's default delete controls will not notify customers.

Testing

  • tsc --noEmit passes for changed files.
  • biome check clean.
  • Pug template renders correctly both with and without a custom message.

Replace the automatic afterDelete notification hook with a deliberate
admin flow: a custom edit-view button opens a confirmation modal with an
editable, pre-filled message. On confirm, an admin API route clears each
affected order's pickupTimeslot, emails every booked customer (including
the admin's personalised note), then deletes the timeslot.

- collections/Timeslots.ts: remove afterDelete hook; add DeleteTimeslotButton
- components/admin/DeleteTimeslotButton.tsx: confirmation modal + message box
- app/api/admin/timeslots/[id]/delete/route.ts: GET count + POST delete/notify
- lib/email.ts: sendTimeslotDeletedEmail accepts optional customMessage
- lib/templates/timeslotDeleted.pug: 'A note from us' section
- importMap.js: register component
@choden-dev
choden-dev merged commit 60acd84 into main Jul 14, 2026
4 checks passed
@choden-dev
choden-dev deleted the feat/timeslot-delete-confirm-message branch July 14, 2026 09:25
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.

1 participant