changed
This commit is contained in:
@@ -54,7 +54,7 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedAuthor.id, updateAuthor, modalIcon)" (cancel)="onModalCancel(modalIcon)">
|
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedAuthor.id)">
|
||||||
<app-update-author #updateAuthor [author]="selectedAuthor"></app-update-author>
|
<app-update-author #updateAuthor [author]="selectedAuthor"></app-update-author>
|
||||||
</app-modal-icon>
|
</app-modal-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
|
|||||||
export class AuthorTable implements OnInit {
|
export class AuthorTable implements OnInit {
|
||||||
private authorsService = inject(AuthorsService);
|
private authorsService = inject(AuthorsService);
|
||||||
private notificationService = inject(NzNotificationService)
|
private notificationService = inject(NzNotificationService)
|
||||||
|
|
||||||
authors = signal<GetAuthorDto[]>([]);
|
authors = signal<GetAuthorDto[]>([]);
|
||||||
authorsLoading = signal<boolean>(false);
|
authorsLoading = signal<boolean>(false);
|
||||||
updateAuthor = viewChild.required<UpdateAuthor>('updateAuthor');
|
updateAuthor = viewChild.required<UpdateAuthor>('updateAuthor');
|
||||||
@@ -51,9 +52,9 @@ export class AuthorTable implements OnInit {
|
|||||||
this.authorsLoading.set(false)
|
this.authorsLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(author:number) {
|
async delete(id) {
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.authorsService.deleteAuthorEndpoint(author))
|
await firstValueFrom(this.authorsService.deleteAuthorEndpoint(id))
|
||||||
this.notificationService.success(
|
this.notificationService.success(
|
||||||
'Success',
|
'Success',
|
||||||
'Suppression effectuée'
|
'Suppression effectuée'
|
||||||
@@ -67,8 +68,8 @@ export class AuthorTable implements OnInit {
|
|||||||
await this.fetchAuthors();
|
await this.fetchAuthors();
|
||||||
}
|
}
|
||||||
|
|
||||||
async edit(id: number, updateAuthorComponent: UpdateAuthor) {
|
async edit(id) {
|
||||||
if (updateAuthorComponent.updateAuthorForm.invalid) {
|
if (this.updateAuthor().updateAuthorForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error(
|
||||||
'Erreur',
|
'Erreur',
|
||||||
'Erreur d\'écriture dans le formulaire'
|
'Erreur d\'écriture dans le formulaire'
|
||||||
@@ -77,7 +78,7 @@ export class AuthorTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const authors = updateAuthorComponent.updateAuthorForm.getRawValue();
|
const authors = this.updateAuthor().updateAuthorForm.getRawValue();
|
||||||
|
|
||||||
await firstValueFrom(this.authorsService.updateAuthorEndpoint(id, authors))
|
await firstValueFrom(this.authorsService.updateAuthorEndpoint(id, authors))
|
||||||
|
|
||||||
@@ -99,14 +100,9 @@ export class AuthorTable implements OnInit {
|
|||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModalOk(authorId: number, updateAuthorComponent: UpdateAuthor, modal: ModalIcon) {
|
async onModalOk(authorId) {
|
||||||
await this.edit(authorId, updateAuthorComponent);
|
await this.edit(authorId);
|
||||||
updateAuthorComponent.updateAuthorForm.reset();
|
this.updateAuthor().updateAuthorForm.reset();
|
||||||
modal.isVisible = false;
|
|
||||||
await this.fetchAuthors();
|
await this.fetchAuthors();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalCancel(modal: ModalIcon) {
|
|
||||||
modal.isVisible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedBook.id, updateBook, modalIcon)" (cancel)="onModalCancel(modalIcon)">
|
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedBook.id)">
|
||||||
<app-update-book #updateBook [book]="selectedBook"></app-update-book>
|
<app-update-book #updateBook [book]="selectedBook"></app-update-book>
|
||||||
</app-modal-icon>
|
</app-modal-icon>
|
||||||
</div>
|
</div>
|
||||||
@@ -24,6 +24,7 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
|
|||||||
export class BookTable implements OnInit {
|
export class BookTable implements OnInit {
|
||||||
private booksService = inject(BooksService);
|
private booksService = inject(BooksService);
|
||||||
private notificationService = inject(NzNotificationService)
|
private notificationService = inject(NzNotificationService)
|
||||||
|
|
||||||
books = signal<GetBookDto[]>([]);
|
books = signal<GetBookDto[]>([]);
|
||||||
booksLoading = signal<boolean>(false);
|
booksLoading = signal<boolean>(false);
|
||||||
updateBook = viewChild.required<UpdateBook>('updateBook');
|
updateBook = viewChild.required<UpdateBook>('updateBook');
|
||||||
@@ -51,9 +52,9 @@ export class BookTable implements OnInit {
|
|||||||
this.booksLoading.set(false)
|
this.booksLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(book:number) {
|
async delete(bookId) {
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.booksService.deleteBookEndpoint(book))
|
await firstValueFrom(this.booksService.deleteBookEndpoint(bookId))
|
||||||
this.notificationService.success(
|
this.notificationService.success(
|
||||||
'Success',
|
'Success',
|
||||||
'Suppression effectuée'
|
'Suppression effectuée'
|
||||||
@@ -67,8 +68,8 @@ export class BookTable implements OnInit {
|
|||||||
await this.fetchBooks();
|
await this.fetchBooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
async edit(id: number, updateBookComponent: UpdateBook) {
|
async edit(id) {
|
||||||
if (updateBookComponent.updateBookForm.invalid) {
|
if (this.updateBook().updateBookForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error(
|
||||||
'Erreur',
|
'Erreur',
|
||||||
'Erreur d\'écriture dans le formulaire'
|
'Erreur d\'écriture dans le formulaire'
|
||||||
@@ -77,7 +78,7 @@ export class BookTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const books = updateBookComponent.updateBookForm.getRawValue();
|
const books = this.updateBook().updateBookForm.getRawValue();
|
||||||
|
|
||||||
await firstValueFrom(this.booksService.updateBookEndpoint(id, books))
|
await firstValueFrom(this.booksService.updateBookEndpoint(id, books))
|
||||||
console.log("Payload envoyé :", books);
|
console.log("Payload envoyé :", books);
|
||||||
@@ -95,20 +96,16 @@ export class BookTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedBook: GetBookDto | null = null;
|
selectedBook: GetBookDto | null = null;
|
||||||
openEditModal(book: GetBookDto) {
|
openEditModal(book) {
|
||||||
this.selectedBook = { ...book };
|
this.selectedBook = { ...book };
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModalOk(bookId: number, updateBookComponent: UpdateBook, modal: ModalIcon) {
|
async onModalOk(bookId) {
|
||||||
await this.edit(bookId, updateBookComponent);
|
await this.edit(bookId);
|
||||||
updateBookComponent.updateBookForm.reset();
|
this.updateBook().updateBookForm.reset();
|
||||||
modal.isVisible = false;
|
|
||||||
await this.fetchBooks();
|
await this.fetchBooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalCancel(modal: ModalIcon) {
|
|
||||||
modal.isVisible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</nz-form-label>
|
</nz-form-label>
|
||||||
|
|
||||||
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
|
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
|
||||||
<nz-select formControlName="authorId" [nzPlaceHolder]="'Choisir un auteur'" nzShowSearch [nzFilterOption]="filterAuthor">
|
<nz-select formControlName="authorId" [nzPlaceHolder]="'Choisir un auteur'">
|
||||||
@for (author of authors(); track author.id) {
|
@for (author of authors(); track author.id) {
|
||||||
<nz-option [nzValue]="author.id" [nzLabel]="author.firstName + ' ' + author.name"></nz-option>
|
<nz-option [nzValue]="author.id" [nzLabel]="author.firstName + ' ' + author.name"></nz-option>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,4 @@ export class CreateBook implements OnInit {
|
|||||||
await this.fetchAuthors();
|
await this.fetchAuthors();
|
||||||
}
|
}
|
||||||
|
|
||||||
filterAuthor(input: string, option: any) {
|
|
||||||
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
</nz-form-label>
|
</nz-form-label>
|
||||||
|
|
||||||
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
|
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
|
||||||
<nz-select formControlName="userId" [nzPlaceHolder]="'Choisir un utilisateur'" nzShowSearch [nzFilterOption]="filter">
|
<nz-select formControlName="userId" [nzPlaceHolder]="'Choisir un utilisateur'">
|
||||||
@for (user of users(); track user.id) {
|
@for (user of users(); track user.id) {
|
||||||
<nz-option [nzValue]="user.id" [nzLabel]="user.firstName + ' ' + user.name"></nz-option>
|
<nz-option [nzValue]="user.id" [nzLabel]="user.firstName + ' ' + user.name"></nz-option>
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
</nz-form-label>
|
</nz-form-label>
|
||||||
|
|
||||||
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
|
<nz-form-control nzSpan="40" nzErrorTip="Ce champ est requis">
|
||||||
<nz-select formControlName="bookId" [nzPlaceHolder]="'Choisir un livre'" nzShowSearch [nzFilterOption]="filter">
|
<nz-select formControlName="bookId" [nzPlaceHolder]="'Choisir un livre'">
|
||||||
@for (book of books(); track book.id) {
|
@for (book of books(); track book.id) {
|
||||||
<nz-option [nzValue]="book.id" [nzLabel]="book.title"></nz-option>
|
<nz-option [nzValue]="book.id" [nzLabel]="book.title"></nz-option>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,4 @@ export class CreateLoan implements OnInit {
|
|||||||
await this.fetchBooks();
|
await this.fetchBooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
filter(input: string, option: any) {
|
|
||||||
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedLoan.id, updateLoan, modalIcon)" (cancel)="onModalCancel(modalIcon)">
|
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedLoan.id)">
|
||||||
<app-update-loan #updateLoan [loan]="selectedLoan"></app-update-loan>
|
<app-update-loan #updateLoan [loan]="selectedLoan"></app-update-loan>
|
||||||
</app-modal-icon>
|
</app-modal-icon>
|
||||||
</div>
|
</div>
|
||||||
@@ -11,7 +11,7 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
|
|||||||
import {format} from "date-fns";
|
import {format} from "date-fns";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-loan-table',
|
selector: 'app-loan-table',
|
||||||
imports: [
|
imports: [
|
||||||
DatePipe,
|
DatePipe,
|
||||||
NzTableComponent,
|
NzTableComponent,
|
||||||
@@ -20,14 +20,15 @@ import {format} from "date-fns";
|
|||||||
ModalIcon,
|
ModalIcon,
|
||||||
NzIconDirective,
|
NzIconDirective,
|
||||||
],
|
],
|
||||||
templateUrl: './loan-table.html',
|
templateUrl: './loan-table.html',
|
||||||
styleUrl: './loan-table.css',
|
styleUrl: './loan-table.css',
|
||||||
})
|
})
|
||||||
export class LoanTable implements OnInit {
|
export class LoanTable implements OnInit {
|
||||||
private loansService = inject(LoansService);
|
private loansService = inject(LoansService);
|
||||||
private notificationService = inject(NzNotificationService)
|
private notificationService = inject(NzNotificationService)
|
||||||
loans = signal<GetLoanDto[]>([]);
|
loans = signal<GetLoanDto[]>([]);
|
||||||
loansLoading = signal<boolean>(false);
|
loansLoading = signal<boolean>(false);
|
||||||
|
|
||||||
updateLoan = viewChild.required<UpdateLoan>('updateLoan');
|
updateLoan = viewChild.required<UpdateLoan>('updateLoan');
|
||||||
modal = viewChild.required<ModalIcon>('modalIcon');
|
modal = viewChild.required<ModalIcon>('modalIcon');
|
||||||
|
|
||||||
@@ -68,8 +69,8 @@ export class LoanTable implements OnInit {
|
|||||||
await this.fetchLoans();
|
await this.fetchLoans();
|
||||||
}
|
}
|
||||||
|
|
||||||
async edit(id: number, updateLoanComponent: UpdateLoan) {
|
async edit(id) {
|
||||||
if (updateLoanComponent.updateLoanForm.invalid) {
|
if (this.updateLoan().updateLoanForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error(
|
||||||
'Erreur',
|
'Erreur',
|
||||||
'Erreur d\'écriture dans le formulaire'
|
'Erreur d\'écriture dans le formulaire'
|
||||||
@@ -78,20 +79,20 @@ export class LoanTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const plannedDate = updateLoanComponent.updateLoanForm.get('plannedReturningDate').value;
|
const plannedDate = this.updateLoan().updateLoanForm.get('plannedReturningDate').value;
|
||||||
const plannedDateResult = format(plannedDate, 'yyyy-MM-dd');
|
const plannedDateResult = format(plannedDate, 'yyyy-MM-dd');
|
||||||
|
|
||||||
const effectiveDate = updateLoanComponent.updateLoanForm.get('effectiveReturningDate').value;
|
const effectiveDate = this.updateLoan().updateLoanForm.get('effectiveReturningDate').value;
|
||||||
const effectiveDateResult = format(effectiveDate, 'yyyy-MM-dd');
|
const effectiveDateResult = format(effectiveDate, 'yyyy-MM-dd');
|
||||||
|
|
||||||
const loans = updateLoanComponent.updateLoanForm.getRawValue();
|
const loans = this.updateLoan().updateLoanForm.getRawValue();
|
||||||
loans.plannedReturningDate = plannedDateResult;
|
loans.plannedReturningDate = plannedDateResult;
|
||||||
loans.effectiveReturningDate = effectiveDateResult;
|
loans.effectiveReturningDate = effectiveDateResult;
|
||||||
|
|
||||||
const updatedLoanDto = {
|
const updatedLoanDto = {
|
||||||
id: this.selectedLoan.id,
|
id: this.selectedLoan.id,
|
||||||
bookId: updateLoanComponent.updateLoanForm.get('bookId').value,
|
bookId: this.updateLoan().updateLoanForm.get('bookId').value,
|
||||||
userId: updateLoanComponent.updateLoanForm.get('userId').value,
|
userId: this.updateLoan().updateLoanForm.get('userId').value,
|
||||||
date: this.selectedLoan.date,
|
date: this.selectedLoan.date,
|
||||||
plannedReturningDate: loans.plannedReturningDate,
|
plannedReturningDate: loans.plannedReturningDate,
|
||||||
effectiveReturningDate: loans.effectiveReturningDate
|
effectiveReturningDate: loans.effectiveReturningDate
|
||||||
@@ -111,7 +112,7 @@ export class LoanTable implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async validationDate(loanId: number) {
|
async validationDate(loanId ) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const PatchLoanValue = {
|
const PatchLoanValue = {
|
||||||
@@ -142,19 +143,17 @@ export class LoanTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedLoan: GetLoanDto | null = null;
|
selectedLoan: GetLoanDto | null = null;
|
||||||
openEditModal(loan: GetLoanDto) {
|
|
||||||
|
openEditModal(loan) {
|
||||||
this.selectedLoan = { ...loan };
|
this.selectedLoan = { ...loan };
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModalOk(loanId: number, updateLoanComponent: UpdateLoan, modal: ModalIcon) {
|
async onModalOk(loanId) {
|
||||||
await this.edit(loanId, updateLoanComponent);
|
await this.edit(loanId);
|
||||||
updateLoanComponent.updateLoanForm.reset();
|
this.updateLoan().updateLoanForm.reset();
|
||||||
modal.isVisible = false;
|
|
||||||
await this.fetchLoans();
|
await this.fetchLoans();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalCancel(modal: ModalIcon) {
|
|
||||||
modal.isVisible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Component, input} from '@angular/core';
|
import {Component, input, OnChanges, OnInit} from '@angular/core';
|
||||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
|
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
|
||||||
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
||||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||||
@@ -21,13 +21,14 @@ import {NzInputDirective} from "ng-zorro-antd/input";
|
|||||||
templateUrl: './update-author.html',
|
templateUrl: './update-author.html',
|
||||||
styleUrl: './update-author.css',
|
styleUrl: './update-author.css',
|
||||||
})
|
})
|
||||||
export class UpdateAuthor {
|
export class UpdateAuthor implements OnChanges {
|
||||||
updateAuthorForm = new FormGroup({
|
updateAuthorForm = new FormGroup({
|
||||||
name: new FormControl<string>(null, [Validators.required]),
|
name: new FormControl<string>(null, [Validators.required]),
|
||||||
firstName: new FormControl<string>(null, [Validators.required])
|
firstName: new FormControl<string>(null, [Validators.required])
|
||||||
})
|
})
|
||||||
|
|
||||||
author = input.required<GetAuthorDto>()
|
author = input.required<GetAuthorDto>()
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
if (this.author) {
|
if (this.author) {
|
||||||
this.updateAuthorForm.patchValue({
|
this.updateAuthorForm.patchValue({
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedUser.id, updateUser, modalIcon)" (cancel)="onModalCancel(modalIcon)">
|
<app-modal-icon #modalIcon nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedUser.id)">
|
||||||
<app-update-user #updateUser [user]="selectedUser"></app-update-user>
|
<app-update-user #updateUser [user]="selectedUser"></app-update-user>
|
||||||
</app-modal-icon>
|
</app-modal-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Component, inject, input, OnInit, signal, viewChild} from '@angular/core';
|
import {Component, inject,OnInit, signal, viewChild} from '@angular/core';
|
||||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||||
import {Modal} from "../modal/modal";
|
import {Modal} from "../modal/modal";
|
||||||
import {DatePipe} from "@angular/common";
|
import {DatePipe} from "@angular/common";
|
||||||
@@ -28,6 +28,7 @@ import {format} from "date-fns";
|
|||||||
export class UserTable implements OnInit {
|
export class UserTable implements OnInit {
|
||||||
private usersService = inject(UsersService);
|
private usersService = inject(UsersService);
|
||||||
private notificationService = inject(NzNotificationService)
|
private notificationService = inject(NzNotificationService)
|
||||||
|
|
||||||
users = signal<GetUserDto[]>([]);
|
users = signal<GetUserDto[]>([]);
|
||||||
usersLoading = signal<boolean>(false);
|
usersLoading = signal<boolean>(false);
|
||||||
updateUser = viewChild.required<UpdateUser>('updateUser');
|
updateUser = viewChild.required<UpdateUser>('updateUser');
|
||||||
@@ -52,9 +53,9 @@ export class UserTable implements OnInit {
|
|||||||
this.usersLoading.set(false)
|
this.usersLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(user:number) {
|
async delete(userId) {
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.usersService.deleteUserEndpoint(user))
|
await firstValueFrom(this.usersService.deleteUserEndpoint(userId))
|
||||||
this.notificationService.success(
|
this.notificationService.success(
|
||||||
'Success',
|
'Success',
|
||||||
'Suppression effectuée'
|
'Suppression effectuée'
|
||||||
@@ -68,8 +69,8 @@ export class UserTable implements OnInit {
|
|||||||
await this.fetchUsers();
|
await this.fetchUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
async edit(id: number, updateUserComponent: UpdateUser) {
|
async edit(id) {
|
||||||
if (updateUserComponent.updateUserForm.invalid) {
|
if (this.updateUser().updateUserForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error(
|
||||||
'Erreur',
|
'Erreur',
|
||||||
'Erreur d\'écriture dans le formulaire'
|
'Erreur d\'écriture dans le formulaire'
|
||||||
@@ -78,10 +79,10 @@ export class UserTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const rawDate = updateUserComponent.updateUserForm.get('birthDate').value;
|
const rawDate = this.updateUser().updateUserForm.get('birthDate').value;
|
||||||
const birthDate = format(rawDate, 'yyyy-MM-dd');
|
const birthDate = format(rawDate, 'yyyy-MM-dd');
|
||||||
|
|
||||||
const users = updateUserComponent.updateUserForm.getRawValue();
|
const users = this.updateUser().updateUserForm.getRawValue();
|
||||||
users.birthDate = birthDate;
|
users.birthDate = birthDate;
|
||||||
|
|
||||||
await firstValueFrom(this.usersService.updateUserEndpoint(id, users))
|
await firstValueFrom(this.usersService.updateUserEndpoint(id, users))
|
||||||
@@ -104,14 +105,10 @@ export class UserTable implements OnInit {
|
|||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModalOk(userId: number, updateUserComponent: UpdateUser, modal: ModalIcon) {
|
async onModalOk(userId) {
|
||||||
await this.edit(userId, updateUserComponent);
|
await this.edit(userId);
|
||||||
updateUserComponent.updateUserForm.reset();
|
this.updateUser().updateUserForm.reset();
|
||||||
modal.isVisible = false;
|
|
||||||
await this.fetchUsers();
|
await this.fetchUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalCancel(modal: ModalIcon) {
|
|
||||||
modal.isVisible = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user