2018-05-14 08:10:55 +00:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnDestroy,
|
|
|
|
OnInit,
|
2018-05-28 05:41:56 +00:00
|
|
|
Output,
|
2018-05-29 09:32:22 +00:00
|
|
|
EventEmitter, Input,
|
2018-05-14 08:10:55 +00:00
|
|
|
} from '@angular/core';
|
2018-05-29 05:24:36 +00:00
|
|
|
import { FormGroup, FormBuilder, Validators, AbstractControl, FormControl, ValidationErrors } from '@angular/forms';
|
2018-05-02 08:09:39 +00:00
|
|
|
import { Member } from '@overflow/commons-typescript/model/member';
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-member-signup',
|
2018-05-28 05:41:56 +00:00
|
|
|
templateUrl: './member-signup.component.html',
|
2018-04-06 06:59:49 +00:00
|
|
|
})
|
2018-05-28 05:41:56 +00:00
|
|
|
export class MemberSignupComponent implements OnInit, OnDestroy {
|
|
|
|
@Output() signup = new EventEmitter<{member: Member, password: string}>();
|
|
|
|
|
2018-05-29 11:42:39 +00:00
|
|
|
@Input() member;
|
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-29 09:32:22 +00:00
|
|
|
selectPolicy: AbstractControl;
|
|
|
|
captcha: AbstractControl;
|
2018-05-03 07:19:10 +00:00
|
|
|
termsDisplay = false;
|
|
|
|
policyDisplay = false;
|
2018-04-06 06:59:49 +00:00
|
|
|
|
|
|
|
constructor(
|
2018-04-12 08:06:15 +00:00
|
|
|
private formBuilder: FormBuilder,
|
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-05-29 09:32:22 +00:00
|
|
|
'selectPolicy': [
|
|
|
|
false, [ Validators.requiredTrue ],
|
|
|
|
],
|
|
|
|
'captcha': [
|
|
|
|
false, [ Validators.requiredTrue ],
|
|
|
|
]
|
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-05-29 09:32:22 +00:00
|
|
|
this.selectPolicy = this.signupForm.controls['selectPolicy'];
|
|
|
|
this.captcha = this.signupForm.controls['captcha'];
|
2018-04-10 07:30:05 +00:00
|
|
|
}
|
|
|
|
|
2018-05-29 05:24:36 +00:00
|
|
|
pwMatchValidator(control: FormControl): ValidationErrors {
|
2018-04-10 10:19:41 +00:00
|
|
|
let pw;
|
|
|
|
if (control.parent) {
|
|
|
|
pw = control.parent.controls['password'].value;
|
|
|
|
}
|
|
|
|
if (control.value !== pw) {
|
|
|
|
return { notMatched: true };
|
|
|
|
}
|
2018-05-29 05:24:36 +00:00
|
|
|
return null;
|
2018-04-10 10:19:41 +00:00
|
|
|
}
|
2018-04-06 06:59:49 +00:00
|
|
|
|
2018-05-28 05:41:56 +00:00
|
|
|
signupFormSubmit() {
|
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-05-28 05:41:56 +00:00
|
|
|
this.signup.emit({member: member, password: password});
|
2018-04-06 06:59:49 +00:00
|
|
|
}
|
|
|
|
|
2018-05-03 07:19:10 +00:00
|
|
|
termsDisplayOpen() {
|
|
|
|
this.termsDisplay = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
policyDisplayOpen() {
|
|
|
|
this.policyDisplay = true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|