From f684c0551b1942e603717300083607ed7b5d6b5e Mon Sep 17 00:00:00 2001 From: Felix Bjerhem Aronsson Date: Mon, 6 Nov 2023 19:22:41 +0100 Subject: [PATCH] Made The Cloud bookable (#87) * Added TheCloud as a room * Modified BIG HUB Exception to apply to The Cloud * Reverted formatting changes caused by autoformatting * Fixed additional space I missed --- backend/prisma/schema.prisma | 1 + backend/src/schemas/v1/room.gql | 1 + backend/src/services/event.service.ts | 18 ++++++++++-------- frontend/src/common/rooms.js | 5 +++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index f7eec02..88dd5d0 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -25,6 +25,7 @@ enum room { BIG_HUB GROUP_ROOM CTC + THE_CLOUD } model rule { diff --git a/backend/src/schemas/v1/room.gql b/backend/src/schemas/v1/room.gql index 82a5bfc..33f032a 100644 --- a/backend/src/schemas/v1/room.gql +++ b/backend/src/schemas/v1/room.gql @@ -2,4 +2,5 @@ enum Room { BIG_HUB GROUP_ROOM CTC + THE_CLOUD } diff --git a/backend/src/services/event.service.ts b/backend/src/services/event.service.ts index 44a5cfa..1dc3227 100644 --- a/backend/src/services/event.service.ts +++ b/backend/src/services/event.service.ts @@ -1,7 +1,7 @@ +import { PrismaClient, event, room } from "@prisma/client"; +import { Error, User } from "../models"; import { Event } from "../models/event"; import { checkRules } from "./rule.service"; -import { User, Error } from "../models"; -import { PrismaClient, event, room } from "@prisma/client"; /* * Events must end after they start @@ -34,11 +34,12 @@ const bookedByIsSpecified = (event: Event) => { }; /** - * Big hub cannot be booked for a private event + * Big hub and The Cloud cannot be booked for a private event */ -const bookingBigHubAsPrivate = (event: Event) => { +const bookingImportantAsPrivate = (event: Event) => { return ( - event.booked_as == event.booked_by && event.room.includes(room.BIG_HUB) + event.booked_as == event.booked_by && + (event.room.includes(room.BIG_HUB) || event.room.includes(room.THE_CLOUD)) ); }; @@ -118,12 +119,13 @@ const validEvent = async ( }; } - if (bookingBigHubAsPrivate(event)) { + if (bookingImportantAsPrivate(event)) { return { - sv: "Storhubben får inte bokas som privatperson", - en: "The big hub cannot be booked as a private person", + sv: "Storhubben och The Cloud får inte bokas som privatperson", + en: "The big hub and The Cloud cannot be booked as a private person", }; } + if (!roomSpecified(event)) { return { sv: "Inget rum specificerat", diff --git a/frontend/src/common/rooms.js b/frontend/src/common/rooms.js index fe42b87..de8cee0 100644 --- a/frontend/src/common/rooms.js +++ b/frontend/src/common/rooms.js @@ -14,6 +14,11 @@ const ROOMS = [ text: "CTC", color: "#E15554", }, + { + value: "THE_CLOUD", + text: "The Cloud", + color: "#FF9100", + }, ]; export default ROOMS;