diff --git a/app/actions/getRatings.ts b/app/actions/getRatings.ts new file mode 100644 index 0000000..996a961 --- /dev/null +++ b/app/actions/getRatings.ts @@ -0,0 +1,19 @@ +"use server"; + +import { cookies } from "next/headers"; +import prisma from "../../lib/prisma"; +import { Prisma } from "@prisma/client"; +import { auth } from "@/lib/auth"; +import { getPlanCookie } from "./actions"; +import { Faculty, Rating } from "@prisma/client"; + +export async function getRatings(profUid: any) { + let profs: Rating[] = []; + let ratings = await prisma.rating.findMany({ + where: { + profUid: profUid, + }, + }); + + return ratings; +} diff --git a/app/calendar/page.tsx b/app/calendar/page.tsx index 947a25c..4900c4f 100644 --- a/app/calendar/page.tsx +++ b/app/calendar/page.tsx @@ -120,11 +120,11 @@ export default async function CalendarPage() { //let times = await getUniqueStartEndTimes(); return ( -
-
+
+
-
+
diff --git a/app/page.tsx b/app/page.tsx index 43564af..7222e56 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -91,7 +91,12 @@ async function Home(props: any) { } > - +
@@ -100,7 +105,7 @@ async function Home(props: any) {
-
+
{props.fullCourseList}
diff --git a/app/profratings/[profuid]/page.tsx b/app/profratings/[profuid]/page.tsx index 9382c56..a02e186 100644 --- a/app/profratings/[profuid]/page.tsx +++ b/app/profratings/[profuid]/page.tsx @@ -1,8 +1,81 @@ -export default async function Page({ +"use client"; +import { + Button, + Card, + CardBody, + CardHeader, + Chip, + Divider, +} from "@nextui-org/react"; +import Star from "@mui/icons-material/Star"; +import Image from "next/image"; + +import { useCallback, useEffect, useState } from "react"; +import { useRouter } from "next/navigation"; +import { Faculty, Rating } from "@prisma/client"; +import { getProfs, getNumRatings } from "app/actions/getProfs"; +import { getRatings } from "app/actions/getRatings"; +import StarRating from "@mui/material/Rating"; + +export default function Page({ params, }: { params: Promise<{ profuid: string }>; }) { - const slug = (await params).profuid; - return
{slug}
; + const [ratings, setRatings] = useState([]); + + const getData = useCallback(async () => { + const slug = (await params).profuid; + const theratings = await getRatings(slug); + setRatings(theratings); + }, []); + + useEffect(() => { + getData(); + }, [getData]); + + return ( +
+ {ratings?.map((rating: Rating) => ( + + + {rating.courseSubject} {rating.courseNumber} + + + +
Overall:
+ + } + /> + +
Difficulty:
+ + } + /> +
{rating.review}
+
+
+ ))} +
+ ); } diff --git a/app/profs/page.tsx b/app/profs/page.tsx index a8c2fe8..7354581 100644 --- a/app/profs/page.tsx +++ b/app/profs/page.tsx @@ -49,7 +49,7 @@ export default function ProfPage() { return ( <> -
+
{profs?.map((prof: any) => )}
diff --git a/components/Filters.tsx b/components/Filters.tsx index 95e1b6e..6b9c89c 100644 --- a/components/Filters.tsx +++ b/components/Filters.tsx @@ -54,6 +54,7 @@ export default function Filters(props: any) { ); const handleSelectionChange = (e: any) => { + console.log(e.target.value); setSelectedTerm([e.target.value]); if (e.target.value) { @@ -140,18 +141,18 @@ export default function Filters(props: any) { const firstLoad = useCallback(async () => { let termCookie = cookies.get("termCookie"); let searchTermCookie = cookies.get("searchTermCookie"); - setSelectedTerm(searchParams.get("term")?.toString().split(",")); + setdotw(searchParams.get("dotw")?.toString().split(",")); // setSelectedStartTime(searchParams.get("stime")?.toString().split(",")); if (!termCookie) { cookies.set("termCookie", "S2025"); params.set("term", "S2025"); replace(`${pathname}?${params.toString()}`); - setSelectedTerm(searchParams.get("term")?.toString().split(",")); + setSelectedTerm(["S2025"]); } else { params.set("term", termCookie); - replace(`${pathname}?${params.toString()}`); - setSelectedTerm(searchParams.get("term")?.toString().split(",")); + await replace(`${pathname}?${params.toString()}`); + setSelectedTerm([termCookie]); } }, []); @@ -162,13 +163,12 @@ export default function Filters(props: any) { return ( <> -
+