feat(timeslots): confirm-and-message flow for timeslot deletion#98
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
pickupTimeslotso the customer can re-book,Changes
collections/Timeslots.ts: removed the automaticafterDeletenotification hook; registeredDeleteTimeslotButtonviaadmin.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-authenticatedGET(affected count + label) andPOST(clear references, notify, delete).lib/email.ts:sendTimeslotDeletedEmailnow accepts an optionalcustomMessage.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
afterDeletehook was removed, notification now happens only through this new button. Payload's default delete controls will not notify customers.Testing
tsc --noEmitpasses for changed files.biome checkclean.