feat(backend): add responsable emprunts endpoint
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { ActiviteResponsable, StatutCount } from '../repositories/responsable.repository';
|
||||
import {
|
||||
ActiviteResponsable,
|
||||
EmpruntResponsable,
|
||||
StatutCount,
|
||||
} from '../repositories/responsable.repository';
|
||||
import { DashboardResponsableData } from '../services/responsable.service';
|
||||
|
||||
export interface RepartitionStatutResponse {
|
||||
@@ -34,6 +38,31 @@ export interface DashboardResponsableResponse {
|
||||
activiteRecente: ActiviteResponsableResponse[];
|
||||
}
|
||||
|
||||
export interface EmpruntResponsableResponse {
|
||||
id: number;
|
||||
statut: string;
|
||||
dateEmprunt: Date;
|
||||
dateRetourPrevue: Date;
|
||||
dateRetourReelle: Date | null;
|
||||
etudiant: {
|
||||
id: number;
|
||||
nom: string;
|
||||
prenom: string;
|
||||
email: string;
|
||||
classe: string | null;
|
||||
};
|
||||
materiel: {
|
||||
id: number;
|
||||
nom: string;
|
||||
reference: string;
|
||||
statut: string;
|
||||
categorie: {
|
||||
id: number;
|
||||
nom: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function toRepartition(rows: StatutCount[]): RepartitionStatutResponse {
|
||||
const parStatut: Record<string, number> = {};
|
||||
let total = 0;
|
||||
@@ -81,3 +110,32 @@ export function toDashboardResponsableResponse(
|
||||
activiteRecente: data.activiteRecente.map(toActiviteResponse),
|
||||
};
|
||||
}
|
||||
|
||||
export function toEmpruntResponsableResponse(
|
||||
emprunt: EmpruntResponsable,
|
||||
): EmpruntResponsableResponse {
|
||||
return {
|
||||
id: emprunt.id,
|
||||
statut: emprunt.statut,
|
||||
dateEmprunt: emprunt.dateEmprunt,
|
||||
dateRetourPrevue: emprunt.dateRetourPrevue,
|
||||
dateRetourReelle: emprunt.dateRetourReelle,
|
||||
etudiant: {
|
||||
id: emprunt.utilisateur.id,
|
||||
nom: emprunt.utilisateur.nom,
|
||||
prenom: emprunt.utilisateur.prenom,
|
||||
email: emprunt.utilisateur.email,
|
||||
classe: emprunt.utilisateur.classe,
|
||||
},
|
||||
materiel: {
|
||||
id: emprunt.materiel.id,
|
||||
nom: emprunt.materiel.nom,
|
||||
reference: emprunt.materiel.reference,
|
||||
statut: emprunt.materiel.statut,
|
||||
categorie: {
|
||||
id: emprunt.materiel.categorie.id,
|
||||
nom: emprunt.materiel.categorie.nom,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user