feat(dashboard, core-flows): associate shipping option to type (#13226)
* feat(dashboard, core-flows): allow associating shipping option type to a shipping option * edit as well * fix translation schema * fix some tests * changeset * add new test to update shipping option type * add new test to create shipping option with shipping option type * pr comments * pr comments * rename variable * make zod great again
This commit is contained in:
@@ -4,12 +4,8 @@ import {
|
||||
ShippingOptionDTO,
|
||||
UpsertShippingOptionDTO,
|
||||
} from "@medusajs/framework/types"
|
||||
import {
|
||||
Modules,
|
||||
arrayDifference,
|
||||
getSelectsAndRelationsFromObjectArray,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
||||
import { arrayDifference, getSelectsAndRelationsFromObjectArray, Modules, } from "@medusajs/framework/utils"
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
|
||||
/**
|
||||
* The data to create or update shipping options.
|
||||
@@ -65,7 +61,13 @@ export const upsertShippingOptionsStep = createStep(
|
||||
|
||||
const upsertedShippingOptions: ShippingOptionDTO[] =
|
||||
await fulfillmentService.upsertShippingOptions(
|
||||
input as UpsertShippingOptionDTO[]
|
||||
input.map(inputItem => {
|
||||
const upsertShippingOption = inputItem as UpsertShippingOptionDTO
|
||||
if (inputItem.type_id) {
|
||||
upsertShippingOption.type = inputItem.type_id
|
||||
}
|
||||
return upsertShippingOption;
|
||||
})
|
||||
)
|
||||
|
||||
const upsertedShippingOptionIds = upsertedShippingOptions.map((s) => s.id)
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { FulfillmentWorkflow } from "@medusajs/framework/types"
|
||||
import {
|
||||
MedusaError,
|
||||
Modules,
|
||||
ShippingOptionPriceType,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
|
||||
import { MedusaError, Modules, ShippingOptionPriceType, } from "@medusajs/framework/utils"
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { CreateShippingOptionDTO } from "@medusajs/types"
|
||||
|
||||
/**
|
||||
* The data to validate shipping option prices.
|
||||
@@ -96,7 +93,7 @@ export const validateShippingOptionPricesStep = createStep(
|
||||
|
||||
const validation =
|
||||
await fulfillmentModuleService.validateShippingOptionsForPriceCalculation(
|
||||
calculatedOptions as FulfillmentWorkflow.CreateShippingOptionsWorkflowInput[]
|
||||
calculatedOptions as CreateShippingOptionDTO[]
|
||||
)
|
||||
|
||||
if (validation.some((v) => !v)) {
|
||||
|
||||
@@ -6,10 +6,7 @@ import {
|
||||
WorkflowData,
|
||||
WorkflowResponse,
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
createShippingOptionsPriceSetsStep,
|
||||
upsertShippingOptionsStep,
|
||||
} from "../steps"
|
||||
import { createShippingOptionsPriceSetsStep, upsertShippingOptionsStep, } from "../steps"
|
||||
import { setShippingOptionsPriceSetsStep } from "../steps/set-shipping-options-price-sets"
|
||||
import { validateFulfillmentProvidersStep } from "../steps/validate-fulfillment-providers"
|
||||
import { validateShippingOptionPricesStep } from "../steps/validate-shipping-option-prices"
|
||||
|
||||
Reference in New Issue
Block a user