Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kaarthik108 committed Jul 22, 2023
1 parent dfd3bf0 commit b76eb67
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 64 deletions.
10 changes: 7 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Handler,
} from "aws-lambda";
import fetch from "node-fetch";
import { EmailTemplate } from "./src/emails/test";
import { renderEmail } from "renderEmail"; // Import the function from the .tsx file

const RESEND_API_KEY = process.env["RESEND_API_KEY"];

Expand All @@ -13,6 +13,11 @@ interface ResendResponse {
message?: string;
}

const html = renderEmail(
"Kaarthik", // Provide title as a string
"/" // Provide link as a string
);

export const handler: Handler = async (
event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResultV2> => {
Expand Down Expand Up @@ -53,8 +58,7 @@ export const handler: Handler = async (
from: "[email protected]",
to: ["[email protected]"],
subject: "hello world",
react: EmailTemplate({ firstName: "John" }),
html: "<h1>Hello world</h1>",
html: html,
text: "Hello world",
}),
});
Expand Down
49 changes: 18 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"@react-email/components": "^0.0.7",
"@react-email/render": "0.0.7",
"aws-lambda": "^1.0.7",
"node-fetch": "^3.3.1",
"react-email": "^1.9.4",
Expand Down
7 changes: 7 additions & 0 deletions renderEmail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { render } from "@react-email/render";
import React from "react";
import TestTemplate from "./src/emails/TestTemplate";

export function renderEmail(title: string, link: string) {
return render(<TestTemplate title={title} link={link} />);
}
22 changes: 22 additions & 0 deletions src/emails/TestTemplate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// src/emails/testTemplate.tsx
import { Button } from '@react-email/button';
import { Hr } from '@react-email/hr';
import { Html } from '@react-email/html';
import { Text } from '@react-email/text';
import * as React from 'react';

type TestTemplateProps = {
/* Define the shape of the props here. For example: */
title: string;
link: string;
};

export default function TestTemplate({ title, link }: TestTemplateProps) {
return (
<Html lang="en">
<Text>{title}</Text>
<Hr />
<Button href={link}>Click me</Button>
</Html>
);
}
17 changes: 0 additions & 17 deletions src/emails/emailComponentPicker.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/emails/test.tsx

This file was deleted.

0 comments on commit b76eb67

Please sign in to comment.