Implemented the new react version of the frontend

This commit is contained in:
Mohammed Abad committed 2026-03-31 01:56:38 +01:00
1 parent 236e6e06fb
commit ffe7e52527
65 files changed
+5228 -177

No files matched your search

@@ -0,0 +1,122 @@
import { useState } from 'react';
import { Link } from 'react-router-dom';
import { ChevronDown, ChevronUp, Play } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Progress } from '@/components/ui/progress';
import { getYear, getTmdbPosterUrl } from '@/lib/media-utils';
import type { Season } from '@/types';
interface SeasonsContainerProps {
seasons: Season[];
entryId: number;
}
export function SeasonsContainer({
seasons,
entryId,
}: SeasonsContainerProps) {
const [expanded, setExpanded] = useState(false);
// Sort: specials (season 0) at bottom, rest latest to oldest
const sorted = [...seasons].sort((a, b) => {
if (a.season_number === 0) return 1;
if (b.season_number === 0) return -1;
return b.season_number - a.season_number;
});
const display = expanded ? sorted : sorted.slice(0, 2);
return (
<div className="space-y-3">
<h3 className="text-lg font-semibold">Seasons</h3>
<div className="space-y-2">
{display.map((season) => (
<SeasonItem key={season.id} season={season} entryId={entryId} />
))}
</div>
{sorted.length > 2 && (
<Button
variant="ghost"
size="sm"
onClick={() => setExpanded(!expanded)}
className="w-full"
>
{expanded ? (
<>
<ChevronUp className="mr-1 h-4 w-4" /> Show Less
</>
) : (
<>
<ChevronDown className="mr-1 h-4 w-4" /> Show All (
{sorted.length})
</>
)}
</Button>
)}
</div>
);
}
function SeasonItem({
season,
entryId,
}: {
season: Season;
entryId: number;
}) {
const watchedCount =
season.episodes?.filter(
(ep) => ep.date_first_seen || (ep.episodeSeens && ep.episodeSeens.length > 0)
).length ?? 0;
const totalEpisodes = season.episode_count || season.episodes?.length || 0;
const progress = totalEpisodes > 0 ? (watchedCount / totalEpisodes) * 100 : 0;
return (
<Link
to={`/entry/${entryId}/season/${season.id}`}
className="flex items-center gap-4 rounded-lg border border-border p-3 transition-colors hover:bg-accent/50"
>
{/* Poster thumbnail */}
<div className="h-16 w-11 shrink-0 overflow-hidden rounded bg-muted">
<img
src={getTmdbPosterUrl(season.poster_path, 'w92')}
alt={season.name}
className="h-full w-full object-cover"
loading="lazy"
/>
</div>
{/* Info */}
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2">
<span className="font-medium text-sm truncate">{season.name}</span>
<span className="text-xs text-muted-foreground">
{getYear(season.air_date)}
</span>
</div>
<div className="flex items-center gap-2 mt-1">
<Progress value={progress} className="h-1.5 flex-1" />
<span className="text-xs text-muted-foreground shrink-0">
{watchedCount}/{totalEpisodes}
</span>
</div>
</div>
{/* Quick watch button */}
{watchedCount < totalEpisodes && (
<Button
size="icon"
variant="ghost"
className="h-8 w-8 shrink-0"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
// TODO: Mark next unwatched episode as seen
}}
>
<Play className="h-4 w-4" />
</Button>
)}
</Link>
);
}