diff --git a/src/components/PersonDetails/index.tsx b/src/components/PersonDetails/index.tsx index 7eb32fa0b..e0a44d4f5 100644 --- a/src/components/PersonDetails/index.tsx +++ b/src/components/PersonDetails/index.tsx @@ -44,30 +44,18 @@ const PersonDetails: React.FC = () => { } const sortedCast = combinedCredits?.cast.sort((a, b) => { - const aDate = - a.mediaType === 'movie' - ? a.releaseDate?.slice(0, 4) ?? 0 - : a.firstAirDate?.slice(0, 4) ?? 0; - const bDate = - b.mediaType === 'movie' - ? b.releaseDate?.slice(0, 4) ?? 0 - : b.firstAirDate?.slice(0, 4) ?? 0; - if (aDate > bDate) { + const aVotes = a.voteCount ?? 0; + const bVotes = b.voteCount ?? 0; + if (aVotes > bVotes) { return -1; } return 1; }); const sortedCrew = combinedCredits?.crew.sort((a, b) => { - const aDate = - a.mediaType === 'movie' - ? a.releaseDate?.slice(0, 4) ?? 0 - : a.firstAirDate?.slice(0, 4) ?? 0; - const bDate = - b.mediaType === 'movie' - ? b.releaseDate?.slice(0, 4) ?? 0 - : b.firstAirDate?.slice(0, 4) ?? 0; - if (aDate > bDate) { + const aVotes = a.voteCount ?? 0; + const bVotes = b.voteCount ?? 0; + if (aVotes > bVotes) { return -1; } return 1; @@ -75,6 +63,94 @@ const PersonDetails: React.FC = () => { const isLoading = !combinedCredits && !errorCombinedCredits; + const cast = (sortedCast ?? []).length > 0 && ( + <> +