Skip to content

Commit

Permalink
The cancellation will be completed even if the user is registered on …
Browse files Browse the repository at this point in the history
…another team. (#27)
  • Loading branch information
Prybrt06 authored Jan 28, 2024
1 parent 136f5fd commit 1134eab
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/controllers/team/respond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,8 @@ const teamRegistrationResponse: Interfaces.Controller.Async = async (

// Check for admin insufficient balance

// Check if status is registered in another team in the event
const otherTeam = await prisma.team.findFirst({
where: {
eventId: team.eventId,
members: {
some: {
userId,
registrationStatus: RegistrationStatus.REGISTERED,
},
},
},
});

if (otherTeam) {
return next(Errors.Team.userAlreadyRegistered);
}

// Update Status
// Cancel Team Registration
if (status === RegistrationStatus.CANCELLED) {
// Cancel Team Registration
await prisma.team.update({
where: {
id: team.id,
Expand All @@ -130,7 +112,29 @@ const teamRegistrationResponse: Interfaces.Controller.Async = async (
},
},
});
} else if (status === RegistrationStatus.REGISTERED) {

return res.json(Success.Team.userStatusUpdated);
}

// Check if status is registered in another team in the event
const otherTeam = await prisma.team.findFirst({
where: {
eventId: team.eventId,
members: {
some: {
userId,
registrationStatus: RegistrationStatus.REGISTERED,
},
},
},
});

if (otherTeam) {
return next(Errors.Team.userAlreadyRegistered);
}

// Update Status
if (status === RegistrationStatus.REGISTERED) {
// Update team and member status.
// Complete it in a single transaction.

Expand Down

0 comments on commit 1134eab

Please sign in to comment.