forked from GonzalesRav/DEV003-burger-queen-api-client
-
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.
- api service conected - method post in login component - login and response interfaces
- Loading branch information
1 parent
ff7eb4b
commit c49acfc
Showing
7 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
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
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,4 @@ | ||
export interface LoginI { | ||
email: string; | ||
password: string; | ||
} |
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,4 @@ | ||
export interface ResponseI { | ||
status: string; | ||
response: string; | ||
} |
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 |
---|---|---|
|
@@ -5,12 +5,13 @@ | |
</div> | ||
|
||
<div class="col-md-6 col-lg-6" style="margin-top: 80px;"> | ||
<form [formGroup]="formLogin" | ||
<!-- Cómo colocarlo sin necesidad de definir parámetro --> | ||
<form [formGroup]="formLogin" (ngSubmit)="onClickLogin(formLogin.value)" | ||
style="background-color: #EA8D6F; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0,0,0,0.3);" class="p-3"> | ||
<img src="../assets/images/bienvenido.png" alt="Welcome Image" class="img-fluid mx-auto d-block"> | ||
<div class="form-group mt-3"> | ||
<label for="exampleInputEmail1">Email</label> | ||
<input type="email" class="form-control" formControlName="email" id="exampleInputEmail1" | ||
<input type="email" class="form-control" formControlName="email" id="email" name="email" | ||
aria-describedby="emailHelp" placeholder="[email protected]" style="width: 100%; margin-left: 5px;"> | ||
|
||
<div class="alert alert-danger mt-3 p-1" [hidden]="email.valid"> | ||
|
@@ -19,14 +20,14 @@ | |
</div> | ||
<div class="form-group mt-3"> | ||
<label for="exampleInputPassword1">Contraseña</label> | ||
<input type="password" class="form-control" formControlName="password" id="exampleInputPassword1" | ||
<input type="password" class="form-control" formControlName="password" id="password" name="password" | ||
placeholder="********" style="width: 100%; margin-left: 5px;"> | ||
|
||
<div class="alert alert-danger mt-3 p-1" | ||
[hidden]="password.valid || password.pristine"> El campo debe estar | ||
lleno. </div> | ||
</div> | ||
<button type="submit" class="btn btn-warning mx-auto d-block mt-3" [disabled]="formLogin.invalid" style="background-color: #FDE293;" (click)="onClickLogin()">INICIAR | ||
<button type="submit" class="btn btn-warning mx-auto d-block mt-3" [disabled]="formLogin.invalid" style="background-color: #FDE293;">INICIAR | ||
SESIÓN</button> | ||
</form> | ||
</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
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,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { ApiBQService } from '../services/api-bq.service'; | ||
|
||
describe('ApiBQService', () => { | ||
let service: ApiBQService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(ApiBQService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
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,20 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { LoginI } from '../interfaces/login.interface'; | ||
import { ResponseI } from '../interfaces/response.interface'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http' | ||
import { Observable } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ApiBQService { | ||
|
||
url:string = "http://localhost:8080/"; | ||
|
||
constructor(private http:HttpClient) { } | ||
|
||
loginByEmail(form: LoginI):Observable<ResponseI>{ | ||
let authUrl = this.url + 'login' | ||
return this.http.post<ResponseI>(authUrl, form) | ||
} | ||
} |