Skip to content

Commit

Permalink
Finish ratings, lint code, add basic splash page
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic committed Nov 11, 2024
1 parent 97c74bb commit 67cf9c5
Show file tree
Hide file tree
Showing 37 changed files with 968 additions and 390 deletions.
13 changes: 10 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended"
],
"plugins": ["react", "unused-imports", "import", "@typescript-eslint", "jsx-a11y", "prettier"],
"plugins": [
"react",
"unused-imports",
"import",
"@typescript-eslint",
"jsx-a11y",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
Expand Down Expand Up @@ -80,8 +87,8 @@
],
"padding-line-between-statements": [
"warn",
{"blankLine": "always", "prev": "*", "next": "return"},
{"blankLine": "always", "prev": ["const", "let", "var"], "next": "*"},
{ "blankLine": "always", "prev": "*", "next": "return" },
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
{
"blankLine": "any",
"prev": ["const", "let", "var"],
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"endOfLint": "lf",
"printWidhth": 80,
"tabWidth": 2,
"trailingComma": "es5"
}
1 change: 1 addition & 0 deletions app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const dynamic = "force-dynamic"; // defaults to auto
import NextAuth from "next-auth";

import { config } from "../../../../lib/auth";

const handler = NextAuth(config);
Expand Down
3 changes: 2 additions & 1 deletion app/api/createplan/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// api/test.ts
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";
import { getServerSession } from "next-auth/next";
import { auth } from "../../../lib/auth";

export async function POST(request: NextRequest) {
Expand Down Expand Up @@ -51,6 +51,7 @@ export async function GET(request: NextRequest) {
courses: true,
},
});

//console.log(plans);
return NextResponse.json(courses, { status: 200 });
}
Expand Down
15 changes: 0 additions & 15 deletions app/api/getCourses/route.ts

This file was deleted.

24 changes: 24 additions & 0 deletions app/api/getProfClasses/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Faculty } from "./../../../node_modules/.prisma/client/index.d";
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";

export async function GET(request: NextRequest) {
const { searchParams } = await new URL(request.url);
const profID = parseInt((await searchParams.get("prof")) || "1");

const courses = await prisma.course.findMany({
include: {
instructor: true,
},
where: {
instructor: {
id: profID,
},
},
});

//console.log(plans);
console.log(courses);
return NextResponse.json(courses, { status: 200 });
}
9 changes: 9 additions & 0 deletions app/api/getProfs/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";

export async function GET(request: NextRequest) {
const profs = await prisma.faculty.findMany({});

return NextResponse.json(profs, { status: 200 });
}
3 changes: 3 additions & 0 deletions app/api/getcourseplans/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";
import { auth } from "../../../lib/auth";

Expand All @@ -11,6 +12,7 @@ export async function GET(request: NextRequest) {
},
});
let courses: any;

