feat: entry details overhaul, navigation, rating half-stars, library growth "all", accuracy field
- SeasonPage: add back navigation link to entry details page - EpisodePage: add breadcrumb navigation back to entry and season pages - EntryCard: non-library entries now open a details dialog on click with overview, rating, and add-to-library button - EntryDetailsPage: move favorite and mark-watched buttons into grouped dropdown menu with separators - EntryDetailsPage: add favorite badge (heart icon) on top-left of poster - EntryDetailsPage: add "mark as watched" clickable text next to runtime for unwatched movies - EntryDetailsPage: genre pills are now clickable links that navigate to library page with genre filter - EntryDetailsPage: hide status pill for movies; show status as text next to release date for TV series - EntryDetailsPage: add delete entry option in dropdown menu with confirmation dialog and redirect to library - EntryDetailsPage: add TMDB and IMDb external links under poster using entry.entryIds - EntryDetailsPage: group all dropdown actions by relevance (Watch/Rate, Organize, Manage, Danger) with separators - RatingDialog: support half-star ratings (0.5 increments) with left/right click zones per star - RatingDialog: fix clear rating button by syncing state on dialog open and using dedicated handleClear function - LibraryGrowthChart: add "All" option to year selector (default) showing cumulative growth across all years - Frontend: add SeenAccuracy type to types/index.ts, update API layers and hooks to support accuracy - EntrySeenDialog: add Date Accuracy selector (Exact/Estimated/Unknown) with EXACT default - EpisodeSeenEditDialog: add Date Accuracy selector, updated overrideSubmit signature - SeasonPage: pass accuracy through bulk mark-all-watched flow
This commit is contained in:
1 parent
ebdef6ba6c
commit
63fdc00ac2
15 files changed
+396
-109
No files matched your search
@@ -16,7 +16,7 @@ export const entrySeenApi = {
|
||||
throw err;
|
||||
}),
|
||||
|
||||
create: (data: { entry_id: number; date_seen: string; seen_with?: string }) =>
|
||||
create: (data: { entry_id: number; date_seen: string; seen_with?: string; accuracy?: string }) =>
|
||||
api.post<EntrySeen>('/entry-seen', data).then((r) => r.data),
|
||||
|
||||
update: (id: number, data: Partial<EntrySeen>) =>
|
||||
|
||||
@@ -21,6 +21,7 @@ export const episodeSeenApi = {
|
||||
episode_id: number;
|
||||
date_seen: string;
|
||||
seen_with?: string;
|
||||
accuracy?: string;
|
||||
}) => api.post<EpisodeSeen>('/episode-seen', data).then((r) => r.data),
|
||||
|
||||
update: (id: number, data: Partial<EpisodeSeen>) =>
|
||||
|
||||
@@ -56,13 +56,50 @@ export function LibraryGrowthChart() {
|
||||
return Array.from(set).sort((a, b) => b - a);
|
||||
}, [allEntries, currentYear]);
|
||||
|
||||
const [year, setYear] = useState(currentYear);
|
||||
const [year, setYear] = useState<number | 'all'>('all');
|
||||
|
||||
// Ensure selected year is always within the available years
|
||||
const effectiveYear = years.includes(year) ? year : years[0];
|
||||
// Ensure selected year is always valid
|
||||
const effectiveYear = year === 'all' ? 'all' : (years.includes(year) ? year : years[0]);
|
||||
|
||||
const chartData = useMemo(() => {
|
||||
const library = allEntries.filter((e) => !e.watchlist);
|
||||
|
||||
if (effectiveYear === 'all') {
|
||||
// Build monthly data across all years
|
||||
const dateEntries = library
|
||||
.map((e) => {
|
||||
const d = getEntryDate(e);
|
||||
return d ? new Date(d) : null;
|
||||
})
|
||||
.filter(Boolean) as Date[];
|
||||
|
||||
if (dateEntries.length === 0) {
|
||||
return MONTH_LABELS.map((label) => ({ month: label, count: 0, cumulative: 0 }));
|
||||
}
|
||||
|
||||
const minYear = Math.min(...dateEntries.map((d) => d.getFullYear()));
|
||||
const maxYear = Math.max(...dateEntries.map((d) => d.getFullYear()));
|
||||
|
||||
// Build data points for each month across all years
|
||||
const data: { month: string; count: number; cumulative: number }[] = [];
|
||||
let cumulative = 0;
|
||||
|
||||
for (let y = minYear; y <= maxYear; y++) {
|
||||
for (let m = 0; m < 12; m++) {
|
||||
const count = dateEntries.filter(
|
||||
(d) => d.getFullYear() === y && d.getMonth() === m
|
||||
).length;
|
||||
cumulative += count;
|
||||
data.push({
|
||||
month: `${MONTH_LABELS[m]} ${y}`,
|
||||
count,
|
||||
cumulative,
|
||||
});
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
const beforeYear = library.filter((e) => {
|
||||
const d = getEntryDate(e);
|
||||
return d && new Date(d).getFullYear() < effectiveYear;
|
||||
@@ -97,9 +134,13 @@ export function LibraryGrowthChart() {
|
||||
</div>
|
||||
<select
|
||||
value={effectiveYear}
|
||||
onChange={(e) => setYear(Number(e.target.value))}
|
||||
onChange={(e) => {
|
||||
const val = e.target.value;
|
||||
setYear(val === 'all' ? 'all' : Number(val));
|
||||
}}
|
||||
className="rounded-md border border-border bg-card text-foreground text-xs px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"
|
||||
>
|
||||
<option value="all">All</option>
|
||||
{years.map((y) => (
|
||||
<option key={y} value={y}>{y}</option>
|
||||
))}
|
||||
|
||||
@@ -30,18 +30,14 @@ import {
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useCreateEntrySeen, useUpdateEntrySeen } from '@/hooks/useEntrySeen';
|
||||
import { useCreateEpisodeSeen } from '@/hooks/useEpisodeSeen';
|
||||
import type { Entry, Season, EntrySeen } from '@/types';
|
||||
import type { Entry, Season, EntrySeen, SeenAccuracy } from '@/types';
|
||||
|
||||
const movieSeenSchema = z.object({
|
||||
date_seen: z.string().min(1, 'Date is required'),
|
||||
seen_with: z.string().optional(),
|
||||
});
|
||||
|
||||
const tvSeenSchema = z.object({
|
||||
season_id: z.string().min(1, 'Season is required'),
|
||||
episode_id: z.string().min(1, 'Episode is required'),
|
||||
const seenSchema = z.object({
|
||||
season_id: z.string().optional(),
|
||||
episode_id: z.string().optional(),
|
||||
date_seen: z.string().min(1, 'Date is required'),
|
||||
seen_with: z.string().optional(),
|
||||
accuracy: z.enum(['EXACT', 'ESTIMATED', 'UNKNOWN']).default('EXACT'),
|
||||
});
|
||||
|
||||
interface EntrySeenDialogProps {
|
||||
@@ -67,24 +63,27 @@ export function EntrySeenDialog({
|
||||
const [selectedSeasonId, setSelectedSeasonId] = useState<string>('');
|
||||
|
||||
const isTV = entry.is_tvseries;
|
||||
const schema = isTV ? tvSeenSchema : movieSeenSchema;
|
||||
const seasonList = Array.isArray(seasons) ? seasons : [];
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
watch,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: zodResolver(schema),
|
||||
resolver: zodResolver(seenSchema),
|
||||
defaultValues: {
|
||||
date_seen: editRecord?.date_seen || format(new Date(), 'yyyy-MM-dd'),
|
||||
seen_with: editRecord?.seen_with || '',
|
||||
season_id: '',
|
||||
episode_id: '',
|
||||
accuracy: (editRecord?.accuracy || 'EXACT') as SeenAccuracy,
|
||||
},
|
||||
});
|
||||
|
||||
const accuracyValue = watch('accuracy') as SeenAccuracy;
|
||||
|
||||
const createEntrySeen = useCreateEntrySeen();
|
||||
const updateEntrySeen = useUpdateEntrySeen();
|
||||
const createEpisodeSeen = useCreateEpisodeSeen();
|
||||
@@ -94,6 +93,7 @@ export function EntrySeenDialog({
|
||||
);
|
||||
|
||||
const onSubmit = (data: Record<string, string | undefined>) => {
|
||||
const acc = (data.accuracy as SeenAccuracy) || 'EXACT';
|
||||
if (isTV && data.episode_id) {
|
||||
createEpisodeSeen.mutate(
|
||||
{
|
||||
@@ -101,6 +101,7 @@ export function EntrySeenDialog({
|
||||
episode_id: parseInt(data.episode_id),
|
||||
date_seen: data.date_seen!,
|
||||
seen_with: data.seen_with || undefined,
|
||||
accuracy: acc,
|
||||
},
|
||||
{ onSuccess: () => onOpenChange(false) }
|
||||
);
|
||||
@@ -112,6 +113,7 @@ export function EntrySeenDialog({
|
||||
entry_id: entry.id,
|
||||
date_seen: data.date_seen,
|
||||
seen_with: data.seen_with || undefined,
|
||||
accuracy: acc,
|
||||
},
|
||||
},
|
||||
{ onSuccess: () => onOpenChange(false) }
|
||||
@@ -122,6 +124,7 @@ export function EntrySeenDialog({
|
||||
entry_id: entry.id,
|
||||
date_seen: data.date_seen!,
|
||||
seen_with: data.seen_with || undefined,
|
||||
accuracy: acc,
|
||||
},
|
||||
{ onSuccess: () => onOpenChange(false) }
|
||||
);
|
||||
@@ -234,6 +237,24 @@ export function EntrySeenDialog({
|
||||
<Input id="seen_with" {...register('seen_with')} placeholder="e.g. John, Jane" />
|
||||
</div>
|
||||
|
||||
{/* Accuracy */}
|
||||
<div className="space-y-2">
|
||||
<Label>Date Accuracy</Label>
|
||||
<Select
|
||||
value={accuracyValue}
|
||||
onValueChange={(v) => setValue('accuracy', v as SeenAccuracy)}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="EXACT">Exact</SelectItem>
|
||||
<SelectItem value="ESTIMATED">Estimated</SelectItem>
|
||||
<SelectItem value="UNKNOWN">Unknown</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
|
||||
@@ -9,8 +9,15 @@ import {
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { useUpdateEpisodeSeen, useCreateEpisodeSeen } from '@/hooks/useEpisodeSeen';
|
||||
import type { EpisodeSeen } from '@/types';
|
||||
import type { EpisodeSeen, SeenAccuracy } from '@/types';
|
||||
|
||||
interface EpisodeSeenEditDialogProps {
|
||||
open: boolean;
|
||||
@@ -23,7 +30,7 @@ interface EpisodeSeenEditDialogProps {
|
||||
seasonId?: number;
|
||||
mode?: 'create' | 'edit';
|
||||
/** If provided, called instead of the normal create/update mutation */
|
||||
overrideSubmit?: (date: string, seenWith: string) => void;
|
||||
overrideSubmit?: (date: string, seenWith: string, accuracy: SeenAccuracy) => void;
|
||||
}
|
||||
|
||||
export function EpisodeSeenEditDialog({
|
||||
@@ -39,13 +46,14 @@ export function EpisodeSeenEditDialog({
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const [date, setDate] = useState(record?.date_seen?.split('T')[0] ?? today);
|
||||
const [seenWith, setSeenWith] = useState(record?.seen_with ?? '');
|
||||
const [accuracy, setAccuracy] = useState<SeenAccuracy>(record?.accuracy ?? 'EXACT');
|
||||
|
||||
const updateEpisodeSeen = useUpdateEpisodeSeen();
|
||||
const createEpisodeSeen = useCreateEpisodeSeen();
|
||||
|
||||
const handleSave = () => {
|
||||
if (overrideSubmit) {
|
||||
overrideSubmit(date, seenWith);
|
||||
overrideSubmit(date, seenWith, accuracy);
|
||||
return;
|
||||
}
|
||||
if (mode === 'edit' && record) {
|
||||
@@ -56,6 +64,7 @@ export function EpisodeSeenEditDialog({
|
||||
entry_id: entryId,
|
||||
date_seen: date,
|
||||
seen_with: seenWith || null,
|
||||
accuracy,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
@@ -66,6 +75,7 @@ export function EpisodeSeenEditDialog({
|
||||
episode_id: epId,
|
||||
date_seen: date,
|
||||
seen_with: seenWith || undefined,
|
||||
accuracy,
|
||||
season_id: seasonId,
|
||||
});
|
||||
}
|
||||
@@ -97,6 +107,19 @@ export function EpisodeSeenEditDialog({
|
||||
placeholder="Optional"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label>Date Accuracy</Label>
|
||||
<Select value={accuracy} onValueChange={(v) => setAccuracy(v as SeenAccuracy)}>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="EXACT">Exact</SelectItem>
|
||||
<SelectItem value="ESTIMATED">Estimated</SelectItem>
|
||||
<SelectItem value="UNKNOWN">Unknown</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -22,6 +22,13 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
|
||||
const [selected, setSelected] = useState<number>(currentRating);
|
||||
const updateRatings = useUpdateEntryRatings();
|
||||
|
||||
// Sync selected when dialog opens or entry rating changes
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setSelected(entry.entryRatings?.user_rating ?? 0);
|
||||
}
|
||||
}, [open, entry.entryRatings?.user_rating]);
|
||||
|
||||
const displayRating = hovered ?? selected;
|
||||
|
||||
const handleRate = (rating: number) => {
|
||||
@@ -36,6 +43,18 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
const handleClear = () => {
|
||||
setSelected(0);
|
||||
updateRatings.mutate({
|
||||
id: entry.id,
|
||||
ratings: {
|
||||
id: entry.entryRatings?.id,
|
||||
user_rating: null,
|
||||
},
|
||||
});
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="w-auto sm:max-w-none">
|
||||
@@ -45,32 +64,51 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-col items-center gap-4 py-2">
|
||||
<div className="flex gap-1.5">
|
||||
{Array.from({ length: 10 }, (_, i) => i + 1).map((star) => (
|
||||
<button
|
||||
key={star}
|
||||
className="transition-transform hover:scale-125 focus:outline-none"
|
||||
onMouseEnter={() => setHovered(star)}
|
||||
onMouseLeave={() => setHovered(null)}
|
||||
onClick={() => handleRate(star)}
|
||||
>
|
||||
<Star
|
||||
className={`h-8 w-8 transition-colors ${
|
||||
star <= displayRating
|
||||
? 'fill-yellow-400 text-yellow-400'
|
||||
: 'text-muted-foreground/30'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
))}
|
||||
<div className="flex gap-0.5">
|
||||
{Array.from({ length: 10 }, (_, i) => i + 1).map((star) => {
|
||||
const halfValue = star - 0.5;
|
||||
return (
|
||||
<div key={star} className="relative h-8 w-8">
|
||||
{/* Left half — half star */}
|
||||
<button
|
||||
className="absolute inset-y-0 left-0 w-1/2 z-10 focus:outline-none"
|
||||
onMouseEnter={() => setHovered(halfValue)}
|
||||
onMouseLeave={() => setHovered(null)}
|
||||
onClick={() => handleRate(halfValue)}
|
||||
/>
|
||||
{/* Right half — full star */}
|
||||
<button
|
||||
className="absolute inset-y-0 right-0 w-1/2 z-10 focus:outline-none"
|
||||
onMouseEnter={() => setHovered(star)}
|
||||
onMouseLeave={() => setHovered(null)}
|
||||
onClick={() => handleRate(star)}
|
||||
/>
|
||||
{/* Star icon */}
|
||||
<div className="pointer-events-none transition-transform hover:scale-125">
|
||||
{displayRating >= star ? (
|
||||
<Star className="h-8 w-8 fill-yellow-400 text-yellow-400 transition-colors" />
|
||||
) : displayRating >= halfValue ? (
|
||||
<div className="relative h-8 w-8">
|
||||
<Star className="absolute h-8 w-8 text-muted-foreground/30 transition-colors" />
|
||||
<div className="absolute inset-0 overflow-hidden w-1/2">
|
||||
<Star className="h-8 w-8 fill-yellow-400 text-yellow-400 transition-colors" />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<Star className="h-8 w-8 text-muted-foreground/30 transition-colors" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<p className="text-xl font-semibold tabular-nums">
|
||||
{displayRating > 0 ? `${displayRating} / 10` : '—'}
|
||||
</p>
|
||||
|
||||
{selected > 0 && (
|
||||
<Button variant="ghost" size="sm" onClick={() => handleRate(0)}>
|
||||
{(selected > 0 || currentRating > 0) && (
|
||||
<Button variant="ghost" size="sm" onClick={handleClear}>
|
||||
Clear rating
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Plus, Trash2, Star, Loader2 } from 'lucide-react';
|
||||
import { Plus, Trash2, Star, Loader2, Calendar, Clock } from 'lucide-react';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils';
|
||||
import { useCreateEntry, useDeleteEntry } from '@/hooks/useEntries';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
@@ -18,6 +24,7 @@ interface EntryCardProps {
|
||||
|
||||
export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
||||
const [showConfirm, setShowConfirm] = useState(false);
|
||||
const [showDetailDialog, setShowDetailDialog] = useState(false);
|
||||
const createEntry = useCreateEntry();
|
||||
const deleteEntry = useDeleteEntry();
|
||||
const libraryEntry = useLibraryStore((s) => {
|
||||
@@ -174,7 +181,13 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
||||
|
||||
return (
|
||||
<>
|
||||
{entryLink ? <Link to={entryLink}>{card}</Link> : card}
|
||||
{entryLink ? (
|
||||
<Link to={entryLink}>{card}</Link>
|
||||
) : (
|
||||
<div className="cursor-pointer" onClick={() => setShowDetailDialog(true)}>
|
||||
{card}
|
||||
</div>
|
||||
)}
|
||||
<ConfirmDialog
|
||||
open={showConfirm}
|
||||
onOpenChange={setShowConfirm}
|
||||
@@ -184,6 +197,66 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) {
|
||||
onConfirm={confirmRemove}
|
||||
variant="destructive"
|
||||
/>
|
||||
{/* Details dialog for non-library entries */}
|
||||
{!entryLink && tmdbEntry && (
|
||||
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
||||
<DialogContent className="sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex gap-4">
|
||||
<img
|
||||
src={posterUrl}
|
||||
alt={title}
|
||||
className="h-48 w-32 shrink-0 rounded-lg object-cover"
|
||||
/>
|
||||
<div className="flex-1 space-y-2 min-w-0">
|
||||
<div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
|
||||
{year && (
|
||||
<span className="flex items-center gap-1">
|
||||
<Calendar className="h-3 w-3" />
|
||||
{year}
|
||||
</span>
|
||||
)}
|
||||
{isTv ? (
|
||||
<Badge variant="secondary" className="text-[10px]">TV Series</Badge>
|
||||
) : (
|
||||
<Badge variant="secondary" className="text-[10px]">Movie</Badge>
|
||||
)}
|
||||
</div>
|
||||
{tmdbEntry.vote_average > 0 && (
|
||||
<div className="flex items-center gap-1 text-sm">
|
||||
<Star className="h-3.5 w-3.5 fill-yellow-400 text-yellow-400" />
|
||||
<span>{tmdbEntry.vote_average.toFixed(1)}/10</span>
|
||||
</div>
|
||||
)}
|
||||
{tmdbEntry.overview && (
|
||||
<p className="text-sm text-muted-foreground line-clamp-6">
|
||||
{tmdbEntry.overview}
|
||||
</p>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
className="mt-2"
|
||||
onClick={(ev) => {
|
||||
ev.stopPropagation();
|
||||
handleAdd(ev);
|
||||
setShowDetailDialog(false);
|
||||
}}
|
||||
disabled={createEntry.isPending}
|
||||
>
|
||||
{createEntry.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Plus className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ export function useCreateEntrySeen() {
|
||||
entry_id: number;
|
||||
date_seen: string;
|
||||
seen_with?: string;
|
||||
accuracy?: string;
|
||||
}) => entrySeenApi.create(data),
|
||||
onSuccess: (_data, variables) => {
|
||||
queryClient.invalidateQueries({
|
||||
@@ -50,7 +51,7 @@ export function useUpdateEntrySeen() {
|
||||
data,
|
||||
}: {
|
||||
id: number;
|
||||
data: { entry_id: number; date_seen?: string; seen_with?: string };
|
||||
data: { entry_id: number; date_seen?: string; seen_with?: string; accuracy?: 'EXACT' | 'ESTIMATED' | 'UNKNOWN' };
|
||||
}) => entrySeenApi.update(id, data),
|
||||
onSuccess: (_data, variables) => {
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -27,6 +27,7 @@ export function useCreateEpisodeSeen() {
|
||||
episode_id: number;
|
||||
date_seen: string;
|
||||
seen_with?: string;
|
||||
accuracy?: string;
|
||||
season_id?: number;
|
||||
}) => episodeSeenApi.create(data),
|
||||
onSuccess: (_data, variables) => {
|
||||
@@ -61,7 +62,7 @@ export function useUpdateEpisodeSeen() {
|
||||
data,
|
||||
}: {
|
||||
id: number;
|
||||
data: { episode_id: number; entry_id: number; date_seen?: string; seen_with?: string | null };
|
||||
data: { episode_id: number; entry_id: number; date_seen?: string; seen_with?: string | null; accuracy?: 'EXACT' | 'ESTIMATED' | 'UNKNOWN' };
|
||||
}) => episodeSeenApi.update(id, data),
|
||||
onSuccess: (_data, variables) => {
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import { useParams, Link, useNavigate } from 'react-router-dom';
|
||||
import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
|
||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||
import { useCollections } from '@/hooks/useCollections';
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
@@ -24,8 +25,9 @@ import {
|
||||
ImageIcon,
|
||||
Settings,
|
||||
Star,
|
||||
Loader2,
|
||||
History,
|
||||
Trash2,
|
||||
ExternalLink,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
Tooltip,
|
||||
@@ -35,13 +37,14 @@ import {
|
||||
} from '@/components/ui/tooltip';
|
||||
import { CastList } from '@/components/entries/CastList';
|
||||
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
|
||||
import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory';
|
||||
// EpisodeWatchHistory is available for future use
|
||||
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
||||
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
||||
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
||||
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
||||
import { RatingDialog } from '@/components/dialogs/RatingDialog';
|
||||
import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
|
||||
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
||||
import { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons';
|
||||
import {
|
||||
getPosterUrl,
|
||||
@@ -51,18 +54,20 @@ import {
|
||||
formatRuntime,
|
||||
formatDate,
|
||||
} from '@/lib/media-utils';
|
||||
import { useUpdateEntry } from '@/hooks/useEntries';
|
||||
import { useUpdateEntry, useDeleteEntry } from '@/hooks/useEntries';
|
||||
import type { Collection, Entry } from '@/types';
|
||||
|
||||
export function EntryDetailsPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const entryId = parseInt(id!, 10);
|
||||
const navigate = useNavigate();
|
||||
const { data: entry, isLoading } = useEntry(entryId);
|
||||
const { data: seasons } = useEntrySeasons(entryId);
|
||||
const { data: watchHistory = [] } = useEntrySeenByEntry(entryId);
|
||||
const updateEntry = useUpdateEntry();
|
||||
const refreshEntry = useRefreshEntry();
|
||||
const deleteEntrySeen = useDeleteEntrySeen();
|
||||
const deleteEntry = useDeleteEntry();
|
||||
|
||||
// Merge library entry with detail entry so we get both library flags AND full details (credits, etc.)
|
||||
const libraryEntry = useLibraryStore((s) => s.entries.get(entryId));
|
||||
@@ -76,6 +81,7 @@ export function EntryDetailsPage() {
|
||||
const [showCollectionDialog, setShowCollectionDialog] = useState(false);
|
||||
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
||||
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
|
||||
if (isLoading || !displayEntry) {
|
||||
return <EntryDetailsSkeleton />;
|
||||
@@ -112,41 +118,6 @@ export function EntryDetailsPage() {
|
||||
<div className="mx-auto max-w-4xl">
|
||||
{/* Action buttons — top right */}
|
||||
<div className="flex justify-end gap-1 -mt-10 relative z-10 mb-2">
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant={e.favorit ? 'default' : 'outline'}
|
||||
size="icon"
|
||||
className="h-9 w-9"
|
||||
onClick={toggleFavorite}
|
||||
disabled={updateEntry.isPending}
|
||||
>
|
||||
{updateEntry.isPending ? (
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
<Heart className={`h-4 w-4 ${e.favorit ? 'fill-current' : ''}`} />
|
||||
)}
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{e.favorit ? 'Unfavorite' : 'Favorite'}</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="h-9 w-9"
|
||||
onClick={() => setShowSeenDialog(true)}
|
||||
>
|
||||
<Eye className="h-4 w-4" />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>Mark Watched</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" className="h-9 w-9">
|
||||
@@ -154,6 +125,11 @@ export function EntryDetailsPage() {
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-56">
|
||||
{/* Watch & Rate */}
|
||||
<DropdownMenuItem onClick={() => setShowSeenDialog(true)}>
|
||||
<Eye className="mr-2 h-4 w-4" />
|
||||
Mark as watched
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowRatingDialog(true)}>
|
||||
<Star className="mr-2 h-4 w-4" />
|
||||
Rate this
|
||||
@@ -164,6 +140,16 @@ export function EntryDetailsPage() {
|
||||
Watch History
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuSeparator />
|
||||
{/* Organize */}
|
||||
<DropdownMenuItem onClick={toggleFavorite} disabled={updateEntry.isPending}>
|
||||
<Heart className={`mr-2 h-4 w-4 ${e.favorit ? 'fill-current' : ''}`} />
|
||||
{e.favorit ? 'Unfavorite' : 'Favorite'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
||||
<FolderPlus className="mr-2 h-4 w-4" />
|
||||
Add to collection
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() =>
|
||||
updateEntry.mutate({ id: e.id, data: { hidden: !e.hidden } })
|
||||
@@ -172,14 +158,12 @@ export function EntryDetailsPage() {
|
||||
<EyeOff className="mr-2 h-4 w-4" />
|
||||
{e.hidden ? 'Unhide' : 'Hide'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
{/* Manage */}
|
||||
<DropdownMenuItem onClick={() => refreshEntry.mutate(e.id)} disabled={refreshEntry.isPending}>
|
||||
<RefreshCw className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? 'animate-spin' : ''}`} />
|
||||
{refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
||||
<FolderPlus className="mr-2 h-4 w-4" />
|
||||
Add to collection
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
|
||||
<ImageIcon className="mr-2 h-4 w-4" />
|
||||
Manage media
|
||||
@@ -188,6 +172,15 @@ export function EntryDetailsPage() {
|
||||
<Settings className="mr-2 h-4 w-4" />
|
||||
Settings
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
{/* Danger */}
|
||||
<DropdownMenuItem
|
||||
className="text-destructive focus:text-destructive"
|
||||
onClick={() => setShowDeleteConfirm(true)}
|
||||
>
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
Delete entry
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
@@ -196,25 +189,52 @@ export function EntryDetailsPage() {
|
||||
<div className="flex flex-col gap-6 relative items-start sm:flex-row sm:gap-8 sm:-mt-8">
|
||||
{/* LEFT: Sticky poster */}
|
||||
<div className="sm:sticky sm:top-20 w-32 sm:w-44 shrink-0 self-start mx-auto sm:mx-0">
|
||||
<img
|
||||
src={poster}
|
||||
alt={e.title}
|
||||
className="w-full aspect-2/3 rounded-xl object-cover shadow-2xl ring-1 ring-border/50"
|
||||
/>
|
||||
<div className="relative">
|
||||
{e.favorit && (
|
||||
<div className="absolute top-2 left-2 z-10 rounded-full bg-background/80 p-1 backdrop-blur-sm">
|
||||
<Heart className="h-4 w-4 fill-red-500 text-red-500" />
|
||||
</div>
|
||||
)}
|
||||
<img
|
||||
src={poster}
|
||||
alt={e.title}
|
||||
className="w-full aspect-2/3 rounded-xl object-cover shadow-2xl ring-1 ring-border/50"
|
||||
/>
|
||||
</div>
|
||||
{/* External links */}
|
||||
{e.entryIds && (
|
||||
<div className="flex items-center justify-center gap-3 mt-3">
|
||||
{e.entryIds.tmdb_id && (
|
||||
<a
|
||||
href={`https://www.themoviedb.org/${e.is_tvseries ? 'tv' : 'movie'}/${e.entryIds.tmdb_id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<ExternalLink className="h-3 w-3" />
|
||||
TMDB
|
||||
</a>
|
||||
)}
|
||||
{e.entryIds.imdb_id && (
|
||||
<a
|
||||
href={`https://www.imdb.com/title/${e.entryIds.imdb_id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<ExternalLink className="h-3 w-3" />
|
||||
IMDb
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* RIGHT: Entry info */}
|
||||
<div className="flex-1 min-w-0 space-y-4">
|
||||
{/* Title + status + director */}
|
||||
{/* Title + director */}
|
||||
<div className="space-y-1">
|
||||
<div className="flex flex-wrap items-start gap-2">
|
||||
<h1 className="text-3xl font-bold leading-tight">{e.title}</h1>
|
||||
{e.status && (
|
||||
<Badge variant="secondary" className="mt-1 shrink-0">
|
||||
{e.status}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<h1 className="text-3xl font-bold leading-tight">{e.title}</h1>
|
||||
{director?.people?.name && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
by{' '}
|
||||
@@ -244,6 +264,12 @@ export function EntryDetailsPage() {
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
{e.is_tvseries && e.status && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<span>{e.status}</span>
|
||||
</>
|
||||
)}
|
||||
{e.runtime && !e.is_tvseries && (
|
||||
<>
|
||||
<span>•</span>
|
||||
@@ -275,15 +301,29 @@ export function EntryDetailsPage() {
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{!e.is_tvseries && watchHistory.length === 0 && (
|
||||
<>
|
||||
<span>•</span>
|
||||
<button
|
||||
className="inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors underline decoration-dotted"
|
||||
onClick={() => setShowSeenDialog(true)}
|
||||
>
|
||||
<Eye className="h-3 w-3" />
|
||||
Mark as watched
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Genres */}
|
||||
{e.genres && e.genres.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{e.genres.map((g) => (
|
||||
<Badge key={g.id} variant="outline" className="text-xs">
|
||||
{g.name}
|
||||
</Badge>
|
||||
<Link key={g.id} to={`/library?genre=${encodeURIComponent(g.name)}`}>
|
||||
<Badge variant="outline" className="text-xs cursor-pointer hover:bg-accent transition-colors">
|
||||
{g.name}
|
||||
</Badge>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
@@ -417,6 +457,20 @@ export function EntryDetailsPage() {
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<ConfirmDialog
|
||||
open={showDeleteConfirm}
|
||||
onOpenChange={setShowDeleteConfirm}
|
||||
title="Delete Entry"
|
||||
description={`Are you sure you want to delete "${e.title}" from your library? This action cannot be undone.`}
|
||||
confirmLabel="Delete"
|
||||
variant="destructive"
|
||||
onConfirm={() => {
|
||||
deleteEntry.mutate(e.id, {
|
||||
onSuccess: () => navigate('/library'),
|
||||
});
|
||||
setShowDeleteConfirm(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useParams, useNavigate, Link } from 'react-router-dom';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { seasonsApi } from '@/api/seasons';
|
||||
import {
|
||||
@@ -57,6 +57,23 @@ export function EpisodePage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-8">
|
||||
{/* Back navigation */}
|
||||
<div className="flex items-center gap-3 text-sm text-muted-foreground">
|
||||
<Link
|
||||
to={`/entry/${entryId}`}
|
||||
className="hover:text-foreground transition-colors"
|
||||
>
|
||||
Entry
|
||||
</Link>
|
||||
<span>/</span>
|
||||
<Link
|
||||
to={`/entry/${entryId}/season/${seasonId}`}
|
||||
className="hover:text-foreground transition-colors"
|
||||
>
|
||||
Season
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Top bar: nav breadcrumb + Mark Watched */}
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
|
||||
@@ -8,9 +8,10 @@ import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Eye, CheckCircle2, ListChecks } from 'lucide-react';
|
||||
import { Eye, CheckCircle2, ListChecks, ArrowLeft } from 'lucide-react';
|
||||
import { getTmdbPosterUrl, getYear, formatDate } from '@/lib/media-utils';
|
||||
import type { Episode } from '@/types';
|
||||
import type { SeenAccuracy } from '@/types';
|
||||
|
||||
export function SeasonPage() {
|
||||
const { entryId, seasonId } = useParams<{
|
||||
@@ -25,6 +26,7 @@ export function SeasonPage() {
|
||||
const [showMarkAllDialog, setShowMarkAllDialog] = useState(false);
|
||||
const [markAllDate, setMarkAllDate] = useState(new Date().toISOString().split('T')[0]);
|
||||
const [markAllSeenWith, setMarkAllSeenWith] = useState('');
|
||||
const [markAllAccuracy, setMarkAllAccuracy] = useState<SeenAccuracy>('EXACT');
|
||||
const [showMarkAllConfirm, setShowMarkAllConfirm] = useState(false);
|
||||
|
||||
if (isLoading || !season) {
|
||||
@@ -52,6 +54,15 @@ export function SeasonPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-8 animate-page-enter">
|
||||
{/* Back to entry */}
|
||||
<Link
|
||||
to={`/entry/${entryId}`}
|
||||
className="inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
Back to entry
|
||||
</Link>
|
||||
|
||||
{/* Header */}
|
||||
<div className="flex gap-6">
|
||||
<img
|
||||
@@ -205,9 +216,10 @@ export function SeasonPage() {
|
||||
episodeId={-1}
|
||||
entryId={parseInt(entryId!, 10)}
|
||||
seasonId={parseInt(seasonId!, 10)}
|
||||
overrideSubmit={(date, seenWith) => {
|
||||
overrideSubmit={(date, seenWith, accuracy) => {
|
||||
setMarkAllDate(date);
|
||||
setMarkAllSeenWith(seenWith);
|
||||
setMarkAllAccuracy(accuracy);
|
||||
setShowMarkAllDialog(false);
|
||||
setShowMarkAllConfirm(true);
|
||||
}}
|
||||
@@ -233,6 +245,7 @@ export function SeasonPage() {
|
||||
episode_id: ep.id,
|
||||
date_seen: markAllDate,
|
||||
seen_with: markAllSeenWith || undefined,
|
||||
accuracy: markAllAccuracy,
|
||||
season_id: parseInt(seasonId!, 10),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,11 +102,14 @@ export interface Episode {
|
||||
season?: Season;
|
||||
}
|
||||
|
||||
export type SeenAccuracy = 'EXACT' | 'ESTIMATED' | 'UNKNOWN';
|
||||
|
||||
export interface EntrySeen {
|
||||
id: number;
|
||||
entry_id: number;
|
||||
date_seen: string;
|
||||
seen_with: string | null;
|
||||
accuracy: SeenAccuracy;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -117,6 +120,7 @@ export interface EpisodeSeen {
|
||||
episode_id: number;
|
||||
date_seen: string;
|
||||
seen_with: string | null;
|
||||
accuracy: SeenAccuracy;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user