Skip to content

Commit

Permalink
Handle N/A or Null for individual RMP data
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiramTadepalli committed Nov 27, 2024
1 parent 7e57b6d commit d318103
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/components/common/SingleProfInfo/singleProfInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,20 @@ function SingleProfInfo({ rmp }: Props) {
return (
<Grid container spacing={2} className="p-4">
<Grid size={6}>
<p className="text-xl font-bold">{rmp.data.avgRating}</p>
<p className="text-xl font-bold">
{typeof rmp.data.avgRating !== undefined && rmp.data.avgRating > 0
? rmp.data.avgRating
: 'N/A'}
</p>
<p>Professor rating</p>
</Grid>
<Grid size={6}>
<p className="text-xl font-bold">{rmp.data.avgDifficulty}</p>
<p className="text-xl font-bold">
{typeof rmp.data.avgDifficulty !== undefined &&
rmp.data.avgDifficulty > 0
? rmp.data.avgDifficulty
: 'N/A'}
</p>
<p>Difficulty</p>
</Grid>
<Grid size={6}>
Expand All @@ -131,7 +140,10 @@ function SingleProfInfo({ rmp }: Props) {
</Grid>
<Grid size={6}>
<p className="text-xl font-bold">
{rmp.data.wouldTakeAgainPercent.toFixed(0) + '%'}
{typeof rmp.data.wouldTakeAgainPercent !== undefined &&
rmp.data.wouldTakeAgainPercent > 0
? rmp.data.wouldTakeAgainPercent.toFixed(0) + '%'
: 'N/A'}
</p>
<p>Would take again</p>
</Grid>
Expand Down

0 comments on commit d318103

Please sign in to comment.