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
@@ -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>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user