Skip to content

feat(timeslots): notify customers when a booked timeslot is deleted#97

Merged
choden-dev merged 1 commit into
mainfrom
feat/notify-timeslot-deletion
Jul 14, 2026
Merged

feat(timeslots): notify customers when a booked timeslot is deleted#97
choden-dev merged 1 commit into
mainfrom
feat/notify-timeslot-deletion

Conversation

@choden-dev

Copy link
Copy Markdown
Owner

Summary

Investigated whether Payload notifies customers when a pickup timeslot is deleted. It did not: the Timeslots collection only had an afterChange hook (for edits), with no afterDelete. Deleting a booked timeslot left affected orders with a dangling reference and gave customers no notice.

This PR adds customer notification on timeslot deletion.

Changes

  • lib/templates/timeslotDeleted.pug (new): apology email template that reassures the customer their order is unaffected and asks them to select a new pickup slot. Uses the existing shared mixins/styles. No em dashes in the copy.
  • lib/email.ts: new sendTimeslotDeletedEmail(), following the existing sendTimeslotChangedEmail pattern. Subject: Action Needed: Select a New Pickup Time — <orderNumber>.
  • collections/Timeslots.ts: new afterDelete hook notifyOnTimeslotDelete that:
    • finds all orders referencing the deleted timeslot,
    • clears each order's pickupTimeslot reference so the customer can re-select,
    • emails each affected customer (fire-and-forget so the admin UI is not blocked).

This mirrors the existing afterChange notification behavior and complements the existing Orders afterDelete bookedCount handling.

Testing

  • tsc --noEmit passes for changed files.
  • biome check clean.

@choden-dev
choden-dev merged commit 6215661 into main Jul 14, 2026
4 checks passed
@choden-dev
choden-dev deleted the feat/notify-timeslot-deletion branch July 14, 2026 08:58
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