diff --git a/src/app/modules/admin/member/user/components/view.component.html b/src/app/modules/admin/member/user/components/view.component.html index 10e4efd..b89f0a9 100644 --- a/src/app/modules/admin/member/user/components/view.component.html +++ b/src/app/modules/admin/member/user/components/view.component.html @@ -228,12 +228,12 @@ 레벨 {{ level.getName() }} @@ -306,12 +306,12 @@ 사이트변경 {{ site.getUrl() }} 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 a9a7c01..e795b9a 100644 --- a/src/app/modules/admin/member/user/components/view.component.ts +++ b/src/app/modules/admin/member/user/components/view.component.ts @@ -93,13 +93,6 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { isLoading = false; searchInputControl = new FormControl(); - /* NONE: 0; - NORMAL: 1; - PENDING: 2; - WITHDRAWAL: 3; - DORMANCY: 4; - BLACKLIST: 5; - SUSPENDED: 6; */ memberStateOptions = [ { value: 1, @@ -185,13 +178,13 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { nickname: [{ value: '', disabled: true }], ownCash: [''], mobilePhoneNumber: [''], - levelId: [''], + levelName: [''], state: [''], isExcahngeMoney: [''], comp: [''], coupon: [''], recommender: [{ value: '', disabled: true }], - siteId: [''], + siteUrl: [''], recommendCount: [''], hodingGameMoney: [{ value: '0', disabled: true }], }); @@ -289,10 +282,26 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); }); - this._siteService - .listSites() - .then((result) => (this.sites = result.getSitesList())); + this._siteService.listSites().then((result) => { + this.sites = result + .getSitesList() + .filter((v) => !!v.getShow() && !!v.getCanUse()); + this.memberDefaultForm + .get('siteUrl') + ?.setValue(this.currentMember?.getSite()?.getUrl()); + 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.banks = result.getBanksList())); @@ -310,7 +319,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { signinPw: '', exchangePw: '', mobilePhoneNumber: this.currentMember?.getMobilePhoneNumber(), - levelId: this.currentMember?.getMemberLevel()?.getId(), + levelName: this.currentMember?.getMemberLevel()?.getId(), state: this.currentMember?.getState(), nickname: this.currentMember?.getNickname(), bankId: this.currentMember?.getBankAccount()?.getId(), @@ -386,23 +395,27 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { nickname, ownCash, mobilePhoneNumber, - levelId, + levelName, state, isExcahngeMoney, comp, coupon, - siteId, + siteUrl, hodingGameMoney, } = this.memberDefaultForm.value; - if (!!levelId && levelId == '') { - req.setMemberLevelId(levelId); + if (!!levelName && levelName !== '') { + const level = this.memberLevels.find( + (v) => v.getName() === levelName + ); + if (!!level) req.setMemberLevelId(level?.getId()); } - if (!!mobilePhoneNumber && mobilePhoneNumber == '') { + if (!!mobilePhoneNumber && mobilePhoneNumber !== '') { req.setMobilePhoneNumber(mobilePhoneNumber); } - if (!!siteId && siteId == '') { - req.setSiteId(siteId); + if (!!siteUrl && siteUrl !== '') { + const site = this.sites.find((v) => v.getUrl() === siteUrl); + if (!!site) req.setSiteId(site.getId()); } } @@ -479,21 +492,14 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { ?.value as string; if (!password || !passwordConfirm) { - this.changePasswordResultShowAlert = true; - this.alertConfig = { - type: 'error', - message: '비밀번호를 입력하세요.', - }; + this.showAlert('error', '비밀번호를 입력하세요.'); this.closeChangePasswordAlert(); return; } if (password !== passwordConfirm) { - this.changePasswordResultShowAlert = true; - this.alertConfig = { - type: 'error', - message: '비밀번호가 일치하지 않습니다.', - }; + this.showAlert('error', '비밀번호가 일치하지 않습니다.'); + this.closeChangePasswordAlert(); return; } @@ -512,22 +518,12 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._memberService .updateMemberForPassword(req) .then((result) => { - this.changePasswordResultShowAlert = true; - - this.alertConfig = { - type: 'success', - message: '비밀번호가 수정 되었습니다.', - }; + this.showAlert('success', '비밀번호가 수정 되었습니다.'); this._changeDetectorRef.markForCheck(); }) .catch((reson) => { - this.changePasswordResultShowAlert = true; - // Set the alert - this.alertConfig = { - type: 'error', - message: '패스워드 변경이 실패하였습니다.', - }; + this.showAlert('error', '패스워드 변경이 실패하였습니다.'); this._changeDetectorRef.markForCheck(); }) .finally(() => this.closeChangePasswordAlert()); @@ -539,10 +535,8 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { const state = event.value; if (!state) { - this.alertConfig = { - type: 'error', - message: '상태값이 선택 되지 않았습니다.', - }; + this.showAlert('error', '상태값이 선택 되지 않았습니다.'); + this.closeChangePasswordAlert(); return; } @@ -554,19 +548,10 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._memberService .updateMemberForState(req) .then((result) => { - this.changePasswordResultShowAlert = true; - this.alertConfig = { - type: 'success', - message: '회원 상태가 수정 되었습니다.', - }; + this.showAlert('success', '회원 상태가 수정 되었습니다.'); }) .catch((reson) => { - this.changePasswordResultShowAlert = true; - // Set the alert - this.alertConfig = { - type: 'error', - message: '회원 상태 변경이 실패하였습니다.', - }; + this.showAlert('error', '회원 상태 변경이 실패하였습니다.'); }) .finally(() => this.closeChangePasswordAlert()); } @@ -575,6 +560,15 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { const state = this.memberDefaultForm.get('state')?.value; } + private showAlert(type: FuseAlertType, message: string): void { + this.changePasswordResultShowAlert = true; + // Set the alert + this.alertConfig = { + type, + message, + }; + } + private closeChangePasswordAlert(): void { setTimeout(() => { this.changePasswordResultShowAlert = false; 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 30c208f..54f52e4 100644 --- a/src/app/modules/admin/member/user/resolvers/user.resolver.ts +++ b/src/app/modules/admin/member/user/resolvers/user.resolver.ts @@ -5,12 +5,18 @@ import { Router, RouterStateSnapshot, } from '@angular/router'; +import { BankService } from 'app/modules/polyglot/bank/services/bank.service'; import { MemberService } from 'app/modules/polyglot/member/services/member.service'; +import { MemberLevelService } from 'app/modules/polyglot/member_level/services/member_level.service'; +import { SiteService } from 'app/modules/polyglot/site/services/site.service'; +import { ListBanksResponse } from 'app/modules/proto/c2se/bank_pb'; +import { ListMemberLevelsResponse } from 'app/modules/proto/c2se/member_level_pb'; import { GetMemberResponse } from 'app/modules/proto/c2se/member_pb'; import { ListMembersRequest, ListMembersResponse, } from 'app/modules/proto/c2se/member_pb'; +import { ListSitesResponse } from 'app/modules/proto/c2se/site_pb'; import { catchError, Observable, throwError } from 'rxjs'; @@ -155,3 +161,84 @@ 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(); + } +} + +export class MemberLevelsResolver implements Resolve { + /** + * Constructor + */ + constructor(private _memberLevelService: MemberLevelService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListMemberLevelsResponse.Result { + return this._memberLevelService.listMemberLevels(); + } +}