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: [
|
rules: [
|
||||||
{
|
{
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
value: isReturn ? '"true"' : '"false"',
|
value: isReturn ? "true" : "false",
|
||||||
attribute: "is_return",
|
attribute: "is_return",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
value: data.enabled_in_store ? '"true"' : '"false"',
|
value: data.enabled_in_store ? "true" : "false",
|
||||||
attribute: "enabled_in_store",
|
attribute: "enabled_in_store",
|
||||||
operator: "eq",
|
operator: "eq",
|
||||||
},
|
},
|
||||||
|
|||||||
+8
-6
@@ -1,4 +1,4 @@
|
|||||||
import { ShippingOptionPriceType } from "@medusajs/framework/utils"
|
import { isDefined, ShippingOptionPriceType } from "@medusajs/framework/utils"
|
||||||
import {
|
import {
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
parallelize,
|
parallelize,
|
||||||
@@ -73,9 +73,7 @@ export const listShippingOptionsForCartWithPricingWorkflowId =
|
|||||||
*/
|
*/
|
||||||
export const listShippingOptionsForCartWithPricingWorkflow = createWorkflow(
|
export const listShippingOptionsForCartWithPricingWorkflow = createWorkflow(
|
||||||
listShippingOptionsForCartWithPricingWorkflowId,
|
listShippingOptionsForCartWithPricingWorkflowId,
|
||||||
(
|
(input: WorkflowData<ListShippingOptionsForCartWithPricingWorkflowInput>) => {
|
||||||
input: WorkflowData<ListShippingOptionsForCartWithPricingWorkflowInput>
|
|
||||||
) => {
|
|
||||||
const optionIds = transform({ input }, ({ input }) =>
|
const optionIds = transform({ input }, ({ input }) =>
|
||||||
(input.options ?? []).map(({ id }) => id)
|
(input.options ?? []).map(({ id }) => id)
|
||||||
)
|
)
|
||||||
@@ -141,8 +139,12 @@ export const listShippingOptionsForCartWithPricingWorkflow = createWorkflow(
|
|||||||
{ input, cart, fulfillmentSetIds },
|
{ input, cart, fulfillmentSetIds },
|
||||||
({ input, cart, fulfillmentSetIds }) => ({
|
({ input, cart, fulfillmentSetIds }) => ({
|
||||||
context: {
|
context: {
|
||||||
is_return: input.is_return ?? false,
|
is_return: input.is_return ? "true" : "false",
|
||||||
enabled_in_store: input.enabled_in_store ?? true,
|
enabled_in_store: !isDefined(input.enabled_in_store)
|
||||||
|
? "true"
|
||||||
|
: input.enabled_in_store
|
||||||
|
? "true"
|
||||||
|
: "false",
|
||||||
},
|
},
|
||||||
|
|
||||||
filters: {
|
filters: {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { useQueryGraphStep, validatePresenceOfStep } from "../../common"
|
|||||||
import { useRemoteQueryStep } from "../../common/steps/use-remote-query"
|
import { useRemoteQueryStep } from "../../common/steps/use-remote-query"
|
||||||
import { cartFieldsForPricingContext } from "../utils/fields"
|
import { cartFieldsForPricingContext } from "../utils/fields"
|
||||||
import { ListShippingOptionsForCartWorkflowInput } from "@medusajs/types"
|
import { ListShippingOptionsForCartWorkflowInput } from "@medusajs/types"
|
||||||
|
import { isDefined } from "@medusajs/framework/utils"
|
||||||
|
|
||||||
export const listShippingOptionsForCartWorkflowId =
|
export const listShippingOptionsForCartWorkflowId =
|
||||||
"list-shipping-options-for-cart"
|
"list-shipping-options-for-cart"
|
||||||
@@ -40,9 +41,7 @@ export const listShippingOptionsForCartWorkflowId =
|
|||||||
*/
|
*/
|
||||||
export const listShippingOptionsForCartWorkflow = createWorkflow(
|
export const listShippingOptionsForCartWorkflow = createWorkflow(
|
||||||
listShippingOptionsForCartWorkflowId,
|
listShippingOptionsForCartWorkflowId,
|
||||||
(
|
(input: WorkflowData<ListShippingOptionsForCartWorkflowInput>) => {
|
||||||
input: WorkflowData<ListShippingOptionsForCartWorkflowInput>
|
|
||||||
) => {
|
|
||||||
const cartQuery = useQueryGraphStep({
|
const cartQuery = useQueryGraphStep({
|
||||||
entity: "cart",
|
entity: "cart",
|
||||||
filters: { id: input.cart_id },
|
filters: { id: input.cart_id },
|
||||||
@@ -92,12 +91,17 @@ export const listShippingOptionsForCartWorkflow = createWorkflow(
|
|||||||
|
|
||||||
const queryVariables = transform(
|
const queryVariables = transform(
|
||||||
{ input, fulfillmentSetIds, cart },
|
{ input, fulfillmentSetIds, cart },
|
||||||
({ input, fulfillmentSetIds, cart }) => ({
|
({ input, fulfillmentSetIds, cart }) => {
|
||||||
|
return {
|
||||||
id: input.option_ids,
|
id: input.option_ids,
|
||||||
|
|
||||||
context: {
|
context: {
|
||||||
is_return: input.is_return ?? false,
|
is_return: input.is_return ? "true" : "false",
|
||||||
enabled_in_store: input.enabled_in_store ?? true,
|
enabled_in_store: !isDefined(input.enabled_in_store)
|
||||||
|
? "true"
|
||||||
|
: input.enabled_in_store
|
||||||
|
? "true"
|
||||||
|
: "false",
|
||||||
},
|
},
|
||||||
|
|
||||||
filters: {
|
filters: {
|
||||||
@@ -112,7 +116,8 @@ export const listShippingOptionsForCartWorkflow = createWorkflow(
|
|||||||
},
|
},
|
||||||
|
|
||||||
calculated_price: { context: cart },
|
calculated_price: { context: cart },
|
||||||
})
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const shippingOptions = useRemoteQueryStep({
|
const shippingOptions = useRemoteQueryStep({
|
||||||
|
|||||||
Reference in new issue
Block a user