-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added welcome email after subscription
- Loading branch information
Showing
13 changed files
with
862 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { EmailService } from './email.service'; | ||
|
||
describe('EmailService', () => { | ||
let service: EmailService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [EmailService], | ||
}).compile(); | ||
|
||
service = module.get<EmailService>(EmailService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { Resend } from 'resend'; | ||
import { renderWelcomeEmail } from '@altairgraphql/emails'; | ||
|
||
@Injectable() | ||
export class EmailService { | ||
private resend: Resend; | ||
constructor(private configService: ConfigService) { | ||
this.resend = new Resend(this.configService.get('email.resendApiKey')); | ||
} | ||
|
||
async sendWelcomeEmail(email: string, username: string) { | ||
const { data, error } = await this.resend.emails.send({ | ||
from: | ||
this.configService.get('email.defaultFrom') ?? 'info@mail.altairgraphql.dev', | ||
to: email, | ||
replyTo: this.configService.get('email.replyTo'), | ||
subject: 'Welcome to Altair GraphQL Cloud', | ||
html: await renderWelcomeEmail({ username }), | ||
}); | ||
if (error) { | ||
console.error('Error sending welcome email', error); | ||
} | ||
|
||
return { data, error }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@altairgraphql/emails", | ||
"version": "8.0.0", | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@react-email/components": "^0.0.25" | ||
}, | ||
"devDependencies": { | ||
"@types/html-to-text": "^9.0.4", | ||
"@types/prismjs": "^1.26.5", | ||
"react-email": "^3.0.1", | ||
"typescript": "5.2.2" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"dev": "email dev", | ||
"prepare": "yarn build" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { | ||
Body, | ||
Button, | ||
Container, | ||
Head, | ||
Heading, | ||
Html, | ||
Img, | ||
Link, | ||
Preview, | ||
Row, | ||
Section, | ||
Text, | ||
Tailwind, | ||
} from '@react-email/components'; | ||
import * as React from 'react'; | ||
|
||
export interface WelcomeEmailProps { | ||
username: string; | ||
} | ||
|
||
const PropDefaults: WelcomeEmailProps = { | ||
username: 'User', | ||
}; | ||
|
||
export const WelcomeEmail = ({ | ||
username = PropDefaults.username, | ||
}: WelcomeEmailProps) => { | ||
return ( | ||
<Html> | ||
<Head /> | ||
<Preview>Welcome to Altair GraphQL Cloud</Preview> | ||
<Tailwind | ||
config={{ | ||
theme: { | ||
extend: { | ||
colors: { | ||
brand: '#64CB29', | ||
offwhite: '#fafbfb', | ||
}, | ||
spacing: { | ||
0: '0px', | ||
20: '20px', | ||
45: '45px', | ||
}, | ||
}, | ||
}, | ||
}} | ||
> | ||
<Body className="bg-offwhite text-base font-sans"> | ||
<Img | ||
src={`https://altairgraphql.dev/assets/img/altair_logo_128.png`} | ||
width="100" | ||
height="100" | ||
alt="Altair GraphQL Cloud" | ||
className="mx-auto my-20" | ||
/> | ||
<Container className="bg-white p-45"> | ||
<Heading className="text-center my-0 leading-8"> | ||
Welcome to Altair GraphQL Cloud | ||
</Heading> | ||
|
||
<Section> | ||
<Row> | ||
<Text className="text-base">Hey {username}! 👋🏾</Text> | ||
|
||
<Text className="text-base"> | ||
I'm Samuel, the creator of Altair GraphQL Client. Thanks so much | ||
for subscribing to Altair GraphQL Cloud! | ||
</Text> | ||
|
||
<Text className="text-base"> | ||
I'd love to hear what made you choose Altair Premium and what | ||
features you're most excited about. Just hit reply and let me know | ||
your thoughts! | ||
</Text> | ||
|
||
<Text className="text-base"> | ||
In the meantime, you can get started by checking out the docs | ||
</Text> | ||
</Row> | ||
</Section> | ||
|
||
{/* <ul>{steps?.map(({ Description }) => Description)}</ul> */} | ||
|
||
<Section className="text-center"> | ||
<Button | ||
className="bg-brand text-white rounded-md py-3 px-[18px] block" | ||
href="https://altairgraphql.dev/docs/cloud/" | ||
> | ||
Get Started | ||
</Button> | ||
</Section> | ||
|
||
{/* <Section className="mt-45"> | ||
<Row> | ||
{links?.map((link) => ( | ||
<Column key={link}> | ||
<Link className="text-black underline font-bold">{link}</Link>{' '} | ||
<span className="text-green-500">→</span> | ||
</Column> | ||
))} | ||
</Row> | ||
</Section> */} | ||
</Container> | ||
|
||
{/* <Container className="mt-20"> | ||
<Section> | ||
<Row> | ||
<Column className="text-right px-20"> | ||
<Link>Unsubscribe</Link> | ||
</Column> | ||
<Column className="text-left"> | ||
<Link>Manage Preferences</Link> | ||
</Column> | ||
</Row> | ||
</Section> | ||
<Text className="text-center text-gray-400 mb-45"> | ||
Netlify, 44 Montgomery Street, Suite 300 San Francisco, CA | ||
</Text> | ||
</Container> */} | ||
</Body> | ||
</Tailwind> | ||
</Html> | ||
); | ||
}; | ||
|
||
export default WelcomeEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Options, render } from '@react-email/components'; | ||
import { WelcomeEmail, WelcomeEmailProps } from './emails/Welcome'; | ||
|
||
export const renderWelcomeEmail = (props: WelcomeEmailProps, options?: Options) => { | ||
return render(<WelcomeEmail {...props} />, options); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"include": ["."], | ||
"exclude": ["dist", "build", "node_modules"], | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"strict": true, | ||
"declaration": true, | ||
"sourceMap": true, | ||
"jsx": "react-jsx", | ||
"esModuleInterop": true, | ||
"lib": ["es2022", "dom", "DOM.Iterable"], | ||
"skipLibCheck": true | ||
} | ||
} |
Oops, something went wrong.