feat(backend): add responsable stock endpoint
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
ActiviteResponsable,
|
||||
EmpruntResponsable,
|
||||
MaterielResponsable,
|
||||
StatutCount,
|
||||
} from '../repositories/responsable.repository';
|
||||
import { DashboardResponsableData } from '../services/responsable.service';
|
||||
@@ -63,6 +64,26 @@ export interface EmpruntResponsableResponse {
|
||||
};
|
||||
}
|
||||
|
||||
export interface MaterielResponsableResponse {
|
||||
id: number;
|
||||
nom: string;
|
||||
marque: string;
|
||||
modele: string;
|
||||
reference: string;
|
||||
statut: string;
|
||||
etatGeneral: string;
|
||||
categorie: {
|
||||
id: number;
|
||||
nom: string;
|
||||
};
|
||||
accessoires: Array<{
|
||||
id: number;
|
||||
nom: string;
|
||||
quantiteAttendue: number;
|
||||
obligatoire: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
function toRepartition(rows: StatutCount[]): RepartitionStatutResponse {
|
||||
const parStatut: Record<string, number> = {};
|
||||
let total = 0;
|
||||
@@ -139,3 +160,27 @@ export function toEmpruntResponsableResponse(
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function toMaterielResponsableResponse(
|
||||
materiel: MaterielResponsable,
|
||||
): MaterielResponsableResponse {
|
||||
return {
|
||||
id: materiel.id,
|
||||
nom: materiel.nom,
|
||||
marque: materiel.marque,
|
||||
modele: materiel.modele,
|
||||
reference: materiel.reference,
|
||||
statut: materiel.statut,
|
||||
etatGeneral: materiel.etatGeneral,
|
||||
categorie: {
|
||||
id: materiel.categorie.id,
|
||||
nom: materiel.categorie.nom,
|
||||
},
|
||||
accessoires: materiel.accessoires.map((liaison) => ({
|
||||
id: liaison.accessoire.id,
|
||||
nom: liaison.accessoire.nom,
|
||||
quantiteAttendue: liaison.quantiteAttendue,
|
||||
obligatoire: liaison.obligatoire,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user