From c93a972425573dae6590492883b8c1ddd402a5a4 Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Tue, 30 Aug 2022 08:17:58 +0000 Subject: [PATCH] bug fix --- .../member/user/components/view.component.ts | 365 ++++++++++-------- 1 file changed, 208 insertions(+), 157 deletions(-) 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 46113e9..36ed5e6 100644 --- a/src/app/modules/admin/member/user/components/view.component.ts +++ b/src/app/modules/admin/member/user/components/view.component.ts @@ -129,7 +129,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { memberSettleForm!: FormGroup; memberGameSettingForm!: FormGroup; - passwordConfirmConfigForm!: FormGroup; + fuseAlertConfirmConfigForm!: FormGroup; /* currentMember?: User; */ currentMember?: MemberModel; @@ -150,6 +150,9 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { }; changePasswordResultShowAlert: boolean = false; + alertTitle = '알림'; + alertChangePasswordMessage = '비밀번호를 변경 하시겠습니까?'; + alertUpdateMemberMessage = '회원을 수정 하시겠습니까?'; private _unsubscribeAll: Subject = new Subject(); @@ -223,7 +226,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { canBetSlot: [], }); - this.passwordConfirmConfigForm = this._formBuilder.group({ + this.fuseAlertConfirmConfigForm = this._formBuilder.group({ title: '알림', message: '비밀번호를 변경 하시겠습니까?', icon: this._formBuilder.group({ @@ -407,6 +410,8 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { return; } + /* const dialogRef; */ + const req = new UpdateMemberRequest(); req.setId(this.currentMember?.getId()); @@ -434,89 +439,100 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { } private modifyMemberDefaultInfo(): void { - if (!this.currentMember?.getId()) { - return; - } + this.showConfirmAlert(this.alertTitle, this.alertUpdateMemberMessage).then( + (result) => { + if (!!result && !!this.currentMember?.getId()) { + const req = new UpdateMemberRequest(); + req.setId(this.currentMember?.getId()); - const req = new UpdateMemberRequest(); - req.setId(this.currentMember?.getId()); + const { + username, + signinPw, + nickname, + ownCash, + mobilePhoneNumber, + levelName, + state, + isExcahngeMoney, + comp, + coupon, + siteUrl, + hodingGameMoney, + } = this.memberDefaultForm.value; - const { - username, - signinPw, - nickname, - ownCash, - mobilePhoneNumber, - levelName, - state, - isExcahngeMoney, - comp, - coupon, - siteUrl, - hodingGameMoney, - } = this.memberDefaultForm.value; + if (!!levelName && levelName !== '') { + const level = this.memberLevels.find( + (v) => v.getName() === levelName + ); + if (!!level) req.setMemberLevelId(level?.getId()); + } + if (!!mobilePhoneNumber && mobilePhoneNumber !== '') { + req.setMobilePhoneNumber(mobilePhoneNumber); + } + if (!!siteUrl && siteUrl !== '') { + const site = this.sites.find((v) => v.getUrl() === siteUrl); + if (!!site) req.setSiteId(site.getId()); + } - if (!!levelName && levelName !== '') { - const level = this.memberLevels.find((v) => v.getName() === levelName); - if (!!level) req.setMemberLevelId(level?.getId()); - } - if (!!mobilePhoneNumber && mobilePhoneNumber !== '') { - req.setMobilePhoneNumber(mobilePhoneNumber); - } - if (!!siteUrl && siteUrl !== '') { - const site = this.sites.find((v) => v.getUrl() === siteUrl); - if (!!site) req.setSiteId(site.getId()); - } - - this._memberService - .updateMember(req) - .then((result) => { - console.log(result); - this.showAlert('success', '수정이 완료되었습니다.'); - }) - .catch((resson) => { - this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); - }) - .finally(() => this.closeChangePasswordAlert()); + this._memberService + .updateMember(req) + .then((result) => { + console.log(result); + this.showAlert('success', '수정이 완료되었습니다.'); + }) + .catch((resson) => { + this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } + } + ); } private modifyMemberBankAccountInfo(): void { if (!this.memberBankForm.valid) { return; } - const { - exchangePw, - exchangePwConfirm, - bankName, - accountHolder, - accountNumber, - description, - } = this.memberBankForm.value; - const bankId = this.currentMember?.getBankAccount()?.getId(); - const bankReq = new UpdateMemberBankAccountRequest(); - const bankFind = this.banks.find((v) => v.getName() === bankName); + this.showConfirmAlert(this.alertTitle, this.alertUpdateMemberMessage).then( + (result) => { + if (!!result) { + const { + exchangePw, + exchangePwConfirm, + bankName, + accountHolder, + accountNumber, + description, + } = this.memberBankForm.value; - if (!bankId || !bankFind) { - console.log('Error bankId undefined or bankFind undefined'); - return; - } + const bankId = this.currentMember?.getBankAccount()?.getId(); + const bankReq = new UpdateMemberBankAccountRequest(); + const bankFind = this.banks.find((v) => v.getName() === bankName); - bankReq.setAccountNumber(accountNumber); - bankReq.setBankId(bankFind?.getId()); - bankReq.setId(bankId); - bankReq.setMemo(description); - bankReq.setName(accountHolder); + if (!bankId || !bankFind) { + console.log('Error bankId undefined or bankFind undefined'); + return; + } - this._memberBankAccountService - .updateMemberBankAccount(bankReq) - .then((result) => { - this.showAlert('success', '수정이 완료되었습니다.'); - }) - .catch((reson) => { - this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); - }) - .finally(() => this.closeChangePasswordAlert()); + bankReq.setAccountNumber(accountNumber); + bankReq.setBankId(bankFind?.getId()); + bankReq.setId(bankId); + bankReq.setMemo(description); + bankReq.setName(accountHolder); + + this._memberBankAccountService + .updateMemberBankAccount(bankReq) + .then((result) => { + this.showAlert('success', '수정이 완료되었습니다.'); + }) + .catch((reson) => { + this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } + } + ); } private modifyMemberSttlemtSettingInfo(): void { @@ -524,67 +540,83 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { return; } - const { - rateCasinoBacara, - rateCasinoRoulette, - rateCasinoDragonTiger, - rateCasino, - rateSlot, - rateCasinoLoosing, - rateSlotLoosing, - canFirstChargeComp, - canPerChargeComp, - canExchange, - manualPaymentTypeForPartner, - } = this.memberSettleForm.value; + this.showConfirmAlert(this.alertTitle, this.alertUpdateMemberMessage).then( + (result) => { + if (!!result) { + const { + rateCasinoBacara, + rateCasinoRoulette, + rateCasinoDragonTiger, + rateCasino, + rateSlot, + rateCasinoLoosing, + rateSlotLoosing, + canFirstChargeComp, + canPerChargeComp, + canExchange, + manualPaymentTypeForPartner, + } = this.memberSettleForm.value; - const updateSSReq = new UpdateMemberSettlementSettingRequest(); + const updateSSReq = new UpdateMemberSettlementSettingRequest(); - updateSSReq.setId( - this.currentMember?.getMemberSettlementSetting()?.getId()! + updateSSReq.setId( + this.currentMember?.getMemberSettlementSetting()?.getId()! + ); + updateSSReq.setRateCasinoBacara(rateCasinoBacara); + updateSSReq.setRateCasinoRoulette(rateCasinoRoulette); + updateSSReq.setRateCasinoDragonTiger(rateCasinoDragonTiger); + updateSSReq.setRateCasino(rateCasino); + updateSSReq.setRateSlot(rateSlot); + updateSSReq.setRateCasinoLoosing(rateCasinoLoosing); + updateSSReq.setRateSlotLoosing(rateSlotLoosing); + updateSSReq.setCanFirstChargeComp(canFirstChargeComp); + updateSSReq.setCanPerChargeComp(canPerChargeComp); + updateSSReq.setCanExchange(canExchange); + updateSSReq.setManualPaymentTypeForPartner( + manualPaymentTypeForPartner + ); + + this._memberSettlementSettingService + .updateMemberSettlementSetting(updateSSReq) + .then((result) => { + this.showAlert('success', '수정이 완료되었습니다.'); + }) + .catch((reson) => { + this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } + } ); - updateSSReq.setRateCasinoBacara(rateCasinoBacara); - updateSSReq.setRateCasinoRoulette(rateCasinoRoulette); - updateSSReq.setRateCasinoDragonTiger(rateCasinoDragonTiger); - updateSSReq.setRateCasino(rateCasino); - updateSSReq.setRateSlot(rateSlot); - updateSSReq.setRateCasinoLoosing(rateCasinoLoosing); - updateSSReq.setRateSlotLoosing(rateSlotLoosing); - updateSSReq.setCanFirstChargeComp(canFirstChargeComp); - updateSSReq.setCanPerChargeComp(canPerChargeComp); - updateSSReq.setCanExchange(canExchange); - updateSSReq.setManualPaymentTypeForPartner(manualPaymentTypeForPartner); - - this._memberSettlementSettingService - .updateMemberSettlementSetting(updateSSReq) - .then((result) => { - this.showAlert('success', '수정이 완료되었습니다.'); - }) - .catch((reson) => { - this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); - }) - .finally(() => this.closeChangePasswordAlert()); } private modifyMemberGameSettingInfo(): void { - const { canBetPowerball, canBetCasino, canBetSlot } = - this.memberGameSettingForm.value; + this.showConfirmAlert(this.alertTitle, this.alertUpdateMemberMessage).then( + (result) => { + if (!!result) { + const { canBetPowerball, canBetCasino, canBetSlot } = + this.memberGameSettingForm.value; - const updateGSReq = new UpdateMemberGameSettingRequest(); - updateGSReq.setId(this.currentMember?.getMemberGameSetting()?.getId()!); - updateGSReq.setCanBetPowerball(canBetPowerball); - updateGSReq.setCanBetCasino(canBetCasino); - updateGSReq.setCanBetSlot(canBetSlot); + const updateGSReq = new UpdateMemberGameSettingRequest(); + updateGSReq.setId( + this.currentMember?.getMemberGameSetting()?.getId()! + ); + updateGSReq.setCanBetPowerball(canBetPowerball); + updateGSReq.setCanBetCasino(canBetCasino); + updateGSReq.setCanBetSlot(canBetSlot); - this._memberGameSettingService - .updateMemberGameSetting(updateGSReq) - .then((result) => { - this.showAlert('success', '수정이 완료되었습니다.'); - }) - .catch((reson) => { - this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); - }) - .finally(() => this.closeChangePasswordAlert()); + this._memberGameSettingService + .updateMemberGameSetting(updateGSReq) + .then((result) => { + this.showAlert('success', '수정이 완료되었습니다.'); + }) + .catch((reson) => { + this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } + } + ); } /** * Navigate to the panel @@ -637,14 +669,11 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { return; } - const dialogRef = this._fuseConfirmationService.open( - this.passwordConfirmConfigForm.value - ); - - /* const dialogRef = this._matDialog.open(AddComposeComponent); */ - - dialogRef.afterClosed().subscribe((result) => { - if (result === 'confirmed') { + this.showConfirmAlert( + this.alertTitle, + this.alertChangePasswordMessage + ).then((result) => { + if (!!result) { const req = new UpdateMemberForPasswordRequest(); req.setPassword(password); req.setId(this.currentMember!.getId()); @@ -682,14 +711,11 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { return; } - const dialogRef = this._fuseConfirmationService.open( - this.passwordConfirmConfigForm.value - ); - - /* const dialogRef = this._matDialog.open(AddComposeComponent); */ - - dialogRef.afterClosed().subscribe((result) => { - if (result === 'confirmed') { + this.showConfirmAlert( + this.alertTitle, + this.alertChangePasswordMessage + ).then((result) => { + if (!!result) { const req = new UpdateMemberBankAccountForExchangePasswordRequest(); req.setExchangePassword(password); req.setId(this.currentMember!.getId()); @@ -717,23 +743,26 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { return; } - const req = new UpdateMemberForStateRequest(); - req.setId(this.currentMember!.getId()); - req.setState(state); + this.showConfirmAlert( + this.alertTitle, + '회원 상태를 수정하시겠습니까?' + ).then((result) => { + if (!!result) { + const req = new UpdateMemberForStateRequest(); + req.setId(this.currentMember!.getId()); + req.setState(state); - this._memberService - .updateMemberForState(req) - .then((result) => { - this.showAlert('success', '회원 상태가 수정 되었습니다.'); - }) - .catch((reson) => { - this.showAlert('error', '회원 상태 변경이 실패하였습니다.'); - }) - .finally(() => this.closeChangePasswordAlert()); - } - - __changeMemberState(): void { - const state = this.memberDefaultForm.get('state')?.value; + this._memberService + .updateMemberForState(req) + .then((result) => { + this.showAlert('success', '회원 상태가 수정 되었습니다.'); + }) + .catch((reson) => { + this.showAlert('error', '회원 상태 변경이 실패하였습니다.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } + }); } private showAlert(type: FuseAlertType, message: string): void { @@ -752,4 +781,26 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); }, 5000); } + + private async showConfirmAlert( + title: string, + message: string + ): Promise { + this.fuseAlertConfirmConfigForm.get('title')?.setValue(title); + this.fuseAlertConfirmConfigForm.get('message')?.setValue(message); + + return new Promise((resolve, reject) => { + const dialogRef = this._fuseConfirmationService.open( + this.fuseAlertConfirmConfigForm.value + ); + + dialogRef.afterClosed().subscribe((result) => { + if (result === 'confirmed') { + resolve(true); + } else { + resolve(false); + } + }); + }); + } }