diff --git a/@overflow/member/component/member-totp.component.ts b/@overflow/member/component/member-totp.component.ts index 2556911..1fcbd8c 100644 --- a/@overflow/member/component/member-totp.component.ts +++ b/@overflow/member/component/member-totp.component.ts @@ -1,14 +1,16 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import { DomainMember } from '@overflow/commons-typescript/model/domain'; +import { Member } from '@overflow/commons-typescript/model/member'; @Component({ selector: 'of-member-totp', templateUrl: './member-totp.component.html', }) export class MemberTotpComponent implements OnInit { - @Input() member; + @Input() domainMember: DomainMember; @Input() totp; - @Output() totpRegist = new EventEmitter<{code: string, secretCode: string}>(); - @Output() totpCreate = new EventEmitter(); + @Output() regist = new EventEmitter<{member: Member, code: string, secretCode: string}>(); + @Output() create = new EventEmitter(); selectedItem: any; totpSettingDisplay = false; @@ -22,9 +24,9 @@ export class MemberTotpComponent implements OnInit { ngOnInit() { this.lists = [ - {id: 1, name: 'Email', value: this.member.email, description: 'blabla', }, - {id: 2, name: 'Phone', value: this.member.phone, description: 'blabla', }, - {id: 3, name: 'Google 2factor', value: this.member.totpType, description: 'blabla', }, + {id: 1, name: 'Email', value: this.domainMember.member.email, description: 'blabla', }, + {id: 2, name: 'Phone', value: this.domainMember.member.phone, description: 'blabla', }, + {id: 3, name: 'Google 2factor', value: this.domainMember.member.totpType, description: 'blabla', }, ]; } @@ -35,13 +37,13 @@ export class MemberTotpComponent implements OnInit { if (this.selectedItem.id === 3) { this.headerItem = '구글 인증기 설정하기'; this.totpSettingDisplay = true; - this.totpCreate.emit(); + this.create.emit(this.domainMember.member); } } totpInput(e) { if ( e.target.value.length === 6 ) { - this.totpRegist.emit(e.target.value); + this.regist.emit(e.target.value); } return; } diff --git a/@overflow/member/container/member-totp-container.component.html b/@overflow/member/container/member-totp-container.component.html index 5e1cb43..99b7d0b 100644 --- a/@overflow/member/container/member-totp-container.component.html +++ b/@overflow/member/container/member-totp-container.component.html @@ -1,5 +1,7 @@ + (regist)="regist($event)" + (create)="create()" +> + diff --git a/@overflow/member/container/member-totp-container.component.ts b/@overflow/member/container/member-totp-container.component.ts index 633f9ce..68b60e3 100644 --- a/@overflow/member/container/member-totp-container.component.ts +++ b/@overflow/member/container/member-totp-container.component.ts @@ -1,53 +1,40 @@ -import { Component, OnInit} from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { Store } from '@ngrx/store'; -import * as TotpStore from '../store/entity/member-totp'; -import { AuthSelector } from '../store/entity/member'; import { Member, MemberTotp } from '@overflow/commons-typescript/model/member'; -import {Observable} from 'rxjs'; +import { Observable } from 'rxjs'; +import { DomainMember } from '@overflow/commons-typescript/model/domain'; + +import * as TotpEntityStore from '../store/entity/member-totp'; +import { AuthContainerSelector } from '@overflow/shared/auth/store'; @Component({ selector: 'of-member-totp-container', templateUrl: './member-totp-container.component.html', }) export class MemberTotpContainerComponent implements OnInit { - member: Member; + domainMember$: Observable; totp$: Observable; lists = []; - constructor(private activatedRoute: ActivatedRoute, - private router: Router, - private store: Store, - ) { } + constructor( + private activatedRoute: ActivatedRoute, + private router: Router, + private store: Store, + ) { } ngOnInit() { - this.store.select(AuthSelector.select('member')).subscribe( - (member: Member) => { - this.member = member; - }, - (error) => { - console.log(error); - } - ); + this.domainMember$ = this.store.select(AuthContainerSelector.selectDomainMember); } - onTotpRegist(obj: any) { + regist(info: {member: Member, code: string, secretCode: string}) { const secretCode = 'X6AWAK573M5372NM'; - this.store.dispatch(new TotpStore.Regist({ member: this.member, secretCode: obj.secretCode, code: obj.code })); - - // this.store.select(AuthSelector.select('memberTotp')).subscribe( - // (memberTotp: MemberTotp) => { - // - // }, - // (error) => { - // console.log(error); - // } - // ); + this.store.dispatch(new TotpEntityStore.Regist(info)); } - onTotpCreate() { - this.store.dispatch(new TotpStore.CreateTotp(this.member)); + create(member: Member) { + this.store.dispatch(new TotpEntityStore.CreateTotp(member)); } }