-
Notifications
You must be signed in to change notification settings - Fork 126
MM2-43 - Resend Integration #35
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
Conversation
apps/backend/medusa-config.ts
Outdated
} | ||
} | ||
// { | ||
// resolve: './src/modules/payouts', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this comments
@@ -0,0 +1,23 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why its any?
@@ -0,0 +1,111 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -0,0 +1,37 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -0,0 +1,22 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -0,0 +1,22 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -0,0 +1,21 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
export const VendorAccountSubmissionEmailTemplate: React.FC<Readonly<EmailTemplateProps>> = ({ data }) => { | ||
return ( | ||
<div> | ||
<h1>Hello, {data.userName} 👋</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use snake case user_name
return ( | ||
<div> | ||
<h1> | ||
Hello, {data.userName} 👋 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use snake case
new password. Please note, the link is valid for the next 24 hours only. | ||
</p> | ||
<div> | ||
<a href={`${data.host}/resetPassword?resetPasswordToken=${data.resetPasswordToken}`}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use snake case
@@ -0,0 +1,19 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data is any
@@ -0,0 +1,41 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
return ( | ||
<div> | ||
<h1> | ||
{data.userName} has placed an order for {data.order.item} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snake case
{data.userName} has placed an order for {data.order.item} | ||
</h1> | ||
<p> | ||
New Order #{data.order.display_id} for {data.order.item}.{data.userName} has just ordered {data.order.item}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snake case
|
||
<div> | ||
<p> | ||
You should now ship the products to {data.userName}. The shipping address can be found in the order details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snake case
return ( | ||
<div> | ||
<h1> | ||
{data.userName} has invited you to join the team at {data.storeName}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use snake case in these file
@@ -0,0 +1,32 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -0,0 +1,21 @@ | |||
interface EmailTemplateProps { | |||
data: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
this.options = options | ||
} | ||
|
||
private async sendMail(subject: string, body: ReactNode, toEmail: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it would be a lot better if we would have this provider like this
async send(notification: NotificationTypes.ProviderSendNotificationDTO) {
const { data, error } = await this.resendClient.emails.send({
from: notification.from?.trim() || this.config_.from,
to: notification.to,
subject: notification.content?.subject,
react: notification.content?.react
})
if (error) {
throw new MedusaError(MedusaError.Types.UNEXPECTED_STATE, error.message)
}
if (!data) {
throw new MedusaError(
MedusaError.Types.UNEXPECTED_STATE,
'No data returned by resend client'
)
}
return data
}
have all of the email templates in the src/email-templates
folder
and then use it like this in the subscriber
const notificationModuleService: INotificationModuleService =
container.resolve(Modules.NOTIFICATION)
await notificationModuleService.createNotifications({
to: "test@gmail.com",
from: "test@medusajs.com",
channel: "email",
content: {
react: VendorAccountRejectedEmailTemplate({ data: orderData }),
}
],
we then would have a good typescript check and seperation between use case and provider
…onfig from medusa-config
9ee4f55
to
8a2ddbc
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…ercurjs#35) [MVM-403]: multiple variants list
feat(emails): added email service and email templates