Skip to content

Commit

Permalink
build verified
Browse files Browse the repository at this point in the history
  • Loading branch information
subru-37 committed Jan 16, 2025
1 parent 539d934 commit 90895fe
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions apps/core-admin/src/controllers/extras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ export const addNewExtra = async (req: Request, res: Response) => {
const { assignToAllParticipants } = req?.query;
const { name } = req?.body;

if(!name) {
if (!name) {
return res.status(400).json({ error: 'Name is required' });
}

await prisma.$transaction(async (tx: typeof prisma) => {

const newExtra = await tx.extras.create({
data: {
name,
Expand All @@ -23,15 +22,15 @@ export const addNewExtra = async (req: Request, res: Response) => {
});

if (!newExtra) {
return res.status(500).json({error: 'Something went wrong'});
return res.status(500).json({ error: 'Something went wrong' });
}

if (assignToAllParticipants === 'true') {
const participants = await prisma.participant.findMany({
where: {
organizationId: orgId,
eventId: eventId,
}
},
});

for (let participant of participants) {
Expand All @@ -43,7 +42,7 @@ export const addNewExtra = async (req: Request, res: Response) => {
});

if (!participantExtra) {
return res.status(500).json({error: 'Something went wrong'});
return res.status(500).json({ error: 'Something went wrong' });
}
}
}
Expand Down

0 comments on commit 90895fe

Please sign in to comment.