import { NotificationsService } from 'angular2-notifications';
import { UserService } from '../shared';
-import { FormReactive, USER_USERNAME, USER_PASSWORD } from '../../../shared';
+import {
+ FormReactive,
+ USER_USERNAME,
+ USER_EMAIL,
+ USER_PASSWORD
+} from '../../../shared';
@Component({
selector: 'my-user-add',
form: FormGroup;
formErrors = {
'username': '',
+ 'email': '',
'password': ''
};
validationMessages = {
'username': USER_USERNAME.MESSAGES,
+ 'email': USER_EMAIL.MESSAGES,
'password': USER_PASSWORD.MESSAGES,
};
buildForm() {
this.form = this.formBuilder.group({
username: [ '', USER_USERNAME.VALIDATORS ],
+ email: [ '', USER_EMAIL.VALIDATORS ],
password: [ '', USER_PASSWORD.VALIDATORS ],
});
addUser() {
this.error = null;
- const { username, password } = this.form.value;
+ const { username, password, email } = this.form.value;
- this.userService.addUser(username, password).subscribe(
+ this.userService.addUser(username, password, email).subscribe(
() => {
this.notificationsService.success('Success', `User ${username} created.`);
this.router.navigate([ '/admin/users/list' ]);