Création de l'interface et user et début de la vue login

pull/1/head
Raphael LACOTE 8 months ago
parent e1c2433dcf
commit 76b02cf282

@ -3,9 +3,11 @@ import { BookListComponent } from './components/book-list/book-list.component';
import { BookFormComponent } from './components/book-form/book-form.component';
import { BookDetailComponent } from './components/book-detail/book-detail.component';
import { BookHomeComponent } from './components/book-home/book-home.component';
import { LoginComponent } from './components/login/login.component';
export const routes: Routes = [
{ path: '', component: BookHomeComponent },
{ path: '', component: LoginComponent },
{ path: 'books', component: BookListComponent },
{ path: 'book/add', component: BookFormComponent },
{ path: 'book/:id', component: BookDetailComponent },

@ -0,0 +1,25 @@
<section>
<h2>Identifiez vous !</h2>
<form [formGroup]="loginForm">
<div>
<mat-form-field class="full-width">
<mat-label>Login</mat-label>
<input matInput type="text" formControlName="login" />
</mat-form-field>
</div>
<div>
<mat-form-field class="full-width">
<mat-label>Password</mat-label>
<input matInput type="text" formControlName="password" />
</mat-form-field>
</div>
<div>
<button mat-flat-button color="primary" type="button" (click)="Connect()">Connexion</button>
</div>
</form>
</section>

@ -0,0 +1,50 @@
import { Component, EventEmitter, Output } from '@angular/core';
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatMenuModule } from '@angular/material/menu';
import { User } from '../../models/user.model';
@Component({
selector: 'app-login',
standalone: true,
imports: [
MatFormFieldModule,
MatInputModule,
MatButtonModule,
MatMenuModule,
MatDatepickerModule,
MatNativeDateModule,
FormsModule,
ReactiveFormsModule
],
templateUrl: './login.component.html',
styleUrl: './login.component.css'
})
export class LoginComponent {
user: User = { login: '', password: '' }
loginForm: FormGroup = new FormGroup({
login: new FormControl(this.user.login, Validators.required),
password: new FormControl(this.user.password, Validators.required),
});
Connect() {
// if (this.loginForm.invalid) {
// console.log("ERREUR");
// return;
// }
console.log(this.user.login)
console.log(this.user.password)
if(this.user.login != this.user.password){
console.log("ERREUR");
return;
}
}
}
Loading…
Cancel
Save