+
+
+ Filmography
+
+
+
+
+
+
- {person.filmography.map(item => (
+ {sortedFilmography.map(item => (
handleMediaClick(item.id.toString())}
diff --git a/src/components/CastView.tsx b/src/components/CastView.tsx
index 6c1062f..d762aed 100644
--- a/src/components/CastView.tsx
+++ b/src/components/CastView.tsx
@@ -22,11 +22,11 @@ export default function CastView({ onPersonClick, enabledCategories, itemsPerPag
const [searchQuery, setSearchQuery] = useState(() => {
return localStorage.getItem('castSearchQuery') || '';
});
- const [sortBy, setSortBy] = useState<'name' | 'role' | 'birthDate' | 'height'>(() => {
- return (localStorage.getItem('castSortBy') as 'name' | 'role' | 'birthDate' | 'height') || 'name';
+ const [sortBy, setSortBy] = useState<'name' | 'role' | 'birthDate' | 'height' | 'roleCount'>(() => {
+ return (localStorage.getItem('castSortBy') as 'name' | 'role' | 'birthDate' | 'height' | 'roleCount') || 'roleCount';
});
const [sortOrder, setSortOrder] = useState<'asc' | 'desc'>(() => {
- return (localStorage.getItem('castSortOrder') as 'asc' | 'desc') || 'asc';
+ return (localStorage.getItem('castSortOrder') as 'asc' | 'desc') || 'desc';
});
const [filterOccupation, setFilterOccupation] = useState(() => {
return localStorage.getItem('castFilterOccupation') || '';
@@ -68,13 +68,13 @@ export default function CastView({ onPersonClick, enabledCategories, itemsPerPag
const handleResetFilters = () => {
setSearchQuery('');
- setSortBy('name');
- setSortOrder('asc');
+ setSortBy('roleCount');
+ setSortOrder('desc');
setFilterOccupation('');
setFilterMediaType('');
};
- const hasActiveFilters = searchQuery || filterOccupation || filterMediaType || sortBy !== 'name' || sortOrder !== 'asc';
+ const hasActiveFilters = searchQuery || filterOccupation || filterMediaType || sortBy !== 'roleCount' || sortOrder !== 'desc';
useEffect(() => {
const loadCast = async () => {
@@ -137,6 +137,10 @@ export default function CastView({ onPersonClick, enabledCategories, itemsPerPag
const heightA = a.height || 0;
const heightB = b.height || 0;
comparison = heightA - heightB;
+ } else if (sortBy === 'roleCount') {
+ const roleCountA = a.filmography?.length || 0;
+ const roleCountB = b.filmography?.length || 0;
+ comparison = roleCountA - roleCountB;
}
return sortOrder === 'desc' ? -comparison : comparison;
@@ -247,6 +251,7 @@ export default function CastView({ onPersonClick, enabledCategories, itemsPerPag
+
@@ -345,7 +350,7 @@ export default function CastView({ onPersonClick, enabledCategories, itemsPerPag
referrerPolicy="no-referrer"
/>
-
+
{person.name}
@@ -353,6 +358,11 @@ export default function CastView({ onPersonClick, enabledCategories, itemsPerPag
{person.role}
+ {person.filmography && person.filmography.length > 0 && (
+
+ {person.filmography.length}
+
+ )}
{person.filmography && person.filmography.length > 0 && (