feat(backend): add responsable anomalies endpoint

This commit is contained in:
SaidSoighiri94
2026-07-15 15:30:24 +02:00
parent 26f036046d
commit 1ce023de71
6 changed files with 194 additions and 6 deletions
@@ -2,13 +2,16 @@ import { Request, Response } from 'express';
import { AppError } from '../errors/app-error';
import {
getDashboardResponsable,
listerAnomaliesResponsable,
listerMaterielsResponsable,
listerEmpruntsResponsable,
parseCategorieId,
parseStatutAnomalie,
parseStatutMateriel,
parseStatutEmprunt,
} from '../services/responsable.service';
import {
toAnomalieResponsableResponse,
toDashboardResponsableResponse,
toEmpruntResponsableResponse,
toMaterielResponsableResponse,
@@ -52,3 +55,19 @@ export async function getMateriels(req: Request, res: Response): Promise<void> {
});
res.json({ data: materiels.map(toMaterielResponsableResponse) });
}
export async function getAnomalies(req: Request, res: Response): Promise<void> {
const user = req.user;
if (!user) {
throw new AppError(401, 'Authentification requise');
}
const statut = parseStatutAnomalie(req.query.statut);
const type = typeof req.query.type === 'string' ? req.query.type : undefined;
const anomalies = await listerAnomaliesResponsable(user.roleCode, user.campusId, {
statut,
type,
});
res.json({ data: anomalies.map(toAnomalieResponsableResponse) });
}