Admin
Email Management
| Path | /email-management |
|---|---|
| Status | live |
| Drill-down pages | /email-templates |
| Pop-ups | Add / edit recipient, Delete confirm |
| Tabs | โ |
| API routes | /api/email-recipients/api/email-recipients/options/api/email-recipients/:id/api/email-recipients/:id/active |
What's on the page
- Search (email, name or phone), Sent For (one alert, with how many active recipients get it), Type (To / Bcc), Active, Clear. Filters, sort and page are kept in the link.
- Columns: Email, Name, Phone, Type, Sent For (the alerts ticked; the filtered one is highlighted), Active switch, Edit and Delete. Every column but Phone sorts.
- Add To / Add Bcc open the form: email, name, phone, type, active and the alerts to tick. A new recipient starts with the Dental Day schedule alerts ticked (approvals, cancel/reschedule, status changes, Dental Day updates, low bookings, operatory changes).
- Delete asks first; switching someone off pauses every alert without losing their ticks.
Business rules
Data comes from: email_recipients (one row per address and type, To or Bcc; unique per type), email_recipient_notify_types (which alerts each row gets) and email_notify_types (the alert list, its labels and order). API: GET /api/email-recipients (one page), /options (alert types with counts), POST /, PUT /:id, PATCH /:id/active, DELETE /:id.
How it works:
- Needs the Email Management access key (or admin), checked on the server.
- Saving checks the email is one address (stored lower-case), the type is To or Bcc, the phone has at least 7 digits, and every alert exists. The same address can't be added twice for one type ("already on the list").
- Senders read who gets an alert at send time: To rows go in To, Bcc rows in Bcc, active rows only. Every add, edit, switch and delete is in the Audit Log.
- Each row lists its alerts by name. A row with nothing ticked gets no alerts (stored as
none, which no sender matches). - The old comma list (
email_recipients.notify_types) is still filled in automatically for the senders that read it.
Database tables & columns
| Table | Columns used |
|---|---|
email_notify_types | key, label, sort_order |
email_recipient_notify_types | notify_type, recipient_id |
email_recipients | active, created_at, email, email_type, id, name, notify_types, phone, updated_at |
File structure
Its own files
- apps/
- web/
- src/
- features/
- email-management/
- components/
- RecipientDialog.tsx
- pages/
- EmailManagementPage.tsx
- api.ts
- index.ts
- components/
- email-management/
- features/
- src/
- web/
Shared code it uses (followed through its imports and the helpers its API calls; sign-in/access plumbing and UI primitives left out)
- apps/
- web/
- src/
- components/
- data/
- DataTable.tsx
- reports/
- DentrixSourceNote.tsx
- FilterSelect.tsx
- HowItWorksNote.tsx
- ReportHeader.tsx
- sortable-grid.tsx
- TablePagination.tsx
- data/
- hooks/
- usePagedList.ts
- services/
- api.ts
- components/
- src/
- worker/
- src/
- db/
- index.ts
- features/
- email-recipients/
- queries.ts
- routes.ts
- service.ts
- email-recipients/
- lib/
- db-errors.ts
- list-query.ts
- utils/
- email.ts
- db/
- src/
- web/