Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(customer): add remove from group, update group #6149

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: pr comments
  • Loading branch information
srindom committed Jan 22, 2024
commit 9f298e7852a5852b15506444f81a2f0a260117fb
16 changes: 7 additions & 9 deletions packages/customer/src/services/customer-module.ts
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ export default class CustomerModuleService implements ICustomerModuleService {
@MedusaContext() sharedContext: Context = {}
) {
let updateData: CustomerTypes.UpdateCustomerDTO[] = []
if (typeof idsOrSelector === "string") {
if (isString(idsOrSelector)) {
updateData = [
{
id: idsOrSelector,
@@ -280,7 +280,7 @@ export default class CustomerModuleService implements ICustomerModuleService {
sharedContext?: Context
): Promise<CustomerTypes.CustomerGroupDTO[]>

@InjectManager("baseRepository_")
@InjectTransactionManager("baseRepository_")
async updateCustomerGroup(
groupIdOrSelector:
| string
@@ -290,7 +290,7 @@ export default class CustomerModuleService implements ICustomerModuleService {
@MedusaContext() sharedContext: Context = {}
) {
let updateData: CustomerTypes.UpdateCustomerGroupDTO[] = []
if (typeof groupIdOrSelector === "string") {
if (isString(groupIdOrSelector)) {
updateData = [
{
id: groupIdOrSelector,
@@ -319,7 +319,7 @@ export default class CustomerModuleService implements ICustomerModuleService {
sharedContext
)

if (typeof groupIdOrSelector === "string") {
if (isString(groupIdOrSelector)) {
return await this.baseRepository_.serialize<CustomerTypes.CustomerGroupDTO>(
groups[0],
{ populate: true }
@@ -359,19 +359,17 @@ export default class CustomerModuleService implements ICustomerModuleService {
}

async removeCustomerFromGroup(
groupCustomerPair: { customer_id: string; customer_group_id: string },
groupCustomerPair: CustomerTypes.GroupCustomerPair,
sharedContext?: Context
): Promise<void>
async removeCustomerFromGroup(
groupCustomerPairs: { customer_id: string; customer_group_id: string }[],
groupCustomerPairs: CustomerTypes.GroupCustomerPair[],
sharedContext?: Context
): Promise<void>

@InjectTransactionManager("baseRepository_")
async removeCustomerFromGroup(
data:
| { customer_id: string; customer_group_id: string }
| { customer_id: string; customer_group_id: string }[],
data: CustomerTypes.GroupCustomerPair | CustomerTypes.GroupCustomerPair[],
@MedusaContext() sharedContext: Context = {}
): Promise<void> {
const pairs = Array.isArray(data) ? data : [data]