fix(core-flows): update cart promotion data usage (#9456)

**What**
The nullish coalescing can't really work since we are using proxies under the hood which is present
This commit is contained in:
Adrien de Peretti
2024-10-04 09:19:47 +02:00
committed by GitHub
parent 00a51b59b1
commit 5a573928c4

View File

@@ -1,8 +1,9 @@
import { PromotionActions } from "@medusajs/framework/utils" import { PromotionActions } from "@medusajs/framework/utils"
import { import {
WorkflowData,
createWorkflow, createWorkflow,
parallelize, parallelize,
transform,
WorkflowData,
} from "@medusajs/framework/workflows-sdk" } from "@medusajs/framework/workflows-sdk"
import { useRemoteQueryStep } from "../../common" import { useRemoteQueryStep } from "../../common"
import { import {
@@ -42,10 +43,18 @@ export const updateCartPromotionsWorkflow = createWorkflow(
list: false, list: false,
}) })
const promo_codes = transform({ input }, (data) => {
return (data.input.promo_codes || []) as string[]
})
const action = transform({ input }, (data) => {
return data.input.action || PromotionActions.ADD
})
const promotionCodesToApply = getPromotionCodesToApply({ const promotionCodesToApply = getPromotionCodesToApply({
cart: cart, cart: cart,
promo_codes: input.promo_codes ?? [], promo_codes,
action: input.action || PromotionActions.ADD, action: action as PromotionActions,
}) })
const actions = getActionsToComputeFromPromotionsStep({ const actions = getActionsToComputeFromPromotionsStep({