if (user) {
courses = await prisma.coursePlan.findMany({
where: {
Expand All @@ -26,6 +28,7 @@ export async function GET(request: NextRequest) {
} else {
courses = null;
}

//console.log(plans);
return NextResponse.json(courses, { status: 200 });
}
9 changes: 5 additions & 4 deletions app/api/getplancourses/route.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// api/test.ts
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";
import { getServerSession } from "next-auth/next";
import { auth } from "../../../lib/auth";
import { getPlanCookie } from "../../../app/actions";

export async function GET(request: NextRequest) {
let planCookie: any = await getPlanCookie();
const planCookie: any = await getPlanCookie();
const session = await auth();

let courses = await prisma.coursePlan.findMany({
const courses = await prisma.coursePlan.findMany({
where: {
AND: {
User: {
Expand All @@ -23,6 +23,7 @@ export async function GET(request: NextRequest) {
courses: true,
},
});

return NextResponse.json(courses, { status: 200 });
}

Expand All @@ -33,7 +34,7 @@ export async function POST(request: NextRequest) {
const plan = data.plan;
const session = await auth();

let courses = await prisma.coursePlan.update({
const courses = await prisma.coursePlan.update({
where: {
id: parseInt(plan),
},
Expand Down
39 changes: 39 additions & 0 deletions app/api/submitReview/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";
import { auth } from "../../../lib/auth";

export async function POST(request: NextRequest) {
const data = await request.json();
const facultyID = parseInt(await data.facultyID);
const courseID = parseInt(await data.courseID);

const session = await auth();

//@ts-ignore
const user = await prisma.user.findUnique({
where: {
//@ts-ignore
uuid: session?.user?.id,
},
});
if (user?.id) {
const newReview = await prisma.rating.create({
data: {
userId: user?.id,
courseID: courseID,
facultyID: facultyID,
overallRating: data.overallRating,
difficulty: data.difficulty,
takeAgain: data.takeAgain,
forCredit: data.forCredit,
grade: data.grade,
review: data.review,
},
});
return NextResponse.json(newReview, { status: 200 });
}

//console.log(plans);
return NextResponse.json("Submission Failed, no user", { status: 500 });
}
4 changes: 3 additions & 1 deletion app/api/updatePlan/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// api/test.ts
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";
import { getServerSession } from "next-auth/next";
import { auth } from "../../../lib/auth";
import { getPlanCookie } from "../../../app/actions";

Expand Down Expand Up @@ -50,7 +50,9 @@ export async function GET(request: NextRequest) {
courses: true,
},
});

console.log(courses);

return NextResponse.json(courses, { status: 200 });
}

Expand Down
1 change: 1 addition & 0 deletions app/api/user/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// api/test.ts
import { NextResponse, NextRequest } from "next/server";

import prisma from "../../../lib/prisma";

export async function POST(request: NextRequest) {
Expand Down
25 changes: 12 additions & 13 deletions app/calendar/page.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import { title } from "../../components/primitives";
import FullCalendar from "@fullcalendar/react";
import timeGridPlugin from "@fullcalendar/timegrid"; // a plugin!
// a plugin!

import CreatePlan from "../../components/CreatePlan";
import moment from "moment";
import Calendar from "../../components/Calendar";
import prisma from "../../lib/prisma";
import { auth } from "../../lib/auth";
import { getPlanCookie } from "../actions";
import { BorderColor } from "@mui/icons-material";
import { generateColorFromName } from "../../components/primitives";
export default async function CalendarPage() {
async function getEvents() {
let output: any = [];
let planCookie: any = await getPlanCookie();
const output: any = [];
const planCookie: any = await getPlanCookie();

let courses;

if (planCookie) {
let plan = await prisma.coursePlan.findUnique({
const plan = await prisma.coursePlan.findUnique({
where: {
id: parseInt(planCookie),
},
Expand All @@ -30,10 +27,10 @@ export default async function CalendarPage() {

if (courses) {
for (let i = 0; i < courses.length; i++) {
let color = generateColorFromName(courses[i].subject);
const color = generateColorFromName(courses[i].subject);

let num: string = courses[i].courseReferenceNumber;
let meetingTimes = await prisma.meetingTime.findFirst({
const num: string = courses[i].courseReferenceNumber;
const meetingTimes = await prisma.meetingTime.findFirst({
where: {
courseReferenceNumber: num,
},
Expand Down Expand Up @@ -99,10 +96,12 @@ export default async function CalendarPage() {
maxstart?.endTime.slice(0, 2) + ":" + maxstart?.beginTime.slice(2),
};*/
console.log(maxstart);

return maxstart;
}

let events = await getEvents();
const events = await getEvents();

//let times = await getUniqueStartEndTimes();
return (
<div className="grid grid-cols-3 p-4 -mt-20 w-screen absolute start-0 px-32 gap-20">
Expand Down
2 changes: 1 addition & 1 deletion app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function Error({
}) {
useEffect(() => {
// Log the error to an error reporting service
/* eslint-disable no-console */
console.error(error);
}, [error]);

Expand Down
10 changes: 5 additions & 5 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import "../styles/globals.css";
import { Metadata, Viewport } from "next";
import { Link } from "@nextui-org/link";
import clsx from "clsx";

import { Providers } from "./providers";
import { NextAuthProvider } from "../components/providers/NextAuthProvider";
import { CookiesProvider } from "next-client-cookies/server";

import { NextAuthProvider } from "../components/providers/NextAuthProvider";
import { siteConfig } from "../config/site";
import { fontSans } from "../config/fonts";
import { Navbar } from "../components/navbar";

import { Providers } from "./providers";

export const metadata: Metadata = {
title: {
default: siteConfig.name,
Expand Down Expand Up @@ -52,14 +52,14 @@ export default function RootLayout({
defaultTheme: "dark",
}}
>
<div className="relative flex flex-col h-screen">
<div className="relative flex flex-col h-screen ">
<Navbar />
<main className="container mx-auto max-w-7xl pt-16 px-6 flex-grow">
{children}
</main>
<footer className="w-full flex items-center justify-center py-3">
<div className="columns-1 container max-w-4xl text-center">
<span className="text-xs ">
<span className="text-xs">
The Course Planner is a student-run service, and displays
classes from the Tri-College course database. We recommend
confirming your schedule with the official course listings
Expand Down
13 changes: 13 additions & 0 deletions app/login/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function DocsLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<section className="flex flex-col items-center justify-center gap-4 max-h-[75vh] -mt-5 ">
<div className="inline-block max-w-lg text-center justify-center overflow-scroll rounded-lg scrollbar-hide">
{children}
</div>
</section>
);
}
20 changes: 18 additions & 2 deletions app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
export default async function LoginPage() {
return <div className="">login</div>;
"use client";
import { Card } from "@nextui-org/react";
import { title } from "../../components/primitives";
export default function LoginPage() {
return (
<div className="w-5/6 justify-center text-center ml-auto mr-auto grid gap-10">
<div className="text-7xl">Welcome to the</div>
<div className={title({ size: "lg", color: "logo" })}>SCCS</div>
<div className={title({ size: "lg" })}>Course Planner&nbsp;</div>
<div className={title({ size: "sm" })}>Version 2.0&nbsp;</div>

<div className="text-xl">
Please excuse us as we polish some remaining bugs, but feel free to
explore and plan your classes! If you have suggestions or feedback,
please email [email protected].
</div>
</div>
);
}
Loading

0 comments on commit 67cf9c5

Please sign in to comment.