Skip to content

Commit 313063b

Browse files
authored
Merge pull request #20 from codee-sh/feat/improve-emails-action
Feat/improve emails action
2 parents 717e980 + 0650896 commit 313063b

6 files changed

Lines changed: 17 additions & 7 deletions

File tree

.changeset/fluffy-lilies-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@codee-sh/medusa-plugin-automations": patch
3+
---
4+
5+
Add transformContext from -emails plugin

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
"devDependencies": {
5555
"@changesets/cli": "^2.29.8",
56-
"@codee-sh/medusa-plugin-notification-emails": "0.1.0",
56+
"@codee-sh/medusa-plugin-notification-emails": "0.1.1",
5757
"@medusajs/admin-sdk": "2.8.8",
5858
"@medusajs/cli": "2.8.8",
5959
"@medusajs/framework": "2.8.8",

src/modules/mpn-automation/services/email-action-service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { FieldConfig } from "../types"
22
import { BaseActionService } from "./base-action-service"
33
import { renderTemplate } from "@codee-sh/medusa-plugin-notification-emails/templates/emails"
4+
import { transformContext } from "@codee-sh/medusa-plugin-notification-emails/utils"
5+
46
import type {
57
TemplateData,
68
TemplateOptionsType,
@@ -95,14 +97,16 @@ export class EmailActionService extends BaseActionService {
9597
const {
9698
templateName,
9799
context,
100+
contextType,
98101
options,
99102
customTemplateFunction,
100103
} = params
101104

102-
// Use external plugin's renderTemplate function
105+
const transformedContext = transformContext(contextType, context)
106+
103107
const result = await renderTemplate(
104108
templateName,
105-
context,
109+
transformedContext,
106110
options || {},
107111
customTemplateFunction
108112
)

src/modules/mpn-automation/types/modules/order/order.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,4 +560,5 @@ export const ORDER_QUERY_FIELDS = [
560560
"order.fulfillments.*",
561561
"order.credit_lines.*",
562562
"order.summary.*",
563+
"order.payment_collections.*",
563564
]

src/subscribers/mpn.automation.action.email.executed.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export default async function mpnAutomationActionEmailExecutedHandler({
2929
contextType,
3030
} = data
3131

32-
console.log(eventName, data)
33-
3432
const { result } = await runEmailActionWorkflow(
3533
container
3634
).run({

src/workflows/order/steps/get-order-by-id.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { OrderTypes } from "@medusajs/framework/types"
1+
import type { OrderTypes, CustomerTypes } from "@medusajs/framework/types"
22
import {
33
ContainerRegistrationKeys,
44
MedusaError,
@@ -15,7 +15,9 @@ export interface GetOrderByIdStepInput {
1515
}
1616

1717
export interface GetOrderByIdStepOutput {
18-
order: OrderTypes.OrderDTO
18+
order: OrderTypes.OrderDTO & {
19+
customer: CustomerTypes.CustomerDTO
20+
}
1921
}
2022

2123
export const getOrderByIdStepId = "get-order-by-id"

0 commit comments

Comments
 (0)