Skip to content

Commit

Permalink
Merge pull request #6 from agilesix/ui
Browse files Browse the repository at this point in the history
fix registration not displaying and switch error messages to uswds
  • Loading branch information
aurora-a-k-a-lightning committed Feb 23, 2018
2 parents cf41a82 + f8fc171 commit a496cd1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions frontend/src/app/auth/auth.component.ts
Expand Up @@ -8,7 +8,7 @@ import { Router } from '@angular/router';
})
export class AuthComponent implements OnInit {

@Input() authMode: 'Login' | 'Register' = 'Login';
@Input() authMode: 'login' | 'register' = 'login';

constructor( private router: Router ) { }

Expand All @@ -33,11 +33,11 @@ export class AuthComponent implements OnInit {
}

isLoginMode() {
return this.authMode === 'Login';
return this.authMode === 'login';
}

isRegisterMode() {
return this.authMode === 'Register';
return this.authMode === 'register';
}


Expand Down
28 changes: 17 additions & 11 deletions frontend/src/app/register-form/register-form.component.html
Expand Up @@ -6,26 +6,32 @@
name='email'
[(ngModel)]="signUpUser.email"
class="validate" />

<!-- Name field needs wired up (added to db?)-->
<label for="email">Name</label>
<input id="name"
type="text"
name='name' />

<label for="password_create">Password</label>
<input id="password_create"
type="password"
required
name='password'
[(ngModel)]="signUpUser.password"
class="validate" />
<label for="password_confirmation">Password confirmation</label>
<input id="password_confirmation"
type="password"
required
name='password_confirmation'
[(ngModel)]="signUpUser.passwordConfirmation"
class="validate" />

<div class="usa-alert usa-alert-error" *ngIf="signUpUser.password != signUpUser.passwordConfirmation">
<div class="usa-alert-body">
<p class="usa-alert-text">Passwords must match</p>
</div>
<div [ngClass]="{'usa-input-error' : signUpUser.password != signUpUser.passwordConfirmation}">
<label for="password_confirmation">Password confirmation</label>
<input id="password_confirmation"
type="password"
required
name='password_confirmation'
[(ngModel)]="signUpUser.passwordConfirmation"
class="validate" />
<span class="usa-input-error-message" *ngIf="signUpUser.password != signUpUser.passwordConfirmation" role="alert">Passwords must match</span>
</div>

<input type="submit"
[disabled]="!(f.valid) || !(signUpUser.password == signUpUser.passwordConfirmation)"
value="Sign up" />
Expand Down
17 changes: 6 additions & 11 deletions frontend/src/app/register-form/register-form.component.ts
@@ -1,5 +1,4 @@

import {Component, OnInit, EventEmitter, Output} from '@angular/core';
import {Component, OnInit, Output, EventEmitter} from '@angular/core';
import {AuthService} from '../services/auth.service';

@Component({
Expand All @@ -17,28 +16,24 @@ export class RegisterFormComponent implements OnInit {

@Output() onFormResult = new EventEmitter<any>();

constructor(public authService: AuthService) { }
constructor(public authService: AuthService) {}

ngOnInit() {}


onSignUpSubmit() {

this.authService.registerUser(this.signUpUser).subscribe(

(res) => {

res => {
if (res.status === 200) {
this.onFormResult.emit({signedUp: true, res});
}

},

(err) => {
console.log(err.json());
err => {
console.log('err:', err);
this.onFormResult.emit({signedUp: false, err});
}
);

}

}
2 changes: 1 addition & 1 deletion frontend/src/app/toolbar/toolbar.component.html
Expand Up @@ -27,7 +27,7 @@
</nav>

<div class="a2-profile center-align" *ngIf="(authService.userSignedIn$ | async)">
<img src="./../../../assets/images/avatar.png" class="circle img-50" alt="John Smith">
<img *ngIf="authTokenService.currentUserData" src="./../../../assets/images/avatar.png" class="circle img-50" alt="John Smith">
<p *ngIf="authTokenService.currentUserData">
<b>{{authTokenService.currentUserData.name}} Bob Smith</b>
<br/><small>{{authTokenService.currentUserData.email}}</small>
Expand Down

0 comments on commit a496cd1

Please sign in to comment.