se agrego controller para traer solo eventos disponibles y no todos
This commit is contained in:
@@ -54,4 +54,9 @@ export class EventosController {
|
||||
res.download(filePath);
|
||||
}
|
||||
|
||||
@Post('disponibles')
|
||||
getEventosDisponibles (){
|
||||
return this.eventoService.getEventosDisponibles()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity';
|
||||
import { Participante } from 'src/participante/participante.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { MoreThanOrEqual, Repository } from 'typeorm';
|
||||
import { actualizarEventoDto } from './dto/actualizarEvento.dto';
|
||||
import { crearEventoDto } from './dto/crearEvento.dto';
|
||||
import { Evento } from './evento.entity';
|
||||
@@ -103,17 +103,6 @@ export class EventosService {
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
const worksheet = workbook.addWorksheet('Participantes');
|
||||
|
||||
// Definir estilos
|
||||
const headerStyle = {
|
||||
font: { bold: true },
|
||||
alignment: { horizontal: 'center' },
|
||||
border: { bottom: { style: 'medium' } },
|
||||
};
|
||||
|
||||
const dataStyle = {
|
||||
alignment: { horizontal: 'left' },
|
||||
};
|
||||
|
||||
// Definir las columnas
|
||||
worksheet.columns = [
|
||||
{ header: 'Asistencia', key: 'asistencia', width: 10, style: {alignment: {horizontal: 'center'}}},
|
||||
@@ -147,9 +136,18 @@ export class EventosService {
|
||||
// Generar el archivo Excel y guardarlo en el servidor
|
||||
const fileName = `participantes-${idEvento}.xlsx`;
|
||||
const filePath = `./${fileName}`;
|
||||
await workbook.xlsx.writeFile(filePath);
|
||||
|
||||
/* await workbook.xlsx.writeFile(filePath);
|
||||
*/
|
||||
// Devolver la ruta del archivo para que el cliente pueda descargarlo
|
||||
return filePath;
|
||||
}
|
||||
|
||||
getEventosDisponibles(){
|
||||
const hoy = new Date();
|
||||
return this.eventoRepository.find({
|
||||
where: {
|
||||
fecha_fin: MoreThanOrEqual(hoy)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user