Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnisLielturks committed May 14, 2024
1 parent 768d332 commit 896d378
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Launch your medusajs backend and call the following endpoint

```bash
curl --request POST \
--url http://localhost:9000/email_test \
--url http://localhost:9000/admin/email_test \
--header 'Content-Type: application/json' \
--data '{
"event": "testing",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rootxpdev/medusa-email-plugin",
"version": "0.4.9",
"version": "0.5.0",
"description": "Send emails when certain actions happens in medusa store",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.ts → src/api/admin/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { json, Router } from "express"
import { z } from "zod"
import EmailsService from "../services/emails";
import EmailsService from "../../services/emails";

const router = Router()

Expand Down
13 changes: 4 additions & 9 deletions src/services/emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class EmailsService extends NotificationService {
for (const option of order.shipping_methods) {
totalValue += option.shipping_option.amount;
}
await this.sendEmail(order.email, 'Order received', event, {
await this.sendEmail(order.email, event, {
event,
order,
cart: await this.cartService.retrieve(order.cart_id || ''),
Expand All @@ -95,13 +95,8 @@ class EmailsService extends NotificationService {
};
}

await this.sendEmail('test@test.com', 'Testing', event, {
event,
data,
})

return {
to: 'arnis@arnis.lv',
to: null,
data: {},
status: "sent",
};
Expand All @@ -116,7 +111,7 @@ class EmailsService extends NotificationService {
status: string;
data: Record<string, unknown>;
}> {
await this.sendEmail('arnis@test.com', 'Testing', 'sample', {
await this.sendEmail('arnis@test.com', 'sample', {
event: notification,
})

Expand All @@ -127,7 +122,7 @@ class EmailsService extends NotificationService {
};
}

async sendEmail(toAddress: string, subject: string, templateName: string, data: any) {
async sendEmail(toAddress: string, templateName: string, data: any) {
// console.log('data', data)
this.logger.info(JSON.stringify(data));
const transport = nodemailer.createTransport({
Expand Down

0 comments on commit 896d378

Please sign in to comment.