Skip to content

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

Closed
wants to merge 7 commits into from
Closed

Conversation

mjaskot
Copy link
Collaborator

@mjaskot mjaskot commented Dec 18, 2024

feat(emails): added email service and email templates

@mjaskot mjaskot added the enhancement New feature or request label Dec 18, 2024
@mjaskot mjaskot requested a review from vholik December 18, 2024 09:32
@mjaskot mjaskot self-assigned this Dec 18, 2024
}
}
// {
// resolve: './src/modules/payouts',
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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>
Copy link
Collaborator

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} 👋
Copy link
Collaborator

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}`}>
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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}
Copy link
Collaborator

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}.
Copy link
Collaborator

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.
Copy link
Collaborator

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}.
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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) {
Copy link
Collaborator

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

@mjaskot mjaskot force-pushed the feature/MM2-43-resend-integration branch from 9ee4f55 to 8a2ddbc Compare January 7, 2025 08:55
@mjaskot mjaskot changed the base branch from main to feature/MM2-87-seller-registration January 13, 2025 09:35
Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mercur-vendor ❌ Failed (Inspect) Jan 15, 2025 10:59am

@slusarczykmichal slusarczykmichal changed the base branch from feature/MM2-87-seller-registration to main February 11, 2025 06:12
@slusarczykmichal slusarczykmichal deleted the feature/MM2-43-resend-integration branch February 17, 2025 09:19
LukaszMielczarek pushed a commit to LukaszMielczarek/mercur that referenced this pull request May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants