From e6a0c6e988d4315ca054f72a495604aa1d4d2cdd Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Sat, 20 Aug 2022 07:24:32 +0000 Subject: [PATCH] bug fix --- .../components/list.component.ts | 80 +++++++++++-------- .../services/member_referrer.service.ts | 6 +- 2 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/app/modules/admin/member/partner-recommendation/components/list.component.ts b/src/app/modules/admin/member/partner-recommendation/components/list.component.ts index 64632da..05f1507 100644 --- a/src/app/modules/admin/member/partner-recommendation/components/list.component.ts +++ b/src/app/modules/admin/member/partner-recommendation/components/list.component.ts @@ -125,21 +125,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { this.__addBtnConfirmConfig(); this.__removeBtnConfirmConfig(); - this._memberReffererService.listMemberReferrers().then((result) => { - const list = result.getMemberReferrersList(); - - this.removePartnerStoreDataSource.data = result.getMemberReferrersList(); - /* this.registPartnerStoreDataSource.data */ - const partnerStores = this.listMembers.filter( - (m) => - m.getMemberClass()?.getId() === 'e11cac11-3825-4f4e-9cd5-39367f23f973' - ); - - this.registPartnerStoreDataSource.data = partnerStores; - - // Mark for check - this._changeDetectorRef.markForCheck(); - }); // Get the products this._activatedRoute.data.subscribe((data) => { let listMemberResult: ListMembersResponse.Result = @@ -147,22 +132,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { this.listMembers = listMemberResult.getMembersList(); - /* this.registPartnerStoreDataSource.data = listMemberResult - .getMembersList() - .filter( - (v: MemberModel) => - v.getMemberClass()?.getId() === - 'e11cac11-3825-4f4e-9cd5-39367f23f973' && - ); - this.removePartnerStoreDataSource.data = listMemberResult - .getMembersList() - .filter( - (v: MemberModel) => - v.getMemberClass()?.getId() === - 'e11cac11-3825-4f4e-9cd5-39367f23f973' - ); */ - - /* console.log('dddd', listMemberResult.getMembersList()); */ + this.__generationRefererList(); // Mark for check this._changeDetectorRef.markForCheck(); @@ -374,8 +344,12 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { dialogRef.afterClosed().subscribe((result) => { if (result === 'confirmed') { if (!!this.registSelection.hasValue()) { + /* const mrArr = this.removePartnerStoreDataSource.data; */ + this.registSelection.selected.forEach((m: MemberModel) => { - this._memberReffererService.createMemberReferrer(m.getId()); + this._memberReffererService + .createMemberReferrer(m.getId()) + .then(() => this.__generationRefererList()); }); } } @@ -390,6 +364,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { // Subscribe to afterClosed from the dialog reference dialogRef.afterClosed().subscribe((result) => { if (result === 'confirmed') { + if (!!this.removeSelection.hasValue()) { + /* const mrArr = this.removePartnerStoreDataSource.data; */ + + this.removeSelection.selected.forEach((m: MemberReferrerModel) => { + this._memberReffererService + .deleteMemberReferrer(m.getId()) + .then(() => this.__generationRefererList()); + }); + } } }); } @@ -406,4 +389,37 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { console.log(info.getMember()?.getUsername()); return '매장'; } + + __generationRefererList(): void { + this._memberReffererService.listMemberReferrers().then((result) => { + const list = result.getMemberReferrersList(); + + this.removePartnerStoreDataSource.data = result.getMemberReferrersList(); + /* this.registPartnerStoreDataSource.data */ + const registArr: MemberModel[] = []; + + const partnerStores = this.listMembers.filter( + (m) => + m.getMemberClass()?.getId() === 'e11cac11-3825-4f4e-9cd5-39367f23f973' + ); + + list.forEach((rm) => { + if (partnerStores.length > 0) { + partnerStores.forEach((ps) => { + if (rm.getMember()?.getId() === ps.getId() && !rm.getCanUse()) { + registArr.push(ps); + } + }); + } + }); + + this.registPartnerStoreDataSource.data = partnerStores; + this.removePartnerStoreDataSource.data = list.filter( + (v) => !!v.getCanUse() + ); + + // Mark for check + this._changeDetectorRef.markForCheck(); + }); + } } diff --git a/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts b/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts index eb9dac8..6f5c9f4 100644 --- a/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts +++ b/src/app/modules/polyglot/member_referrer/services/member_referrer.service.ts @@ -134,11 +134,15 @@ export class MemberReferrerService { ); } - deleteMemberReferrer(): Promise { + deleteMemberReferrer( + id: string + ): Promise { return new Promise( (resolve, reject) => { let req = new DeleteMemberReferrerRequest(); + req.setId(id); + this.__natsService .request( SUBJECT_DELETE_MEMBER_REFERRER,