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

@@ -0,0 +1,100 @@
import { useState } from 'react';
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { useUpdateEpisodeSeen, useCreateEpisodeSeen } from '@/hooks/useEpisodeSeen';
import type { EpisodeSeen } from '@/types';
interface EpisodeSeenEditDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
/** Pass for edit mode */
record?: EpisodeSeen;
/** Required for create mode */
episodeId?: number;
entryId: number;
mode?: 'create' | 'edit';
}
export function EpisodeSeenEditDialog({
open,
onOpenChange,
record,
episodeId,
entryId,
mode = record ? 'edit' : 'create',
}: EpisodeSeenEditDialogProps) {
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 updateEpisodeSeen = useUpdateEpisodeSeen();
const createEpisodeSeen = useCreateEpisodeSeen();
const handleSave = () => {
if (mode === 'edit' && record) {
updateEpisodeSeen.mutate({
id: record.id,
data: {
episode_id: record.episode_id,
entry_id: entryId,
date_seen: date,
seen_with: seenWith || null,
},
});
} else {
const epId = episodeId ?? record?.episode_id;
if (!epId) return;
createEpisodeSeen.mutate({
entry_id: entryId,
episode_id: epId,
date_seen: date,
seen_with: seenWith || undefined,
});
}
onOpenChange(false);
};
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-sm">
<DialogHeader>
<DialogTitle>{mode === 'edit' ? 'Edit Watch Record' : 'Mark as Watched'}</DialogTitle>
</DialogHeader>
<div className="space-y-4 py-2">
<div className="space-y-1.5">
<Label htmlFor="date">Date Watched</Label>
<Input
id="date"
type="date"
value={date}
onChange={(e) => setDate(e.target.value)}
/>
</div>
<div className="space-y-1.5">
<Label htmlFor="seen-with">Seen With</Label>
<Input
id="seen-with"
value={seenWith}
onChange={(e) => setSeenWith(e.target.value)}
placeholder="Optional"
/>
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>Cancel</Button>
<Button onClick={handleSave} disabled={!date}>
{mode === 'edit' ? 'Save' : 'Add'}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}