update when-then blocks across docs

This commit is contained in:
Shahed Nasser
2024-12-11 11:08:52 +02:00
parent fd23f13cfd
commit 3522c0f0e0
6 changed files with 83 additions and 75 deletions
@@ -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({