feat(backend): add responsable emprunts endpoint
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { AppError } from '../errors/app-error';
|
||||
import { getDashboardResponsable } from '../services/responsable.service';
|
||||
import { toDashboardResponsableResponse } from '../dtos/responsable.dto';
|
||||
import {
|
||||
getDashboardResponsable,
|
||||
listerEmpruntsResponsable,
|
||||
parseStatutEmprunt,
|
||||
} from '../services/responsable.service';
|
||||
import {
|
||||
toDashboardResponsableResponse,
|
||||
toEmpruntResponsableResponse,
|
||||
} from '../dtos/responsable.dto';
|
||||
|
||||
export async function getDashboard(req: Request, res: Response): Promise<void> {
|
||||
const user = req.user;
|
||||
@@ -12,3 +19,14 @@ export async function getDashboard(req: Request, res: Response): Promise<void> {
|
||||
const dashboard = await getDashboardResponsable(user.id, user.roleCode, user.campusId);
|
||||
res.json({ data: toDashboardResponsableResponse(dashboard) });
|
||||
}
|
||||
|
||||
export async function getEmprunts(req: Request, res: Response): Promise<void> {
|
||||
const user = req.user;
|
||||
if (!user) {
|
||||
throw new AppError(401, 'Authentification requise');
|
||||
}
|
||||
|
||||
const statut = parseStatutEmprunt(req.query.statut);
|
||||
const emprunts = await listerEmpruntsResponsable(user.roleCode, user.campusId, { statut });
|
||||
res.json({ data: emprunts.map(toEmpruntResponsableResponse) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user