Skip to content

Commit

Permalink
Merge pull request #11 from gdsc-nits-org/fixes
Browse files Browse the repository at this point in the history
Fix: Minor Bugs
  • Loading branch information
JOSU9435 authored Jan 17, 2024
2 parents 06a90d1 + 68c92f5 commit ee64a01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/controllers/event/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const createEvent: Interfaces.Controller.Async = async (req, res, next) => {
if (extraQuestions && !Array.isArray(extraQuestions)) {
return next(Errors.Module.invalidInput);
}
if (minTeamSize > maxTeamSize) return next(Errors.Module.invalidInput);

if (
!(registrationIncentive && typeof registrationIncentive === "number") ||
Expand All @@ -75,9 +76,13 @@ const createEvent: Interfaces.Controller.Async = async (req, res, next) => {

const regStart = new Date(registrationStartTime);
const regEnd = new Date(registrationEndTime);

if (JSON.stringify(regStart) === "null" || JSON.stringify(regEnd) === "null")
return next(Errors.Module.invalidInput);

if (regStart && regEnd && regStart > regEnd)
return next(Errors.Module.invalidInput);

if (
!(await prisma.module.findFirst({
where: { id: moduleId },
Expand Down
22 changes: 14 additions & 8 deletions src/controllers/event/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,36 @@ const updateEvent: Interfaces.Controller.Async = async (req, res, next) => {

const { eventId: EID } = req.params;
const eventId = String(EID);
if (
String(eventId + "") ||
typeof eventId !== "string" ||
eventId.length !== 24
)
if (typeof eventId !== "string" || eventId.length !== 24)
return next(Errors.Module.invalidInput);

if (!(await prisma.event.findFirst({ where: { id: eventId } })))
return next(Errors.Module.eventNotFound);
const eventOriginal = await prisma.event.findFirst({
where: { id: eventId },
});
if (!eventOriginal) return next(Errors.Module.eventNotFound);
if (moduleId) {
if (!moduleId || typeof moduleId !== "string" || eventId.length !== 24)
return next(Errors.Module.invalidInput);
if (!(await prisma.module.findFirst({ where: { id: moduleId } })))
return next(Errors.Module.moduleNotFound);
}

if (minTeamSize > maxTeamSize) return next(Errors.Module.invalidInput);
let regStart;
if (registrationStartTime) regStart = new Date(registrationStartTime);
else {
regStart = new Date(eventOriginal.registrationStartTime);
}
let regEnd;
if (registrationEndTime) regEnd = new Date(registrationEndTime);
else {
regEnd = new Date(eventOriginal.registrationEndTime);
}
if (registrationStartTime && JSON.stringify(regStart) === "null")
return next(Errors.Module.invalidInput);
if (registrationEndTime && JSON.stringify(regEnd) === "null")
return next(Errors.Module.invalidInput);
if (regStart && regEnd && regStart > regEnd)
return next(Errors.Module.invalidInput);

const { organizers, managers }: { organizers: [string]; managers: [string] } =
req.body;
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/team/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const getAllTeamsOfEvent: Interfaces.Controller.Async = async (
],
},
select: {
teamName: true,
id: true,
members: {
select: {
user: {
Expand Down

0 comments on commit ee64a01

Please sign in to comment.