From ee7a23f47549772248cff4a9788b0ef11cc47b7c Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Sat, 14 Dec 2024 20:18:11 -0600 Subject: [PATCH] Changes for null data For #68 and #76 --- src/components/CourseOverview.tsx | 2 +- src/components/SearchResultsTable.tsx | 11 ++++---- src/components/SingleProfInfo.tsx | 37 ++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/components/CourseOverview.tsx b/src/components/CourseOverview.tsx index 15ee147..2c72547 100644 --- a/src/components/CourseOverview.tsx +++ b/src/components/CourseOverview.tsx @@ -14,7 +14,7 @@ const CourseOverview = ({ header, grades }: CourseOverviewProps) => { const isCourse = typeof header !== 'string'; return (
-

+

{isCourse ? searchQueryLabel(header) : header}

{isCourse && ( diff --git a/src/components/SearchResultsTable.tsx b/src/components/SearchResultsTable.tsx index 4d94dbe..8ce448d 100644 --- a/src/components/SearchResultsTable.tsx +++ b/src/components/SearchResultsTable.tsx @@ -226,7 +226,8 @@ function Row({ )) || - (rmp.state === 'done' && ( + (rmp.state === 'done' && rmp.data.numRatings == 0 && <>) || + (rmp.state === 'done' && rmp.data.numRatings != 0 && ( + +

+ {rmp.data.numRatings.toLocaleString()} +

+

Ratings given

+
+ + + Visit Rate My Professors + + + + ); + } + const topTags = rmp.data.teacherRatingTags.sort( (a, b) => b.tagCount - a.tagCount, ); @@ -61,11 +86,15 @@ function SingleProfInfo({ rmp }: Props) { return ( -

{rmp.data.avgRating}

+

+ {rmp.data.avgRating > 0 ? rmp.data.avgRating : 'N/A'} +

Professor rating

-

{rmp.data.avgDifficulty}

+

+ {rmp.data.avgDifficulty > 0 ? rmp.data.avgDifficulty : 'N/A'} +

Difficulty

@@ -76,7 +105,9 @@ function SingleProfInfo({ rmp }: Props) {

- {rmp.data.wouldTakeAgainPercent.toFixed(0) + '%'} + {rmp.data.wouldTakeAgainPercent > 0 + ? rmp.data.wouldTakeAgainPercent.toFixed(0) + '%' + : 'N/A'}

Would take again