Skip to content

Conversation

@reunefe
Copy link
Contributor

@reunefe reunefe commented Jan 9, 2026

Continues on #573

@reunefe reunefe requested a review from bertyhell January 9, 2026 10:19
break;
default:
emailTemplateToSend = undefined;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

usually i make a mapping object:

const MAP_MATERIAL_REQUEST_STATUS_TO_EMAIL_TEMPLATE = {
	[Lookup_App_Material_Request_Status_Enum.Cancelled]: EmailTemplate.MATERIAL_REQUEST_REQUESTER_CANCELLED,
	[Lookup_App_Material_Request_Status_Enum.Approved]: EmailTemplate.MATERIAL_REQUEST_MAINTAINER_APPROVED ,
	[Lookup_App_Material_Request_Status_Enum.Denied]: EmailTemplate.MATERIAL_REQUEST_MAINTAINER_DENIED,
}

and then you can use is more easily:

const emailTemplateToSend: EmailTemplate | undefined = MAP_MATERIAL_REQUEST_STATUS_TO_EMAIL_TEMPLATE[send] || undefined;

this makes it easier to reuse in other places

Comment on lines +582 to +584
`Failed to send email to maintainer that the material request was ${request.status}`,
err,
{ request, user }
Copy link
Contributor

Choose a reason for hiding this comment

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

try to avoid parameters in the message
put all variables in the additional info at the end
that way, if we capture this error somewhere higher up in the callstack, we can easily use the additional info to choose how to deal with this error

Suggested change
`Failed to send email to maintainer that the material request was ${request.status}`,
err,
{ request, user }
'Failed to send email about material request status update',
err,
{ status: request.status, template, request, user }

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