fix(core-flows, dashboard): handling fulfillment rules (#11111)
**What** - fix storing "true" | "false" strings from admin - use strings instead of booleans for context filtering
This commit is contained in:
1 parent
b418fb129a
commit
6e5912612c
3 files changed
+22
-15
No files matched your search
+2
-2
@@ -151,13 +151,13 @@ export function CreateShippingOptionsForm({
|
||||
rules: [
|
||||
{
|
||||
// eslint-disable-next-line
|
||||
value: isReturn ? '"true"' : '"false"',
|
||||
value: isReturn ? "true" : "false",
|
||||
attribute: "is_return",
|
||||
operator: "eq",
|
||||
},
|
||||
{
|
||||
// eslint-disable-next-line
|
||||
value: data.enabled_in_store ? '"true"' : '"false"',
|
||||
value: data.enabled_in_store ? "true" : "false",
|
||||
attribute: "enabled_in_store",
|
||||
operator: "eq",
|
||||
},
|
||||
|
||||
+8
-6
@@ -1,4 +1,4 @@
|
||||
import { ShippingOptionPriceType } from "@medusajs/framework/utils"
|
||||
import { isDefined, ShippingOptionPriceType } from "@medusajs/framework/utils"
|
||||
import {
|
||||
createWorkflow,
|
||||
parallelize,
|
||||
@@ -73,9 +73,7 @@ export const listShippingOptionsForCartWithPricingWorkflowId =
|
||||
*/
|
||||
export const listShippingOptionsForCartWithPricingWorkflow = createWorkflow(
|
||||
listShippingOptionsForCartWithPricingWorkflowId,
|
||||
(
|
||||
input: WorkflowData<ListShippingOptionsForCartWithPricingWorkflowInput>
|
||||
) => {
|
||||
(input: WorkflowData<ListShippingOptionsForCartWithPricingWorkflowInput>) => {
|
||||
const optionIds = transform({ input }, ({ input }) =>
|
||||
(input.options ?? []).map(({ id }) => id)
|
||||
)
|
||||
@@ -141,8 +139,12 @@ export const listShippingOptionsForCartWithPricingWorkflow = createWorkflow(
|
||||
{ input, cart, fulfillmentSetIds },
|
||||
({ input, cart, fulfillmentSetIds }) => ({
|
||||
context: {
|
||||
is_return: input.is_return ?? false,
|
||||
enabled_in_store: input.enabled_in_store ?? true,
|
||||
is_return: input.is_return ? "true" : "false",
|
||||
enabled_in_store: !isDefined(input.enabled_in_store)
|
||||
? "true"
|
||||
: input.enabled_in_store
|
||||
? "true"
|
||||
: "false",
|
||||
},
|
||||
|
||||
filters: {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useQueryGraphStep, validatePresenceOfStep } from "../../common"
|
||||
import { useRemoteQueryStep } from "../../common/steps/use-remote-query"
|
||||
import { cartFieldsForPricingContext } from "../utils/fields"
|
||||
import { ListShippingOptionsForCartWorkflowInput } from "@medusajs/types"
|
||||
import { isDefined } from "@medusajs/framework/utils"
|
||||
|
||||
export const listShippingOptionsForCartWorkflowId =
|
||||
"list-shipping-options-for-cart"
|
||||
@@ -40,9 +41,7 @@ export const listShippingOptionsForCartWorkflowId =
|
||||
*/
|
||||
export const listShippingOptionsForCartWorkflow = createWorkflow(
|
||||
listShippingOptionsForCartWorkflowId,
|
||||
(
|
||||
input: WorkflowData<ListShippingOptionsForCartWorkflowInput>
|
||||
) => {
|
||||
(input: WorkflowData<ListShippingOptionsForCartWorkflowInput>) => {
|
||||
const cartQuery = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
filters: { id: input.cart_id },
|
||||
@@ -92,12 +91,17 @@ export const listShippingOptionsForCartWorkflow = createWorkflow(
|
||||
|
||||
const queryVariables = transform(
|
||||
{ input, fulfillmentSetIds, cart },
|
||||
({ input, fulfillmentSetIds, cart }) => ({
|
||||
({ input, fulfillmentSetIds, cart }) => {
|
||||
return {
|
||||
id: input.option_ids,
|
||||
|
||||
context: {
|
||||
is_return: input.is_return ?? false,
|
||||
enabled_in_store: input.enabled_in_store ?? true,
|
||||
is_return: input.is_return ? "true" : "false",
|
||||
enabled_in_store: !isDefined(input.enabled_in_store)
|
||||
? "true"
|
||||
: input.enabled_in_store
|
||||
? "true"
|
||||
: "false",
|
||||
},
|
||||
|
||||
filters: {
|
||||
@@ -112,7 +116,8 @@ export const listShippingOptionsForCartWorkflow = createWorkflow(
|
||||
},
|
||||
|
||||
calculated_price: { context: cart },
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const shippingOptions = useRemoteQueryStep({
|
||||
|
||||
Reference in new issue
Block a user