Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fluffy-lilies-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codee-sh/medusa-plugin-automations": patch
---

Add transformContext from -emails plugin
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"devDependencies": {
"@changesets/cli": "^2.29.8",
"@codee-sh/medusa-plugin-notification-emails": "0.1.0",
"@codee-sh/medusa-plugin-notification-emails": "0.1.1",
"@medusajs/admin-sdk": "2.8.8",
"@medusajs/cli": "2.8.8",
"@medusajs/framework": "2.8.8",
Expand Down
8 changes: 6 additions & 2 deletions src/modules/mpn-automation/services/email-action-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { FieldConfig } from "../types"
import { BaseActionService } from "./base-action-service"
import { renderTemplate } from "@codee-sh/medusa-plugin-notification-emails/templates/emails"
import { transformContext } from "@codee-sh/medusa-plugin-notification-emails/utils"

import type {
TemplateData,
TemplateOptionsType,
Expand Down Expand Up @@ -95,14 +97,16 @@ export class EmailActionService extends BaseActionService {
const {
templateName,
context,
contextType,
options,
customTemplateFunction,
} = params

// Use external plugin's renderTemplate function
const transformedContext = transformContext(contextType, context)

const result = await renderTemplate(
templateName,
context,
transformedContext,
options || {},
customTemplateFunction
)
Expand Down
1 change: 1 addition & 0 deletions src/modules/mpn-automation/types/modules/order/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,4 +560,5 @@ export const ORDER_QUERY_FIELDS = [
"order.fulfillments.*",
"order.credit_lines.*",
"order.summary.*",
"order.payment_collections.*",
]
2 changes: 0 additions & 2 deletions src/subscribers/mpn.automation.action.email.executed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export default async function mpnAutomationActionEmailExecutedHandler({
contextType,
} = data

console.log(eventName, data)

const { result } = await runEmailActionWorkflow(
container
).run({
Expand Down
6 changes: 4 additions & 2 deletions src/workflows/order/steps/get-order-by-id.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { OrderTypes } from "@medusajs/framework/types"
import type { OrderTypes, CustomerTypes } from "@medusajs/framework/types"
import {
ContainerRegistrationKeys,
MedusaError,
Expand All @@ -15,7 +15,9 @@ export interface GetOrderByIdStepInput {
}

export interface GetOrderByIdStepOutput {
order: OrderTypes.OrderDTO
order: OrderTypes.OrderDTO & {
customer: CustomerTypes.CustomerDTO
}
}

export const getOrderByIdStepId = "get-order-by-id"
Expand Down