From 3b71dd1fe3d31dcd2ec89b2229822beb00aacfdd Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Thu, 25 Aug 2022 06:30:48 +0000 Subject: [PATCH] bug fix --- .../member/user/components/view.component.ts | 30 ++++++----- .../user/resolvers/member-bank.resolver.ts | 50 +++++++++++++++++ .../member/user/resolvers/user.resolver.ts | 54 ------------------- .../modules/admin/member/user/user.routing.ts | 2 + 4 files changed, 69 insertions(+), 67 deletions(-) create mode 100644 src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts diff --git a/src/app/modules/admin/member/user/components/view.component.ts b/src/app/modules/admin/member/user/components/view.component.ts index cd535b8..d09e34f 100644 --- a/src/app/modules/admin/member/user/components/view.component.ts +++ b/src/app/modules/admin/member/user/components/view.component.ts @@ -59,6 +59,8 @@ import { UpdateMemberBankAccountRequest, } from 'app/modules/proto/c2se/member_bank_account_pb'; import { MemberBankAccountService } from 'app/modules/polyglot/member_bank_account/services/member_bank_account.service'; +import { ListBanksResponse } from 'app/modules/proto/c2se/bank_pb'; +import { ListMemberClassesResponse } from 'app/modules/proto/c2se/member_class_pb'; @Component({ selector: 'user-view', @@ -299,18 +301,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); }); - /* this._memberLevelService.listMemberLevels().then((result) => { - this.memberLevels = result - .getMemberLevelsList() - .filter((v) => !!v.getShow()); - - this.memberDefaultForm - .get('levelName') - ?.setValue(this.currentMember?.getMemberLevel()?.getName()); - this._changeDetectorRef.markForCheck(); - }); */ - - this._bankService.listBanks().then((result) => { + /* this._bankService.listBanks().then((result) => { this.memberBankForm.get('bankName')?.value; this.memberBankForm.patchValue({ @@ -323,7 +314,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); this.banks = result.getBanksList(); - }); + }); */ this._activatedRoute.data.subscribe((data) => { let member: GetMemberResponse.Result = data['member']; @@ -347,6 +338,19 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { data['listMemberLevels']; this.memberLevels = listMemberLevelsResult.getMemberLevelsList(); + let listMemberClassesResult: ListMemberClassesResponse.Result = + data['listMemberClasses']; + + let listbanksResult: ListBanksResponse.Result = data['listMemberBanks']; + this.banks = listbanksResult.getBanksList(); + + this.memberBankForm.patchValue({ + bankName: this.currentMember?.getBankAccount()?.getBank()?.getName(), + accountNumber: this.currentMember?.getBankAccount()?.getAccountNumber(), + accountHolder: this.currentMember?.getBankAccount()?.getName(), + description: this.currentMember?.getBankAccount()?.getMemo(), + }); + // Mark for check this._changeDetectorRef.markForCheck(); }); diff --git a/src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts b/src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts new file mode 100644 index 0000000..5ca18fe --- /dev/null +++ b/src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@angular/core'; +import { + ActivatedRouteSnapshot, + Resolve, + Router, + RouterStateSnapshot, +} from '@angular/router'; +import { BankService } from 'app/modules/polyglot/bank/services/bank.service'; +import { MemberClassService } from 'app/modules/polyglot/member_class/services/member_class.service'; +import { + ListBanksRequest, + ListBanksResponse, +} from 'app/modules/proto/c2se/bank_pb'; +import { + ListMemberClassesRequest, + ListMemberClassesResponse, +} from 'app/modules/proto/c2se/member_class_pb'; + +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class ListMemberBanksResolver implements Resolve { + /** + * Constructor + */ + constructor(private _router: Router, private __bankService: BankService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListBanksResponse.Result { + return this.__bankService.listBanks(); + } +} diff --git a/src/app/modules/admin/member/user/resolvers/user.resolver.ts b/src/app/modules/admin/member/user/resolvers/user.resolver.ts index a61cf44..8608dfa 100644 --- a/src/app/modules/admin/member/user/resolvers/user.resolver.ts +++ b/src/app/modules/admin/member/user/resolvers/user.resolver.ts @@ -161,57 +161,3 @@ export class MemberResolver implements Resolve { return this._memberService.getMember(memberId!); } } - -export class SitesResolver implements Resolve { - /** - * Constructor - */ - constructor(private __siteService: SiteService) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Resolver - * - * @param route - * @param state - */ - resolve( - route: ActivatedRouteSnapshot, - state: RouterStateSnapshot - ): - | Observable - | Promise - | ListSitesResponse.Result { - return this.__siteService.listSites(); - } -} - -export class BanksResolver implements Resolve { - /** - * Constructor - */ - constructor(private _bankService: BankService) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Resolver - * - * @param route - * @param state - */ - resolve( - route: ActivatedRouteSnapshot, - state: RouterStateSnapshot - ): - | Observable - | Promise - | ListBanksResponse.Result { - return this._bankService.listBanks(); - } -} diff --git a/src/app/modules/admin/member/user/user.routing.ts b/src/app/modules/admin/member/user/user.routing.ts index ee7454c..70bb64f 100644 --- a/src/app/modules/admin/member/user/user.routing.ts +++ b/src/app/modules/admin/member/user/user.routing.ts @@ -2,6 +2,7 @@ import { Route } from '@angular/router'; import { ListComponent } from 'app/modules/admin/member/user/components/list.component'; import { ViewComponent } from 'app/modules/admin/member/user/components/view.component'; +import { ListMemberBanksResolver } from './resolvers/member-bank.resolver'; import { ListMemberClassesResolver } from './resolvers/member-class.resolver'; import { ListMemberLevelsResolver } from './resolvers/member-level.resolver'; @@ -15,6 +16,7 @@ export const userRoutes: Route[] = [ listmembers: ListMemberResolver, listMemberClasses: ListMemberClassesResolver, listMemberLevels: ListMemberLevelsResolver, + listMemberBanks: ListMemberBanksResolver, }, }, {