listo socket
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const moment = require('moment');
|
||||
const io = require('../../socket');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrito = require(`${dbPath}/Carrito`);
|
||||
@@ -9,19 +10,11 @@ const Programa = require(`${dbPath}/Programa`);
|
||||
const Status = require(`${dbPath}/Status`);
|
||||
const TipoCarrito = require(`${dbPath}/TipoCarrito`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const ahora = moment();
|
||||
const horaMax = moment(
|
||||
`${ahora.year()}-${
|
||||
ahora.month() < 9 ? '0' + (ahora.month() + 1) : ahora.month() + 1
|
||||
}-${ahora.date() < 9 ? '0' + ahora.date() : ahora.date()} 19:00`
|
||||
);
|
||||
const horaMin = moment(
|
||||
`${ahora.year()}-${
|
||||
ahora.month() < 9 ? '0' + (ahora.month() + 1) : ahora.month() + 1
|
||||
}-${ahora.date() < 9 ? '0' + ahora.date() : ahora.date()} 09:00`
|
||||
);
|
||||
|
||||
const pedir = async (body) => {
|
||||
const ahora = moment();
|
||||
const horaMax = moment(`${ahora.format('YYYY-MM-DD')} 19:00`);
|
||||
const horaMin = moment(`${ahora.format('YYYY-MM-DD')} 09:00`);
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id usuario', true);
|
||||
const idTipoCarrito = validarNumeroEntero(
|
||||
body.idTipoCarrito,
|
||||
@@ -96,40 +89,13 @@ const pedir = async (body) => {
|
||||
idEquipo,
|
||||
})
|
||||
)
|
||||
.then((res) =>
|
||||
Prestamo.findOne({
|
||||
where: { idPrestamo: res.idPrestamo },
|
||||
include: [
|
||||
{
|
||||
model: Equipo,
|
||||
include: [
|
||||
{
|
||||
model: Carrito,
|
||||
include: [{ model: Modulo }, { model: TipoCarrito }],
|
||||
attributes: ['idCarrito', 'sobrenombre'],
|
||||
},
|
||||
{ model: Status },
|
||||
{ model: Programa },
|
||||
],
|
||||
attributes: [
|
||||
'idEquipo',
|
||||
'numeroSerie',
|
||||
'numeroInventario',
|
||||
'sobrenombre',
|
||||
],
|
||||
},
|
||||
],
|
||||
attributes: [
|
||||
'idPrestamo',
|
||||
'activo',
|
||||
'horaMaxRecoger',
|
||||
'horaInicio',
|
||||
'horaFin',
|
||||
'horaEntrega',
|
||||
'createdAt',
|
||||
],
|
||||
})
|
||||
);
|
||||
.then((res) => {
|
||||
io.getIO().emit('actualizar', { idPrestamo: res.idPrestamo });
|
||||
return {
|
||||
message:
|
||||
'Haz solicitado un equipo de cómputo correctamente. Presentate al módulo señalado y prestenta tu QR.',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = pedir;
|
||||
|
||||
Reference in New Issue
Block a user