- | {{ data.user.name}} {{data.user.firstName }} |
- {{ data.book.title }} |
- {{ data.date | date: 'dd/MM/yyyy' }} |
- {{ data.plannedReturningDate | date: 'dd/MM/yyyy'}} |
- {{ data.effectiveReturningDate | date: 'dd/MM/yyyy'}} |
+ {{ loan.userName}} {{loan.userFirstName }} |
+ {{ loan.bookTitle }} |
+ {{ loan.date | date: 'dd/MM/yyyy' }} |
+ {{ loan.plannedReturningDate | date: 'dd/MM/yyyy'}} |
+ {{ loan.effectiveReturningDate | date: 'dd/MM/yyyy'}} |
diff --git a/src/app/components/loan-table/loan-table.ts b/src/app/components/loan-table/loan-table.ts
index f900874..8b564f2 100644
--- a/src/app/components/loan-table/loan-table.ts
+++ b/src/app/components/loan-table/loan-table.ts
@@ -1,10 +1,12 @@
-import { Component } from '@angular/core';
+import {Component, inject, OnInit, signal} from '@angular/core';
import {DatePipe} from "@angular/common";
import {Modal} from "../modal/modal";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {NzTableComponent} from "ng-zorro-antd/table";
import {UpdateLoan} from "../update-loan/update-loan";
-import {LoanInfo} from "../../interfaces/loan.interfaces";
+import {GetLoanDto, LoansService} from "../../services/api";
+import {NzNotificationService} from "ng-zorro-antd/notification";
+import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-loan-table',
@@ -18,189 +20,32 @@ import {LoanInfo} from "../../interfaces/loan.interfaces";
templateUrl: './loan-table.html',
styleUrl: './loan-table.css',
})
-export class LoanTable {
- listOfData: LoanInfo[] = [
- {
- book: {
- title: 'Dune',
- isbn: '9780441013593',
- author: 'Frank Herbert',
- releaseYear: 1965
- },
- user: {
- name: 'Dupont',
- firstName: 'Mathys',
- email: 'mathys@biblio.fr',
- birthDate: new Date('2004-05-21'),
- loan: []
- },
- date: new Date('2025-11-01'),
- plannedReturningDate: new Date('2025-12-01'),
- effectiveReturningDate: null
- },
- {
- book: {
- title: '1984',
- isbn: '9780451524935',
- author: 'George Orwell',
- releaseYear: 1949
- },
- user: {
- name: 'Durand',
- firstName: 'Lucie',
- email: 'lucie@biblio.fr',
- birthDate: new Date('1998-03-12'),
- loan: []
- },
- date: new Date('2025-10-20'),
- plannedReturningDate: new Date('2025-11-20'),
- effectiveReturningDate: new Date('2025-11-05')
- },
- {
- book: {
- title: 'Le Seigneur des Anneaux',
- isbn: '9780261102385',
- author: 'J.R.R. Tolkien',
- releaseYear: 1954
- },
- user: {
- name: 'Bernard',
- firstName: 'Thomas',
- email: 'thomas@biblio.fr',
- birthDate: new Date('1990-07-04'),
- loan: []
- },
- date: new Date('2025-09-10'),
- plannedReturningDate: new Date('2025-10-10'),
- effectiveReturningDate: new Date('2025-10-02')
- },
- {
- book: {
- title: 'Les Misérables',
- isbn: '9780140444308',
- author: 'Victor Hugo',
- releaseYear: 1862
- },
- user: {
- name: 'Moreau',
- firstName: 'Sophie',
- email: 'sophie@biblio.fr',
- birthDate: new Date('1987-02-25'),
- loan: []
- },
- date: new Date('2025-11-03'),
- plannedReturningDate: new Date('2025-12-03'),
- effectiveReturningDate: null
- },
- {
- book: {
- title: 'Fahrenheit 451',
- isbn: '9781451673319',
- author: 'Ray Bradbury',
- releaseYear: 1953
- },
- user: {
- name: 'Leroy',
- firstName: 'Julien',
- email: 'julien@biblio.fr',
- birthDate: new Date('2001-09-18'),
- loan: []
- },
- date: new Date('2025-10-15'),
- plannedReturningDate: new Date('2025-11-15'),
- effectiveReturningDate: new Date('2025-11-13')
- },
- {
- book: {
- title: 'Harry Potter à l’école des sorciers',
- isbn: '9780747532743',
- author: 'J.K. Rowling',
- releaseYear: 1997
- },
- user: {
- name: 'Petit',
- firstName: 'Emma',
- email: 'emma@biblio.fr',
- birthDate: new Date('2006-11-30'),
- loan: []
- },
- date: new Date('2025-11-08'),
- plannedReturningDate: new Date('2025-12-08'),
- effectiveReturningDate: null
- },
- {
- book: {
- title: 'Le Petit Prince',
- isbn: '9780156012195',
- author: 'Antoine de Saint-Exupéry',
- releaseYear: 1943
- },
- user: {
- name: 'Roux',
- firstName: 'Nicolas',
- email: 'nicolas@biblio.fr',
- birthDate: new Date('1995-08-14'),
- loan: []
- },
- date: new Date('2025-09-25'),
- plannedReturningDate: new Date('2025-10-25'),
- effectiveReturningDate: new Date('2025-10-20')
- },
- {
- book: {
- title: 'L’Étranger',
- isbn: '9782070360024',
- author: 'Albert Camus',
- releaseYear: 1942
- },
- user: {
- name: 'Fontaine',
- firstName: 'Claire',
- email: 'claire@biblio.fr',
- birthDate: new Date('1992-04-17'),
- loan: []
- },
- date: new Date('2025-10-05'),
- plannedReturningDate: new Date('2025-11-05'),
- effectiveReturningDate: new Date('2025-11-01')
- },
- {
- book: {
- title: 'Le Hobbit',
- isbn: '9780261102217',
- author: 'J.R.R. Tolkien',
- releaseYear: 1937
- },
- user: {
- name: 'Blanc',
- firstName: 'Hugo',
- email: 'hugo@biblio.fr',
- birthDate: new Date('2000-01-09'),
- loan: []
- },
- date: new Date('2025-11-02'),
- plannedReturningDate: new Date('2025-12-02'),
- effectiveReturningDate: null
- },
- {
- book: {
- title: 'La Peste',
- isbn: '9780141185064',
- author: 'Albert Camus',
- releaseYear: 1947
- },
- user: {
- name: 'Garnier',
- firstName: 'Léa',
- email: 'lea@biblio.fr',
- birthDate: new Date('1999-06-11'),
- loan: []
- },
- date: new Date('2025-09-01'),
- plannedReturningDate: new Date('2025-10-01'),
- effectiveReturningDate: new Date('2025-09-27')
+export class LoanTable implements OnInit {
+ private loansService = inject(LoansService);
+ private notificationService = inject(NzNotificationService)
+
+ loans = signal([]);
+
+ loansLoading = signal(false);
+
+ async ngOnInit() {
+ await this.fetchloans();
+ }
+
+ async fetchloans() {
+ this.loansLoading.set(true)
+
+ try {
+ const loans = await firstValueFrom(this.loansService.getAllLoanEndpoint())
+
+ } catch (e) {
+ this.notificationService.error(
+ 'Erreur',
+ 'Erreur de communication avec l\'API'
+ )
}
- ];
+ this.loansLoading.set(false)
+ }
delete() {
return
diff --git a/src/app/components/user-table/user-table.html b/src/app/components/user-table/user-table.html
index 4b9782b..e220f8a 100644
--- a/src/app/components/user-table/user-table.html
+++ b/src/app/components/user-table/user-table.html
@@ -1,4 +1,5 @@
-
+
| Nom |
@@ -10,15 +11,15 @@
- @for (data of basicTable.data; track data) {
+ @for (user of users(); track user.id) {
- | {{ data.name}} |
- {{ data.firstName }} |
- {{ data.email }} |
- {{ data.birthDate | date: 'dd/MM/yyyy'}} |
+ {{ user.name}} |
+ {{ user.firstName }} |
+ {{ user.email }} |
+ {{ user.birthDate | date: 'dd/MM/yyyy'}} |
-
+
| Livre |
@@ -27,11 +28,11 @@
- @for (loans of data.loan; track loans) {
+ @for (loan of user.loans; track loan.id) {
- | {{ loans.book.title }} |
- {{ loans.date | date: 'dd/MM/yyyy' }} |
- {{ loans.effectiveReturningDate | date: 'dd/MM/yyyy'}} |
+ {{ loan.bookTitle }} |
+ {{ loan.date | date: 'dd/MM/yyyy' }} |
+ {{ loan.effectiveReturningDate | date: 'dd/MM/yyyy'}} |
}
diff --git a/src/app/components/user-table/user-table.ts b/src/app/components/user-table/user-table.ts
index 43fc804..5bce3aa 100644
--- a/src/app/components/user-table/user-table.ts
+++ b/src/app/components/user-table/user-table.ts
@@ -1,10 +1,12 @@
-import { Component } from '@angular/core';
+import {Component, inject, OnInit, signal} from '@angular/core';
import {NzTableComponent} from "ng-zorro-antd/table";
import {Modal} from "../modal/modal";
import {DatePipe} from "@angular/common";
import {NzButtonComponent} from "ng-zorro-antd/button";
-import {UserInfo} from "../../interfaces/user.interfaces";
import {UpdateUser} from "../update-user/update-user";
+import {GetUserDto, UsersService} from "../../services/api";
+import {NzNotificationService} from "ng-zorro-antd/notification";
+import {firstValueFrom} from "rxjs";
@Component({
selector: 'app-user-table',
@@ -18,245 +20,32 @@ import {UpdateUser} from "../update-user/update-user";
templateUrl: './user-table.html',
styleUrl: './user-table.css',
})
-export class UserTable {
- listOfData: UserInfo[] = [
- {
- name: 'Dupont',
- firstName: 'Mathys',
- email: 'mathys@biblio.fr',
- birthDate: new Date('2004-05-21'),
- loan: [
- {
- book: {
- title: 'Dune',
- isbn: '9780441013593',
- author: 'Frank Herbert',
- releaseYear: 1965
- },
- user: null,
- date: new Date('2025-11-01'),
- plannedReturningDate: new Date('2025-12-01'),
- effectiveReturningDate: null
- },
- {
- book: {
- title: 'Dune',
- isbn: '9780441013593',
- author: 'Frank Herbert',
- releaseYear: 1965
- },
- user: null,
- date: new Date('2025-11-01'),
- plannedReturningDate: new Date('2025-12-01'),
- effectiveReturningDate: null
- },
- {
- book: {
- title: 'Dune',
- isbn: '9780441013593',
- author: 'Frank Herbert',
- releaseYear: 1965
- },
- user: null,
- date: new Date('2025-11-01'),
- plannedReturningDate: new Date('2025-12-01'),
- effectiveReturningDate: null
- },
- {
- book: {
- title: 'Dune',
- isbn: '9780441013593',
- author: 'Frank Herbert',
- releaseYear: 1965
- },
- user: null,
- date: new Date('2025-11-01'),
- plannedReturningDate: new Date('2025-12-01'),
- effectiveReturningDate: null
- }
- ]
- },
- {
- name: 'Durand',
- firstName: 'Lucie',
- email: 'lucie@biblio.fr',
- birthDate: new Date('1998-03-12'),
- loan: [
- {
- book: {
- title: '1984',
- isbn: '9780451524935',
- author: 'George Orwell',
- releaseYear: 1949
- },
- user: null,
- date: new Date('2025-10-20'),
- plannedReturningDate: new Date('2025-11-20'),
- effectiveReturningDate: new Date('2025-11-05')
- }
- ]
- },
- {
- name: 'Bernard',
- firstName: 'Thomas',
- email: 'thomas@biblio.fr',
- birthDate: new Date('1990-07-04'),
- loan: [
- {
- book: {
- title: 'Le Seigneur des Anneaux',
- isbn: '9780261102385',
- author: 'J.R.R. Tolkien',
- releaseYear: 1954
- },
- user: null,
- date: new Date('2025-09-10'),
- plannedReturningDate: new Date('2025-10-10'),
- effectiveReturningDate: new Date('2025-10-02')
- }
- ]
- },
- {
- name: 'Moreau',
- firstName: 'Sophie',
- email: 'sophie@biblio.fr',
- birthDate: new Date('1987-02-25'),
- loan: [
- {
- book: {
- title: 'Les Misérables',
- isbn: '9780140444308',
- author: 'Victor Hugo',
- releaseYear: 1862
- },
- user: null,
- date: new Date('2025-11-03'),
- plannedReturningDate: new Date('2025-12-03'),
- effectiveReturningDate: null
- }
- ]
- },
- {
- name: 'Leroy',
- firstName: 'Julien',
- email: 'julien@biblio.fr',
- birthDate: new Date('2001-09-18'),
- loan: [
- {
- book: {
- title: 'Fahrenheit 451',
- isbn: '9781451673319',
- author: 'Ray Bradbury',
- releaseYear: 1953
- },
- user: null,
- date: new Date('2025-10-15'),
- plannedReturningDate: new Date('2025-11-15'),
- effectiveReturningDate: new Date('2025-11-13')
- }
- ]
- },
- {
- name: 'Petit',
- firstName: 'Emma',
- email: 'emma@biblio.fr',
- birthDate: new Date('2006-11-30'),
- loan: [
- {
- book: {
- title: 'Harry Potter à l’école des sorciers',
- isbn: '9780747532743',
- author: 'J.K. Rowling',
- releaseYear: 1997
- },
- user: null,
- date: new Date('2025-11-08'),
- plannedReturningDate: new Date('2025-12-08'),
- effectiveReturningDate: null
- }
- ]
- },
- {
- name: 'Roux',
- firstName: 'Nicolas',
- email: 'nicolas@biblio.fr',
- birthDate: new Date('1995-08-14'),
- loan: [
- {
- book: {
- title: 'Le Petit Prince',
- isbn: '9780156012195',
- author: 'Antoine de Saint-Exupéry',
- releaseYear: 1943
- },
- user: null,
- date: new Date('2025-09-25'),
- plannedReturningDate: new Date('2025-10-25'),
- effectiveReturningDate: new Date('2025-10-20')
- }
- ]
- },
- {
- name: 'Fontaine',
- firstName: 'Claire',
- email: 'claire@biblio.fr',
- birthDate: new Date('1992-04-17'),
- loan: [
- {
- book: {
- title: 'L’Étranger',
- isbn: '9782070360024',
- author: 'Albert Camus',
- releaseYear: 1942
- },
- user: null,
- date: new Date('2025-10-05'),
- plannedReturningDate: new Date('2025-11-05'),
- effectiveReturningDate: new Date('2025-11-01')
- }
- ]
- },
- {
- name: 'Blanc',
- firstName: 'Hugo',
- email: 'hugo@biblio.fr',
- birthDate: new Date('2000-01-09'),
- loan: [
- {
- book: {
- title: 'Le Hobbit',
- isbn: '9780261102217',
- author: 'J.R.R. Tolkien',
- releaseYear: 1937
- },
- user: null,
- date: new Date('2025-11-02'),
- plannedReturningDate: new Date('2025-12-02'),
- effectiveReturningDate: null
- }
- ]
- },
- {
- name: 'Garnier',
- firstName: 'Léa',
- email: 'lea@biblio.fr',
- birthDate: new Date('1999-06-11'),
- loan: [
- {
- book: {
- title: 'La Peste',
- isbn: '9780141185064',
- author: 'Albert Camus',
- releaseYear: 1947
- },
- user: null,
- date: new Date('2025-09-01'),
- plannedReturningDate: new Date('2025-10-01'),
- effectiveReturningDate: new Date('2025-09-27')
- }
- ]
+export class UserTable implements OnInit {
+ private usersService = inject(UsersService);
+ private notificationService = inject(NzNotificationService)
+
+ users = signal([]);
+
+ usersLoading = signal(false);
+
+ async ngOnInit() {
+ await this.fetchUsers();
+ }
+
+ async fetchUsers() {
+ this.usersLoading.set(true)
+
+ try {
+ const users = await firstValueFrom(this.usersService.getAllUsersEndpoint())
+
+ } catch (e) {
+ this.notificationService.error(
+ 'Erreur',
+ 'Erreur de communication avec l\'API'
+ )
}
- ];
+ this.usersLoading.set(false)
+ }
delete() {
return
diff --git a/src/app/interfaces/author.interfaces.ts b/src/app/interfaces/author.interfaces.ts
deleted file mode 100644
index 55b2781..0000000
--- a/src/app/interfaces/author.interfaces.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface AuthorInfo {
- name: string;
- firstName: string;
-}
\ No newline at end of file
diff --git a/src/app/interfaces/book.interfaces.ts b/src/app/interfaces/book.interfaces.ts
deleted file mode 100644
index bcf6555..0000000
--- a/src/app/interfaces/book.interfaces.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export interface BookInfo {
- title: string;
- isbn: string;
- releaseYear: number;
- author: string;
-}
\ No newline at end of file
diff --git a/src/app/interfaces/loan.interfaces.ts b/src/app/interfaces/loan.interfaces.ts
deleted file mode 100644
index 40b907f..0000000
--- a/src/app/interfaces/loan.interfaces.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import {BookInfo} from "./book.interfaces";
-import {UserInfo} from "./user.interfaces";
-
-export interface LoanInfo {
- book: BookInfo;
- user: UserInfo;
- date: Date;
- plannedReturningDate: Date;
- effectiveReturningDate: Date;
-}
\ No newline at end of file
diff --git a/src/app/interfaces/user.interfaces.ts b/src/app/interfaces/user.interfaces.ts
deleted file mode 100644
index 2211918..0000000
--- a/src/app/interfaces/user.interfaces.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import {LoanInfo} from "./loan.interfaces";
-
-export interface UserInfo {
- name: string;
- firstName: string;
- email: string;
- birthDate: Date;
- loan: LoanInfo[];
-}
\ No newline at end of file
diff --git a/src/app/pages/author/author.html b/src/app/pages/author/author.html
index b20b3dd..53be2b3 100644
--- a/src/app/pages/author/author.html
+++ b/src/app/pages/author/author.html
@@ -3,8 +3,6 @@
- @for (author of authors; track $index) {
-
- }
+
diff --git a/src/app/pages/author/author.ts b/src/app/pages/author/author.ts
index db317c6..67c74ba 100644
--- a/src/app/pages/author/author.ts
+++ b/src/app/pages/author/author.ts
@@ -1,7 +1,6 @@
-import {Component, input} from '@angular/core';
+import {Component} from '@angular/core';
import {CreateAuthor} from "../../components/create-author/create-author";
import {Modal} from "../../components/modal/modal";
-import {AuthorInfo} from "../../interfaces/author.interfaces";
import {AuthorCard} from "../../components/author-card/author-card";
@Component({
@@ -14,16 +13,6 @@ import {AuthorCard} from "../../components/author-card/author-card";
templateUrl: './author.html',
styleUrl: './author.css',
})
-export class Author {
- authorInfo = input.required();
-
- authors: AuthorInfo[] = [
- { name: 'Victor', firstName: 'Hugo' },
- { name: 'J.K.', firstName: 'Rowling' },
- { name: 'J.R.R.', firstName: 'Tolkien' },
- { name: 'Frank', firstName: 'Herbert' },
- { name: 'Ray', firstName: 'Bradbury' },
- { name: 'George ', firstName: 'Orwell' }
- ];
+export class Author{
}
diff --git a/src/app/pages/book/book.html b/src/app/pages/book/book.html
index 79d21b2..9be1fa1 100644
--- a/src/app/pages/book/book.html
+++ b/src/app/pages/book/book.html
@@ -3,8 +3,6 @@
- @for (book of books; track $index) {
-
- }
+
diff --git a/src/app/pages/book/book.ts b/src/app/pages/book/book.ts
index b79d09d..c69f913 100644
--- a/src/app/pages/book/book.ts
+++ b/src/app/pages/book/book.ts
@@ -1,5 +1,4 @@
-import { Component } from '@angular/core';
-import {BookInfo} from "../../interfaces/book.interfaces";
+import {Component, inject, OnInit, signal} from '@angular/core';
import {BookCard} from "../../components/book-card/book-card";
import {Modal} from "../../components/modal/modal";
import {CreateBook} from "../../components/create-book/create-book";
@@ -14,14 +13,5 @@ import {CreateBook} from "../../components/create-book/create-book";
templateUrl: './book.html',
styleUrls: ['./book.css'],
})
-export class Book {
- books: BookInfo[] = [
- { title: '1984', isbn: '978-0451524935', author: 'George Orwell', releaseYear: 1949 },
- { title: 'Le Seigneur des Anneaux', isbn: '978-0544003415', author: 'J.R.R. Tolkien', releaseYear: 1954 },
- { title: 'Dune', isbn: '978-0441013593', author: 'Frank Herbert', releaseYear: 1965 },
- { title: 'Fahrenheit 451', isbn: '978-1451673319', author: 'Ray Bradbury', releaseYear: 1953 },
- { title: 'Les Misérables', isbn: '978-2070409185', author: 'Victor Hugo', releaseYear: 1862 },
- { title: 'Harry Potter à l’école des sorciers', isbn: '978-2070643028', author: 'J.K. Rowling', releaseYear: 1997 },
- ];
-
+export class Book{
}
diff --git a/src/app/pages/loan/loan.ts b/src/app/pages/loan/loan.ts
index bfeb6f4..56e5d87 100644
--- a/src/app/pages/loan/loan.ts
+++ b/src/app/pages/loan/loan.ts
@@ -1,14 +1,14 @@
import { Component } from '@angular/core';
-import {LoanTable} from "../../components/loan-table/loan-table";
import {Modal} from "../../components/modal/modal";
import {CreateLoan} from "../../components/create-loan/create-loan";
+import {LoanTable} from "../../components/loan-table/loan-table";
@Component({
selector: 'app-loan',
imports: [
- LoanTable,
Modal,
- CreateLoan
+ CreateLoan,
+ LoanTable
],
templateUrl: './loan.html',
styleUrl: './loan.css',
| |