This commit is contained in:
geek 2018-05-29 20:42:39 +09:00
parent 8f6bae5586
commit ac08c59512
8 changed files with 20 additions and 42 deletions

View File

@ -17,20 +17,7 @@
<of-member-policy (close)="policyDisplay = false"></of-member-policy> <of-member-policy (close)="policyDisplay = false"></of-member-policy>
</p-dialog> </p-dialog>
<p-dialog <div class="ui-g" *ngIf="!member">
header="Membership is welcome."
[modal]="true"
[width]="800"
[(visible)]="signupComplete"
[showHeader]="true"
[closeOnEscape]="false"
(onHide)="closeSignup()">
<div>Membership is welcome. </div>
</p-dialog>
<div class="ui-g">
<div class="ui-g-12 ui-md-9 ui-lg-7"> <div class="ui-g-12 ui-md-9 ui-lg-7">
<form [formGroup]="signupForm" (ngSubmit)="signupFormSubmit()"> <form [formGroup]="signupForm" (ngSubmit)="signupFormSubmit()">
<table class="login-table"> <table class="login-table">
@ -178,3 +165,8 @@
</form> </form>
</div> </div>
</div> </div>
<div class="ui-g" *ngIf="member">
sdklsdlkfklsdfklsdklfskldfjk
{{member.email}}
</div>

View File

@ -14,9 +14,8 @@ import { Member } from '@overflow/commons-typescript/model/member';
}) })
export class MemberSignupComponent implements OnInit, OnDestroy { export class MemberSignupComponent implements OnInit, OnDestroy {
@Output() signup = new EventEmitter<{member: Member, password: string}>(); @Output() signup = new EventEmitter<{member: Member, password: string}>();
@Output() doneSignup = new EventEmitter();
@Input() signupComplete; @Input() member;
signupForm: FormGroup; signupForm: FormGroup;
email: AbstractControl; email: AbstractControl;
@ -134,10 +133,6 @@ export class MemberSignupComponent implements OnInit, OnDestroy {
this.policyDisplay = true; this.policyDisplay = true;
} }
closeSignup() {
this.doneSignup.emit();
}
onScriptLoad() { onScriptLoad() {
console.log('Google reCAPTCHA loaded and is ready for use!'); console.log('Google reCAPTCHA loaded and is ready for use!');
} }

View File

@ -1 +1 @@
<of-member-signup [signupComplete]="signupComplete$ | async" (signup)="onSignup($event)" (doneSignup)="onDoneSignup()" ></of-member-signup> <of-member-signup [member]="member$ | async" (signup)="onSignup($event)" ></of-member-signup>

View File

@ -8,7 +8,7 @@ import {select, Store} from '@ngrx/store';
import * as MemberEntityStore from '../store/entity/member'; import * as MemberEntityStore from '../store/entity/member';
import { MemberSignupContainerSelector } from '../store'; import { MemberSignupContainerSelector } from '../store';
import {Observable} from 'rxjs'; import { Observable } from 'rxjs';
@Component({ @Component({
selector: 'of-member-signup-container', selector: 'of-member-signup-container',
@ -16,16 +16,14 @@ import {Observable} from 'rxjs';
}) })
export class MemberSignupContainerComponent implements OnInit, OnDestroy { export class MemberSignupContainerComponent implements OnInit, OnDestroy {
@Output() doneSignup = new EventEmitter(); member$: Observable<Member>;
signupComplete$: Observable<boolean>;
constructor( constructor(
private store: Store<any>, private store: Store<any>,
) { } ) { }
ngOnInit() { ngOnInit() {
this.signupComplete$ = this.store.pipe(select(MemberSignupContainerSelector.selectSignupComplete)); this.member$ = this.store.pipe(select(MemberSignupContainerSelector.selectMember));
} }
ngOnDestroy() { ngOnDestroy() {
@ -35,7 +33,4 @@ export class MemberSignupContainerComponent implements OnInit, OnDestroy {
this.store.dispatch(new MemberEntityStore.Signup(info)); this.store.dispatch(new MemberEntityStore.Signup(info));
} }
onDoneSignup() {
this.doneSignup.emit();
}
} }

View File

@ -12,7 +12,7 @@ export function reducer(state = initialState, action: Actions): State {
switch (action.type) { switch (action.type) {
case ActionType.Signup: { case ActionType.Signup: {
return { return {
signupComplete: false, member: null,
pending: true, pending: true,
error: null, error: null,
}; };
@ -20,7 +20,7 @@ export function reducer(state = initialState, action: Actions): State {
case ActionType.SignupSuccess: { case ActionType.SignupSuccess: {
return { return {
signupComplete: true, member: action.payload,
pending: false, pending: false,
error: null, error: null,
}; };
@ -28,7 +28,7 @@ export function reducer(state = initialState, action: Actions): State {
case ActionType.SignupFailure: { case ActionType.SignupFailure: {
return { return {
signupComplete: false, member: null,
pending: false, pending: false,
error: action.payload, error: action.payload,
}; };

View File

@ -1,22 +1,23 @@
import { Selector, createSelector } from '@ngrx/store'; import { Selector, createSelector } from '@ngrx/store';
import { RESTClientError } from '@loafer/ng-rest'; import { RESTClientError } from '@loafer/ng-rest';
import { Member } from '@overflow/commons-typescript/model/member';
export interface State { export interface State {
signupComplete: boolean; member: Member;
pending: boolean; pending: boolean;
error: RESTClientError; error: RESTClientError;
} }
export const initialState: State = { export const initialState: State = {
signupComplete: false, member: null,
pending: false, pending: false,
error: null, error: null,
}; };
export function getSelectors(selector: Selector<any, State>) { export function getSelectors(selector: Selector<any, State>) {
return { return {
selectSignupComplete: createSelector(selector, (state: State) => state.signupComplete), selectMember: createSelector(selector, (state: State) => state.member),
selectPending: createSelector(selector, (state: State) => state.pending), selectPending: createSelector(selector, (state: State) => state.pending),
selectError: createSelector(selector, (state: State) => state.error), selectError: createSelector(selector, (state: State) => state.error),
}; };

View File

@ -1,6 +1,6 @@
<div class="ui-g"> <div class="ui-g">
<div class="ui-g-12 ui-md-9 ui-lg-7"> <div class="ui-g-12 ui-md-9 ui-lg-7">
<of-member-signup-container (doneSignup)="signupComplete()"></of-member-signup-container> <of-member-signup-container ></of-member-signup-container>
</div> </div>
<div class="ui-g-12 ui-md-3 ui-lg-5 login-descript"> <div class="ui-g-12 ui-md-3 ui-lg-5 login-descript">
<table class="login-table"> <table class="login-table">

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import { ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: 'of-pages-auth-signup', selector: 'of-pages-auth-signup',
@ -10,7 +10,6 @@ export class SignupPageComponent implements OnInit {
returnURL: string; returnURL: string;
constructor( constructor(
private router: Router,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
) { } ) { }
@ -20,8 +19,4 @@ export class SignupPageComponent implements OnInit {
initForm() { initForm() {
} }
signupComplete() {
this.router.navigate(['/auth/signin']);
}
} }