fix(frontend): calendar thumbnail, episode delete confirm, mark-as-watched dialog

- CalendarPage: restore poster/still thumbnail (h-8 w-5) in episode items;
  add getTmdbPosterUrl import; extend EpisodeWithEntry type with poster_path
- EpisodeSeenEditDialog: add mode 'create'|'edit' support; record prop is now
  optional; create mode uses useCreateEpisodeSeen with today as default date
- EpisodePage: Mark as Watched button now opens EpisodeSeenEditDialog (create
  mode) instead of firing mutation directly; delete shows ConfirmDialog before
  deleting; remove unused useCreateEpisodeSeen import
This commit is contained in:
Mohammed Abad committed 2026-04-01 00:59:09 +01:00
1 parent 3ca24434d7
commit 191f4d6aae
8 files changed
+350 -101

No files matched your search

+24 -28
View File
@@ -4,8 +4,8 @@ import { format, startOfMonth, endOfMonth, eachDayOfInterval, getDay, addMonths,
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { useEpisodesByMonth } from '@/hooks/useEpisodes';
import { getTmdbPosterUrl, getPosterUrl } from '@/lib/media-utils';
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '@/components/ui/tooltip';
import { getTmdbPosterUrl } from '@/lib/media-utils';
import type { Episode } from '@/types';
const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -123,13 +123,7 @@ export function CalendarPage() {
function EpisodeCalendarItem({ episode }: { episode: Episode }) {
type EpisodeWithEntry = Episode & {
entry?: {
id: number;
title?: string;
poster_path?: string | null;
medias?: unknown[];
isInLibrary?: boolean;
};
entry?: { id: number; title?: string; poster_path?: string | null };
};
const ep = episode as EpisodeWithEntry;
const entry = ep.entry;
@@ -137,29 +131,29 @@ function EpisodeCalendarItem({ episode }: { episode: Episode }) {
const entryTitle = entry?.title ?? '';
const seasonId = episode.season_id;
const posterSrc = episode.still_path
? getTmdbPosterUrl(episode.still_path, 'w92')
: entry
? getPosterUrl({ ...(entry as Parameters<typeof getPosterUrl>[0]), isInLibrary: false })
: undefined;
const seasonLabel = `S${String(seasonId).padStart(2, '0')}`;
const episodeLabel = `E${String(episode.episode_number).padStart(2, '0')}`;
const thumbSrc = episode.still_path
? getTmdbPosterUrl(episode.still_path, 'w92')
: entry?.poster_path
? getTmdbPosterUrl(entry.poster_path, 'w92')
: undefined;
const content = (
<div className="flex items-center gap-1.5 rounded bg-accent/60 hover:bg-accent px-1 py-1 transition-colors cursor-pointer">
{posterSrc && (
<div className="flex items-stretch gap-1 rounded bg-primary/10 hover:bg-primary/20 px-1 py-0.5 transition-colors cursor-pointer overflow-hidden">
{thumbSrc && (
<img
src={posterSrc}
src={thumbSrc}
alt=""
className="h-10 w-7 rounded object-cover shrink-0"
className="h-8 w-5 rounded-sm object-cover shrink-0"
/>
)}
<div className="min-w-0">
<div className="min-w-0 flex flex-col justify-center">
<p className="text-[10px] font-medium truncate leading-tight">
{entryTitle}
{entryTitle || 'Unknown'}
</p>
<p className="text-[9px] text-muted-foreground tabular-nums">
<p className="text-[9px] text-muted-foreground tabular-nums leading-tight">
{seasonLabel} {episodeLabel}
</p>
</div>
@@ -181,13 +175,15 @@ function EpisodeCalendarItem({ episode }: { episode: Episode }) {
)}
</TooltipTrigger>
<TooltipContent side="right" className="max-w-50">
<p className="text-xs font-semibold">{entryTitle}</p>
{episode.name && (
<p className="text-xs">{episode.name}</p>
)}
<p className="text-xs text-muted-foreground">
{seasonLabel} {episodeLabel}
</p>
<div className="space-y-0.5">
<p className="text-xs font-semibold">{entryTitle}</p>
{episode.name && (
<p className="text-xs text-muted-foreground">{episode.name}</p>
)}
<p className="text-xs text-muted-foreground tabular-nums">
{seasonLabel} {episodeLabel}
</p>
</div>
</TooltipContent>
</Tooltip>
);