Skip to content

Commit

Permalink
Changed all tables with rmp data
Browse files Browse the repository at this point in the history
changed tables with rmp data
  • Loading branch information
George-Zhang5246 committed Nov 8, 2024
1 parent 1f573a5 commit 7a09c54
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/basic-features/typescript for more information.
13 changes: 8 additions & 5 deletions src/components/common/CompareTable/compareTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,14 @@ function GradeAndRmpRow({
<Typography className="text-base">{loadingFiller}</Typography>
</Skeleton>
)) ||
(rmp.state === 'done' && (
<Typography className="text-base inline">
{getRmpValue(rmp.data as RMPInterface)}
</Typography>
)) ||
(rmp.state === 'done' &&
getRmpValue(rmp.data as RMPInterface) == 0 && <CloseIcon />) ||
(rmp.state === 'done' &&
getRmpValue(rmp.data as RMPInterface) != 0 && (
<Typography className="text-base inline">
{getRmpValue(rmp.data as RMPInterface)}
</Typography>
)) ||
null}
</TableCell>
))}
Expand Down
11 changes: 6 additions & 5 deletions src/components/common/SearchResultsTable/searchResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ function Row({
<Rating sx={{ fontSize: 25 }} readOnly />
</Skeleton>
)) ||
(rmp.state === 'done' && (
(rmp.state === 'done' && rmp.data.numRatings == 0 && <></>) ||
(rmp.state === 'done' && rmp.data.numRatings != 0 && (
<Tooltip
title={'Professor rating: ' + rmp.data.avgRating}
placement="top"
Expand Down Expand Up @@ -393,16 +394,16 @@ const SearchResultsTable = ({
const bRmp = rmp[searchQueryLabel(convertToProfOnly(b))];
//drop loading/error rows to bottom
if (
(!aRmp || aRmp.state !== 'done') &&
(!bRmp || bRmp.state !== 'done')
(!aRmp || aRmp.state !== 'done' || aRmp.data.numRatings == 0) &&
(!bRmp || bRmp.state !== 'done' || bRmp.data.numRatings == 0)
) {
// If both aRmp and bRmp are not done, treat them as equal and return 0
return 0;
}
if (!aRmp || aRmp.state !== 'done') {
if (!aRmp || aRmp.state !== 'done' || aRmp.data.numRatings == 0) {
return 9999;
}
if (!bRmp || bRmp.state !== 'done') {
if (!bRmp || bRmp.state !== 'done' || bRmp.data.numRatings == 0) {
return -9999;
}
const aRating = aRmp?.data?.avgRating ?? 0; // Fallback to 0 if undefined
Expand Down
23 changes: 23 additions & 0 deletions src/components/common/SingleProfInfo/singleProfInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ function SingleProfInfo({ rmp }: Props) {
</Grid>
);
}
if (rmp.data.numRatings == 0) {
return (
<Grid container spacing={2} className="p-4">
<Grid item xs={6}>
<p className="text-xl font-bold">
{rmp.data.numRatings.toLocaleString()}
</p>
<p>Ratings given</p>
</Grid>
<Grid item xs={12}>
<Link
href={
'https://www.ratemyprofessors.com/professor/' + rmp.data.legacyId
}
target="_blank"
className="underline text-blue-600 hover:text-blue-800 visited:text-purple-600"
>
Visit Rate My Professors
</Link>
</Grid>
</Grid>
);
}
return (
<Grid container spacing={2} className="p-4">
<Grid item xs={6}>
Expand Down

0 comments on commit 7a09c54

Please sign in to comment.