Skip to content

Support multiple emails per teacher - #180

Merged
buzz-code merged 4 commits into
mainfrom
claude/teacher-additional-email-1f7jsm
Sep 5, 2026
Merged

buzz-code merged 4 commits into
mainfrom
claude/teacher-additional-email-1f7jsm

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

Summary

Teacher can now store multiple emails (like the existing phone/phone2 pair), and the report-file mail is sent to all of them.

  • Teacher.entity.ts: email is now string[] | null (simple-array column). A plain comma-separated string (e.g. from Excel import) is normalized into an array before validation and before save.
  • Datagrid: each address rendered as its own EmailField.
  • Edit form: ArrayInput/SimpleFormIterator with type="email" inputs to add/remove addresses.
  • Export: addresses joined with , .
  • Migration widens teachers.email from varchar(500) to text in place — existing single-address values remain valid, no data conversion needed.
  • Bumps server/shared to merged nra-server#51, so sendBulkTeacherMailWithFile sends to every address in the array (still backward compatible with a plain string).

Testing

  • cd server && yarn test — 117 suites / 1030 tests pass
  • cd client && yarn test — 31 suites / 204 tests pass
  • tsc --noEmit clean

🤖 Generated with Claude Code


Generated by Claude Code

Teacher.email is now a string array instead of a single address, so a
teacher can be reached at more than one address (like the existing
phone/phone2 pair, but as a real array since it's actually sent to,
not just displayed):

- Teacher.entity.ts: email column is `simple-array`, validated as an
  array of email addresses; a plain comma-separated string (e.g. from
  Excel import) is normalized into an array before validation and
  before save.
- Datagrid shows each address as its own EmailField; the edit form
  uses ArrayInput/SimpleFormIterator to add/remove addresses.
- Export joins the addresses into a comma-separated string.
- Migration widens the column from varchar(500) to text in place
  (existing single-address values remain valid).
- Bumps server/shared to pick up sendBulkTeacherMailWithFile sending
  to every address in the array (still backward compatible with a
  plain string).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qta52umWJRr3CBuj4XVfCV
- email array input uses type="email" (proper keyboard/semantics,
  not a plain text box)
- merge normalizeNumber/normalizeEmail into one BeforeInsert/
  BeforeUpdate hook - no need for two separate ones

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qta52umWJRr3CBuj4XVfCV
Points at buzz-code/nra-server#51 (sendBulkTeacherMailWithFile
multi-email support), now merged to main.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qta52umWJRr3CBuj4XVfCV
Copilot AI lite review requested due to automatic review settings September 5, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Email normalization helper returns undefined for undefined input and UI rendering uses unstable React keys for repeated emails.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Support multiple email addresses per Teacher across server entity, export, UI, plus DB migration so report-file mail can target all addresses.

Changes:

  • Convert Teacher.email to simple-array (string[] | null) with normalization hook + transform
  • Update teacher export header to emit comma-separated list, add spec coverage
  • Update React-Admin teacher list + form to display/edit multiple emails
File summaries
File Description
server/src/migrations/1788633251783-ConvertTeacherEmailToArray.ts Widen teachers.email to text for multi-value storage
server/src/entity-modules/teacher.config.ts Export header now joins email array for CSV/export
server/src/entity-modules/tests/teacher.config.spec.ts Assert export uses function + joins emails
server/src/db/entities/Teacher.entity.ts Switch email to simple-array + normalize/validate
client/src/entities/teacher.jsx Render multiple EmailField values; edit via ArrayInput
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +41 to +48
<FunctionField
source="email"
render={(record) => [].concat(record.email ?? []).map((addr) => (
<div key={addr}>
<EmailField record={{ email: addr }} source="email" />
</div>
))}
/>
Comment on lines +102 to +108
function splitEmails(value: unknown): string[] | null {
if (typeof value !== 'string') return value as string[] | null;
return value
.split(',')
.map((e) => e.trim())
.filter(Boolean);
}
@buzz-code
buzz-code merged commit bd25804 into main Sep 5, 2026
4 checks passed
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.

3 participants