added login form

This commit is contained in:
2025-11-12 16:35:20 +01:00
parent 07729fd236
commit 4bdae0252b
7 changed files with 69 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

View File

View File

@@ -0,0 +1,23 @@
<form nz-form nzLayout="horizontal" [formGroup]="loginForm" (ngSubmit)="submitForm()">
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Identifiant
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input placeholder="Saisir votre identifiant" formControlName="name">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="8" nzRequired>
Mot de passe
</nz-form-label>
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
<input nz-input type="password" placeholder="Mot de passe" formControlName="password">
</nz-form-control>
</nz-form-item>
<button class="ml-26 mt-4" nz-button [nzType]="'primary'" (click)="submitForm()">Connexion</button>
</form>

View File

@@ -0,0 +1,39 @@
import { Component } from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzButtonComponent} from "ng-zorro-antd/button";
@Component({
selector: 'app-login',
imports: [
NzColDirective,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzInputDirective,
NzRowDirective,
ReactiveFormsModule,
NzButtonComponent
],
templateUrl: './login.html',
styleUrl: './login.css',
})
export class Login {
loginForm = new FormGroup({
name: new FormControl<string>(null, [Validators.required]),
password: new FormControl<string>(null, [Validators.required]),
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.loginForm.invalid) return;
// Pour obtenir la valeur du formulaire
console.log(this.loginForm.getRawValue())
// Pour vider le formulaire
this.loginForm.reset()
}}

View File

@@ -4,9 +4,7 @@ import {Modal} from "../modal/modal";
import {DatePipe} from "@angular/common";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {UserInfo} from "../../interfaces/user.interfaces";
import {LoanTable} from "../loan-table/loan-table";
import {UpdateUser} from "../update-user/update-user";
import {UpdateLoan} from "../update-loan/update-loan";
@Component({
selector: 'app-user-table',
@@ -15,9 +13,7 @@ import {UpdateLoan} from "../update-loan/update-loan";
Modal,
NzButtonComponent,
NzTableComponent,
LoanTable,
UpdateUser,
UpdateLoan
],
templateUrl: './user-table.html',
styleUrl: './user-table.css',

View File

@@ -1,5 +1,3 @@
<p>welcome works!</p>
<h1 class="text-3xl font-bold underline">
Hello world!
</h1>
<div class="w-90 p-5 rounded-2xl shadow-lg shadow-gray-400 m-auto">
<app-login></app-login>
</div>

View File

@@ -1,9 +1,12 @@
import { Component } from '@angular/core';
import {CreateBook} from "../../components/create-book/create-book";
import {Login} from "../../components/login/login";
@Component({
selector: 'app-welcome',
imports: [],
imports: [
Login
],
templateUrl: './welcome.html',
styleUrl: './welcome.css'
})