Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event add controller changed #21

Merged
merged 12 commits into from
Jan 26, 2024
13 changes: 9 additions & 4 deletions src/controllers/event/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ const createEvent: Interfaces.Controller.Async = async (req, res, next) => {
const { organizers, managers }: { organizers: [string]; managers: [string] } =
req.body;

let connectOrganiser: {
userId: string;
}[] = [];
let connectManager: {
userId: string;
}[] = [];

if (organizers) {
if (!organizers.every((organizer) => organizer.length === 24)) {
return next(Errors.Module.invalidInput);
Expand All @@ -103,6 +110,7 @@ const createEvent: Interfaces.Controller.Async = async (req, res, next) => {
if (!userIdExist) {
return next(Errors.User.userNotFound);
}
connectOrganiser = await Utils.Event.connectId(organizers);
}

if (managers) {
Expand All @@ -115,12 +123,9 @@ const createEvent: Interfaces.Controller.Async = async (req, res, next) => {
if (!userIdExist) {
return next(Errors.User.userNotFound);
}
connectManager = await Utils.Event.connectId(managers);
}

const connectOrganiser = await Utils.Event.connectId(organizers);

const connectManager = await Utils.Event.connectId(managers);

const event = await prisma.event.create({
data: {
description,
Expand Down
Loading