Skip to content

Commit

Permalink
Revert "refactor(emails): Create base template for code emails"
Browse files Browse the repository at this point in the history
This reverts commit 94820ab.
  • Loading branch information
ntatoud authored and ivan-dalmet committed Jul 22, 2024
1 parent d01ba6f commit a0fce18
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 65 deletions.
53 changes: 0 additions & 53 deletions src/emails/components/BaseEmailCode.tsx

This file was deleted.

47 changes: 44 additions & 3 deletions src/emails/templates/delete-account-code.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
import { BaseEmailCode, EmailCodeProps } from '../components/BaseEmailCode';
import { Container, Heading, Section, Text } from '@react-email/components';

export const EmailDeleteAccountCode = (props: EmailCodeProps) => {
return <BaseEmailCode type="deleteAccountCode" {...props} />;
import { Footer } from '@/emails/components/Footer';
import { Layout } from '@/emails/components/Layout';
import { styles } from '@/emails/styles';
import { VALIDATION_TOKEN_EXPIRATION_IN_MINUTES } from '@/features/auth/utils';
import i18n from '@/lib/i18n/server';

type EmailDeleteAccountCodeProps = {
language: string;
name: string;
code: string;
};

export const EmailDeleteAccountCode = ({
language,
name,
code,
}: EmailDeleteAccountCodeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:deleteAccountCode.preview')}>
<Container style={styles.container}>
<Heading style={styles.h1}>
{i18n.t('emails:deleteAccountCode.title')}
</Heading>
<Section style={styles.section}>
<Text style={styles.text}>
{i18n.t('emails:deleteAccountCode.hello', { name: name ?? '' })}
<br />
{i18n.t('emails:deleteAccountCode.intro')}
</Text>
<Text style={styles.code}>{code}</Text>
<Text style={styles.textMuted}>
{i18n.t('emails:deleteAccountCode.validityTime', {
expiration: VALIDATION_TOKEN_EXPIRATION_IN_MINUTES,
})}
<br />
{i18n.t('emails:deleteAccountCode.ignoreHelper')}
</Text>
</Section>
<Footer />
</Container>
</Layout>
);
};

export default EmailDeleteAccountCode;
47 changes: 44 additions & 3 deletions src/emails/templates/email-address-change.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
import { BaseEmailCode, EmailCodeProps } from '../components/BaseEmailCode';
import { Container, Heading, Section, Text } from '@react-email/components';

export const EmailAddressChange = (props: EmailCodeProps) => {
return <BaseEmailCode type="emailAddressChange" {...props} />;
import { Footer } from '@/emails/components/Footer';
import { Layout } from '@/emails/components/Layout';
import { styles } from '@/emails/styles';
import { VALIDATION_TOKEN_EXPIRATION_IN_MINUTES } from '@/features/auth/utils';
import i18n from '@/lib/i18n/server';

type EmailAddressChangeProps = {
language: string;
name: string;
code: string;
};

export const EmailAddressChange = ({
language,
name,
code,
}: EmailAddressChangeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:emailAddressChange.preview')}>
<Container style={styles.container}>
<Heading style={styles.h1}>
{i18n.t('emails:emailAddressChange.title')}
</Heading>
<Section style={styles.section}>
<Text style={styles.text}>
{i18n.t('emails:emailAddressChange.hello', { name: name ?? '' })}
<br />
{i18n.t('emails:emailAddressChange.intro')}
</Text>
<Text style={styles.code}>{code}</Text>
<Text style={styles.textMuted}>
{i18n.t('emails:emailAddressChange.validityTime', {
expiration: VALIDATION_TOKEN_EXPIRATION_IN_MINUTES,
})}
<br />
{i18n.t('emails:emailAddressChange.ignoreHelper')}
</Text>
</Section>
<Footer />
</Container>
</Layout>
);
};

export default EmailAddressChange;
45 changes: 42 additions & 3 deletions src/emails/templates/login-code.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
import { BaseEmailCode, EmailCodeProps } from '../components/BaseEmailCode';
import { Container, Heading, Section, Text } from '@react-email/components';

export const EmailLoginCode = (props: EmailCodeProps) => {
return <BaseEmailCode type="loginCode" {...props} />;
import { Footer } from '@/emails/components/Footer';
import { Layout } from '@/emails/components/Layout';
import { styles } from '@/emails/styles';
import { VALIDATION_TOKEN_EXPIRATION_IN_MINUTES } from '@/features/auth/utils';
import i18n from '@/lib/i18n/server';

type EmailLoginCodeProps = {
language: string;
name: string;
code: string;
};

export const EmailLoginCode = ({
language,
name,
code,
}: EmailLoginCodeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:loginCode.preview')}>
<Container style={styles.container}>
<Heading style={styles.h1}>{i18n.t('emails:loginCode.title')}</Heading>
<Section style={styles.section}>
<Text style={styles.text}>
{i18n.t('emails:loginCode.hello', { name: name ?? '' })}
<br />
{i18n.t('emails:loginCode.intro')}
</Text>
<Text style={styles.code}>{code}</Text>
<Text style={styles.textMuted}>
{i18n.t('emails:loginCode.validityTime', {
expiration: VALIDATION_TOKEN_EXPIRATION_IN_MINUTES,
})}
<br />
{i18n.t('emails:loginCode.ignoreHelper')}
</Text>
</Section>
<Footer />
</Container>
</Layout>
);
};

export default EmailLoginCode;
47 changes: 44 additions & 3 deletions src/emails/templates/register-code.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
import { BaseEmailCode, EmailCodeProps } from '../components/BaseEmailCode';
import { Container, Heading, Section, Text } from '@react-email/components';

const EmailRegisterCode = (props: EmailCodeProps) => {
return <BaseEmailCode type="registerCode" {...props} />;
import { Footer } from '@/emails/components/Footer';
import { Layout } from '@/emails/components/Layout';
import { styles } from '@/emails/styles';
import { VALIDATION_TOKEN_EXPIRATION_IN_MINUTES } from '@/features/auth/utils';
import i18n from '@/lib/i18n/server';

type EmailRegisterCodeProps = {
language: string;
name?: string;
code: string;
};

export const EmailRegisterCode = ({
language,
name,
code,
}: EmailRegisterCodeProps) => {
i18n.changeLanguage(language);
return (
<Layout preview={i18n.t('emails:registerCode.preview')}>
<Container style={styles.container}>
<Heading style={styles.h1}>
{i18n.t('emails:registerCode.title')}
</Heading>
<Section style={styles.section}>
<Text style={styles.text}>
{i18n.t('emails:registerCode.hello', { name: name ?? '' })}
<br />
{i18n.t('emails:registerCode.intro')}
</Text>
<Text style={styles.code}>{code}</Text>
<Text style={styles.textMuted}>
{i18n.t('emails:registerCode.validityTime', {
expiration: VALIDATION_TOKEN_EXPIRATION_IN_MINUTES,
})}
<br />
{i18n.t('emails:registerCode.ignoreHelper')}
</Text>
</Section>
<Footer />
</Container>
</Layout>
);
};

export default EmailRegisterCode;

0 comments on commit a0fce18

Please sign in to comment.