-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(auth-form): integrates email and password
- Loading branch information
Felipe Luna
committed
Feb 18, 2024
1 parent
71f0427
commit 025fdba
Showing
10 changed files
with
137 additions
and
9 deletions.
There are no files selected for viewing
30 changes: 29 additions & 1 deletion
30
modules/feature/auth/form/src/lib/auth-form/auth-form-email/auth-form-email.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
<p>auth-form-email works!</p> | ||
<mat-form-field appearance="outline" class="form-field"> | ||
<mat-label>Informe seu email</mat-label> | ||
<input | ||
[formControl]="control" | ||
matInput | ||
placeholder="Ex: user@gmail.com" | ||
type="email" | ||
/> | ||
@if (control.hasError('email') && !control.hasError('required')) { | ||
<mat-error data-testid="error-email" | ||
>Por favor, insira um email válido</mat-error | ||
> | ||
} @if (control.hasError('required')) { | ||
<mat-error data-testid="error-required" | ||
>O email é <strong>obrigatório</strong></mat-error | ||
> | ||
} | ||
</mat-form-field> | ||
|
||
<div class="container"> | ||
<button | ||
[disabled]="control.invalid" | ||
[routerLink]="['../', 'password']" | ||
mat-button | ||
color="primary" | ||
> | ||
Próximo | ||
</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.form-field { | ||
width: 100%; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
justify-content: end; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 15 additions & 1 deletion
16
modules/feature/auth/form/src/lib/auth-form/auth-form-email/auth-form-email.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
import { AuthFormComponent } from './../auth-form.component'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
import { FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'lib-auth-form-email', | ||
standalone: true, | ||
imports: [CommonModule], | ||
imports: [ | ||
CommonModule, | ||
MatButtonModule, | ||
MatInputModule, | ||
ReactiveFormsModule, | ||
RouterModule, | ||
], | ||
templateUrl: './auth-form-email.component.html', | ||
styleUrl: './auth-form-email.component.scss', | ||
}) | ||
export class AuthFormEmailComponent implements OnInit { | ||
control!: FormControl<string>; | ||
|
||
constructor(private authformComponent: AuthFormComponent) {} | ||
|
||
ngOnInit(): void { | ||
// eslint-disable-next-line no-console | ||
console.log(this.authformComponent.form.value); | ||
|
||
this.control = this.authformComponent.form.controls.email; | ||
} | ||
} |
14 changes: 13 additions & 1 deletion
14
.../feature/auth/form/src/lib/auth-form/auth-form-password/auth-form-password.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
<p>auth-form-password works!</p> | ||
<mat-form-field appearance="outline" class="form-field"> | ||
<mat-label>Informe sua senha</mat-label> | ||
<input | ||
[formControl]="this.control" | ||
matInput | ||
placeholder="Mínimo de 6 caracteres" | ||
type="password" | ||
/> | ||
</mat-form-field> | ||
|
||
<div class="container"> | ||
<button mat-button color="primary">Entrar</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.form-field { | ||
width: 100%; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
justify-content: end; | ||
} |
10 changes: 9 additions & 1 deletion
10
...ature/auth/form/src/lib/auth-form/auth-form-password/auth-form-password.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
...es/feature/auth/form/src/lib/auth-form/auth-form-password/auth-form-password.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, inject } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
import { AuthFormComponent } from '../auth-form.component'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'lib-auth-form-password', | ||
standalone: true, | ||
imports: [CommonModule], | ||
imports: [CommonModule, MatButtonModule, MatInputModule, ReactiveFormsModule], | ||
templateUrl: './auth-form-password.component.html', | ||
styleUrl: './auth-form-password.component.scss', | ||
}) | ||
export class AuthFormPasswordComponent {} | ||
export class AuthFormPasswordComponent { | ||
control = inject(AuthFormComponent).form.controls.password; | ||
} |
1 change: 1 addition & 0 deletions
1
modules/feature/auth/form/src/lib/auth-form/auth-form.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<form class="form" [formGroup]="form"> | ||
<mat-card class="form__card"> | ||
<h1>Login</h1> | ||
<router-outlet></router-outlet> | ||
</mat-card> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters