Skip to content

Commit

Permalink
Made The Cloud bookable (#87)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Supergamer1337 authored Nov 6, 2023
1 parent 7995fdf commit f684c05
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum room {
BIG_HUB
GROUP_ROOM
CTC
THE_CLOUD
}

model rule {
Expand Down
1 change: 1 addition & 0 deletions backend/src/schemas/v1/room.gql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ enum Room {
BIG_HUB
GROUP_ROOM
CTC
THE_CLOUD
}
18 changes: 10 additions & 8 deletions backend/src/services/event.service.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
);
};

Expand Down Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/common/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const ROOMS = [
text: "CTC",
color: "#E15554",
},
{
value: "THE_CLOUD",
text: "The Cloud",
color: "#FF9100",
},
];

export default ROOMS;

0 comments on commit f684c05

Please sign in to comment.