Files
outline/server/emails/templates/ConfirmUpdateEmail.tsx
Tom MoorandCopilot Autofix powered by AI 5693618de4 Add translation hooks to transactional emails (#11785)
* First pass

* fix: Missing translations

* fix: Missing translations

* welcome

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* translations

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-20 23:28:51 -04:00

89 lines
2.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import * as React from "react";
import env from "@server/env";
import type { EmailProps } from "./BaseEmail";
import BaseEmail, { EmailMessageCategory } from "./BaseEmail";
import Body from "./components/Body";
import Button from "./components/Button";
import EmailTemplate from "./components/EmailLayout";
import EmptySpace from "./components/EmptySpace";
import Footer from "./components/Footer";
import Header from "./components/Header";
import Heading from "./components/Heading";
type Props = EmailProps & {
code: string;
previous: string | null;
teamUrl: string;
};
/**
* Email sent to a user when they request to change their email.
*/
export default class ConfirmUpdateEmail extends BaseEmail<Props> {
protected get category() {
return EmailMessageCategory.Authentication;
}
protected subject() {
return this.t("Your email update request");
}
protected preview() {
return this.t("Here’s your email change confirmation.");
}
protected renderAsText({ teamUrl, code, previous, to }: Props): string {
return `
${
previous
? this.t(
"You requested to update your {{ appName }} account email. Please follow the link below to confirm the change from {{ previous }} to {{ to }}.",
{ appName: env.APP_NAME, previous, to }
)
: this.t(
"You requested to update your {{ appName }} account email. Please follow the link below to confirm the change to {{ to }}.",
{ appName: env.APP_NAME, to }
)
}
${this.updateLink(teamUrl, code)}
`;
}
protected render({ teamUrl, code, previous, to }: Props) {
return (
<EmailTemplate previewText={this.preview()}>
<Header />
<Body>
<Heading>{this.t("Your email update request")}</Heading>
<p>
{previous
? this.t(
"You requested to update your {{ appName }} account email. Please click below to confirm the change from {{ previous }} to",
{ appName: env.APP_NAME, previous }
)
: this.t(
"You requested to update your {{ appName }} account email. Please click below to confirm the change to",
{ appName: env.APP_NAME }
)}{" "}
<strong>{to}</strong>.
</p>
<EmptySpace height={5} />
<p>
<Button href={this.updateLink(teamUrl, code)}>
{this.t("Confirm Change")}
</Button>
</p>
</Body>
<Footer />
</EmailTemplate>
);
}
private updateLink(teamUrl: string, code: string): string {
return `${teamUrl}/api/users.updateEmail?code=${code}`;
}
}