|
@@ -22,6 +22,7 @@ import { PaginatedList } from '@vendure/common/lib/shared-types';
|
|
|
import { ErrorResultUnion } from '../../../common/error/error-result';
|
|
import { ErrorResultUnion } from '../../../common/error/error-result';
|
|
|
import { Address } from '../../../entity/address/address.entity';
|
|
import { Address } from '../../../entity/address/address.entity';
|
|
|
import { Customer } from '../../../entity/customer/customer.entity';
|
|
import { Customer } from '../../../entity/customer/customer.entity';
|
|
|
|
|
+import { CustomerGroupService } from '../../../service/index';
|
|
|
import { CustomerService } from '../../../service/services/customer.service';
|
|
import { CustomerService } from '../../../service/services/customer.service';
|
|
|
import { OrderService } from '../../../service/services/order.service';
|
|
import { OrderService } from '../../../service/services/order.service';
|
|
|
import { RequestContext } from '../../common/request-context';
|
|
import { RequestContext } from '../../common/request-context';
|
|
@@ -32,7 +33,11 @@ import { Transaction } from '../../decorators/transaction.decorator';
|
|
|
|
|
|
|
|
@Resolver()
|
|
@Resolver()
|
|
|
export class CustomerResolver {
|
|
export class CustomerResolver {
|
|
|
- constructor(private customerService: CustomerService, private orderService: OrderService) {}
|
|
|
|
|
|
|
+ constructor(
|
|
|
|
|
+ private customerService: CustomerService,
|
|
|
|
|
+ private customerGroupService: CustomerGroupService,
|
|
|
|
|
+ private orderService: OrderService,
|
|
|
|
|
+ ) {}
|
|
|
|
|
|
|
|
@Query()
|
|
@Query()
|
|
|
@Allow(Permission.ReadCustomer)
|
|
@Allow(Permission.ReadCustomer)
|
|
@@ -117,6 +122,13 @@ export class CustomerResolver {
|
|
|
@Ctx() ctx: RequestContext,
|
|
@Ctx() ctx: RequestContext,
|
|
|
@Args() args: MutationDeleteCustomerArgs,
|
|
@Args() args: MutationDeleteCustomerArgs,
|
|
|
): Promise<DeletionResponse> {
|
|
): Promise<DeletionResponse> {
|
|
|
|
|
+ const groups = await this.customerService.getCustomerGroups(ctx, args.id);
|
|
|
|
|
+ for (const group of groups) {
|
|
|
|
|
+ await this.customerGroupService.removeCustomersFromGroup(ctx, {
|
|
|
|
|
+ customerGroupId: group.id,
|
|
|
|
|
+ customerIds: [args.id],
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
return this.customerService.softDelete(ctx, args.id);
|
|
return this.customerService.softDelete(ctx, args.id);
|
|
|
}
|
|
}
|
|
|
|
|
|