Skip to content

Commit

Permalink
Merge pull request #124 from SJSUCSClub/123-bug-add-no-data-response-…
Browse files Browse the repository at this point in the history
…for-profile

[Bug] added no data state for profile page
  • Loading branch information
chrehall68 authored Oct 11, 2024
2 parents 5a764ad + 3b0871c commit 010598b
Showing 1 changed file with 40 additions and 28 deletions.
68 changes: 40 additions & 28 deletions app/(main)/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export default async function Page({
</ParamSelect>
</div>
<div className="flex flex-1 flex-col items-stretch gap-md pb-lg">
{searchParams.view === 'votes'
? data.reviews_voted.map((item, i) => (
{searchParams.view === 'votes' ? (
data.reviews_voted.length > 0 ? (
data.reviews_voted.map((item, i) => (
<Review
key={i}
link={`/professors/${item.professor_id}`}
Expand All @@ -59,32 +60,43 @@ export default async function Page({
courseId={`${item.department}-${item.course_number}`}
/>
))
: data.reviews.map((item, i) => (
<Review
key={i}
link={`/professors/${item.professor_id}`}
title={item.professor_name}
name={
item.reviewer_name ??
item.reviewer_username ??
'Anonymous User'
}
createdAt={item.created_at}
updatedAt={item.updated_at}
content={item.content}
quality={item.quality}
ease={item.ease}
grade={item.grade}
tags={item.tags}
takeAgain={item.take_again}
votes={item.votes}
userId={item.user_id}
id={item.id.toString()}
userVote={item.user_vote}
professorId={item.professor_id}
courseId={`${item.department}-${item.course_number}`}
/>
))}
) : (
<p className="w-full p-md text-center italic text-neutral">
You haven&apos;t written any reviews.
</p>
)
) : data.reviews.length > 0 ? (
data.reviews.map((item, i) => (
<Review
key={i}
link={`/professors/${item.professor_id}`}
title={item.professor_name}
name={
item.reviewer_name ??
item.reviewer_username ??
'Anonymous User'
}
createdAt={item.created_at}
updatedAt={item.updated_at}
content={item.content}
quality={item.quality}
ease={item.ease}
grade={item.grade}
tags={item.tags}
takeAgain={item.take_again}
votes={item.votes}
userId={item.user_id}
id={item.id.toString()}
userVote={item.user_vote}
professorId={item.professor_id}
courseId={`${item.department}-${item.course_number}`}
/>
))
) : (
<p className="w-full p-md text-center italic text-neutral">
You haven&apos;t interacted with any reviews.
</p>
)}
</div>
</section>
</main>
Expand Down

0 comments on commit 010598b

Please sign in to comment.