Skip to content

Commit 17ba7b4

Browse files
dawangkgithub-actions[bot]
authored andcommitted
Auto-formatted the code using Prettier
1 parent c2097c6 commit 17ba7b4

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

course-matrix/backend/src/constants/availableFunctions.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const availableFunctions: AvailableFunctions = {
145145
deleteTimetable: async (args: any, req: Request) => {
146146
try {
147147
const { id } = args;
148-
148+
149149
// Retrieve the authenticated user
150150
const user_id = (req as any).user.id;
151151

@@ -199,25 +199,25 @@ export const availableFunctions: AvailableFunctions = {
199199
const { name, semester, courses, restrictions } = args;
200200
// Get user id from session authentication to insert in the user_id col
201201
const user_id = (req as any).user.id;
202-
202+
203203
if (name.length > 50) {
204204
return {
205205
status: 400,
206206
error: "timetable title is over 50 characters long",
207207
};
208208
}
209209

210-
// Timetables cannot exceed the size of 25.
211-
const{count: timetable_count, error: timetableCountError} =
210+
// Timetables cannot exceed the size of 25.
211+
const { count: timetable_count, error: timetableCountError } =
212212
await supabase
213-
.schema("timetable")
214-
.from("timetables")
215-
.select('*', { count: 'exact', head: true })
216-
.eq("user_id", user_id);
213+
.schema("timetable")
214+
.from("timetables")
215+
.select("*", { count: "exact", head: true })
216+
.eq("user_id", user_id);
217217

218218
console.log(timetable_count);
219-
220-
if ((timetable_count ?? 0) >=25){
219+
220+
if ((timetable_count ?? 0) >= 25) {
221221
return {
222222
status: 400,
223223
error: "You have exceeded the limit of 25 timetables",
@@ -305,8 +305,6 @@ export const availableFunctions: AvailableFunctions = {
305305
};
306306
}
307307

308-
309-
310308
// Check if a timetable with the same title already exist for this user
311309
const { data: existingTimetable, error: existingTimetableError } =
312310
await supabase

course-matrix/backend/src/controllers/timetablesController.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ export default {
3131
.status(400)
3232
.json({ error: "Timetable Title cannot be over 50 characters long" });
3333
}
34-
// Timetables cannot exceed the size of 25.
35-
const{count: timetable_count, error: timetableCountError} =
34+
// Timetables cannot exceed the size of 25.
35+
const { count: timetable_count, error: timetableCountError } =
3636
await supabase
37-
.schema("timetable")
38-
.from("timetables")
39-
.select('*', { count: 'exact', head: true })
40-
.eq("user_id", user_id);
37+
.schema("timetable")
38+
.from("timetables")
39+
.select("*", { count: "exact", head: true })
40+
.eq("user_id", user_id);
4141

4242
console.log(timetable_count);
43-
44-
if ((timetable_count ?? 0) >=25){
45-
return res.status(400).json({ error: "You have exceeded the limit of 25 timetables" });
43+
44+
if ((timetable_count ?? 0) >= 25) {
45+
return res
46+
.status(400)
47+
.json({ error: "You have exceeded the limit of 25 timetables" });
4648
}
4749

4850
// Check if a timetable with the same title already exist for this user
@@ -65,7 +67,7 @@ export default {
6567
.json({ error: "A timetable with this title already exists" });
6668
}
6769
//Create query to insert the user_id and timetable_title into the db
68-
70+
6971
let insertTimetable = supabase
7072
.schema("timetable")
7173
.from("timetables")

course-matrix/frontend/src/pages/Home/Home.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import TimetableCard from "./TimetableCard";
44
import TimetableCompareButton from "./TimetableCompareButton";
55
import TimetableCreateNewButton from "./TimetableCreateNewButton";
66
import { useGetTimetablesQuery } from "../../api/timetableApiSlice";
7-
import { useState,useEffect } from "react";
7+
import { useState, useEffect } from "react";
88
import TimetableErrorDialog from "../TimetableBuilder/TimetableErrorDialog";
99

1010
export interface Timetable {
@@ -32,14 +32,12 @@ const Home = () => {
3232
isLoading: boolean;
3333
refetch: () => void;
3434
};
35-
3635

3736
const [errorMessage, setErrorMessage] = useState<string | null>(null);
3837
const [count, setCount] = useState<number>(0);
3938

4039
useEffect(() => {
41-
if(data!==undefined)
42-
setCount(data.length);
40+
if (data !== undefined) setCount(data.length);
4341
}, [data]);
4442

4543
return (
@@ -49,9 +47,14 @@ const Home = () => {
4947
<h1 className="text-2xl font-medium tracking-tight">My Timetables</h1>
5048
<Pin size={24} className="text-blue-500" />
5149

52-
<h1 className={`${
53-
count >= 25 ? "font-bold text-red-500" : "font-normal text-black"
54-
}`}> (Timetable limit: {count}/25)</h1>
50+
<h1
51+
className={`${
52+
count >= 25 ? "font-bold text-red-500" : "font-normal text-black"
53+
}`}
54+
>
55+
{" "}
56+
(Timetable limit: {count}/25)
57+
</h1>
5558
</div>
5659
<TimetableErrorDialog
5760
errorMessage={errorMessage}

0 commit comments

Comments
 (0)