Repository navigation
Support multiple emails per teacher - #180
Merged
Merged
Conversation
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
…onal-email-1f7jsm
There was a problem hiding this comment.
🟡 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.emailtosimple-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); | ||
| } |
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
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:emailis nowstring[] | null(simple-arraycolumn). A plain comma-separated string (e.g. from Excel import) is normalized into an array before validation and before save.EmailField.ArrayInput/SimpleFormIteratorwithtype="email"inputs to add/remove addresses.,.teachers.emailfromvarchar(500)totextin place — existing single-address values remain valid, no data conversion needed.server/sharedto merged nra-server#51, sosendBulkTeacherMailWithFilesends to every address in the array (still backward compatible with a plain string).Testing
cd server && yarn test— 117 suites / 1030 tests passcd client && yarn test— 31 suites / 204 tests passtsc --noEmitclean🤖 Generated with Claude Code
Generated by Claude Code