-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
475eef5
commit 8cc1fd6
Showing
9 changed files
with
176 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <div> {slug}</div>; | ||
const [ratings, setRatings] = useState<Rating[]>([]); | ||
|
||
const getData = useCallback(async () => { | ||
const slug = (await params).profuid; | ||
const theratings = await getRatings(slug); | ||
setRatings(theratings); | ||
}, []); | ||
|
||
useEffect(() => { | ||
getData(); | ||
}, [getData]); | ||
|
||
return ( | ||
<div className="px-2 mt-4"> | ||
{ratings?.map((rating: Rating) => ( | ||
<Card key={rating.id}> | ||
<CardHeader className="font-semibold"> | ||
{rating.courseSubject} {rating.courseNumber} | ||
</CardHeader> | ||
|
||
<CardBody> | ||
<div>Overall: </div> | ||
<StarRating | ||
className="ml-5" | ||
name="overall Rating" | ||
value={rating.overallRating} | ||
precision={1} | ||
readOnly | ||
emptyIcon={ | ||
<Star | ||
style={{ opacity: 0.8, color: "grey" }} | ||
fontSize="inherit" | ||
/> | ||
} | ||
/> | ||
|
||
<div>Difficulty: </div> | ||
<StarRating | ||
className="ml-5" | ||
name="overall Rating" | ||
value={rating.difficulty} | ||
precision={1} | ||
readOnly | ||
emptyIcon={ | ||
<Star | ||
style={{ opacity: 0.8, color: "grey" }} | ||
fontSize="inherit" | ||
/> | ||
} | ||
/> | ||
<div className="mt-10">{rating.review}</div> | ||
</CardBody> | ||
</Card> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters