Repository navigation
fix: use sample data for email previews - #1941
Conversation
| @@ -0,0 +1,67 @@ | |||
| import { | |||
| buildSubstitutionData, | |||
There was a problem hiding this comment.
I think it would make more sense just to edit the buildSubstitutionData object instead of importing it like this. It isn't actually used anywhere in the codebase other than in EmailTemplateQueries so there is no need to use this object structure.
There was a problem hiding this comment.
I've moved things around now so that they make more sense. Everything to do with gathering sample data is in one file, and then the existing rendering code is in another. With all the extra sample data, I think having it in one file would be too large and not have proper separation of concerns.
| TemplateVariable, | ||
| } from './emailTemplateRenderer'; | ||
|
|
||
| const PROPOSAL_WORKFLOW_PREVIEW_DATA: Record<string, unknown> = { |
There was a problem hiding this comment.
This covers proposals, instruments, technicalReviews and call, but the real proposal workflow email (emailActionHandler.ts) passes several other arrays that will still break the preview the same way:
coProposers(BasicUserDetails[])techniques(Technique[])samples(Answer[])hazards(Answer[])fapMeetingDecisions(FapMeetingDecision[])
For example, #{coProposers.map(u => u.firstName).join(', ')} or - const decision = fapMeetingDecisions.find(d => d.instrumentId === 1) will still fail with ... is not a function, because the placeholder is a string.
Could you add sample entries for these too, so the preview works for any template built from the standard email data?
|
@jekabs-karklins and @zacharyjhankin I've pushed changes addressing both of your comments. I have a slight concern that the preview sample data is separate from the actual code that passes the real data to the templates (in |
|
Tested it locally and works |
Description
After the addition of new data provided to email templates, preview functionality is now broken:
This is caused by the preview data using strings, so when, for example, an array function is called on it, an error is returned. This PR provides some sample data to the template preview for any values which can't just be substituted with strings.