member_webapp/@overflow/member/container/member-signin-container.component.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-05-28 11:16:00 +00:00
import { Component, OnInit, Input } from '@angular/core';
2018-04-06 06:59:49 +00:00
import { Store, select } from '@ngrx/store';
2018-05-28 11:16:00 +00:00
import { Observable } from 'rxjs';
2018-04-06 06:59:49 +00:00
2018-05-28 11:16:00 +00:00
import { MemberSigninContainerSelector } from '../store';
import * as MemberEntityStore from '../store/entity/member';
2018-05-28 11:39:58 +00:00
import { Member } from '@overflow/commons-typescript/model/member';
2018-04-06 06:59:49 +00:00
@Component({
2018-05-28 05:41:56 +00:00
selector: 'of-member-signin-container',
templateUrl: './member-signin-container.component.html',
2018-04-06 06:59:49 +00:00
})
2018-05-28 05:41:56 +00:00
export class MemberSigninContainerComponent implements OnInit {
2018-05-28 11:16:00 +00:00
@Input() returnURL: string;
2018-05-28 11:39:58 +00:00
member$: Observable<Member>;
2018-05-28 11:16:00 +00:00
pending$: Observable<boolean>;
error$: Observable<any>;
2018-04-06 06:59:49 +00:00
constructor(
2018-05-28 11:16:00 +00:00
private store: Store<any>,
2018-04-06 06:59:49 +00:00
) {
}
ngOnInit() {
2018-05-28 11:39:58 +00:00
this.member$ = this.store.pipe(select(MemberSigninContainerSelector.selectMember));
2018-05-28 11:16:00 +00:00
this.pending$ = this.store.pipe(select(MemberSigninContainerSelector.selectPending));
this.error$ = this.store.pipe(select(MemberSigninContainerSelector.selectError));
2018-04-06 06:59:49 +00:00
}
2018-05-28 11:16:00 +00:00
onSignin(info: {email: string, password: string}) {
this.store.dispatch(new MemberEntityStore.Signin({...info, returnURL: this.returnURL}));
2018-04-06 06:59:49 +00:00
}
}