2018-05-14 08:10:55 +00:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnDestroy,
|
|
|
|
OnInit,
|
|
|
|
} from '@angular/core';
|
2018-04-06 06:59:49 +00:00
|
|
|
import { Router } from '@angular/router';
|
2018-04-10 10:19:41 +00:00
|
|
|
import { FormGroup, FormBuilder, Validators, AbstractControl, FormControl } from '@angular/forms';
|
2018-05-02 08:09:39 +00:00
|
|
|
import { Member } from '@overflow/commons-typescript/model/member';
|
2018-04-12 08:06:15 +00:00
|
|
|
import * as AuthStore from '../../store/signup';
|
|
|
|
import {Store} from '@ngrx/store';
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-member-signup',
|
|
|
|
templateUrl: './signup.component.html',
|
|
|
|
})
|
2018-05-16 06:01:30 +00:00
|
|
|
export class SignupComponent implements OnInit, OnDestroy {
|
2018-05-14 08:10:55 +00:00
|
|
|
myRecaptcha = new FormControl(false);
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
signupForm: FormGroup;
|
2018-04-10 10:19:41 +00:00
|
|
|
email: AbstractControl;
|
|
|
|
password: AbstractControl;
|
|
|
|
pwConfirm: AbstractControl;
|
|
|
|
name: AbstractControl;
|
|
|
|
phone: AbstractControl;
|
|
|
|
company: AbstractControl;
|
2018-05-03 07:19:10 +00:00
|
|
|
termsDisplay = false;
|
|
|
|
policyDisplay = false;
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private router: Router,
|
2018-04-12 08:06:15 +00:00
|
|
|
private formBuilder: FormBuilder,
|
|
|
|
private store: Store<AuthStore.State>,
|
2018-04-06 06:59:49 +00:00
|
|
|
) { }
|
|
|
|
|
2018-05-14 08:10:55 +00:00
|
|
|
|
2018-04-06 06:59:49 +00:00
|
|
|
ngOnInit() {
|
|
|
|
this.initForm();
|
|
|
|
}
|
|
|
|
|
2018-05-14 08:10:55 +00:00
|
|
|
ngOnDestroy() {
|
|
|
|
}
|
|
|
|
|
2018-04-06 06:59:49 +00:00
|
|
|
initForm() {
|
|
|
|
this.signupForm = this.formBuilder.group({
|
2018-04-12 08:06:15 +00:00
|
|
|
'email': [
|
|
|
|
'geekhot@hotmail.co.kr',
|
|
|
|
[
|
|
|
|
Validators.required,
|
|
|
|
Validators.email
|
|
|
|
]
|
2018-04-06 06:59:49 +00:00
|
|
|
],
|
2018-04-12 08:06:15 +00:00
|
|
|
'password': [
|
|
|
|
'!@#$Qwer1234',
|
|
|
|
[
|
|
|
|
Validators.required,
|
|
|
|
Validators.pattern('^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{6,}$'),
|
|
|
|
Validators.minLength(6),
|
|
|
|
Validators.maxLength(25),
|
|
|
|
]
|
2018-04-06 06:59:49 +00:00
|
|
|
],
|
2018-04-12 08:06:15 +00:00
|
|
|
'pwConfirm': [
|
|
|
|
'!@#$Qwer1234',
|
|
|
|
[
|
|
|
|
Validators.compose([
|
2018-04-10 10:19:41 +00:00
|
|
|
Validators.required, this.pwMatchValidator
|
|
|
|
])
|
2018-04-12 08:06:15 +00:00
|
|
|
]
|
2018-04-06 06:59:49 +00:00
|
|
|
],
|
2018-04-12 08:06:15 +00:00
|
|
|
'name': [
|
|
|
|
'Park',
|
|
|
|
[
|
|
|
|
Validators.required
|
|
|
|
]
|
2018-04-06 06:59:49 +00:00
|
|
|
],
|
2018-04-12 08:06:15 +00:00
|
|
|
'phone': [
|
|
|
|
'010-3040-0303',
|
|
|
|
[
|
|
|
|
Validators.required
|
|
|
|
]
|
2018-04-06 06:59:49 +00:00
|
|
|
],
|
2018-04-12 08:06:15 +00:00
|
|
|
'company': [
|
|
|
|
'atgame',
|
|
|
|
[
|
|
|
|
Validators.required
|
|
|
|
]
|
2018-04-06 06:59:49 +00:00
|
|
|
],
|
2018-04-10 10:19:41 +00:00
|
|
|
});
|
|
|
|
this.email = this.signupForm.controls['email'];
|
|
|
|
this.password = this.signupForm.controls['password'];
|
|
|
|
this.pwConfirm = this.signupForm.controls['pwConfirm'];
|
|
|
|
this.name = this.signupForm.controls['name'];
|
|
|
|
this.phone = this.signupForm.controls['phone'];
|
|
|
|
this.company = this.signupForm.controls['company'];
|
2018-04-10 07:30:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 10:19:41 +00:00
|
|
|
pwMatchValidator(control: FormControl): { [s: string]: boolean } {
|
|
|
|
let pw;
|
|
|
|
if (control.parent) {
|
|
|
|
pw = control.parent.controls['password'].value;
|
|
|
|
}
|
|
|
|
if (control.value !== pw) {
|
|
|
|
return { notMatched: true };
|
|
|
|
}
|
|
|
|
}
|
2018-04-06 06:59:49 +00:00
|
|
|
|
2018-04-10 07:30:05 +00:00
|
|
|
signup() {
|
2018-05-16 06:13:07 +00:00
|
|
|
if (!this.myRecaptcha.valid) {
|
|
|
|
console.log('dddddddd');
|
|
|
|
return;
|
|
|
|
}
|
2018-04-12 08:06:15 +00:00
|
|
|
const signupValue = Object.assign({}, this.signupForm.value);
|
|
|
|
const password = signupValue.password;
|
2018-04-10 10:19:41 +00:00
|
|
|
const member: Member = {
|
2018-04-12 08:06:15 +00:00
|
|
|
email: signupValue.email,
|
|
|
|
name: signupValue.name,
|
|
|
|
phone: signupValue.phone,
|
|
|
|
companyName: signupValue.company,
|
2018-04-10 10:19:41 +00:00
|
|
|
};
|
2018-04-12 08:06:15 +00:00
|
|
|
this.store.dispatch(new AuthStore.Signup({member, password}));
|
2018-04-10 10:19:41 +00:00
|
|
|
console.log(member);
|
2018-04-06 06:59:49 +00:00
|
|
|
}
|
|
|
|
|
2018-05-03 07:19:10 +00:00
|
|
|
termsDisplayOpen() {
|
|
|
|
this.termsDisplay = true;
|
|
|
|
}
|
|
|
|
onTermsDisplayClose() {
|
|
|
|
this.termsDisplay = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
policyDisplayOpen() {
|
|
|
|
this.policyDisplay = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
onPolicyDisplayClose() {
|
|
|
|
this.policyDisplay = false;
|
|
|
|
}
|
2018-05-14 08:10:55 +00:00
|
|
|
|
|
|
|
onScriptLoad() {
|
|
|
|
console.log('Google reCAPTCHA loaded and is ready for use!');
|
|
|
|
}
|
|
|
|
|
|
|
|
onScriptError() {
|
|
|
|
console.log('Something went long when loading the Google reCAPTCHA');
|
|
|
|
}
|
2018-04-06 06:59:49 +00:00
|
|
|
}
|