Add season refresh, rating display, and actions dropdown to SeasonPage
Backend: Added PUT /seasons/:id/refresh endpoint that fetches updated TMDB data for a single season. Frontend: - New SeasonRatingDialog for rating seasons via StarRating - useRefreshSeason and useUpdateSeason hooks with query invalidation - SeasonPage now shows inline season rating (user + TMDB) - Mark Watched, Rate, and Refresh actions moved under a dropdown menu
This commit is contained in:
1 parent
1aa0a84f4d
commit
4d88747649
6 files changed
+247
-13
No files matched your search
@@ -1,16 +1,36 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, Link } from "react-router-dom";
|
||||
import { useSeason, useSeasonEpisodes } from "@/hooks/useSeasons";
|
||||
import {
|
||||
useSeason,
|
||||
useSeasonEpisodes,
|
||||
useRefreshSeason,
|
||||
} from "@/hooks/useSeasons";
|
||||
import { useEntry, useEntrySeasons } from "@/hooks/useEntries";
|
||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||
import { EpisodeSeenEditDialog } from "@/components/dialogs/EpisodeSeenEditDialog";
|
||||
import { MarkSeasonWatchedDialog } from "@/components/dialogs/MarkSeasonWatchedDialog";
|
||||
import { SeasonRatingDialog } from "@/components/dialogs/SeasonRatingDialog";
|
||||
import { StreamingDialog } from "@/components/streaming/StreamingDialog";
|
||||
import { useStreamingStore } from "@/stores/useStreamingStore";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Eye, CheckCircle2, ListChecks, PlayCircle } from "lucide-react";
|
||||
import { StarRating } from "@/components/ui/star-rating";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import {
|
||||
Eye,
|
||||
CheckCircle2,
|
||||
ListChecks,
|
||||
PlayCircle,
|
||||
Ellipsis,
|
||||
RefreshCw,
|
||||
Star,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
@@ -33,8 +53,10 @@ export function SeasonPage() {
|
||||
entry?.title ??
|
||||
useLibraryStore.getState().entries.get(parseInt(entryId!, 10))?.title;
|
||||
const { initialize, play } = useStreamingStore();
|
||||
const refreshSeason = useRefreshSeason();
|
||||
const [dialogEpisode, setDialogEpisode] = useState<Episode | null>(null);
|
||||
const [showMarkAllDialog, setShowMarkAllDialog] = useState(false);
|
||||
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
||||
const [streamingOpen, setStreamingOpen] = useState(false);
|
||||
|
||||
const handleWatchEpisode = (season: number, episodeNumber: number) => {
|
||||
@@ -98,16 +120,37 @@ export function SeasonPage() {
|
||||
<div className="flex-1 flex flex-col justify-center space-y-3">
|
||||
<div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
|
||||
<h1 className="text-xl font-bold sm:text-2xl">{season.name}</h1>
|
||||
{/* Mark Season as Watched — top right */}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="shrink-0 w-full sm:w-auto"
|
||||
onClick={() => setShowMarkAllDialog(true)}
|
||||
>
|
||||
<ListChecks className="mr-1.5 h-4 w-4" />
|
||||
Mark Season Watched
|
||||
</Button>
|
||||
{/* Actions dropdown — top right */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="outline"
|
||||
className="shrink-0 self-end sm:self-start"
|
||||
>
|
||||
<Ellipsis className="h-4 w-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<DropdownMenuItem onClick={() => setShowMarkAllDialog(true)}>
|
||||
<ListChecks className="mr-2 h-4 w-4" />
|
||||
Mark Season Watched
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowRatingDialog(true)}>
|
||||
<Star className="mr-2 h-4 w-4" />
|
||||
Rate Season
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={() => refreshSeason.mutate(season.id)}
|
||||
disabled={refreshSeason.isPending}
|
||||
>
|
||||
<RefreshCw
|
||||
className={`mr-2 h-4 w-4 ${refreshSeason.isPending ? "animate-spin" : ""}`}
|
||||
/>
|
||||
Refresh Season
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<span>Season {season.season_number}</span>
|
||||
@@ -121,6 +164,21 @@ export function SeasonPage() {
|
||||
<span>{totalEpisodes} episodes</span>
|
||||
</div>
|
||||
|
||||
{/* Season rating */}
|
||||
<div className="flex items-center gap-2">
|
||||
<StarRating value={season.user_rating ?? 0} readOnly size="sm" />
|
||||
{season.user_rating != null && season.user_rating > 0 && (
|
||||
<span className="text-sm font-medium tabular-nums">
|
||||
{season.user_rating}/10
|
||||
</span>
|
||||
)}
|
||||
{season.tmdb_rating != null && season.tmdb_rating > 0 && (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
TMDB {season.tmdb_rating}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Watch progress */}
|
||||
<div className="flex items-center gap-3 max-w-xs">
|
||||
<Progress value={progress} className="flex-1 h-2" />
|
||||
@@ -281,6 +339,15 @@ export function SeasonPage() {
|
||||
episodes={episodes}
|
||||
/>
|
||||
|
||||
{/* Season Rating dialog */}
|
||||
{season && (
|
||||
<SeasonRatingDialog
|
||||
open={showRatingDialog}
|
||||
onOpenChange={setShowRatingDialog}
|
||||
season={season}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Streaming dialog */}
|
||||
{entry && streamingOpen && (
|
||||
<StreamingDialog
|
||||
|
||||
Reference in new issue
Block a user