Lint errors
Signed-off-by: Rodrigo Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
4143b67b63
commit
f993d9ebfc
1 file changed
+42
-1
@@ -1,5 +1,6 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import multer from "multer";
|
import multer from "multer";
|
||||||
|
import { startOfDay, endOfDay, startOfWeek, endOfWeek, parseISO, addDays } from 'date-fns';
|
||||||
|
|
||||||
import { authMiddleware } from "../../middleware/auth";
|
import { authMiddleware } from "../../middleware/auth";
|
||||||
import { NextCloudService } from "../../services/nextcloud";
|
import { NextCloudService } from "../../services/nextcloud";
|
||||||
@@ -10,7 +11,47 @@ const upload = multer({ storage: multer.memoryStorage() });
|
|||||||
|
|
||||||
router.use(authMiddleware);
|
router.use(authMiddleware);
|
||||||
|
|
||||||
// ...existing routes...
|
// Nova rota para listar agendamentos
|
||||||
|
router.get("/agendamentos", async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { data } = req.query;
|
||||||
|
let dateFilter: any = {};
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
// Se uma data específica foi fornecida, retorna os agendamentos da semana
|
||||||
|
const parsedDate = parseISO(data as string);
|
||||||
|
const weekStart = startOfWeek(parsedDate);
|
||||||
|
const weekEnd = endOfWeek(parsedDate);
|
||||||
|
|
||||||
|
dateFilter = {
|
||||||
|
data: {
|
||||||
|
gte: weekStart,
|
||||||
|
lte: weekEnd,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const agendamentos = await prisma.agendamento.findMany({
|
||||||
|
where: dateFilter,
|
||||||
|
include: {
|
||||||
|
cliente: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
nome: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
data: 'asc',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
res.json(agendamentos);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Erro ao listar agendamentos:", error);
|
||||||
|
res.status(500).json({ error: "Erro ao listar agendamentos" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Rota para atualizar atendimento com anexos
|
// Rota para atualizar atendimento com anexos
|
||||||
router.patch("/:id", async (req, res) => {
|
router.patch("/:id", async (req, res) => {
|
||||||
|
|||||||
Reference in new issue
Block a user