update when-then blocks across docs
This commit is contained in:
@@ -529,12 +529,15 @@ In the workflow, you retrieve the cart's linked `Custom` record using Query.
|
||||
Next, replace the `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-cart/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
carts,
|
||||
}, (data) =>
|
||||
!data.carts[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
const created = when(
|
||||
"create-cart-custom-link",
|
||||
{
|
||||
input,
|
||||
carts,
|
||||
},
|
||||
(data) =>
|
||||
!data.carts[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
const custom = createCustomStep({
|
||||
@@ -563,14 +566,16 @@ To create the `Custom` record, you use the `createCustomStep` you created in an
|
||||
Next, replace the new `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-cart/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
carts,
|
||||
}, (data) =>
|
||||
data.carts[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
const deleted = when(
|
||||
"delete-cart-custom-link"
|
||||
{
|
||||
input,
|
||||
carts,
|
||||
}, (data) =>
|
||||
data.carts[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
@@ -599,12 +604,10 @@ const updated = when({
|
||||
carts,
|
||||
}, (data) => data.carts[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
return updateCustomStep({
|
||||
id: carts[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
return custom
|
||||
})
|
||||
|
||||
return new WorkflowResponse({
|
||||
|
||||
@@ -541,12 +541,14 @@ In the workflow, you retrieve the customer's linked `Custom` record using Query.
|
||||
Next, replace the `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
!data.customers[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
const created = when(
|
||||
"create-customer-custom-link"
|
||||
{
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
!data.customers[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
const custom = createCustomStep({
|
||||
@@ -575,14 +577,16 @@ To create the `Custom` record, you use the `createCustomStep` you created in an
|
||||
Next, replace the new `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
data.customers[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
const deleted = when(
|
||||
"delete-customer-custom-link",
|
||||
{
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
data.customers[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
@@ -611,12 +615,10 @@ const updated = when({
|
||||
customers,
|
||||
}, (data) => data.customers[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
return updateCustomStep({
|
||||
id: customers[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
return custom
|
||||
})
|
||||
|
||||
return new WorkflowResponse({
|
||||
|
||||
@@ -547,12 +547,14 @@ In the workflow, you retrieve the product's linked `Custom` record using Query.
|
||||
Next, replace the `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-product/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
products,
|
||||
}, (data) =>
|
||||
!data.products[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
const created = when(
|
||||
"create-product-custom-link",
|
||||
{
|
||||
input,
|
||||
products,
|
||||
}, (data) =>
|
||||
!data.products[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
const custom = createCustomStep({
|
||||
@@ -581,14 +583,16 @@ To create the `Custom` record, you use the `createCustomStep` you created in an
|
||||
Next, replace the new `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-product/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
products,
|
||||
}, (data) =>
|
||||
data.products[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
const deleted = when(
|
||||
"delete-product-custom-link",
|
||||
{
|
||||
input,
|
||||
products,
|
||||
}, (data) =>
|
||||
data.products[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
@@ -617,12 +621,10 @@ const updated = when({
|
||||
products,
|
||||
}, (data) => data.products[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
return updateCustomStep({
|
||||
id: products[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
return custom
|
||||
})
|
||||
|
||||
return new WorkflowResponse({
|
||||
|
||||
@@ -553,12 +553,14 @@ In the workflow, you retrieve the promotion's linked `Custom` record using Query
|
||||
Next, replace the `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-promotion/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
promotions,
|
||||
}, (data) =>
|
||||
!data.promotions[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
const created = when(
|
||||
"create-promotion-custom-link",
|
||||
{
|
||||
input,
|
||||
promotions,
|
||||
}, (data) =>
|
||||
!data.promotions[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
const custom = createCustomStep({
|
||||
@@ -587,14 +589,16 @@ To create the `Custom` record, you use the `createCustomStep` you created in an
|
||||
Next, replace the new `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-promotion/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
promotions,
|
||||
}, (data) =>
|
||||
data.promotions[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
const deleted = when(
|
||||
"delete-promotion-custom-link",
|
||||
{
|
||||
input,
|
||||
promotions,
|
||||
}, (data) =>
|
||||
data.promotions[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
@@ -623,12 +627,10 @@ const updated = when({
|
||||
promotions,
|
||||
}, (data) => data.promotions[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
return updateCustomStep({
|
||||
id: promotions[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
return custom
|
||||
})
|
||||
|
||||
return new WorkflowResponse({
|
||||
|
||||
@@ -2296,8 +2296,7 @@ const workflow = createWorkflow(
|
||||
return input.is_active
|
||||
}
|
||||
).then(() => {
|
||||
const stepResult = isActiveStep()
|
||||
return stepResult
|
||||
return isActiveStep()
|
||||
})
|
||||
|
||||
// executed without condition
|
||||
|
||||
@@ -2180,15 +2180,15 @@ export const generatedEditDates = {
|
||||
"app/commerce-modules/auth/reset-password/page.mdx": "2024-11-27T13:33:55.940Z",
|
||||
"app/storefront-development/customers/reset-password/page.mdx": "2024-09-25T10:21:46.647Z",
|
||||
"app/commerce-modules/api-key/links-to-other-modules/page.mdx": "2024-10-08T08:05:36.596Z",
|
||||
"app/commerce-modules/cart/extend/page.mdx": "2024-12-09T16:11:39.857Z",
|
||||
"app/commerce-modules/cart/extend/page.mdx": "2024-12-11T09:05:37.041Z",
|
||||
"app/commerce-modules/cart/links-to-other-modules/page.mdx": "2024-10-08T08:22:35.190Z",
|
||||
"app/commerce-modules/customer/extend/page.mdx": "2024-12-09T16:15:01.163Z",
|
||||
"app/commerce-modules/customer/extend/page.mdx": "2024-12-11T09:05:35.368Z",
|
||||
"app/commerce-modules/fulfillment/links-to-other-modules/page.mdx": "2024-10-08T14:58:24.935Z",
|
||||
"app/commerce-modules/inventory/links-to-other-modules/page.mdx": "2024-10-08T15:18:30.109Z",
|
||||
"app/commerce-modules/pricing/links-to-other-modules/page.mdx": "2024-10-09T13:51:49.986Z",
|
||||
"app/commerce-modules/product/extend/page.mdx": "2024-12-09T16:15:01.163Z",
|
||||
"app/commerce-modules/product/extend/page.mdx": "2024-12-11T09:07:25.252Z",
|
||||
"app/commerce-modules/product/links-to-other-modules/page.mdx": "2024-10-09T14:14:09.401Z",
|
||||
"app/commerce-modules/promotion/extend/page.mdx": "2024-12-09T16:19:19.364Z",
|
||||
"app/commerce-modules/promotion/extend/page.mdx": "2024-12-11T09:07:24.137Z",
|
||||
"app/commerce-modules/promotion/links-to-other-modules/page.mdx": "2024-10-09T14:51:37.194Z",
|
||||
"app/commerce-modules/order/edit/page.mdx": "2024-10-09T08:50:05.334Z",
|
||||
"app/commerce-modules/order/links-to-other-modules/page.mdx": "2024-10-09T11:23:05.488Z",
|
||||
@@ -2246,7 +2246,7 @@ export const generatedEditDates = {
|
||||
"app/commerce-modules/sales-channel/links-to-other-modules/page.mdx": "2024-10-15T14:25:29.097Z",
|
||||
"app/commerce-modules/stock-location/links-to-other-modules/page.mdx": "2024-10-15T14:33:11.483Z",
|
||||
"app/commerce-modules/store/links-to-other-modules/page.mdx": "2024-06-26T07:19:49.931Z",
|
||||
"app/examples/page.mdx": "2024-12-09T16:19:18.598Z",
|
||||
"app/examples/page.mdx": "2024-12-11T09:07:47.589Z",
|
||||
"app/medusa-cli/commands/build/page.mdx": "2024-11-11T11:00:49.665Z",
|
||||
"app/js-sdk/page.mdx": "2024-10-16T12:12:34.512Z",
|
||||
"references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.apiKey/page.mdx": "2024-12-09T13:21:58.136Z",
|
||||
|
||||
Reference in New Issue
Block a user