added edit function for author and book pages

This commit is contained in:
2025-11-22 12:21:24 +01:00
parent ebea9f1a6b
commit 448f43e3eb
12 changed files with 192 additions and 79 deletions

View File

@@ -1,8 +1,9 @@
import { Component } from '@angular/core';
import {Component, input} from '@angular/core';
import {FormControl, FormGroup, FormsModule, 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 {GetBookDto, GetLoanDto} from "../../services/api";
@Component({
selector: 'app-update-loan',
@@ -28,14 +29,15 @@ export class UpdateLoan {
effectiveDate: new FormControl(null, [Validators.required]),
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.updateLoanForm.invalid) return;
// Pour obtenir la valeur du formulaire
console.log(this.updateLoanForm.getRawValue())
// Pour vider le formulaire
this.updateLoanForm.reset()
loan = input.required<GetLoanDto>()
ngOnChanges() {
if (this.loan) {
this.updateLoanForm.patchValue({
name: this.loan().userName,
book: this.loan().bookTitle,
plannedDate: new Date(this.loan().plannedReturningDate),
effectiveDate: new Date(this.loan().effectiveReturningDate)
});
}
}
}