chore: joiner config entity property (#9084)

This commit is contained in:
Carlos R. L. Rodrigues
2024-09-11 06:25:25 -03:00
committed by GitHub
parent 28dc8d4d17
commit fdd0543011
80 changed files with 464 additions and 294 deletions
@@ -16,7 +16,7 @@ export const createCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
const addresses = await service.createAddresses(data)
const addresses = await service.createCustomerAddresses(data)
return new StepResponse(
addresses,
@@ -32,6 +32,6 @@ export const createCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await service.deleteAddresses(ids)
await service.deleteCustomerAddresses(ids)
}
)
@@ -13,10 +13,10 @@ export const deleteCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
const existing = await service.listAddresses({
const existing = await service.listCustomerAddresses({
id: ids,
})
await service.deleteAddresses(ids)
await service.deleteCustomerAddresses(ids)
return new StepResponse(void 0, existing)
},
@@ -29,6 +29,6 @@ export const deleteCustomerAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await service.createAddresses(prevAddresses)
await service.createCustomerAddresses(prevAddresses)
}
)
@@ -55,7 +55,7 @@ export const maybeUnsetDefaultBillingAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await customerModuleService.updateAddresses(
await customerModuleService.updateCustomerAddresses(
{ id: addressesToSet },
{ is_default_billing: true }
)
@@ -54,7 +54,7 @@ export const maybeUnsetDefaultShippingAddressesStep = createStep(
ModuleRegistrationName.CUSTOMER
)
await customerModuleService.updateAddresses(
await customerModuleService.updateCustomerAddresses(
{ id: addressesToSet },
{ is_default_shipping: true }
)
@@ -29,12 +29,12 @@ export const updateCustomerAddressesStep = createStep(
const { selects, relations } = getSelectsAndRelationsFromObjectArray([
data.update,
])
const prevCustomers = await service.listAddresses(data.selector, {
const prevCustomers = await service.listCustomerAddresses(data.selector, {
select: selects,
relations,
})
const customerAddresses = await service.updateAddresses(
const customerAddresses = await service.updateCustomerAddresses(
data.selector,
data.update
)
@@ -51,7 +51,9 @@ export const updateCustomerAddressesStep = createStep(
)
await promiseAll(
prevCustomerAddresses.map((c) => service.updateAddresses(c.id, { ...c }))
prevCustomerAddresses.map((c) =>
service.updateCustomerAddresses(c.id, { ...c })
)
)
}
)
@@ -16,12 +16,12 @@ export const unsetForCreate = async (
return acc
}, [])
const customerDefaultAddresses = await customerService.listAddresses({
const customerDefaultAddresses = await customerService.listCustomerAddresses({
customer_id: customerIds,
[field]: true,
})
await customerService.updateAddresses(
await customerService.updateCustomerAddresses(
{ customer_id: customerIds, [field]: true },
{ [field]: false }
)
@@ -1,7 +1,7 @@
import {
UpdateCustomerAddressDTO,
FilterableCustomerAddressProps,
ICustomerModuleService,
UpdateCustomerAddressDTO,
} from "@medusajs/types"
import { StepResponse } from "@medusajs/workflows-sdk"
@@ -17,18 +17,21 @@ export const unsetForUpdate = async (
return new StepResponse(void 0)
}
const affectedCustomers = await customerService.listAddresses(data.selector, {
select: ["id", "customer_id"],
})
const affectedCustomers = await customerService.listCustomerAddresses(
data.selector,
{
select: ["id", "customer_id"],
}
)
const customerIds = affectedCustomers.map((address) => address.customer_id)
const customerDefaultAddresses = await customerService.listAddresses({
const customerDefaultAddresses = await customerService.listCustomerAddresses({
customer_id: customerIds,
[field]: true,
})
await customerService.updateAddresses(
await customerService.updateCustomerAddresses(
{ customer_id: customerIds, [field]: true },
{ [field]: false }
)