Normalize to double quotes across all files with Prettier
This commit is contained in:
1 parent
73bff72cec
commit
a5659cf4c8
190 files changed
+9523
-8859
No files matched your search
@@ -1,30 +1,37 @@
|
||||
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate, useLocation } from "react-router-dom";
|
||||
import { useState, useEffect } from "react";
|
||||
import {
|
||||
usePerson,
|
||||
usePersonTmdbFilmography,
|
||||
useUpdatePerson,
|
||||
useTmdbPersonPreview,
|
||||
useFetchPersonByTmdbId,
|
||||
} from '@/hooks/usePeople';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { EntryCard } from '@/components/entries/EntryCard';
|
||||
import { getProfileUrl, formatDate } from '@/lib/media-utils';
|
||||
import { ChevronLeft, ChevronRight, Heart, Plus, Loader2, ExternalLink } from 'lucide-react';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
import type { TmdbFilmographyItem } from '@/api/people';
|
||||
} from "@/hooks/usePeople";
|
||||
import { useLibrary } from "@/hooks/useEntries";
|
||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { EntryCard } from "@/components/entries/EntryCard";
|
||||
import { getProfileUrl, formatDate } from "@/lib/media-utils";
|
||||
import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
Heart,
|
||||
Plus,
|
||||
Loader2,
|
||||
ExternalLink,
|
||||
} from "lucide-react";
|
||||
import type { TmdbEntry } from "@/types";
|
||||
import type { TmdbFilmographyItem } from "@/api/people";
|
||||
|
||||
const TMDB_IMG = 'https://image.tmdb.org/t/p';
|
||||
const TMDB_IMG = "https://image.tmdb.org/t/p";
|
||||
|
||||
export function PersonDetailsPage() {
|
||||
const { id, tmdbId } = useParams<{ id?: string; tmdbId?: string }>();
|
||||
const location = useLocation();
|
||||
const isTmdbMode = location.pathname.startsWith('/people/tmdb/');
|
||||
const isTmdbMode = location.pathname.startsWith("/people/tmdb/");
|
||||
|
||||
if (isTmdbMode && tmdbId) {
|
||||
return <TmdbPersonView tmdbId={parseInt(tmdbId, 10)} />;
|
||||
@@ -38,7 +45,8 @@ export function PersonDetailsPage() {
|
||||
function LocalPersonView({ personId }: { personId: number }) {
|
||||
const navigate = useNavigate();
|
||||
const { data: person, isLoading, isError } = usePerson(personId);
|
||||
const { data: tmdbFilmography, isLoading: tmdbLoading } = usePersonTmdbFilmography(personId);
|
||||
const { data: tmdbFilmography, isLoading: tmdbLoading } =
|
||||
usePersonTmdbFilmography(personId);
|
||||
const updatePerson = useUpdatePerson();
|
||||
useLibrary();
|
||||
const libraryMap = useLibraryStore((s) => s.entries);
|
||||
@@ -51,7 +59,7 @@ function LocalPersonView({ personId }: { personId: number }) {
|
||||
<p className="text-sm text-muted-foreground">
|
||||
This person could not be loaded. They may not exist in the database.
|
||||
</p>
|
||||
<Button variant="outline" onClick={() => navigate('/people')}>
|
||||
<Button variant="outline" onClick={() => navigate("/people")}>
|
||||
Back to People
|
||||
</Button>
|
||||
</div>
|
||||
@@ -66,9 +74,15 @@ function LocalPersonView({ personId }: { personId: number }) {
|
||||
<div className="space-y-8 animate-page-enter">
|
||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start sm:gap-8">
|
||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
||||
<AvatarImage src={getProfileUrl(person.profile_path)} alt={person.name} />
|
||||
<AvatarImage
|
||||
src={getProfileUrl(person.profile_path)}
|
||||
alt={person.name}
|
||||
/>
|
||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
||||
{person.name.split(' ').map((n: string) => n[0]).join('')}
|
||||
{person.name
|
||||
.split(" ")
|
||||
.map((n: string) => n[0])
|
||||
.join("")}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
||||
@@ -78,10 +92,17 @@ function LocalPersonView({ personId }: { personId: number }) {
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 shrink-0"
|
||||
onClick={() => updatePerson.mutate({ id: person.id, data: { favorite: !person.favorite } })}
|
||||
onClick={() =>
|
||||
updatePerson.mutate({
|
||||
id: person.id,
|
||||
data: { favorite: !person.favorite },
|
||||
})
|
||||
}
|
||||
disabled={updatePerson.isPending}
|
||||
>
|
||||
<Heart className={`h-5 w-5 ${person.favorite ? 'fill-red-500 text-red-500' : 'text-muted-foreground'}`} />
|
||||
<Heart
|
||||
className={`h-5 w-5 ${person.favorite ? "fill-red-500 text-red-500" : "text-muted-foreground"}`}
|
||||
/>
|
||||
</Button>
|
||||
</div>
|
||||
<PersonMeta
|
||||
@@ -135,7 +156,9 @@ function TmdbPersonView({ tmdbId }: { tmdbId: number }) {
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Could not load person data from TMDB.
|
||||
</p>
|
||||
<Button variant="outline" onClick={() => navigate(-1)}>Go back</Button>
|
||||
<Button variant="outline" onClick={() => navigate(-1)}>
|
||||
Go back
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -167,19 +190,26 @@ function TmdbPersonView({ tmdbId }: { tmdbId: number }) {
|
||||
<Avatar className="h-32 w-32 shrink-0 sm:h-48 sm:w-48">
|
||||
<AvatarImage src={profileUrl} alt={preview.name} />
|
||||
<AvatarFallback className="text-2xl sm:text-3xl">
|
||||
{preview.name.split(' ').map((n: string) => n[0]).join('')}
|
||||
{preview.name
|
||||
.split(" ")
|
||||
.map((n: string) => n[0])
|
||||
.join("")}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="space-y-2 text-center sm:text-left sm:space-y-3">
|
||||
<div className="flex items-center gap-3 justify-center sm:justify-start">
|
||||
<h1 className="text-2xl font-bold sm:text-3xl">{preview.name}</h1>
|
||||
<Button onClick={handleAddToLibrary} disabled={fetchPerson.isPending} size="sm">
|
||||
<Button
|
||||
onClick={handleAddToLibrary}
|
||||
disabled={fetchPerson.isPending}
|
||||
size="sm"
|
||||
>
|
||||
{fetchPerson.isPending ? (
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
)}
|
||||
{fetchPerson.isPending ? 'Adding...' : 'Add to Library'}
|
||||
{fetchPerson.isPending ? "Adding..." : "Add to Library"}
|
||||
</Button>
|
||||
</div>
|
||||
<PersonMeta
|
||||
@@ -227,9 +257,24 @@ function PersonMeta({
|
||||
return (
|
||||
<div className="flex flex-wrap items-center justify-center gap-2 text-sm text-muted-foreground sm:justify-start sm:gap-3">
|
||||
{known_for_department && <span>{known_for_department}</span>}
|
||||
{birthday && (<><span>•</span><span>Born: {formatDate(birthday)}</span></>)}
|
||||
{deathday && (<><span>•</span><span>Died: {formatDate(deathday)}</span></>)}
|
||||
{place_of_birth && (<><span>•</span><span>{place_of_birth}</span></>)}
|
||||
{birthday && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Born: {formatDate(birthday)}</span>
|
||||
</>
|
||||
)}
|
||||
{deathday && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>Died: {formatDate(deathday)}</span>
|
||||
</>
|
||||
)}
|
||||
{place_of_birth && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>{place_of_birth}</span>
|
||||
</>
|
||||
)}
|
||||
{tmdb_id && (
|
||||
<>
|
||||
<span>•</span>
|
||||
@@ -266,17 +311,26 @@ function PersonSkeleton() {
|
||||
/* ─── Filmography ─── */
|
||||
|
||||
interface FilmographySectionProps {
|
||||
libraryMap: Map<number, import('@/types').Entry>;
|
||||
libraryMap: Map<number, import("@/types").Entry>;
|
||||
libraryLoaded: boolean;
|
||||
tmdbFilmography?: { cast: TmdbFilmographyItem[]; crew: TmdbFilmographyItem[] };
|
||||
tmdbFilmography?: {
|
||||
cast: TmdbFilmographyItem[];
|
||||
crew: TmdbFilmographyItem[];
|
||||
};
|
||||
tmdbLoading: boolean;
|
||||
}
|
||||
|
||||
function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLoading }: FilmographySectionProps) {
|
||||
function FilmographySection({
|
||||
libraryMap,
|
||||
libraryLoaded,
|
||||
tmdbFilmography,
|
||||
tmdbLoading,
|
||||
}: FilmographySectionProps) {
|
||||
const [libraryPage, setLibraryPage] = useState(0);
|
||||
const [otherPage, setOtherPage] = useState(0);
|
||||
const PAGE_SIZE = 6; // 6 cols × 1 row
|
||||
const GRID = 'grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6';
|
||||
const GRID =
|
||||
"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6";
|
||||
|
||||
if (tmdbLoading || !libraryLoaded) {
|
||||
return (
|
||||
@@ -293,7 +347,9 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
|
||||
const allTmdbCredits = [
|
||||
...(tmdbFilmography?.cast ?? []),
|
||||
...(tmdbFilmography?.crew?.filter((c) => c.job === 'Director' || c.department === 'Directing') ?? []),
|
||||
...(tmdbFilmography?.crew?.filter(
|
||||
(c) => c.job === "Director" || c.department === "Directing",
|
||||
) ?? []),
|
||||
];
|
||||
const seenTmdbIds = new Set<number>();
|
||||
const dedupedCredits = allTmdbCredits.filter((c) => {
|
||||
@@ -302,7 +358,7 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
return true;
|
||||
});
|
||||
|
||||
const tmdbIdToLibraryEntry = new Map<number, import('@/types').Entry>();
|
||||
const tmdbIdToLibraryEntry = new Map<number, import("@/types").Entry>();
|
||||
for (const entry of libraryMap.values()) {
|
||||
if (entry.entryIds?.tmdb_id != null) {
|
||||
tmdbIdToLibraryEntry.set(Number(entry.entryIds.tmdb_id), entry);
|
||||
@@ -310,14 +366,23 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
}
|
||||
|
||||
// Sort by popularity descending
|
||||
const sorted = [...dedupedCredits].sort((a, b) => (b.popularity ?? 0) - (a.popularity ?? 0));
|
||||
const sorted = [...dedupedCredits].sort(
|
||||
(a, b) => (b.popularity ?? 0) - (a.popularity ?? 0),
|
||||
);
|
||||
const libraryCredits = sorted.filter((c) => tmdbIdToLibraryEntry.has(c.id));
|
||||
|
||||
// "Not in library": sort by release date (new→old), push "self" roles to the end
|
||||
const isSelfRole = (character?: string) => {
|
||||
if (!character) return false;
|
||||
const lower = character.toLowerCase().trim();
|
||||
return lower === 'self' || lower.startsWith('self -') || lower.startsWith('self (') || lower === 'themselves' || lower === 'himself' || lower === 'herself';
|
||||
return (
|
||||
lower === "self" ||
|
||||
lower.startsWith("self -") ||
|
||||
lower.startsWith("self (") ||
|
||||
lower === "themselves" ||
|
||||
lower === "himself" ||
|
||||
lower === "herself"
|
||||
);
|
||||
};
|
||||
const otherCreditsSorted = sorted
|
||||
.filter((c) => !tmdbIdToLibraryEntry.has(c.id))
|
||||
@@ -326,8 +391,12 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
const bSelf = isSelfRole(b.character) ? 1 : 0;
|
||||
if (aSelf !== bSelf) return aSelf - bSelf;
|
||||
// Both same self status → sort by date descending (new first)
|
||||
const dateA = new Date(a.release_date || a.first_air_date || '1900').getTime();
|
||||
const dateB = new Date(b.release_date || b.first_air_date || '1900').getTime();
|
||||
const dateA = new Date(
|
||||
a.release_date || a.first_air_date || "1900",
|
||||
).getTime();
|
||||
const dateB = new Date(
|
||||
b.release_date || b.first_air_date || "1900",
|
||||
).getTime();
|
||||
return dateB - dateA;
|
||||
});
|
||||
const otherCredits = otherCreditsSorted;
|
||||
@@ -341,8 +410,14 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
);
|
||||
}
|
||||
|
||||
const librarySlice = libraryCredits.slice(libraryPage * PAGE_SIZE, (libraryPage + 1) * PAGE_SIZE);
|
||||
const otherSlice = otherCredits.slice(otherPage * PAGE_SIZE, (otherPage + 1) * PAGE_SIZE);
|
||||
const librarySlice = libraryCredits.slice(
|
||||
libraryPage * PAGE_SIZE,
|
||||
(libraryPage + 1) * PAGE_SIZE,
|
||||
);
|
||||
const otherSlice = otherCredits.slice(
|
||||
otherPage * PAGE_SIZE,
|
||||
(otherPage + 1) * PAGE_SIZE,
|
||||
);
|
||||
const libraryTotalPages = Math.ceil(libraryCredits.length / PAGE_SIZE);
|
||||
const otherTotalPages = Math.ceil(otherCredits.length / PAGE_SIZE);
|
||||
|
||||
@@ -359,7 +434,9 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
{libraryTotalPages > 1 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost" size="icon" className="h-7 w-7"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={libraryPage === 0}
|
||||
onClick={() => setLibraryPage((p) => p - 1)}
|
||||
>
|
||||
@@ -369,7 +446,9 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
{libraryPage + 1}/{libraryTotalPages}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost" size="icon" className="h-7 w-7"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={libraryPage === libraryTotalPages - 1}
|
||||
onClick={() => setLibraryPage((p) => p + 1)}
|
||||
>
|
||||
@@ -385,7 +464,9 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
<div key={credit.id} className="space-y-1">
|
||||
<EntryCard entry={entry} />
|
||||
{credit.character && (
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">{credit.character}</p>
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">
|
||||
{credit.character}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -403,7 +484,9 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
{otherTotalPages > 1 && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
variant="ghost" size="icon" className="h-7 w-7"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={otherPage === 0}
|
||||
onClick={() => setOtherPage((p) => p - 1)}
|
||||
>
|
||||
@@ -413,7 +496,9 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
{otherPage + 1}/{otherTotalPages}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost" size="icon" className="h-7 w-7"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-7 w-7"
|
||||
disabled={otherPage === otherTotalPages - 1}
|
||||
onClick={() => setOtherPage((p) => p + 1)}
|
||||
>
|
||||
@@ -433,7 +518,7 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
release_date: credit.release_date,
|
||||
first_air_date: credit.first_air_date,
|
||||
media_type: credit.media_type,
|
||||
overview: '',
|
||||
overview: "",
|
||||
vote_average: 0,
|
||||
vote_count: 0,
|
||||
genre_ids: [],
|
||||
@@ -443,7 +528,9 @@ function FilmographySection({ libraryMap, libraryLoaded, tmdbFilmography, tmdbLo
|
||||
<div key={credit.id} className="space-y-1">
|
||||
<EntryCard tmdbEntry={tmdbEntry} />
|
||||
{credit.character && (
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">{credit.character}</p>
|
||||
<p className="text-xs text-muted-foreground text-center line-clamp-1 px-1">
|
||||
{credit.character}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user