Skip to content

Revised Subject of Project Step Notification #3215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions src/core/email/templates/project-step-changed.template.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { cleanJoin } from '@seedcompany/common';
import {
Button,
Column,
HideInText,
Section,
Text,
} from '@seedcompany/nestjs-email/templates';
import { startCase } from 'lodash';
import { EmailNotification as StepChangeNotification } from '../../../components/project';
import {
ProjectStep as Step,
ProjectType as Type,
} from '../../../components/project/dto';
import { EmailTemplate, Heading } from './base';
import { FormattedDateTime } from './formatted-date-time';
import { useFrontendUrl } from './frontend-url';
Expand All @@ -21,18 +25,22 @@ export function ProjectStepChanged({
}: StepChangeNotification) {
const projectUrl = useFrontendUrl(`/projects/${project.id}`);
const projectName = project.name.value;
const projectType = Type.entry(project.type);
const oldStep = oldStepVal ? Step.entry(oldStepVal).label : undefined;
const newStep = project.step.value
? Step.entry(project.step.value).label
: undefined;

const oldStep = startCase(oldStepVal) || undefined;
const newStep = startCase(project.step.value) || undefined;
const isMultiplication = projectType.value === Type.MultiplicationTranslation;
const title = cleanJoin(' - ', [
isMultiplication && projectType.label,
projectName ?? 'Project',
isMultiplication && primaryPartnerName,
newStep ? `is ${newStep}` : 'Status Change',
]);

return (
<EmailTemplate
title={
projectName && oldStep && newStep
? `${projectName} changed from ${oldStep} to ${newStep}`
: 'Project Status Change'
}
>
<EmailTemplate title={title}>
<Heading>
{projectName && newStep ? (
<>
Expand Down Expand Up @@ -64,12 +72,6 @@ export function ProjectStepChanged({
value={project.modifiedAt}
timezone={recipient.timezone.value}
/>
<br />
Project Type: {project.type}
<br />
{primaryPartnerName ? (
<>Primary Partner: {primaryPartnerName}</>
) : null}
</Text>
<HideInText>
<Button href={projectUrl} paddingTop={16}>
Expand Down
Loading