diff --git a/react_frontend/package-lock.json b/react_frontend/package-lock.json
index 508b7fb..cc75f64 100644
--- a/react_frontend/package-lock.json
+++ b/react_frontend/package-lock.json
@@ -1829,6 +1829,70 @@
"node": ">=14.0.0"
}
},
+ "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": {
+ "version": "1.8.1",
+ "dev": true,
+ "inBundle": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "@emnapi/wasi-threads": "1.1.0",
+ "tslib": "^2.4.0"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": {
+ "version": "1.8.1",
+ "dev": true,
+ "inBundle": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "tslib": "^2.4.0"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": {
+ "version": "1.1.0",
+ "dev": true,
+ "inBundle": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "tslib": "^2.4.0"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": {
+ "version": "1.1.1",
+ "dev": true,
+ "inBundle": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "@emnapi/core": "^1.7.1",
+ "@emnapi/runtime": "^1.7.1",
+ "@tybys/wasm-util": "^0.10.1"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/Brooooooklyn"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": {
+ "version": "0.10.1",
+ "dev": true,
+ "inBundle": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "tslib": "^2.4.0"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": {
+ "version": "2.8.1",
+ "dev": true,
+ "inBundle": true,
+ "license": "0BSD",
+ "optional": true
+ },
"node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.2.2.tgz",
diff --git a/react_frontend/public/images/default-backdrop.png b/react_frontend/public/images/default-backdrop.png
new file mode 100644
index 0000000..40aecba
Binary files /dev/null and b/react_frontend/public/images/default-backdrop.png differ
diff --git a/react_frontend/public/images/default-logo.png b/react_frontend/public/images/default-logo.png
new file mode 100644
index 0000000..aebb1a8
Binary files /dev/null and b/react_frontend/public/images/default-logo.png differ
diff --git a/react_frontend/public/images/default-poster.png b/react_frontend/public/images/default-poster.png
new file mode 100644
index 0000000..cbf4965
Binary files /dev/null and b/react_frontend/public/images/default-poster.png differ
diff --git a/react_frontend/public/images/default-profile.png b/react_frontend/public/images/default-profile.png
new file mode 100644
index 0000000..eacb96e
Binary files /dev/null and b/react_frontend/public/images/default-profile.png differ
diff --git a/react_frontend/public/images/default-still.png b/react_frontend/public/images/default-still.png
new file mode 100644
index 0000000..40aecba
Binary files /dev/null and b/react_frontend/public/images/default-still.png differ
diff --git a/react_frontend/public/images/logo.png b/react_frontend/public/images/logo.png
new file mode 100644
index 0000000..8ae2e69
Binary files /dev/null and b/react_frontend/public/images/logo.png differ
diff --git a/react_frontend/src/App.tsx b/react_frontend/src/App.tsx
index 46a5992..440609d 100644
--- a/react_frontend/src/App.tsx
+++ b/react_frontend/src/App.tsx
@@ -1,121 +1,24 @@
-import { useState } from 'react'
-import reactLogo from './assets/react.svg'
-import viteLogo from './assets/vite.svg'
-import heroImg from './assets/hero.png'
-import './App.css'
+import { RouterProvider } from 'react-router-dom';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+import { TooltipProvider } from '@/components/ui/tooltip';
+import { router } from './router';
-function App() {
- const [count, setCount] = useState(0)
+const queryClient = new QueryClient({
+ defaultOptions: {
+ queries: {
+ retry: 1,
+ refetchOnWindowFocus: false,
+ staleTime: 2 * 60 * 1000,
+ },
+ },
+});
+export function App() {
return (
- <>
-
-
-
-
Get started
-
- Edit src/App.tsx and save to test HMR
-
-
-
-
-
-
-
-
-
-
-
Documentation
-
Your questions, answered
-
-
-
-
-
Connect with us
-
Join the Vite community
-
-
-
-
-
-
- >
- )
+
+
+
+
+
+ );
}
-
-export default App
diff --git a/react_frontend/src/api/collections.ts b/react_frontend/src/api/collections.ts
new file mode 100644
index 0000000..5f67c18
--- /dev/null
+++ b/react_frontend/src/api/collections.ts
@@ -0,0 +1,41 @@
+import { api } from '@/lib/api';
+import { normalizeCollection } from '@/lib/normalizers';
+import type { Collection } from '@/types';
+
+export const collectionsApi = {
+ getAll: () =>
+ api
+ .get('/collections')
+ .then((r) => r.data.map(normalizeCollection)),
+
+ getById: (id: number) =>
+ api
+ .get(`/collections/${id}`)
+ .then((r) => normalizeCollection(r.data)),
+
+ create: (data: Partial) =>
+ api.post('/collections', data).then((r) => r.data),
+
+ update: (id: number, data: Partial) =>
+ api.put(`/collections/${id}`, data).then((r) => normalizeCollection(r.data)),
+
+ updateWithMedia: (id: number, formData: FormData) =>
+ api
+ .put(`/collections/${id}`, formData, {
+ headers: { 'Content-Type': 'multipart/form-data' },
+ })
+ .then((r) => normalizeCollection(r.data)),
+
+ delete: (id: number) =>
+ api.delete(`/collections/${id}`).then((r) => r.data),
+
+ addEntry: (collectionId: number, entryId: number) =>
+ api
+ .post(`/collections/${collectionId}/entries`, { entry_id: entryId })
+ .then((r) => r.data),
+
+ removeEntry: (collectionId: number, entryId: number) =>
+ api
+ .delete(`/collections/${collectionId}/entries/${entryId}`)
+ .then((r) => r.data),
+};
diff --git a/react_frontend/src/api/entries.ts b/react_frontend/src/api/entries.ts
new file mode 100644
index 0000000..0324077
--- /dev/null
+++ b/react_frontend/src/api/entries.ts
@@ -0,0 +1,58 @@
+import { api } from '@/lib/api';
+import { normalizeEntry } from '@/lib/normalizers';
+import type { Entry } from '@/types';
+
+export const entriesApi = {
+ getAll: () =>
+ api.get('/entries').then((r) => r.data.map(normalizeEntry)),
+
+ getById: (id: number) =>
+ api.get(`/entries/${id}`).then((r) => normalizeEntry(r.data)),
+
+ create: (tmdb_id: number, is_tvserie: boolean) =>
+ api.post('/entries', { tmdb_id, is_tvserie }).then((r) => normalizeEntry(r.data)),
+
+ update: (id: number, data: Partial) =>
+ api.put(`/entries/${id}`, data).then((r) => normalizeEntry(r.data)),
+
+ updateRatings: (
+ id: number,
+ ratings: {
+ user_rating?: number | null;
+ tmdb_rating?: number | null;
+ imdb_rating?: number | null;
+ rotten_tomatoes_rating?: number | null;
+ }
+ ) => api.put(`/entries/${id}/ratings`, ratings).then((r) => r.data),
+
+ updateIds: (
+ id: number,
+ ids: { tmdb_id?: number; imdb_id?: string; tvdb_id?: number }
+ ) => api.put(`/entries/${id}/ids`, ids).then((r) => r.data),
+
+ delete: (id: number) => api.delete(`/entries/${id}`).then((r) => r.data),
+
+ refresh: (id: number) =>
+ api.put(`/entries/${id}/refresh`).then((r) => normalizeEntry(r.data)),
+
+ fetchCollection: (id: number) =>
+ api.put(`/entries/${id}/fetch-collection`).then((r) => r.data),
+
+ getSeasons: (id: number) =>
+ api.get(`/entries/${id}/seasons`).then((r) => Array.isArray(r.data) ? r.data : []),
+
+ syncSeries: () => api.get('/entries/sync-series').then((r) => r.data),
+
+ uploadMedia: (id: number, formData: FormData) =>
+ api
+ .post(`/entries/${id}/media`, formData, {
+ headers: { 'Content-Type': 'multipart/form-data' },
+ })
+ .then((r) => r.data),
+
+ setMediaSelected: (entryId: number, mediaId: number) =>
+ api.put(`/entries/${entryId}/media/${mediaId}`).then((r) => r.data),
+
+ deleteMedia: (entryId: number, mediaId: number) =>
+ api.delete(`/entries/${entryId}/media/${mediaId}`).then((r) => r.data),
+};
diff --git a/react_frontend/src/api/entry-seen.ts b/react_frontend/src/api/entry-seen.ts
new file mode 100644
index 0000000..28f86ec
--- /dev/null
+++ b/react_frontend/src/api/entry-seen.ts
@@ -0,0 +1,20 @@
+import { api } from '@/lib/api';
+import type { EntrySeen } from '@/types';
+
+export const entrySeenApi = {
+ getAll: () => api.get('/entry-seen').then((r) => r.data),
+
+ getById: (id: number) =>
+ api.get(`/entry-seen/${id}`).then((r) => r.data),
+
+ getByEntry: (entryId: number) =>
+ api.get(`/entry-seen/by-entry/${entryId}`).then((r) => r.data),
+
+ create: (data: { entry_id: number; date_seen: string; seen_with?: string }) =>
+ api.post('/entry-seen', data).then((r) => r.data),
+
+ update: (id: number, data: Partial) =>
+ api.put(`/entry-seen/${id}`, data).then((r) => r.data),
+
+ delete: (id: number) => api.delete(`/entry-seen/${id}`).then((r) => r.data),
+};
diff --git a/react_frontend/src/api/episode-seen.ts b/react_frontend/src/api/episode-seen.ts
new file mode 100644
index 0000000..3e5645e
--- /dev/null
+++ b/react_frontend/src/api/episode-seen.ts
@@ -0,0 +1,27 @@
+import { api } from '@/lib/api';
+import type { EpisodeSeen } from '@/types';
+
+export const episodeSeenApi = {
+ getAll: () => api.get('/episode-seen').then((r) => r.data),
+
+ getById: (id: number) =>
+ api.get(`/episode-seen/${id}`).then((r) => r.data),
+
+ getByEpisode: (episodeId: number) =>
+ api
+ .get(`/episode-seen/by-episode/${episodeId}`)
+ .then((r) => r.data),
+
+ create: (data: {
+ entry_id: number;
+ episode_id: number;
+ date_seen: string;
+ seen_with?: string;
+ }) => api.post('/episode-seen', data).then((r) => r.data),
+
+ update: (id: number, data: Partial) =>
+ api.put(`/episode-seen/${id}`, data).then((r) => r.data),
+
+ delete: (id: number) =>
+ api.delete(`/episode-seen/${id}`).then((r) => r.data),
+};
diff --git a/react_frontend/src/api/episodes.ts b/react_frontend/src/api/episodes.ts
new file mode 100644
index 0000000..832fdce
--- /dev/null
+++ b/react_frontend/src/api/episodes.ts
@@ -0,0 +1,9 @@
+import { api } from '@/lib/api';
+import type { Episode } from '@/types';
+
+export const episodesApi = {
+ getByMonth: (startDate: string, endDate: string) =>
+ api
+ .get(`/episodes/month/${startDate}/${endDate}`)
+ .then((r) => r.data),
+};
diff --git a/react_frontend/src/api/people.ts b/react_frontend/src/api/people.ts
new file mode 100644
index 0000000..4c809cf
--- /dev/null
+++ b/react_frontend/src/api/people.ts
@@ -0,0 +1,9 @@
+import { api } from '@/lib/api';
+import type { People } from '@/types';
+
+export const peopleApi = {
+ getAll: () => api.get('/people').then((r) => r.data),
+
+ getById: (id: number) =>
+ api.get(`/people/${id}`).then((r) => r.data),
+};
diff --git a/react_frontend/src/api/seasons.ts b/react_frontend/src/api/seasons.ts
new file mode 100644
index 0000000..231c1b2
--- /dev/null
+++ b/react_frontend/src/api/seasons.ts
@@ -0,0 +1,20 @@
+import { api } from '@/lib/api';
+import type { Season } from '@/types';
+
+export const seasonsApi = {
+ getAll: () => api.get('/seasons').then((r) => r.data),
+
+ getById: (id: number) =>
+ api.get(`/seasons/${id}`).then((r) => r.data),
+
+ getEpisodes: (id: number) =>
+ api.get(`/seasons/${id}/episodes`).then((r) => r.data),
+
+ create: (data: Partial) =>
+ api.post('/seasons', data).then((r) => r.data),
+
+ update: (id: number, data: Partial) =>
+ api.put(`/seasons/${id}`, data).then((r) => r.data),
+
+ delete: (id: number) => api.delete(`/seasons/${id}`).then((r) => r.data),
+};
diff --git a/react_frontend/src/api/settings.ts b/react_frontend/src/api/settings.ts
new file mode 100644
index 0000000..345119b
--- /dev/null
+++ b/react_frontend/src/api/settings.ts
@@ -0,0 +1,9 @@
+import { api } from '@/lib/api';
+import type { Settings } from '@/types';
+
+export const settingsApi = {
+ get: () => api.get('/settings').then((r) => r.data),
+
+ update: (data: Partial) =>
+ api.put('/settings', data).then((r) => r.data),
+};
diff --git a/react_frontend/src/api/statistics.ts b/react_frontend/src/api/statistics.ts
new file mode 100644
index 0000000..c11af02
--- /dev/null
+++ b/react_frontend/src/api/statistics.ts
@@ -0,0 +1,5 @@
+import { api } from '@/lib/api';
+
+export const statisticsApi = {
+ get: () => api.get('/statistics').then((r) => r.data),
+};
diff --git a/react_frontend/src/api/tmdb.ts b/react_frontend/src/api/tmdb.ts
new file mode 100644
index 0000000..5ab428b
--- /dev/null
+++ b/react_frontend/src/api/tmdb.ts
@@ -0,0 +1,53 @@
+import { api } from '@/lib/api';
+import type { TmdbEntry, TmdbPaginatedResponse, TmdbPerson } from '@/types';
+
+export const tmdbApi = {
+ getPopularMovies: (page = 1) =>
+ api
+ .get>('/entries/tmdb/popular/movie', {
+ params: { page },
+ })
+ .then((r) => r.data),
+
+ getPopularTv: (page = 1) =>
+ api
+ .get>('/entries/tmdb/popular/tv', {
+ params: { page },
+ })
+ .then((r) => r.data),
+
+ getTrendingMovies: (page = 1) =>
+ api
+ .get>('/entries/tmdb/trending/movie', {
+ params: { page },
+ })
+ .then((r) => r.data),
+
+ getTrendingTv: (page = 1) =>
+ api
+ .get>('/entries/tmdb/trending/tv', {
+ params: { page },
+ })
+ .then((r) => r.data),
+
+ search: (query: string, page = 1) =>
+ api
+ .get>('/entries/tmdb/search', {
+ params: { query, page },
+ })
+ .then((r) => r.data),
+
+ getPopularPeople: (page = 1) =>
+ api
+ .get>('/people/tmdb/popular', {
+ params: { page },
+ })
+ .then((r) => r.data),
+
+ searchPeople: (query: string, page = 1) =>
+ api
+ .get>('/people/tmdb/search', {
+ params: { query, page },
+ })
+ .then((r) => r.data),
+};
diff --git a/react_frontend/src/components/collections/CollectionsGrid.tsx b/react_frontend/src/components/collections/CollectionsGrid.tsx
new file mode 100644
index 0000000..5aab80c
--- /dev/null
+++ b/react_frontend/src/components/collections/CollectionsGrid.tsx
@@ -0,0 +1,71 @@
+import { Link } from 'react-router-dom';
+import { getCollectionPosterUrl } from '@/lib/media-utils';
+import { Skeleton } from '@/components/ui/skeleton';
+import type { Collection } from '@/types';
+
+interface CollectionCardProps {
+ collection: Collection;
+}
+
+export function CollectionCard({ collection }: CollectionCardProps) {
+ return (
+
+
+
})
+
+
+ {collection.name}
+
+
+
+
+ );
+}
+
+export function CollectionCardSkeleton() {
+ return ;
+}
+
+interface CollectionsGridProps {
+ collections: Collection[];
+ isLoading?: boolean;
+}
+
+export function CollectionsGrid({
+ collections,
+ isLoading,
+}: CollectionsGridProps) {
+ if (isLoading) {
+ return (
+
+ {Array.from({ length: 12 }).map((_, i) => (
+
+ ))}
+
+ );
+ }
+
+ if (collections.length === 0) {
+ return (
+
+ No collections found.
+
+ );
+ }
+
+ return (
+
+ {collections.map((collection) => (
+
+ ))}
+
+ );
+}
diff --git a/react_frontend/src/components/dialogs/AddEntryToCollectionDialog.tsx b/react_frontend/src/components/dialogs/AddEntryToCollectionDialog.tsx
new file mode 100644
index 0000000..fcf595f
--- /dev/null
+++ b/react_frontend/src/components/dialogs/AddEntryToCollectionDialog.tsx
@@ -0,0 +1,81 @@
+import { useState } from 'react';
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { Input } from '@/components/ui/input';
+import { Checkbox } from '@/components/ui/checkbox';
+import { ScrollArea } from '@/components/ui/scroll-area';
+import { useCollections } from '@/hooks/useCollections';
+import { collectionsApi } from '@/api/collections';
+import type { Collection } from '@/types';
+
+interface AddEntryToCollectionDialogProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ entryId: number;
+ entryCollections?: Collection[];
+}
+
+export function AddEntryToCollectionDialog({
+ open,
+ onOpenChange,
+ entryId,
+ entryCollections = [],
+}: AddEntryToCollectionDialogProps) {
+ const [search, setSearch] = useState('');
+ const { data: allCollections = [] } = useCollections();
+ const entryCollectionIds = new Set(entryCollections.map((c) => c.id));
+
+ const filtered = allCollections.filter((c) =>
+ c.name.toLowerCase().includes(search.toLowerCase())
+ );
+
+ const handleToggle = async (collectionId: number, checked: boolean) => {
+ if (checked) {
+ await collectionsApi.addEntry(collectionId, entryId);
+ } else {
+ await collectionsApi.removeEntry(collectionId, entryId);
+ }
+ };
+
+ return (
+
+ );
+}
diff --git a/react_frontend/src/components/dialogs/CollectionEditDialog.tsx b/react_frontend/src/components/dialogs/CollectionEditDialog.tsx
new file mode 100644
index 0000000..328067a
--- /dev/null
+++ b/react_frontend/src/components/dialogs/CollectionEditDialog.tsx
@@ -0,0 +1,203 @@
+import { useState, useRef } 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 { Textarea } from '@/components/ui/textarea';
+import { ImageIcon } from 'lucide-react';
+import { useUpdateCollection } from '@/hooks/useCollections';
+import type { Collection } from '@/types';
+
+interface CollectionEditDialogProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ collection: Collection;
+}
+
+export function CollectionEditDialog({
+ open,
+ onOpenChange,
+ collection,
+}: CollectionEditDialogProps) {
+ const [name, setName] = useState(collection.name);
+ const [description, setDescription] = useState(collection.description || '');
+ const [userRating, setUserRating] = useState(
+ collection.user_rating?.toString() || ''
+ );
+ const [posterFile, setPosterFile] = useState(null);
+ const [backdropFile, setBackdropFile] = useState(null);
+ const [posterPreview, setPosterPreview] = useState(null);
+ const [backdropPreview, setBackdropPreview] = useState(null);
+
+ const posterInputRef = useRef(null);
+ const backdropInputRef = useRef(null);
+
+ const updateCollection = useUpdateCollection();
+
+ const handlePosterChange = (e: React.ChangeEvent) => {
+ const file = e.target.files?.[0];
+ if (file) {
+ setPosterFile(file);
+ setPosterPreview(URL.createObjectURL(file));
+ }
+ };
+
+ const handleBackdropChange = (e: React.ChangeEvent) => {
+ const file = e.target.files?.[0];
+ if (file) {
+ setBackdropFile(file);
+ setBackdropPreview(URL.createObjectURL(file));
+ }
+ };
+
+ const handleSubmit = (e: React.FormEvent) => {
+ e.preventDefault();
+
+ const formData = new FormData();
+ formData.append('name', name);
+ formData.append('description', description);
+ formData.append('userRating', userRating || '0');
+
+ if (posterFile) {
+ formData.append('poster', posterFile);
+ }
+ if (backdropFile) {
+ formData.append('backdrop', backdropFile);
+ }
+
+ updateCollection.mutate(
+ { id: collection.id, data: formData },
+ { onSuccess: () => onOpenChange(false) }
+ );
+ };
+
+ return (
+
+ );
+}
diff --git a/react_frontend/src/components/dialogs/ConfirmDialog.tsx b/react_frontend/src/components/dialogs/ConfirmDialog.tsx
new file mode 100644
index 0000000..ddcf8ea
--- /dev/null
+++ b/react_frontend/src/components/dialogs/ConfirmDialog.tsx
@@ -0,0 +1,53 @@
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { Button } from '@/components/ui/button';
+
+interface ConfirmDialogProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ title: string;
+ description: string;
+ confirmLabel?: string;
+ cancelLabel?: string;
+ onConfirm: () => void;
+ variant?: 'default' | 'destructive';
+}
+
+export function ConfirmDialog({
+ open,
+ onOpenChange,
+ title,
+ description,
+ confirmLabel = 'Confirm',
+ cancelLabel = 'Cancel',
+ onConfirm,
+ variant = 'default',
+}: ConfirmDialogProps) {
+ return (
+
+ );
+}
diff --git a/react_frontend/src/components/dialogs/EntryMediaDialog.tsx b/react_frontend/src/components/dialogs/EntryMediaDialog.tsx
new file mode 100644
index 0000000..4950678
--- /dev/null
+++ b/react_frontend/src/components/dialogs/EntryMediaDialog.tsx
@@ -0,0 +1,144 @@
+import { useState } from 'react';
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { ScrollArea } from '@/components/ui/scroll-area';
+import { Check, Trash2, Upload } from 'lucide-react';
+import { getMediaUrl } from '@/lib/api';
+import { entriesApi } from '@/api/entries';
+import { useUploadMedia } from '@/hooks/useEntries';
+import type { Media } from '@/types';
+
+interface EntryMediaDialogProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ entryId: number;
+ medias: Media[];
+}
+
+export function EntryMediaDialog({
+ open,
+ onOpenChange,
+ entryId,
+ medias,
+}: EntryMediaDialogProps) {
+ const [activeTab, setActiveTab] = useState('poster');
+ const uploadMedia = useUploadMedia();
+
+ const filteredMedias = medias.filter((m) => m.type === activeTab);
+
+ const handleUpload = (type: string) => {
+ const input = document.createElement('input');
+ input.type = 'file';
+ input.accept = 'image/*';
+ input.onchange = async (e) => {
+ const file = (e.target as HTMLInputElement).files?.[0];
+ if (!file) return;
+ const formData = new FormData();
+ formData.append(type, file);
+ uploadMedia.mutate({ id: entryId, formData });
+ };
+ input.click();
+ };
+
+ const handleSelect = async (mediaId: number) => {
+ await entriesApi.setMediaSelected(entryId, mediaId);
+ };
+
+ const handleDelete = async (mediaId: number) => {
+ await entriesApi.deleteMedia(entryId, mediaId);
+ };
+
+ return (
+
+ );
+}
diff --git a/react_frontend/src/components/dialogs/EntrySeenDialog.tsx b/react_frontend/src/components/dialogs/EntrySeenDialog.tsx
new file mode 100644
index 0000000..a70f994
--- /dev/null
+++ b/react_frontend/src/components/dialogs/EntrySeenDialog.tsx
@@ -0,0 +1,253 @@
+import { useState } from 'react';
+import { useForm } from 'react-hook-form';
+import { zodResolver } from '@hookform/resolvers/zod';
+import { z } from 'zod';
+import { format } from 'date-fns';
+import { CalendarIcon } from 'lucide-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 {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from '@/components/ui/popover';
+import { Calendar } from '@/components/ui/calendar';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import { cn } from '@/lib/utils';
+import { useCreateEntrySeen, useUpdateEntrySeen } from '@/hooks/useEntrySeen';
+import { useCreateEpisodeSeen } from '@/hooks/useEpisodeSeen';
+import type { Entry, Season, EntrySeen } 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'),
+ date_seen: z.string().min(1, 'Date is required'),
+ seen_with: z.string().optional(),
+});
+
+interface EntrySeenDialogProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ entry: Entry;
+ seasons?: Season[];
+ mode: 'add' | 'edit';
+ editRecord?: EntrySeen;
+}
+
+export function EntrySeenDialog({
+ open,
+ onOpenChange,
+ entry,
+ seasons,
+ mode,
+ editRecord,
+}: EntrySeenDialogProps) {
+ const [date, setDate] = useState(
+ editRecord?.date_seen ? new Date(editRecord.date_seen) : new Date()
+ );
+ const [selectedSeasonId, setSelectedSeasonId] = useState('');
+
+ const isTV = entry.is_tvseries;
+ const schema = isTV ? tvSeenSchema : movieSeenSchema;
+ const seasonList = Array.isArray(seasons) ? seasons : [];
+
+ const {
+ register,
+ handleSubmit,
+ setValue,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(schema),
+ defaultValues: {
+ date_seen: editRecord?.date_seen || format(new Date(), 'yyyy-MM-dd'),
+ seen_with: editRecord?.seen_with || '',
+ season_id: '',
+ episode_id: '',
+ },
+ });
+
+ const createEntrySeen = useCreateEntrySeen();
+ const updateEntrySeen = useUpdateEntrySeen();
+ const createEpisodeSeen = useCreateEpisodeSeen();
+
+ const selectedSeason = seasonList.find(
+ (s) => s.id.toString() === selectedSeasonId
+ );
+
+ const onSubmit = (data: Record) => {
+ if (isTV && data.episode_id) {
+ createEpisodeSeen.mutate(
+ {
+ entry_id: entry.id,
+ episode_id: parseInt(data.episode_id),
+ date_seen: data.date_seen!,
+ seen_with: data.seen_with || undefined,
+ },
+ { onSuccess: () => onOpenChange(false) }
+ );
+ } else if (mode === 'edit' && editRecord) {
+ updateEntrySeen.mutate(
+ {
+ id: editRecord.id,
+ data: {
+ entry_id: entry.id,
+ date_seen: data.date_seen,
+ seen_with: data.seen_with || undefined,
+ },
+ },
+ { onSuccess: () => onOpenChange(false) }
+ );
+ } else {
+ createEntrySeen.mutate(
+ {
+ entry_id: entry.id,
+ date_seen: data.date_seen!,
+ seen_with: data.seen_with || undefined,
+ },
+ { onSuccess: () => onOpenChange(false) }
+ );
+ }
+ };
+
+ return (
+
+ );
+}
diff --git a/react_frontend/src/components/dialogs/EntrySettingsDialog.tsx b/react_frontend/src/components/dialogs/EntrySettingsDialog.tsx
new file mode 100644
index 0000000..d9e9f45
--- /dev/null
+++ b/react_frontend/src/components/dialogs/EntrySettingsDialog.tsx
@@ -0,0 +1,56 @@
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import { Label } from '@/components/ui/label';
+import { Switch } from '@/components/ui/switch';
+import { useUpdateEntry } from '@/hooks/useEntries';
+import type { Entry } from '@/types';
+
+interface EntrySettingsDialogProps {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ entry: Entry;
+}
+
+export function EntrySettingsDialog({
+ open,
+ onOpenChange,
+ entry,
+}: EntrySettingsDialogProps) {
+ const updateEntry = useUpdateEntry();
+
+ const handleToggle = (field: keyof Entry, value: boolean) => {
+ updateEntry.mutate({ id: entry.id, data: { [field]: value } });
+ };
+
+ const settings = [
+ { field: 'favorit' as const, label: 'Favorite' },
+ { field: 'hidden' as const, label: 'Hidden' },
+ { field: 'watchlist' as const, label: 'Watchlist' },
+ ];
+
+ return (
+
+ );
+}
diff --git a/react_frontend/src/components/entries/CastList.tsx b/react_frontend/src/components/entries/CastList.tsx
new file mode 100644
index 0000000..ca8b29d
--- /dev/null
+++ b/react_frontend/src/components/entries/CastList.tsx
@@ -0,0 +1,60 @@
+import { Link } from 'react-router-dom';
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
+import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
+import { getProfileUrl } from '@/lib/media-utils';
+import type { Credit } from '@/types';
+
+interface CastListProps {
+ credits: Credit[];
+}
+
+export function CastList({ credits }: CastListProps) {
+ const castCredits = credits.filter((c) => c.cast_type === 'cast');
+
+ if (castCredits.length === 0) return null;
+
+ return (
+
+
Cast
+
+
+ {castCredits.map((credit) => (
+
+ ))}
+
+
+
+
+ );
+}
+
+function CastCard({ credit }: { credit: Credit }) {
+ const profileUrl = credit.people?.profile_path
+ ? getProfileUrl(credit.people.profile_path)
+ : undefined;
+
+ return (
+
+
+
+
+ {credit.people?.name
+ ?.split(' ')
+ .map((n) => n[0])
+ .join('')}
+
+
+
+
+ {credit.people?.name}
+
+
+ {credit.character}
+
+
+
+ );
+}
diff --git a/react_frontend/src/components/entries/EntryCard.tsx b/react_frontend/src/components/entries/EntryCard.tsx
new file mode 100644
index 0000000..e697399
--- /dev/null
+++ b/react_frontend/src/components/entries/EntryCard.tsx
@@ -0,0 +1,176 @@
+import { useState } from 'react';
+import { Link } from 'react-router-dom';
+import { Plus, Trash2, Star } from 'lucide-react';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Skeleton } from '@/components/ui/skeleton';
+import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils';
+import { useCreateEntry, useDeleteEntry } from '@/hooks/useEntries';
+import { useLibraryStore } from '@/stores/useLibraryStore';
+import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
+import type { Entry, TmdbEntry } from '@/types';
+
+interface EntryCardProps {
+ entry?: Entry;
+ tmdbEntry?: TmdbEntry;
+}
+
+export function EntryCard({ entry, tmdbEntry }: EntryCardProps) {
+ const [showConfirm, setShowConfirm] = useState(false);
+ const createEntry = useCreateEntry();
+ const deleteEntry = useDeleteEntry();
+ const libraryEntry = useLibraryStore((s) => {
+ if (entry?.isInLibrary) return entry;
+ if (tmdbEntry) {
+ for (const e of s.entries.values()) {
+ if (e.entryIds?.tmdb_id === tmdbEntry.id) return e;
+ }
+ }
+ return null;
+ });
+
+ const isInLibrary = !!libraryEntry;
+ const displayEntry = libraryEntry || entry;
+
+ // Resolve display data
+ const title =
+ displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || 'Untitled';
+ const year = displayEntry
+ ? getYear(displayEntry.release_date)
+ : getYear(tmdbEntry?.release_date || tmdbEntry?.first_air_date || null);
+ const rating =
+ displayEntry?.entryRatings?.user_rating ||
+ displayEntry?.entryRatings?.tmdb_rating ||
+ tmdbEntry?.vote_average;
+ const runtime =
+ displayEntry && !displayEntry.is_tvseries
+ ? formatRuntime(displayEntry.runtime)
+ : '';
+ const isTv =
+ displayEntry?.is_tvseries ||
+ tmdbEntry?.media_type === 'tv' ||
+ !!tmdbEntry?.name;
+
+ const posterUrl = displayEntry
+ ? getPosterUrl(displayEntry)
+ : tmdbEntry?.poster_path
+ ? `https://image.tmdb.org/t/p/w342${tmdbEntry.poster_path}`
+ : '/images/default-poster.png';
+
+ const entryLink = displayEntry
+ ? `/entry/${displayEntry.id}`
+ : undefined;
+
+ const handleAdd = (e: React.MouseEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!tmdbEntry) return;
+ createEntry.mutate({ tmdb_id: tmdbEntry.id, is_tvserie: isTv });
+ };
+
+ const handleRemove = (e: React.MouseEvent) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setShowConfirm(true);
+ };
+
+ const confirmRemove = () => {
+ if (libraryEntry) {
+ deleteEntry.mutate(libraryEntry.id);
+ }
+ setShowConfirm(false);
+ };
+
+ const card = (
+
+ {/* Poster */}
+
+

+
+ {/* Library badge – only on home / search (tmdbEntry context) */}
+ {isInLibrary && tmdbEntry && (
+
+ In Library
+
+ )}
+
+ {/* Favorite indicator */}
+ {libraryEntry?.favorit && (
+
+ )}
+
+ {/* Hover overlay */}
+
+
+
+ {title}
+
+
+ {rating != null && rating > 0 && (
+
+
+ {typeof rating === 'number' ? rating.toFixed(1) : rating}
+
+ )}
+ {year && {year}}
+ {runtime && {runtime}}
+
+
+ {/* Actions */}
+
+ {isInLibrary ? (
+
+ ) : tmdbEntry ? (
+
+ ) : null}
+
+
+
+
+
+ );
+
+ return (
+ <>
+ {entryLink ? {card} : card}
+
+ >
+ );
+}
+
+export function EntryCardSkeleton() {
+ return (
+
+
+
+ );
+}
diff --git a/react_frontend/src/components/entries/EntryLibraryGrid.tsx b/react_frontend/src/components/entries/EntryLibraryGrid.tsx
new file mode 100644
index 0000000..6fd8037
--- /dev/null
+++ b/react_frontend/src/components/entries/EntryLibraryGrid.tsx
@@ -0,0 +1,72 @@
+import { useCallback, useRef, useEffect } from 'react';
+import { EntryCard, EntryCardSkeleton } from './EntryCard';
+import type { Entry } from '@/types';
+
+interface EntryLibraryGridProps {
+ entries: Entry[];
+ isLoading?: boolean;
+ hasMore?: boolean;
+ onLoadMore?: () => void;
+}
+
+export function EntryLibraryGrid({
+ entries,
+ isLoading,
+ hasMore,
+ onLoadMore,
+}: EntryLibraryGridProps) {
+ const observerRef = useRef(null);
+
+ const lastEntryRef = useCallback(
+ (node: HTMLDivElement | null) => {
+ if (isLoading) return;
+ if (observerRef.current) observerRef.current.disconnect();
+ observerRef.current = new IntersectionObserver((entries) => {
+ if (entries[0].isIntersecting && hasMore && onLoadMore) {
+ onLoadMore();
+ }
+ });
+ if (node) observerRef.current.observe(node);
+ },
+ [isLoading, hasMore, onLoadMore]
+ );
+
+ useEffect(() => {
+ return () => observerRef.current?.disconnect();
+ }, []);
+
+ if (isLoading && entries.length === 0) {
+ return (
+
+ {Array.from({ length: 21 }).map((_, i) => (
+
+ ))}
+
+ );
+ }
+
+ if (entries.length === 0) {
+ return (
+
+ No entries found.
+
+ );
+ }
+
+ return (
+
+ {entries.map((entry, index) => (
+
+
+
+ ))}
+ {isLoading &&
+ Array.from({ length: 7 }).map((_, i) => (
+
+ ))}
+
+ );
+}
diff --git a/react_frontend/src/components/entries/EpisodeWatchHistory.tsx b/react_frontend/src/components/entries/EpisodeWatchHistory.tsx
new file mode 100644
index 0000000..408b966
--- /dev/null
+++ b/react_frontend/src/components/entries/EpisodeWatchHistory.tsx
@@ -0,0 +1,80 @@
+import { format } from 'date-fns';
+import type { EntrySeen, EpisodeSeen } from '@/types';
+import { Button } from '@/components/ui/button';
+import { Pencil, Trash2 } from 'lucide-react';
+
+interface EpisodeWatchHistoryProps {
+ watchHistory: (EntrySeen | EpisodeSeen)[];
+ onEdit?: (id: number) => void;
+ onDelete?: (id: number) => void;
+}
+
+export function EpisodeWatchHistory({
+ watchHistory,
+ onEdit,
+ onDelete,
+}: EpisodeWatchHistoryProps) {
+ if (watchHistory.length === 0) {
+ return (
+ No watch history yet.
+ );
+ }
+
+ return (
+
+
Watch History
+
+
+
+
+ | Date |
+ Seen With |
+ Actions |
+
+
+
+ {watchHistory.map((record) => (
+
+ |
+ {record.date_seen
+ ? format(new Date(record.date_seen), 'MMM d, yyyy')
+ : '-'}
+ |
+
+ {record.seen_with || '-'}
+ |
+
+
+ {onEdit && (
+
+ )}
+ {onDelete && (
+
+ )}
+
+ |
+
+ ))}
+
+
+
+
+ );
+}
diff --git a/react_frontend/src/components/entries/SeasonsContainer.tsx b/react_frontend/src/components/entries/SeasonsContainer.tsx
new file mode 100644
index 0000000..6368322
--- /dev/null
+++ b/react_frontend/src/components/entries/SeasonsContainer.tsx
@@ -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 (
+
+
Seasons
+
+ {display.map((season) => (
+
+ ))}
+
+ {sorted.length > 2 && (
+
+ )}
+
+ );
+}
+
+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 (
+
+ {/* Poster thumbnail */}
+
+

+
+
+ {/* Info */}
+
+
+ {season.name}
+
+ {getYear(season.air_date)}
+
+
+
+
+
+ {watchedCount}/{totalEpisodes}
+
+
+
+
+ {/* Quick watch button */}
+ {watchedCount < totalEpisodes && (
+
+ )}
+
+ );
+}
diff --git a/react_frontend/src/components/entries/TrendingGrid.tsx b/react_frontend/src/components/entries/TrendingGrid.tsx
new file mode 100644
index 0000000..494afde
--- /dev/null
+++ b/react_frontend/src/components/entries/TrendingGrid.tsx
@@ -0,0 +1,71 @@
+import { useState } from 'react';
+import { Link } from 'react-router-dom';
+import { ChevronRight } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { EntryCard, EntryCardSkeleton } from './EntryCard';
+import type { TmdbEntry } from '@/types';
+
+interface TrendingGridProps {
+ title: string;
+ movieEntries: TmdbEntry[];
+ tvEntries: TmdbEntry[];
+ isLoading?: boolean;
+ moreLink: string;
+}
+
+export function TrendingGrid({
+ title,
+ movieEntries,
+ tvEntries,
+ isLoading,
+ moreLink,
+}: TrendingGridProps) {
+ const [activeTab, setActiveTab] = useState<'movie' | 'tv'>('movie');
+ const entries = activeTab === 'movie' ? movieEntries : tvEntries;
+
+ // Limit to 2 rows (14 items for a 7-column grid)
+ const displayEntries = entries.slice(0, 14);
+
+ return (
+
+
+
{title}
+
+ setActiveTab(v as 'movie' | 'tv')}
+ >
+
+
+ Movies
+
+
+ TV Series
+
+
+
+
+
+
+
+ {isLoading ? (
+
+ {Array.from({ length: 14 }).map((_, i) => (
+
+ ))}
+
+ ) : (
+
+ {displayEntries.map((tmdbEntry) => (
+
+ ))}
+
+ )}
+
+ );
+}
diff --git a/react_frontend/src/components/layout/AppLayout.tsx b/react_frontend/src/components/layout/AppLayout.tsx
new file mode 100644
index 0000000..62e58c4
--- /dev/null
+++ b/react_frontend/src/components/layout/AppLayout.tsx
@@ -0,0 +1,15 @@
+import { Outlet } from 'react-router-dom';
+import { Sidebar } from './Sidebar';
+
+export function AppLayout() {
+ return (
+
+ );
+}
diff --git a/react_frontend/src/components/layout/Sidebar.tsx b/react_frontend/src/components/layout/Sidebar.tsx
new file mode 100644
index 0000000..477e5dc
--- /dev/null
+++ b/react_frontend/src/components/layout/Sidebar.tsx
@@ -0,0 +1,136 @@
+import { NavLink } from 'react-router-dom';
+import {
+ LayoutDashboard,
+ Home,
+ Library,
+ ListVideo,
+ FolderOpen,
+ Image,
+ CalendarDays,
+ Users,
+ Settings,
+ Moon,
+ Sun,
+ Film,
+} from 'lucide-react';
+import { useThemeStore } from '@/stores/useThemeStore';
+import { Button } from '@/components/ui/button';
+import { Separator } from '@/components/ui/separator';
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from '@/components/ui/tooltip';
+
+const mainNav = [
+ { to: '/dashboard', icon: LayoutDashboard, label: 'Dashboard' },
+ { to: '/', icon: Home, label: 'Home' },
+];
+
+const libraryNav = [
+ { to: '/library', icon: Library, label: 'Library' },
+ { to: '/watchlist', icon: ListVideo, label: 'Watchlist' },
+ { to: '/collections', icon: FolderOpen, label: 'Collections' },
+ { to: '/media', icon: Image, label: 'Media' },
+];
+
+const otherNav = [
+ { to: '/calendar', icon: CalendarDays, label: 'Calendar' },
+ { to: '/people', icon: Users, label: 'People' },
+];
+
+function NavItem({
+ to,
+ icon: Icon,
+ label,
+}: {
+ to: string;
+ icon: React.ComponentType<{ className?: string }>;
+ label: string;
+}) {
+ return (
+
+
+
+ `flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-colors ${
+ isActive
+ ? 'bg-sidebar-accent text-sidebar-primary font-medium'
+ : 'text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground'
+ }`
+ }
+ >
+
+ {label}
+
+
+ {label}
+
+ );
+}
+
+export function Sidebar() {
+ const { theme, toggleTheme } = useThemeStore();
+
+ return (
+
+ );
+}
diff --git a/react_frontend/src/hooks/useCollections.ts b/react_frontend/src/hooks/useCollections.ts
new file mode 100644
index 0000000..32fdb51
--- /dev/null
+++ b/react_frontend/src/hooks/useCollections.ts
@@ -0,0 +1,35 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
+import { collectionsApi } from '@/api/collections';
+
+export const collectionKeys = {
+ all: ['collections'] as const,
+ detail: (id: number) => ['collections', id] as const,
+};
+
+export function useCollections() {
+ return useQuery({
+ queryKey: collectionKeys.all,
+ queryFn: collectionsApi.getAll,
+ });
+}
+
+export function useCollection(id: number) {
+ return useQuery({
+ queryKey: collectionKeys.detail(id),
+ queryFn: () => collectionsApi.getById(id),
+ enabled: !!id,
+ });
+}
+
+export function useUpdateCollection() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: ({ id, data }: { id: number; data: FormData }) =>
+ collectionsApi.updateWithMedia(id, data),
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({ queryKey: collectionKeys.detail(variables.id) });
+ queryClient.invalidateQueries({ queryKey: collectionKeys.all });
+ },
+ });
+}
diff --git a/react_frontend/src/hooks/useEntries.ts b/react_frontend/src/hooks/useEntries.ts
new file mode 100644
index 0000000..11c0845
--- /dev/null
+++ b/react_frontend/src/hooks/useEntries.ts
@@ -0,0 +1,111 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
+import { entriesApi } from '@/api/entries';
+import { useLibraryStore } from '@/stores/useLibraryStore';
+import type { Entry } from '@/types';
+
+export const entryKeys = {
+ all: ['entries'] as const,
+ detail: (id: number) => ['entries', id] as const,
+ seasons: (id: number) => ['entries', id, 'seasons'] as const,
+};
+
+export function useLibrary() {
+ const setEntries = useLibraryStore((s) => s.setEntries);
+
+ return useQuery({
+ queryKey: entryKeys.all,
+ queryFn: async () => {
+ const data = await entriesApi.getAll();
+ setEntries(data);
+ return data;
+ },
+ staleTime: 5 * 60 * 1000,
+ });
+}
+
+export function useEntry(id: number) {
+ return useQuery({
+ queryKey: entryKeys.detail(id),
+ queryFn: () => entriesApi.getById(id),
+ enabled: !!id,
+ });
+}
+
+export function useEntrySeasons(id: number) {
+ return useQuery({
+ queryKey: entryKeys.seasons(id),
+ queryFn: () => entriesApi.getSeasons(id),
+ enabled: !!id,
+ });
+}
+
+export function useCreateEntry() {
+ const queryClient = useQueryClient();
+ const addEntry = useLibraryStore((s) => s.addEntry);
+
+ return useMutation({
+ mutationFn: ({
+ tmdb_id,
+ is_tvserie,
+ }: {
+ tmdb_id: number;
+ is_tvserie: boolean;
+ }) => entriesApi.create(tmdb_id, is_tvserie),
+ onSuccess: (entry) => {
+ addEntry(entry);
+ queryClient.invalidateQueries({ queryKey: entryKeys.all });
+ },
+ });
+}
+
+export function useUpdateEntry() {
+ const queryClient = useQueryClient();
+ const updateEntry = useLibraryStore((s) => s.updateEntry);
+
+ return useMutation({
+ mutationFn: ({ id, data }: { id: number; data: Partial }) =>
+ entriesApi.update(id, data),
+ onSuccess: (entry) => {
+ updateEntry(entry.id, entry);
+ queryClient.invalidateQueries({ queryKey: entryKeys.detail(entry.id) });
+ },
+ });
+}
+
+export function useDeleteEntry() {
+ const queryClient = useQueryClient();
+ const removeEntry = useLibraryStore((s) => s.removeEntry);
+
+ return useMutation({
+ mutationFn: (id: number) => entriesApi.delete(id),
+ onSuccess: (_data, id) => {
+ removeEntry(id);
+ queryClient.invalidateQueries({ queryKey: entryKeys.all });
+ },
+ });
+}
+
+export function useRefreshEntry() {
+ const queryClient = useQueryClient();
+ const updateEntry = useLibraryStore((s) => s.updateEntry);
+
+ return useMutation({
+ mutationFn: (id: number) => entriesApi.refresh(id),
+ onSuccess: (entry) => {
+ updateEntry(entry.id, entry);
+ queryClient.invalidateQueries({ queryKey: entryKeys.detail(entry.id) });
+ },
+ });
+}
+
+export function useUploadMedia() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: ({ id, formData }: { id: number; formData: FormData }) =>
+ entriesApi.uploadMedia(id, formData),
+ onSuccess: (_data, { id }) => {
+ queryClient.invalidateQueries({ queryKey: entryKeys.detail(id) });
+ },
+ });
+}
diff --git a/react_frontend/src/hooks/useEntrySeen.ts b/react_frontend/src/hooks/useEntrySeen.ts
new file mode 100644
index 0000000..d90f7fd
--- /dev/null
+++ b/react_frontend/src/hooks/useEntrySeen.ts
@@ -0,0 +1,71 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
+import { entrySeenApi } from '@/api/entry-seen';
+import { entryKeys } from './useEntries';
+
+export const entrySeenKeys = {
+ all: ['entry-seen'] as const,
+ byEntry: (entryId: number) => ['entry-seen', 'by-entry', entryId] as const,
+};
+
+export function useEntrySeenByEntry(entryId: number) {
+ return useQuery({
+ queryKey: entrySeenKeys.byEntry(entryId),
+ queryFn: () => entrySeenApi.getByEntry(entryId),
+ enabled: !!entryId,
+ });
+}
+
+export function useCreateEntrySeen() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: (data: {
+ entry_id: number;
+ date_seen: string;
+ seen_with?: string;
+ }) => entrySeenApi.create(data),
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: entrySeenKeys.byEntry(variables.entry_id),
+ });
+ queryClient.invalidateQueries({
+ queryKey: entryKeys.detail(variables.entry_id),
+ });
+ queryClient.invalidateQueries({ queryKey: entryKeys.all });
+ },
+ });
+}
+
+export function useUpdateEntrySeen() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: ({
+ id,
+ data,
+ }: {
+ id: number;
+ data: { entry_id: number; date_seen?: string; seen_with?: string };
+ }) => entrySeenApi.update(id, data),
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: entrySeenKeys.byEntry(variables.data.entry_id),
+ });
+ },
+ });
+}
+
+export function useDeleteEntrySeen() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: ({ id, entryId }: { id: number; entryId: number }) =>
+ entrySeenApi.delete(id),
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: entrySeenKeys.byEntry(variables.entryId),
+ });
+ queryClient.invalidateQueries({ queryKey: entryKeys.all });
+ },
+ });
+}
diff --git a/react_frontend/src/hooks/useEpisodeSeen.ts b/react_frontend/src/hooks/useEpisodeSeen.ts
new file mode 100644
index 0000000..1b3134a
--- /dev/null
+++ b/react_frontend/src/hooks/useEpisodeSeen.ts
@@ -0,0 +1,65 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
+import { episodeSeenApi } from '@/api/episode-seen';
+import { entryKeys } from './useEntries';
+
+export const episodeSeenKeys = {
+ all: ['episode-seen'] as const,
+ byEpisode: (episodeId: number) =>
+ ['episode-seen', 'by-episode', episodeId] as const,
+};
+
+export function useEpisodeSeenByEpisode(episodeId: number) {
+ return useQuery({
+ queryKey: episodeSeenKeys.byEpisode(episodeId),
+ queryFn: () => episodeSeenApi.getByEpisode(episodeId),
+ enabled: !!episodeId,
+ });
+}
+
+export function useCreateEpisodeSeen() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: (data: {
+ entry_id: number;
+ episode_id: number;
+ date_seen: string;
+ seen_with?: string;
+ }) => episodeSeenApi.create(data),
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: episodeSeenKeys.byEpisode(variables.episode_id),
+ });
+ queryClient.invalidateQueries({
+ queryKey: entryKeys.detail(variables.entry_id),
+ });
+ queryClient.invalidateQueries({
+ queryKey: entryKeys.seasons(variables.entry_id),
+ });
+ },
+ });
+}
+
+export function useDeleteEpisodeSeen() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: ({
+ id,
+ entryId,
+ episodeId,
+ }: {
+ id: number;
+ entryId: number;
+ episodeId: number;
+ }) => episodeSeenApi.delete(id),
+ onSuccess: (_data, variables) => {
+ queryClient.invalidateQueries({
+ queryKey: episodeSeenKeys.byEpisode(variables.episodeId),
+ });
+ queryClient.invalidateQueries({
+ queryKey: entryKeys.detail(variables.entryId),
+ });
+ },
+ });
+}
diff --git a/react_frontend/src/hooks/useEpisodes.ts b/react_frontend/src/hooks/useEpisodes.ts
new file mode 100644
index 0000000..3186043
--- /dev/null
+++ b/react_frontend/src/hooks/useEpisodes.ts
@@ -0,0 +1,15 @@
+import { useQuery } from '@tanstack/react-query';
+import { episodesApi } from '@/api/episodes';
+
+export const episodeKeys = {
+ byMonth: (start: string, end: string) =>
+ ['episodes', 'month', start, end] as const,
+};
+
+export function useEpisodesByMonth(startDate: string, endDate: string) {
+ return useQuery({
+ queryKey: episodeKeys.byMonth(startDate, endDate),
+ queryFn: () => episodesApi.getByMonth(startDate, endDate),
+ enabled: !!startDate && !!endDate,
+ });
+}
diff --git a/react_frontend/src/hooks/usePeople.ts b/react_frontend/src/hooks/usePeople.ts
new file mode 100644
index 0000000..99a854f
--- /dev/null
+++ b/react_frontend/src/hooks/usePeople.ts
@@ -0,0 +1,15 @@
+import { useQuery } from '@tanstack/react-query';
+import { peopleApi } from '@/api/people';
+
+export const peopleKeys = {
+ all: ['people'] as const,
+ detail: (id: number) => ['people', id] as const,
+};
+
+export function usePerson(id: number) {
+ return useQuery({
+ queryKey: peopleKeys.detail(id),
+ queryFn: () => peopleApi.getById(id),
+ enabled: !!id,
+ });
+}
diff --git a/react_frontend/src/hooks/useSeasons.ts b/react_frontend/src/hooks/useSeasons.ts
new file mode 100644
index 0000000..9b3987f
--- /dev/null
+++ b/react_frontend/src/hooks/useSeasons.ts
@@ -0,0 +1,24 @@
+import { useQuery } from '@tanstack/react-query';
+import { seasonsApi } from '@/api/seasons';
+
+export const seasonKeys = {
+ all: ['seasons'] as const,
+ detail: (id: number) => ['seasons', id] as const,
+ episodes: (id: number) => ['seasons', id, 'episodes'] as const,
+};
+
+export function useSeason(id: number) {
+ return useQuery({
+ queryKey: seasonKeys.detail(id),
+ queryFn: () => seasonsApi.getById(id),
+ enabled: !!id,
+ });
+}
+
+export function useSeasonEpisodes(id: number) {
+ return useQuery({
+ queryKey: seasonKeys.episodes(id),
+ queryFn: () => seasonsApi.getEpisodes(id),
+ enabled: !!id,
+ });
+}
diff --git a/react_frontend/src/hooks/useStatistics.ts b/react_frontend/src/hooks/useStatistics.ts
new file mode 100644
index 0000000..585f2c9
--- /dev/null
+++ b/react_frontend/src/hooks/useStatistics.ts
@@ -0,0 +1,9 @@
+import { useQuery } from '@tanstack/react-query';
+import { statisticsApi } from '@/api/statistics';
+
+export function useStatistics() {
+ return useQuery({
+ queryKey: ['statistics'],
+ queryFn: statisticsApi.get,
+ });
+}
diff --git a/react_frontend/src/hooks/useTmdb.ts b/react_frontend/src/hooks/useTmdb.ts
new file mode 100644
index 0000000..acfaf6b
--- /dev/null
+++ b/react_frontend/src/hooks/useTmdb.ts
@@ -0,0 +1,74 @@
+import { useInfiniteQuery } from '@tanstack/react-query';
+import { tmdbApi } from '@/api/tmdb';
+
+export function usePopularMovies() {
+ return useInfiniteQuery({
+ queryKey: ['tmdb', 'popular', 'movie'],
+ queryFn: ({ pageParam }) => tmdbApi.getPopularMovies(pageParam),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined,
+ });
+}
+
+export function usePopularTv() {
+ return useInfiniteQuery({
+ queryKey: ['tmdb', 'popular', 'tv'],
+ queryFn: ({ pageParam }) => tmdbApi.getPopularTv(pageParam),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined,
+ });
+}
+
+export function useTrendingMovies() {
+ return useInfiniteQuery({
+ queryKey: ['tmdb', 'trending', 'movie'],
+ queryFn: ({ pageParam }) => tmdbApi.getTrendingMovies(pageParam),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined,
+ });
+}
+
+export function useTrendingTv() {
+ return useInfiniteQuery({
+ queryKey: ['tmdb', 'trending', 'tv'],
+ queryFn: ({ pageParam }) => tmdbApi.getTrendingTv(pageParam),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined,
+ });
+}
+
+export function useTmdbSearch(query: string) {
+ return useInfiniteQuery({
+ queryKey: ['tmdb', 'search', query],
+ queryFn: ({ pageParam }) => tmdbApi.search(query, pageParam),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined,
+ enabled: query.length > 0,
+ });
+}
+
+export function usePopularPeople() {
+ return useInfiniteQuery({
+ queryKey: ['tmdb', 'popular', 'people'],
+ queryFn: ({ pageParam }) => tmdbApi.getPopularPeople(pageParam),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined,
+ });
+}
+
+export function useTmdbSearchPeople(query: string) {
+ return useInfiniteQuery({
+ queryKey: ['tmdb', 'search', 'people', query],
+ queryFn: ({ pageParam }) => tmdbApi.searchPeople(query, pageParam),
+ initialPageParam: 1,
+ getNextPageParam: (lastPage) =>
+ lastPage.page < lastPage.total_pages ? lastPage.page + 1 : undefined,
+ enabled: query.length > 0,
+ });
+}
diff --git a/react_frontend/src/index.css b/react_frontend/src/index.css
index 0636b4e..201333a 100644
--- a/react_frontend/src/index.css
+++ b/react_frontend/src/index.css
@@ -51,38 +51,38 @@
:root {
--radius: 0.625rem;
- --background: oklch(1 0 0);
- --foreground: oklch(0.145 0 0);
- --card: oklch(1 0 0);
- --card-foreground: oklch(0.145 0 0);
- --popover: oklch(1 0 0);
- --popover-foreground: oklch(0.145 0 0);
- --primary: oklch(0.205 0 0);
- --primary-foreground: oklch(0.985 0 0);
- --secondary: oklch(0.97 0 0);
- --secondary-foreground: oklch(0.205 0 0);
- --muted: oklch(0.97 0 0);
- --muted-foreground: oklch(0.556 0 0);
- --accent: oklch(0.97 0 0);
- --accent-foreground: oklch(0.205 0 0);
+ --background: oklch(0.15 0.01 260);
+ --foreground: oklch(0.95 0.01 260);
+ --card: oklch(0.18 0.01 260);
+ --card-foreground: oklch(0.95 0.01 260);
+ --popover: oklch(0.18 0.01 260);
+ --popover-foreground: oklch(0.95 0.01 260);
+ --primary: oklch(0.65 0.18 250);
+ --primary-foreground: oklch(0.98 0.005 260);
+ --secondary: oklch(0.25 0.015 260);
+ --secondary-foreground: oklch(0.9 0.01 260);
+ --muted: oklch(0.22 0.01 260);
+ --muted-foreground: oklch(0.65 0.015 260);
+ --accent: oklch(0.25 0.02 260);
+ --accent-foreground: oklch(0.95 0.01 260);
--destructive: oklch(0.577 0.245 27.325);
--destructive-foreground: oklch(0.98 0.005 260);
- --border: oklch(0.922 0 0);
- --input: oklch(0.922 0 0);
- --ring: oklch(0.708 0 0);
- --chart-1: oklch(0.87 0 0);
- --chart-2: oklch(0.556 0 0);
- --chart-3: oklch(0.439 0 0);
- --chart-4: oklch(0.371 0 0);
- --chart-5: oklch(0.269 0 0);
- --sidebar: oklch(0.985 0 0);
- --sidebar-foreground: oklch(0.145 0 0);
- --sidebar-primary: oklch(0.205 0 0);
- --sidebar-primary-foreground: oklch(0.985 0 0);
- --sidebar-accent: oklch(0.97 0 0);
- --sidebar-accent-foreground: oklch(0.205 0 0);
- --sidebar-border: oklch(0.922 0 0);
- --sidebar-ring: oklch(0.708 0 0);
+ --border: oklch(0.28 0.015 260);
+ --input: oklch(0.28 0.015 260);
+ --ring: oklch(0.65 0.18 250);
+ --chart-1: oklch(0.65 0.18 250);
+ --chart-2: oklch(0.6 0.15 160);
+ --chart-3: oklch(0.7 0.15 60);
+ --chart-4: oklch(0.6 0.2 300);
+ --chart-5: oklch(0.65 0.2 30);
+ --sidebar: oklch(0.12 0.01 260);
+ --sidebar-foreground: oklch(0.95 0.01 260);
+ --sidebar-primary: oklch(0.65 0.18 250);
+ --sidebar-primary-foreground: oklch(0.98 0.005 260);
+ --sidebar-accent: oklch(0.2 0.02 260);
+ --sidebar-accent-foreground: oklch(0.95 0.01 260);
+ --sidebar-border: oklch(0.25 0.015 260);
+ --sidebar-ring: oklch(0.65 0.18 250);
}
.light {
@@ -134,35 +134,35 @@
}
.dark {
- --background: oklch(0.145 0 0);
- --foreground: oklch(0.985 0 0);
- --card: oklch(0.205 0 0);
- --card-foreground: oklch(0.985 0 0);
- --popover: oklch(0.205 0 0);
- --popover-foreground: oklch(0.985 0 0);
- --primary: oklch(0.922 0 0);
- --primary-foreground: oklch(0.205 0 0);
- --secondary: oklch(0.269 0 0);
- --secondary-foreground: oklch(0.985 0 0);
- --muted: oklch(0.269 0 0);
- --muted-foreground: oklch(0.708 0 0);
- --accent: oklch(0.269 0 0);
- --accent-foreground: oklch(0.985 0 0);
+ --background: oklch(0.15 0.01 260);
+ --foreground: oklch(0.95 0.01 260);
+ --card: oklch(0.18 0.01 260);
+ --card-foreground: oklch(0.95 0.01 260);
+ --popover: oklch(0.18 0.01 260);
+ --popover-foreground: oklch(0.95 0.01 260);
+ --primary: oklch(0.65 0.18 250);
+ --primary-foreground: oklch(0.98 0.005 260);
+ --secondary: oklch(0.25 0.015 260);
+ --secondary-foreground: oklch(0.9 0.01 260);
+ --muted: oklch(0.22 0.01 260);
+ --muted-foreground: oklch(0.65 0.015 260);
+ --accent: oklch(0.25 0.02 260);
+ --accent-foreground: oklch(0.95 0.01 260);
--destructive: oklch(0.704 0.191 22.216);
- --border: oklch(1 0 0 / 10%);
- --input: oklch(1 0 0 / 15%);
- --ring: oklch(0.556 0 0);
- --chart-1: oklch(0.87 0 0);
- --chart-2: oklch(0.556 0 0);
- --chart-3: oklch(0.439 0 0);
- --chart-4: oklch(0.371 0 0);
- --chart-5: oklch(0.269 0 0);
- --sidebar: oklch(0.205 0 0);
- --sidebar-foreground: oklch(0.985 0 0);
- --sidebar-primary: oklch(0.488 0.243 264.376);
- --sidebar-primary-foreground: oklch(0.985 0 0);
- --sidebar-accent: oklch(0.269 0 0);
- --sidebar-accent-foreground: oklch(0.985 0 0);
- --sidebar-border: oklch(1 0 0 / 10%);
- --sidebar-ring: oklch(0.556 0 0);
+ --border: oklch(0.28 0.015 260);
+ --input: oklch(0.28 0.015 260);
+ --ring: oklch(0.65 0.18 250);
+ --chart-1: oklch(0.65 0.18 250);
+ --chart-2: oklch(0.6 0.15 160);
+ --chart-3: oklch(0.7 0.15 60);
+ --chart-4: oklch(0.6 0.2 300);
+ --chart-5: oklch(0.65 0.2 30);
+ --sidebar: oklch(0.12 0.01 260);
+ --sidebar-foreground: oklch(0.95 0.01 260);
+ --sidebar-primary: oklch(0.65 0.18 250);
+ --sidebar-primary-foreground: oklch(0.98 0.005 260);
+ --sidebar-accent: oklch(0.2 0.02 260);
+ --sidebar-accent-foreground: oklch(0.95 0.01 260);
+ --sidebar-border: oklch(0.25 0.015 260);
+ --sidebar-ring: oklch(0.65 0.18 250);
}
diff --git a/react_frontend/src/lib/api.ts b/react_frontend/src/lib/api.ts
new file mode 100644
index 0000000..37f086e
--- /dev/null
+++ b/react_frontend/src/lib/api.ts
@@ -0,0 +1,21 @@
+import axios from 'axios';
+
+// const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:4000/api/v1';
+const API_BASE_URL = import.meta.env.VITE_API_URL || '/api/v1';
+
+export const api = axios.create({
+ baseURL: API_BASE_URL,
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+});
+
+export const getMediaUrl = (
+ category: string,
+ type: string,
+ size: 'preview' | 'full',
+ file: string
+) => `${API_BASE_URL}/media/${category}/${type}/${size}/${file}`;
+
+export const getTmdbImageUrl = (path: string, size = 'w342') =>
+ `https://image.tmdb.org/t/p/${size}${path}`;
diff --git a/react_frontend/src/lib/media-utils.ts b/react_frontend/src/lib/media-utils.ts
new file mode 100644
index 0000000..d95f567
--- /dev/null
+++ b/react_frontend/src/lib/media-utils.ts
@@ -0,0 +1,103 @@
+import { getMediaUrl, getTmdbImageUrl } from '@/lib/api';
+import type { Entry, Collection, Media } from '@/types';
+
+const DEFAULT_POSTER = '/images/default-poster.png';
+
+export function getPosterUrl(entry: Entry): string {
+ // Not in library, use TMDB poster
+ if (!entry.isInLibrary) {
+ return entry.poster_path
+ ? getTmdbImageUrl(entry.poster_path, 'w342')
+ : DEFAULT_POSTER;
+ }
+
+ // In library: try local selected poster
+ if (entry.medias) {
+ const selectedPoster = entry.medias.find(
+ (m: Media) => m.type === 'poster' && m.is_selected
+ );
+ if (selectedPoster?.path) {
+ return getMediaUrl('entries', 'posters', 'preview', selectedPoster.path);
+ }
+ }
+
+ // Fallback to TMDB poster
+ if (entry.poster_path) {
+ return getTmdbImageUrl(entry.poster_path, 'w300');
+ }
+
+ return DEFAULT_POSTER;
+}
+
+export function getBackdropUrl(entry: Entry): string {
+ if (entry.medias) {
+ const selectedBackdrop = entry.medias.find(
+ (m: Media) => m.type === 'backdrop' && m.is_selected
+ );
+ if (selectedBackdrop?.path) {
+ return getMediaUrl(
+ 'entries',
+ 'backdrops',
+ 'full',
+ selectedBackdrop.path
+ );
+ }
+ }
+
+ if (entry.banner_path) {
+ return getTmdbImageUrl(entry.banner_path, 'w1280');
+ }
+
+ return '';
+}
+
+export function getTmdbPosterUrl(
+ posterPath: string | null,
+ size = 'w342'
+): string {
+ if (!posterPath) return DEFAULT_POSTER;
+ return getTmdbImageUrl(posterPath, size);
+}
+
+export function getCollectionPosterUrl(collection: Collection): string {
+ if (collection.medias) {
+ const selectedPoster = collection.medias.find(
+ (m: Media) => m.type === 'poster' && m.is_selected
+ );
+ if (selectedPoster?.path) {
+ return getMediaUrl('collections', 'posters', 'preview', selectedPoster.path);
+ }
+ }
+
+ if (collection.poster_path) {
+ return getTmdbImageUrl(collection.poster_path, 'w342');
+ }
+
+ return DEFAULT_POSTER;
+}
+
+export function getProfileUrl(profilePath: string | null): string {
+ if (!profilePath) return '/images/default-profile.png';
+ return getTmdbImageUrl(profilePath, 'w185');
+}
+
+export function formatRuntime(minutes: number | null): string {
+ if (!minutes) return '';
+ const h = Math.floor(minutes / 60);
+ const m = minutes % 60;
+ return h > 0 ? `${h}h ${m}m` : `${m}m`;
+}
+
+export function formatDate(dateStr: string | null): string {
+ if (!dateStr) return '';
+ return new Date(dateStr).toLocaleDateString('en-US', {
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ });
+}
+
+export function getYear(dateStr: string | null): string {
+ if (!dateStr) return '';
+ return new Date(dateStr).getFullYear().toString();
+}
diff --git a/react_frontend/src/lib/normalizers.ts b/react_frontend/src/lib/normalizers.ts
new file mode 100644
index 0000000..f1d25e8
--- /dev/null
+++ b/react_frontend/src/lib/normalizers.ts
@@ -0,0 +1,104 @@
+/**
+ * Normalizers to transform backend Sequelize JSON responses
+ * into the shape our frontend TypeScript types expect.
+ *
+ * Backend quirks:
+ * - Entry relations use singular aliases: entryId, entryRating, entrySeen
+ * - Media model uses camelCase: isSelected, isLocal, isCustom, isFavorit, mediaableId
+ * - Collection model uses camelCase: isUserCollection, userRating, posterPath, backdropPath, isLocal, tmdbId
+ * - Credit → People alias is "person" (singular)
+ * - Genres come as string arrays from the backend mapper
+ */
+
+import type { Entry, Collection, Media, Credit, Genre } from '@/types';
+
+/* ---------- Media ---------- */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export function normalizeMedia(raw: any): Media {
+ return {
+ id: raw.id,
+ mediaable: raw.mediaable,
+ mediaable_id: raw.mediaableId ?? raw.mediaable_id,
+ type: raw.type,
+ path: raw.path,
+ is_local: raw.isLocal ?? raw.is_local ?? false,
+ is_selected: raw.isSelected ?? raw.is_selected ?? false,
+ is_custom: raw.isCustom ?? raw.is_custom ?? false,
+ is_favorit: raw.isFavorit ?? raw.is_favorit ?? false,
+ };
+}
+
+/* ---------- Credit ---------- */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export function normalizeCredit(raw: any): Credit {
+ const people = raw.person ?? raw.people ?? undefined;
+ return {
+ id: raw.id,
+ entry_id: raw.entry_id,
+ people_id: raw.people_id,
+ character: raw.character,
+ cast_type: raw.cast_type,
+ department: raw.department,
+ job: raw.job,
+ order: raw.order,
+ people: people,
+ };
+}
+
+/* ---------- Genre ---------- */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export function normalizeGenres(raw: any[]): Genre[] {
+ if (!Array.isArray(raw)) return [];
+ return raw.map((g, i) => {
+ if (typeof g === 'string') return { id: i, name: g };
+ return g as Genre;
+ });
+}
+
+/* ---------- Entry ---------- */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export function normalizeEntry(raw: any): Entry {
+ return {
+ ...raw,
+ // Singular → plural aliases (coerce tmdb_id to number for store comparisons)
+ entryIds: (() => {
+ const ids = raw.entryIds ?? raw.entryId;
+ if (!ids) return undefined;
+ return {
+ ...ids,
+ tmdb_id: ids.tmdb_id != null ? Number(ids.tmdb_id) : null,
+ };
+ })(),
+ entryRatings: raw.entryRatings ?? raw.entryRating ?? undefined,
+ entrySeens: raw.entrySeens ?? raw.entrySeen ?? undefined,
+ // Normalize nested arrays
+ medias: raw.medias ? raw.medias.map(normalizeMedia) : undefined,
+ genres: raw.genres ? normalizeGenres(raw.genres) : undefined,
+ credits: raw.credits ? raw.credits.map(normalizeCredit) : undefined,
+ collections: raw.collections
+ ? raw.collections.map(normalizeCollection)
+ : undefined,
+ // Mark as in library when loaded from the library endpoint
+ isInLibrary: raw.isInLibrary ?? true,
+ };
+}
+
+/* ---------- Collection ---------- */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+export function normalizeCollection(raw: any): Collection {
+ return {
+ id: raw.id,
+ tmdb_id: raw.tmdbId ?? raw.tmdb_id ?? null,
+ name: raw.name,
+ description: raw.description ?? raw.overview ?? null,
+ user_rating: raw.userRating ?? raw.user_rating ?? null,
+ poster_path: raw.posterPath ?? raw.poster_path ?? null,
+ backdrop_path: raw.backdropPath ?? raw.backdrop_path ?? null,
+ is_local: raw.isLocal ?? raw.is_local ?? false,
+ is_user_collection: raw.isUserCollection ?? raw.is_user_collection ?? false,
+ createdAt: raw.createdAt,
+ updatedAt: raw.updatedAt,
+ entries: raw.entries ? raw.entries.map(normalizeEntry) : undefined,
+ medias: raw.medias ? raw.medias.map(normalizeMedia) : undefined,
+ };
+}
diff --git a/react_frontend/src/lib/utils.ts b/react_frontend/src/lib/utils.ts
new file mode 100644
index 0000000..bd0c391
--- /dev/null
+++ b/react_frontend/src/lib/utils.ts
@@ -0,0 +1,6 @@
+import { clsx, type ClassValue } from "clsx"
+import { twMerge } from "tailwind-merge"
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs))
+}
diff --git a/react_frontend/src/pages/CalendarPage.tsx b/react_frontend/src/pages/CalendarPage.tsx
new file mode 100644
index 0000000..465e6a9
--- /dev/null
+++ b/react_frontend/src/pages/CalendarPage.tsx
@@ -0,0 +1,139 @@
+import { useState, useMemo } from 'react';
+import { format, startOfMonth, endOfMonth, eachDayOfInterval, getDay, addMonths, subMonths, isSameDay } from 'date-fns';
+import { ChevronLeft, ChevronRight } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { useEpisodesByMonth } from '@/hooks/useEpisodes';
+import { getTmdbPosterUrl } from '@/lib/media-utils';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+
+const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
+
+export function CalendarPage() {
+ const [currentDate, setCurrentDate] = useState(new Date());
+ const monthStart = startOfMonth(currentDate);
+ const monthEnd = endOfMonth(currentDate);
+
+ const startDateStr = format(monthStart, 'yyyy-MM-dd');
+ const endDateStr = format(monthEnd, 'yyyy-MM-dd');
+
+ const { data: episodes = [] } = useEpisodesByMonth(startDateStr, endDateStr);
+
+ const days = useMemo(() => eachDayOfInterval({ start: monthStart, end: monthEnd }), [monthStart, monthEnd]);
+ const startDayOfWeek = getDay(monthStart);
+
+ // Group episodes by date
+ const episodesByDate = useMemo(() => {
+ const map = new Map();
+ episodes.forEach((ep) => {
+ if (!ep.air_date) return;
+ const key = format(new Date(ep.air_date), 'yyyy-MM-dd');
+ const existing = map.get(key) || [];
+ existing.push(ep);
+ map.set(key, existing);
+ });
+ return map;
+ }, [episodes]);
+
+ return (
+
+
+
Calendar
+
+
+
+ {format(currentDate, 'MMMM yyyy')}
+
+
+
+
+
+ {/* Calendar Grid */}
+
+ {/* Day headers */}
+
+ {DAYS.map((day) => (
+
+ {day}
+
+ ))}
+
+
+ {/* Day cells */}
+
+ {/* Empty cells for offset */}
+ {Array.from({ length: startDayOfWeek }).map((_, i) => (
+
+ ))}
+
+ {days.map((day) => {
+ const key = format(day, 'yyyy-MM-dd');
+ const dayEpisodes = episodesByDate.get(key) || [];
+ const isToday = isSameDay(day, new Date());
+
+ return (
+
+
+ {format(day, 'd')}
+
+
+ {dayEpisodes.slice(0, 3).map((ep) => (
+
+
+
+ {ep.still_path && (
+

+ )}
+
+ S{ep.season_id} E{ep.episode_number}
+
+
+
+
+ {ep.name}
+
+ Episode {ep.episode_number}
+
+
+
+ ))}
+ {dayEpisodes.length > 3 && (
+
+ +{dayEpisodes.length - 3} more
+
+ )}
+
+
+ );
+ })}
+
+
+
+ );
+}
diff --git a/react_frontend/src/pages/CollectionDetailsPage.tsx b/react_frontend/src/pages/CollectionDetailsPage.tsx
new file mode 100644
index 0000000..d4b9700
--- /dev/null
+++ b/react_frontend/src/pages/CollectionDetailsPage.tsx
@@ -0,0 +1,118 @@
+import { useState } from 'react';
+import { useParams } from 'react-router-dom';
+import { useCollection } from '@/hooks/useCollections';
+import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
+import { getCollectionPosterUrl } from '@/lib/media-utils';
+import { getTmdbImageUrl } from '@/lib/api';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Button } from '@/components/ui/button';
+import { Star, Pencil } from 'lucide-react';
+import { CollectionEditDialog } from '@/components/dialogs/CollectionEditDialog';
+
+export function CollectionDetailsPage() {
+ const { id } = useParams<{ id: string }>();
+ const { data: collection, isLoading } = useCollection(Number(id));
+ const [showEditDialog, setShowEditDialog] = useState(false);
+
+ if (isLoading) {
+ return (
+
+
+
+
+ {Array.from({ length: 6 }).map((_, i) => (
+
+ ))}
+
+
+ );
+ }
+
+ if (!collection) {
+ return (
+
+ Collection not found.
+
+ );
+ }
+
+ const backdropUrl = collection.backdrop_path
+ ? getTmdbImageUrl(collection.backdrop_path, 'w1280')
+ : null;
+
+ const entries = (collection.entries || []).map((e) => ({
+ ...e,
+ isInLibrary: true,
+ }));
+
+ return (
+
+ {/* Hero banner */}
+
+ {backdropUrl ? (
+

+ ) : (
+
+ )}
+
+
+
+
})
+
+
+ {collection.name}
+
+ {collection.description && (
+
+ {collection.description}
+
+ )}
+
+
+ {entries.length} {entries.length === 1 ? 'entry' : 'entries'}
+
+ {collection.user_rating != null && collection.user_rating > 0 && (
+
+
+
+ {collection.user_rating}/10
+
+
+ )}
+
+
+
+
+
+
+
+ {/* Entries grid */}
+
+
+ {/* Edit dialog */}
+ {showEditDialog && (
+
+ )}
+
+ );
+}
diff --git a/react_frontend/src/pages/CollectionsPage.tsx b/react_frontend/src/pages/CollectionsPage.tsx
new file mode 100644
index 0000000..6ac38f6
--- /dev/null
+++ b/react_frontend/src/pages/CollectionsPage.tsx
@@ -0,0 +1,60 @@
+import { useState, useMemo } from 'react';
+import { useCollections } from '@/hooks/useCollections';
+import { CollectionsGrid } from '@/components/collections/CollectionsGrid';
+import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { Input } from '@/components/ui/input';
+import { Search } from 'lucide-react';
+
+export function CollectionsPage() {
+ const { data: collections = [], isLoading } = useCollections();
+ const [search, setSearch] = useState('');
+ const [filter, setFilter] = useState<'all' | 'official' | 'custom'>('all');
+
+ const filtered = useMemo(() => {
+ let result = collections;
+
+ if (filter === 'official') {
+ result = result.filter((c) => !c.is_user_collection);
+ } else if (filter === 'custom') {
+ result = result.filter((c) => c.is_user_collection);
+ }
+
+ if (search) {
+ const q = search.toLowerCase();
+ result = result.filter((c) => c.name.toLowerCase().includes(q));
+ }
+
+ return result;
+ }, [collections, filter, search]);
+
+ return (
+
+
Collections
+
+
+
setFilter(v as 'all' | 'official' | 'custom')}
+ >
+
+ All
+ Official
+ Custom
+
+
+
+
+
+ setSearch(e.target.value)}
+ className="pl-10"
+ />
+
+
+
+
+
+ );
+}
diff --git a/react_frontend/src/pages/DashboardPage.tsx b/react_frontend/src/pages/DashboardPage.tsx
new file mode 100644
index 0000000..5582733
--- /dev/null
+++ b/react_frontend/src/pages/DashboardPage.tsx
@@ -0,0 +1,114 @@
+import { useMemo } from 'react';
+import { Link } from 'react-router-dom';
+import { useLibrary } from '@/hooks/useEntries';
+import { useStatistics } from '@/hooks/useStatistics';
+import { useLibraryEntries } from '@/stores/useLibraryStore';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Film, Tv, Heart, ListVideo, Clock } from 'lucide-react';
+import { formatRuntime, getPosterUrl } from '@/lib/media-utils';
+
+export function DashboardPage() {
+ useLibrary();
+ const { data: stats, isLoading: statsLoading } = useStatistics();
+ const allEntries = useLibraryEntries();
+
+ const movies = useMemo(() => allEntries.filter((e) => !e.is_tvseries && !e.watchlist), [allEntries]);
+ const tvSeries = useMemo(() => allEntries.filter((e) => e.is_tvseries && !e.watchlist), [allEntries]);
+ const favorites = useMemo(() => allEntries.filter((e) => e.favorit && !e.watchlist), [allEntries]);
+ const watchlist = useMemo(() => allEntries.filter((e) => e.watchlist), [allEntries]);
+
+ const statCards = [
+ {
+ title: 'Movies',
+ value: movies.length,
+ icon: Film,
+ color: 'text-blue-500',
+ },
+ {
+ title: 'TV Series',
+ value: tvSeries.length,
+ icon: Tv,
+ color: 'text-green-500',
+ },
+ {
+ title: 'Favorites',
+ value: favorites.length,
+ icon: Heart,
+ color: 'text-red-500',
+ },
+ {
+ title: 'Watchlist',
+ value: watchlist.length,
+ icon: ListVideo,
+ color: 'text-purple-500',
+ },
+ {
+ title: 'Watch Time',
+ value: stats?.totalWatchTime
+ ? formatRuntime(stats.totalWatchTime)
+ : '0h',
+ icon: Clock,
+ color: 'text-orange-500',
+ },
+ ];
+
+ return (
+
+
Dashboard
+
+ {/* Stats Grid */}
+
+ {statCards.map((stat) => (
+
+
+
+ {stat.title}
+
+
+
+
+ {statsLoading ? (
+
+ ) : (
+ {stat.value}
+ )}
+
+
+ ))}
+
+
+ {/* Recently Watched */}
+
+
Recently Watched
+
+ {allEntries
+ .filter((e) => e.date_last_seen)
+ .sort(
+ (a, b) =>
+ new Date(b.date_last_seen!).getTime() -
+ new Date(a.date_last_seen!).getTime()
+ )
+ .slice(0, 14)
+ .map((entry) => (
+
+
})
+
+ {entry.title}
+
+
+ ))}
+
+
+
+ );
+}
diff --git a/react_frontend/src/pages/EntryDetailsPage.tsx b/react_frontend/src/pages/EntryDetailsPage.tsx
new file mode 100644
index 0000000..208039d
--- /dev/null
+++ b/react_frontend/src/pages/EntryDetailsPage.tsx
@@ -0,0 +1,354 @@
+import { useState } from 'react';
+import { useParams } from 'react-router-dom';
+import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries';
+import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
+import { useLibraryStore } from '@/stores/useLibraryStore';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Separator } from '@/components/ui/separator';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import {
+ Heart,
+ MoreHorizontal,
+ Eye,
+ EyeOff,
+ RefreshCw,
+ FolderPlus,
+ ImageIcon,
+ Settings,
+ Star,
+} from 'lucide-react';
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from '@/components/ui/tooltip';
+import { CastList } from '@/components/entries/CastList';
+import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
+import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory';
+import { CollectionsGrid } from '@/components/collections/CollectionsGrid';
+import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
+import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
+import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
+import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
+import {
+ getPosterUrl,
+ getBackdropUrl,
+ getYear,
+ formatRuntime,
+ formatDate,
+} from '@/lib/media-utils';
+import { useUpdateEntry } from '@/hooks/useEntries';
+import type { Entry } from '@/types';
+
+export function EntryDetailsPage() {
+ const { id } = useParams<{ id: string }>();
+ const entryId = parseInt(id!, 10);
+ const { data: entry, isLoading } = useEntry(entryId);
+ const { data: seasons } = useEntrySeasons(entryId);
+ const { data: watchHistory = [] } = useEntrySeenByEntry(entryId);
+ const updateEntry = useUpdateEntry();
+ const refreshEntry = useRefreshEntry();
+ const deleteEntrySeen = useDeleteEntrySeen();
+
+ // Merge library entry with detail entry so we get both library flags AND full details (credits, etc.)
+ const libraryEntry = useLibraryStore((s) => s.entries.get(entryId));
+ const displayEntry = libraryEntry && entry
+ ? { ...libraryEntry, ...entry, isInLibrary: true }
+ : entry || libraryEntry;
+
+ // Dialog states
+ const [showSettings, setShowSettings] = useState(false);
+ const [showSeenDialog, setShowSeenDialog] = useState(false);
+ const [showMediaDialog, setShowMediaDialog] = useState(false);
+ const [showCollectionDialog, setShowCollectionDialog] = useState(false);
+
+ if (isLoading || !displayEntry) {
+ return ;
+ }
+
+ const e = displayEntry;
+ const backdrop = getBackdropUrl(e);
+ const poster = getPosterUrl(e);
+ const director = e.credits?.find(
+ (c) => c.cast_type === 'crew' && c.job === 'Director'
+ );
+
+ const toggleFavorite = () => {
+ updateEntry.mutate({ id: e.id, data: { favorit: !e.favorit } });
+ };
+
+ return (
+
+ {/* Hero Section */}
+
+ {backdrop && (
+

+ )}
+
+
+
+ {/* Poster */}
+
+

+
+
+ {/* Info */}
+
+
+
{e.title}
+ {e.status && (
+ {e.status}
+ )}
+
+
+
+ {e.release_date && (
+
+
+
+
+ {getYear(e.release_date)}
+
+
+
+ {formatDate(e.release_date)}
+
+
+
+ )}
+ {e.runtime && !e.is_tvseries && (
+ <>
+
•
+
{formatRuntime(e.runtime)}
+ >
+ )}
+ {director && (
+ <>
+
•
+
Dir. {director.people?.name}
+ >
+ )}
+
+
+ {/* Genres */}
+ {e.genres && e.genres.length > 0 && (
+
+ {e.genres.map((g) => (
+
+ {g.name}
+
+ ))}
+
+ )}
+
+ {/* Ratings */}
+
+ {e.entryRatings?.user_rating != null &&
+ e.entryRatings.user_rating > 0 && (
+
+
+
+ {e.entryRatings.user_rating}/10
+
+ You
+
+ )}
+ {e.entryRatings?.tmdb_rating != null &&
+ e.entryRatings.tmdb_rating > 0 && (
+
+
+ {e.entryRatings.tmdb_rating.toFixed(1)}
+
+ TMDB
+
+ )}
+ {e.entryRatings?.imdb_rating != null &&
+ e.entryRatings.imdb_rating > 0 && (
+
+
+ {e.entryRatings.imdb_rating}
+
+ IMDb
+
+ )}
+
+
+ {/* Actions */}
+
+
+
+
+
+
+
+
+
+
+
+ updateEntry.mutate({
+ id: e.id,
+ data: { hidden: !e.hidden },
+ })
+ }
+ >
+
+ {e.hidden ? 'Unhide' : 'Hide'}
+
+ refreshEntry.mutate(e.id)}
+ >
+
+ Refresh Details
+
+ setShowCollectionDialog(true)}
+ >
+
+ Add to Collection
+
+ setShowMediaDialog(true)}
+ >
+
+ Media
+
+ setShowSettings(true)}
+ >
+
+ Settings
+
+
+
+
+
+
+
+
+ {/* Storyline */}
+ {e.storyline && (
+
+
Overview
+
+ {e.storyline}
+
+
+ )}
+
+
+
+ {/* Cast */}
+ {e.credits && e.credits.length > 0 &&
}
+
+ {/* Seasons (TV only) */}
+ {e.is_tvseries && seasons && seasons.length > 0 && (
+ <>
+
+
+ >
+ )}
+
+ {/* Watch History */}
+ {watchHistory.length > 0 && (
+ <>
+
+
+ deleteEntrySeen.mutate({ id: seenId, entryId: e.id })
+ }
+ />
+ >
+ )}
+
+ {/* Dialogs */}
+ {showSettings && (
+
+ )}
+ {showSeenDialog && (
+
+ )}
+ {showMediaDialog && (
+
+ )}
+ {showCollectionDialog && (
+
+ )}
+
+ );
+}
+
+function EntryDetailsSkeleton() {
+ return (
+
+ );
+}
diff --git a/react_frontend/src/pages/EpisodePage.tsx b/react_frontend/src/pages/EpisodePage.tsx
new file mode 100644
index 0000000..6e4d644
--- /dev/null
+++ b/react_frontend/src/pages/EpisodePage.tsx
@@ -0,0 +1,146 @@
+import { useState } from 'react';
+import { useParams, Link } from 'react-router-dom';
+import { useQuery } from '@tanstack/react-query';
+import { seasonsApi } from '@/api/seasons';
+import { useEpisodeSeenByEpisode, useCreateEpisodeSeen } from '@/hooks/useEpisodeSeen';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Button } from '@/components/ui/button';
+import { Separator } from '@/components/ui/separator';
+import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory';
+import { CastList } from '@/components/entries/CastList';
+import { Eye, ChevronLeft, ChevronRight, Clock } from 'lucide-react';
+import { getTmdbPosterUrl, formatDate, formatRuntime } from '@/lib/media-utils';
+import type { Episode } from '@/types';
+
+export function EpisodePage() {
+ const { entryId, seasonId, episodeId } = useParams<{
+ entryId: string;
+ seasonId: string;
+ episodeId: string;
+ }>();
+
+ const { data: episodes = [] } = useQuery({
+ queryKey: ['seasons', parseInt(seasonId!, 10), 'episodes'],
+ queryFn: () => seasonsApi.getEpisodes(parseInt(seasonId!, 10)),
+ });
+
+ const epId = parseInt(episodeId!, 10);
+ const episode: Episode | undefined = episodes.find((ep: Episode) => ep.id === epId);
+ const { data: watchHistory = [] } = useEpisodeSeenByEpisode(epId);
+ const createEpisodeSeen = useCreateEpisodeSeen();
+
+ // Find prev/next episode
+ const currentIndex = episodes.findIndex((ep: Episode) => ep.id === epId);
+ const prevEpisode: Episode | undefined = currentIndex > 0 ? episodes[currentIndex - 1] : undefined;
+ const nextEpisode: Episode | undefined =
+ currentIndex < episodes.length - 1 ? episodes[currentIndex + 1] : undefined;
+
+ if (!episode) {
+ return (
+
+
+
+
+
+ );
+ }
+
+ const handleMarkWatched = () => {
+ createEpisodeSeen.mutate({
+ entry_id: parseInt(entryId!, 10),
+ episode_id: episode.id,
+ date_seen: new Date().toISOString().split('T')[0],
+ });
+ };
+
+ return (
+
+ {/* Thumbnail */}
+ {episode.still_path && (
+
+

+
+ )}
+
+ {/* Info */}
+
+
+
+ Episode {episode.episode_number}
+
+
{episode.name}
+
+
+
+ {episode.air_date && {formatDate(episode.air_date)}}
+ {episode.runtime && (
+
+
+ {formatRuntime(episode.runtime)}
+
+ )}
+
+
+ {episode.overview && (
+
+ {episode.overview}
+
+ )}
+
+
+
+
+ {/* Guest Stars */}
+ {episode.guest_stars && episode.guest_stars.length > 0 && (
+ <>
+
+
+ >
+ )}
+
+ {/* Watch History */}
+ {watchHistory.length > 0 && (
+ <>
+
+
+ >
+ )}
+
+ {/* Navigation */}
+
+
+ {prevEpisode ? (
+
+ ) : (
+
+ )}
+ {nextEpisode ? (
+
+ ) : (
+
+ )}
+
+
+ );
+}
diff --git a/react_frontend/src/pages/HomePage.tsx b/react_frontend/src/pages/HomePage.tsx
new file mode 100644
index 0000000..279d33b
--- /dev/null
+++ b/react_frontend/src/pages/HomePage.tsx
@@ -0,0 +1,78 @@
+import { useTrendingMovies, useTrendingTv, usePopularMovies, usePopularTv, useTmdbSearch } from '@/hooks/useTmdb';
+import { useLibrary } from '@/hooks/useEntries';
+import { TrendingGrid } from '@/components/entries/TrendingGrid';
+import { Input } from '@/components/ui/input';
+import { useState } from 'react';
+import { Search } from 'lucide-react';
+import { EntryCard } from '@/components/entries/EntryCard';
+
+export function HomePage() {
+ const [searchQuery, setSearchQuery] = useState('');
+
+ // Pre-load library
+ useLibrary();
+
+ const trendingMovies = useTrendingMovies();
+ const trendingTv = useTrendingTv();
+ const popularMovies = usePopularMovies();
+ const popularTv = usePopularTv();
+ const searchResults = useTmdbSearch(searchQuery);
+
+ const trendingMovieEntries = trendingMovies.data?.pages.flatMap((p) => p.results) ?? [];
+ const trendingTvEntries = trendingTv.data?.pages.flatMap((p) => p.results) ?? [];
+ const popularMovieEntries = popularMovies.data?.pages.flatMap((p) => p.results) ?? [];
+ const popularTvEntries = popularTv.data?.pages.flatMap((p) => p.results) ?? [];
+ const searchEntries = searchResults.data?.pages.flatMap((p) => p.results) ?? [];
+
+ const isSearching = searchQuery.length > 0;
+
+ return (
+
+ {/* Search */}
+
+
+ setSearchQuery(e.target.value)}
+ className="pl-10"
+ />
+
+
+ {isSearching ? (
+
+
+ Search Results for "{searchQuery}"
+
+ {searchEntries.length === 0 && !searchResults.isLoading ? (
+
No results found.
+ ) : (
+
+ {searchEntries.map((entry) => (
+
+ ))}
+
+ )}
+
+ ) : (
+ <>
+
+
+
+ >
+ )}
+
+ );
+}
diff --git a/react_frontend/src/pages/LibraryPage.tsx b/react_frontend/src/pages/LibraryPage.tsx
new file mode 100644
index 0000000..129442e
--- /dev/null
+++ b/react_frontend/src/pages/LibraryPage.tsx
@@ -0,0 +1,279 @@
+import { useState, useMemo, useCallback } from 'react';
+import { useLibrary } from '@/hooks/useEntries';
+import { useLibraryEntries } from '@/stores/useLibraryStore';
+import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
+import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { Input } from '@/components/ui/input';
+import { Button } from '@/components/ui/button';
+import { Badge } from '@/components/ui/badge';
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
+import { Search, X, SlidersHorizontal, ArrowUpDown } from 'lucide-react';
+import type { Entry } from '@/types';
+
+type FilterTab = 'all' | 'movies' | 'tv' | 'favorites' | 'hidden';
+type SortField = 'date_last_seen' | 'createdAt' | 'title' | 'release_date' | 'rating';
+type SortDir = 'asc' | 'desc';
+
+interface Filters {
+ genre: string;
+ ratingMin: string;
+ ratingMax: string;
+ yearMin: string;
+ yearMax: string;
+}
+
+const defaultFilters: Filters = { genre: '', ratingMin: '', ratingMax: '', yearMin: '', yearMax: '' };
+
+const sortLabels: Record = {
+ date_last_seen: 'Last Watched',
+ createdAt: 'Date Added',
+ title: 'Title',
+ release_date: 'Release Date',
+ rating: 'Rating',
+};
+
+function sortEntries(entries: Entry[], field: SortField, dir: SortDir): Entry[] {
+ return [...entries].sort((a, b) => {
+ let cmp = 0;
+ switch (field) {
+ case 'title':
+ cmp = a.title.localeCompare(b.title);
+ break;
+ case 'release_date':
+ cmp = new Date(a.release_date || '1900').getTime() - new Date(b.release_date || '1900').getTime();
+ break;
+ case 'rating':
+ cmp = (a.entryRatings?.user_rating || a.entryRatings?.tmdb_rating || 0) -
+ (b.entryRatings?.user_rating || b.entryRatings?.tmdb_rating || 0);
+ break;
+ case 'date_last_seen':
+ cmp = new Date(a.date_last_seen || '1900').getTime() - new Date(b.date_last_seen || '1900').getTime();
+ break;
+ case 'createdAt':
+ cmp = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
+ break;
+ }
+ return dir === 'desc' ? -cmp : cmp;
+ });
+}
+
+export function LibraryPage() {
+ const { isLoading } = useLibrary();
+ const [activeTab, setActiveTab] = useState('all');
+ const [search, setSearch] = useState('');
+ const [sortField, setSortField] = useState('date_last_seen');
+ const [sortDir, setSortDir] = useState('desc');
+ const [filters, setFilters] = useState(defaultFilters);
+
+ const allEntries = useLibraryEntries();
+
+ // Gather unique genres from the library
+ const allGenres = useMemo(() => {
+ const set = new Set();
+ allEntries.forEach((e) => e.genres?.forEach((g) => set.add(g.name)));
+ return Array.from(set).sort();
+ }, [allEntries]);
+
+ const hasActiveFilters = filters.genre || filters.ratingMin || filters.ratingMax || filters.yearMin || filters.yearMax;
+
+ const baseEntries = useMemo(() => {
+ switch (activeTab) {
+ case 'movies':
+ return allEntries.filter((e) => !e.is_tvseries && !e.watchlist);
+ case 'tv':
+ return allEntries.filter((e) => e.is_tvseries && !e.watchlist);
+ case 'favorites':
+ return allEntries.filter((e) => e.favorit && !e.watchlist);
+ case 'hidden':
+ return allEntries.filter((e) => e.hidden);
+ default:
+ return allEntries.filter((e) => !e.watchlist);
+ }
+ }, [activeTab, allEntries]);
+
+ const filteredEntries = useMemo(() => {
+ let result = baseEntries;
+
+ if (search) {
+ const q = search.toLowerCase();
+ result = result.filter((e) => e.title.toLowerCase().includes(q));
+ }
+
+ if (filters.genre) {
+ result = result.filter((e) => e.genres?.some((g) => g.name === filters.genre));
+ }
+ if (filters.ratingMin) {
+ const min = parseFloat(filters.ratingMin);
+ result = result.filter((e) => (e.entryRatings?.user_rating || e.entryRatings?.tmdb_rating || 0) >= min);
+ }
+ if (filters.ratingMax) {
+ const max = parseFloat(filters.ratingMax);
+ result = result.filter((e) => (e.entryRatings?.user_rating || e.entryRatings?.tmdb_rating || 0) <= max);
+ }
+ if (filters.yearMin) {
+ const min = parseInt(filters.yearMin);
+ result = result.filter((e) => e.release_date && new Date(e.release_date).getFullYear() >= min);
+ }
+ if (filters.yearMax) {
+ const max = parseInt(filters.yearMax);
+ result = result.filter((e) => e.release_date && new Date(e.release_date).getFullYear() <= max);
+ }
+
+ return sortEntries(result, sortField, sortDir);
+ }, [baseEntries, search, filters, sortField, sortDir]);
+
+ const clearFilters = useCallback(() => setFilters(defaultFilters), []);
+
+ return (
+
+
+
Library
+
+
+ {/* Controls row: search left, sort + filter + tabs right */}
+
+ {/* Search - far left */}
+
+
+ setSearch(e.target.value)}
+ className="pl-10"
+ />
+
+
+ {search && (
+
+ )}
+
+ {/* Spacer */}
+
+
+ {/* Sort */}
+
+
+
+
+
+
+ {/* Filter */}
+
+
+
+
+
+
+
+
+
+
+
+ {hasActiveFilters && (
+
+ )}
+
+
+
+ {/* Tabs */}
+
setActiveTab(v as FilterTab)}
+ >
+
+ All
+ Movies
+ TV Series
+ Favorites
+ Hidden
+
+
+
+
+
+
+ );
+}
diff --git a/react_frontend/src/pages/MediaPage.tsx b/react_frontend/src/pages/MediaPage.tsx
new file mode 100644
index 0000000..9d9772d
--- /dev/null
+++ b/react_frontend/src/pages/MediaPage.tsx
@@ -0,0 +1,125 @@
+import { useState, useMemo } from 'react';
+import { useLibrary } from '@/hooks/useEntries';
+import { useLibraryEntries } from '@/stores/useLibraryStore';
+import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { Input } from '@/components/ui/input';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Search } from 'lucide-react';
+import { getMediaUrl } from '@/lib/api';
+import type { Media } from '@/types';
+
+export function MediaPage() {
+ const { isLoading } = useLibrary();
+ const [search, setSearch] = useState('');
+ const [mediaType, setMediaType] = useState<'all' | 'poster' | 'backdrop' | 'logo'>('all');
+
+ const entries = useLibraryEntries();
+
+ const allMedias = useMemo(() => {
+ const medias: (Media & { entryTitle: string })[] = [];
+ entries.forEach((entry) => {
+ entry.medias?.forEach((m) => {
+ medias.push({ ...m, entryTitle: entry.title });
+ });
+ });
+ return medias;
+ }, [entries]);
+
+ const filtered = useMemo(() => {
+ let result = allMedias;
+
+ if (mediaType !== 'all') {
+ result = result.filter((m) => m.type === mediaType);
+ }
+
+ if (search) {
+ const q = search.toLowerCase();
+ result = result.filter((m) => m.entryTitle.toLowerCase().includes(q));
+ }
+
+ return result;
+ }, [allMedias, mediaType, search]);
+
+ return (
+
+
Media
+
+
+
setMediaType(v as typeof mediaType)}
+ >
+
+ All
+ Posters
+ Backdrops
+ Logos
+
+
+
+
+
+ setSearch(e.target.value)}
+ className="pl-10"
+ />
+
+
+
+ {isLoading ? (
+
+ {Array.from({ length: 18 }).map((_, i) => (
+
+ ))}
+
+ ) : filtered.length === 0 ? (
+
+ No media found.
+
+ ) : (
+
+ {filtered.map((media) => (
+
+

+
+
+ {media.entryTitle}
+
+
+
+ ))}
+
+ )}
+
+ );
+}
diff --git a/react_frontend/src/pages/PeoplePage.tsx b/react_frontend/src/pages/PeoplePage.tsx
new file mode 100644
index 0000000..bb36e97
--- /dev/null
+++ b/react_frontend/src/pages/PeoplePage.tsx
@@ -0,0 +1,95 @@
+import { useState, useCallback, useRef, useEffect } from 'react';
+import { Link } from 'react-router-dom';
+import { usePopularPeople, useTmdbSearchPeople } from '@/hooks/useTmdb';
+import { Input } from '@/components/ui/input';
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Search } from 'lucide-react';
+import { getProfileUrl } from '@/lib/media-utils';
+
+export function PeoplePage() {
+ const [search, setSearch] = useState('');
+ const isSearching = search.length > 0;
+
+ const popularQuery = usePopularPeople();
+ const searchQuery = useTmdbSearchPeople(search);
+
+ const activeQuery = isSearching ? searchQuery : popularQuery;
+ const people = activeQuery.data?.pages.flatMap((p) => p.results) ?? [];
+
+ const observerRef = useRef(null);
+ const lastRef = useCallback(
+ (node: HTMLDivElement | null) => {
+ if (activeQuery.isFetchingNextPage) return;
+ if (observerRef.current) observerRef.current.disconnect();
+ observerRef.current = new IntersectionObserver((entries) => {
+ if (entries[0].isIntersecting && activeQuery.hasNextPage) {
+ activeQuery.fetchNextPage();
+ }
+ });
+ if (node) observerRef.current.observe(node);
+ },
+ [activeQuery.isFetchingNextPage, activeQuery.hasNextPage, activeQuery.fetchNextPage]
+ );
+
+ useEffect(() => {
+ return () => observerRef.current?.disconnect();
+ }, []);
+
+ return (
+
+
People
+
+
+
+ setSearch(e.target.value)}
+ className="pl-10"
+ />
+
+
+ {activeQuery.isLoading ? (
+
+ {Array.from({ length: 24 }).map((_, i) => (
+
+
+
+
+ ))}
+
+ ) : (
+
+ {people.map((person, index) => (
+
+
+
+
+
+ {person.name
+ .split(' ')
+ .map((n) => n[0])
+ .join('')}
+
+
+
+ {person.name}
+
+
+
+ ))}
+
+ )}
+
+ );
+}
diff --git a/react_frontend/src/pages/PersonDetailsPage.tsx b/react_frontend/src/pages/PersonDetailsPage.tsx
new file mode 100644
index 0000000..f403a73
--- /dev/null
+++ b/react_frontend/src/pages/PersonDetailsPage.tsx
@@ -0,0 +1,94 @@
+import { useParams } from 'react-router-dom';
+import { usePerson } from '@/hooks/usePeople';
+import { useQuery } from '@tanstack/react-query';
+import { peopleApi } from '@/api/people';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
+import { Separator } from '@/components/ui/separator';
+import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { EntryCard } from '@/components/entries/EntryCard';
+import { getProfileUrl, formatDate } from '@/lib/media-utils';
+
+export function PersonDetailsPage() {
+ const { id } = useParams<{ id: string }>();
+ const personId = parseInt(id!, 10);
+ const { data: person, isLoading } = usePerson(personId);
+
+ if (isLoading || !person) {
+ return (
+
+ );
+ }
+
+ return (
+
+ {/* Profile header */}
+
+
+
+
+ {person.name
+ .split(' ')
+ .map((n: string) => n[0])
+ .join('')}
+
+
+
+
+
{person.name}
+
+ {person.known_for_department && (
+ {person.known_for_department}
+ )}
+ {person.birthday && (
+ <>
+ •
+ Born: {formatDate(person.birthday)}
+ >
+ )}
+ {person.deathday && (
+ <>
+ •
+ Died: {formatDate(person.deathday)}
+ >
+ )}
+ {person.place_of_birth && (
+ <>
+ •
+ {person.place_of_birth}
+ >
+ )}
+
+
+ {person.biography && (
+
+ {person.biography}
+
+ )}
+
+
+
+
+
+ {/* Filmography placeholder */}
+
+
Filmography
+
+ Filmography details will be loaded from credits associated with this person.
+
+
+
+ );
+}
diff --git a/react_frontend/src/pages/SeasonPage.tsx b/react_frontend/src/pages/SeasonPage.tsx
new file mode 100644
index 0000000..aa48e53
--- /dev/null
+++ b/react_frontend/src/pages/SeasonPage.tsx
@@ -0,0 +1,156 @@
+import { useParams, Link } from 'react-router-dom';
+import { useSeason, useSeasonEpisodes } from '@/hooks/useSeasons';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Progress } from '@/components/ui/progress';
+import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
+import { Eye, CheckCircle2 } from 'lucide-react';
+import { getTmdbPosterUrl, getYear, formatDate } from '@/lib/media-utils';
+
+export function SeasonPage() {
+ const { entryId, seasonId } = useParams<{
+ entryId: string;
+ seasonId: string;
+ }>();
+ const { data: season, isLoading } = useSeason(parseInt(seasonId!, 10));
+ const { data: episodes = [] } = useSeasonEpisodes(parseInt(seasonId!, 10));
+
+ if (isLoading || !season) {
+ return (
+
+ );
+ }
+
+ const watchedCount = episodes.filter(
+ (ep) =>
+ ep.date_first_seen ||
+ (ep.episodeSeens && ep.episodeSeens.length > 0)
+ ).length;
+ const totalEpisodes = episodes.length;
+ const progress = totalEpisodes > 0 ? (watchedCount / totalEpisodes) * 100 : 0;
+
+ return (
+
+ {/* Header */}
+
+

+
+
{season.name}
+
+ Season {season.season_number}
+ {season.air_date && (
+ <>
+ •
+ {getYear(season.air_date)}
+ >
+ )}
+ •
+ {totalEpisodes} episodes
+
+
+ {/* Watch progress */}
+
+
+
+ {watchedCount}/{totalEpisodes}
+
+
+
+ {season.overview && (
+
+ {season.overview}
+
+ )}
+
+
+
+ {/* Episodes */}
+
+
Episodes
+
+ {episodes.map((episode) => {
+ const isWatched =
+ !!episode.date_first_seen ||
+ (episode.episodeSeens && episode.episodeSeens.length > 0);
+
+ return (
+
+ {/* Thumbnail */}
+
+ {episode.still_path ? (
+

+ ) : (
+
+ No Image
+
+ )}
+
+
+ {/* Info */}
+
+
+
+ E{episode.episode_number}
+
+
+ {episode.name}
+
+ {isWatched && (
+
+ )}
+
+ {episode.air_date && (
+
+ {formatDate(episode.air_date)}
+
+ )}
+ {episode.overview && (
+
+ {episode.overview}
+
+ )}
+
+
+ {/* Watch button */}
+
+
+ );
+ })}
+
+
+
+ );
+}
diff --git a/react_frontend/src/pages/SettingsPage.tsx b/react_frontend/src/pages/SettingsPage.tsx
new file mode 100644
index 0000000..b861837
--- /dev/null
+++ b/react_frontend/src/pages/SettingsPage.tsx
@@ -0,0 +1,104 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
+import { settingsApi } from '@/api/settings';
+import { useForm } from 'react-hook-form';
+import { zodResolver } from '@hookform/resolvers/zod';
+import { z } from 'zod';
+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Button } from '@/components/ui/button';
+import { Skeleton } from '@/components/ui/skeleton';
+import { Save } from 'lucide-react';
+import type { Settings } from '@/types';
+
+const settingsSchema = z.object({
+ tmdbApiKey: z.string().min(1, 'TMDB API key is required'),
+ backPort: z.coerce.number().int().positive(),
+});
+
+export function SettingsPage() {
+ const queryClient = useQueryClient();
+ const { data: settings, isLoading } = useQuery({
+ queryKey: ['settings'],
+ queryFn: settingsApi.get,
+ });
+
+ const updateSettings = useMutation({
+ mutationFn: (data: Partial) => settingsApi.update(data),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: ['settings'] });
+ },
+ });
+
+ const {
+ register,
+ handleSubmit,
+ formState: { errors, isDirty },
+ } = useForm({
+ resolver: zodResolver(settingsSchema),
+ values: settings
+ ? { tmdbApiKey: settings.tmdbApiKey, backPort: settings.backPort }
+ : undefined,
+ });
+
+ const onSubmit = (data: { tmdbApiKey: string; backPort: number }) => {
+ updateSettings.mutate(data);
+ };
+
+ if (isLoading) {
+ return (
+
+
Settings
+
+
+ );
+ }
+
+ return (
+
+
Settings
+
+
+
+ );
+}
diff --git a/react_frontend/src/pages/WatchlistPage.tsx b/react_frontend/src/pages/WatchlistPage.tsx
new file mode 100644
index 0000000..5c1d714
--- /dev/null
+++ b/react_frontend/src/pages/WatchlistPage.tsx
@@ -0,0 +1,237 @@
+import { useState, useMemo, useCallback } from 'react';
+import { useLibrary } from '@/hooks/useEntries';
+import { useLibraryEntries } from '@/stores/useLibraryStore';
+import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
+import { Input } from '@/components/ui/input';
+import { Button } from '@/components/ui/button';
+import { Badge } from '@/components/ui/badge';
+import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
+import { Search, SlidersHorizontal, ArrowUpDown } from 'lucide-react';
+import type { Entry } from '@/types';
+
+type SortField = 'createdAt' | 'date_last_seen' | 'title' | 'release_date' | 'rating';
+type SortDir = 'asc' | 'desc';
+
+interface Filters {
+ genre: string;
+ ratingMin: string;
+ ratingMax: string;
+ yearMin: string;
+ yearMax: string;
+}
+
+const defaultFilters: Filters = { genre: '', ratingMin: '', ratingMax: '', yearMin: '', yearMax: '' };
+
+const sortLabels: Record = {
+ createdAt: 'Date Added',
+ date_last_seen: 'Last Watched',
+ title: 'Title',
+ release_date: 'Release Date',
+ rating: 'Rating',
+};
+
+function sortEntries(entries: Entry[], field: SortField, dir: SortDir): Entry[] {
+ return [...entries].sort((a, b) => {
+ let cmp = 0;
+ switch (field) {
+ case 'title':
+ cmp = a.title.localeCompare(b.title);
+ break;
+ case 'release_date':
+ cmp = new Date(a.release_date || '1900').getTime() - new Date(b.release_date || '1900').getTime();
+ break;
+ case 'rating':
+ cmp = (a.entryRatings?.user_rating || a.entryRatings?.tmdb_rating || 0) -
+ (b.entryRatings?.user_rating || b.entryRatings?.tmdb_rating || 0);
+ break;
+ case 'date_last_seen':
+ cmp = new Date(a.date_last_seen || '1900').getTime() - new Date(b.date_last_seen || '1900').getTime();
+ break;
+ case 'createdAt':
+ cmp = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
+ break;
+ }
+ return dir === 'desc' ? -cmp : cmp;
+ });
+}
+
+export function WatchlistPage() {
+ const { isLoading } = useLibrary();
+ const [search, setSearch] = useState('');
+ const [sortField, setSortField] = useState('createdAt');
+ const [sortDir, setSortDir] = useState('desc');
+ const [filters, setFilters] = useState(defaultFilters);
+ const allEntries = useLibraryEntries();
+ const watchlist = useMemo(() => allEntries.filter((e) => e.watchlist), [allEntries]);
+
+ const allGenres = useMemo(() => {
+ const set = new Set();
+ watchlist.forEach((e) => e.genres?.forEach((g) => set.add(g.name)));
+ return Array.from(set).sort();
+ }, [watchlist]);
+
+ const hasActiveFilters = filters.genre || filters.ratingMin || filters.ratingMax || filters.yearMin || filters.yearMax;
+
+ const filtered = useMemo(() => {
+ let result = watchlist;
+
+ if (search) {
+ const q = search.toLowerCase();
+ result = result.filter((e) => e.title.toLowerCase().includes(q));
+ }
+
+ if (filters.genre) {
+ result = result.filter((e) => e.genres?.some((g) => g.name === filters.genre));
+ }
+ if (filters.ratingMin) {
+ const min = parseFloat(filters.ratingMin);
+ result = result.filter((e) => (e.entryRatings?.user_rating || e.entryRatings?.tmdb_rating || 0) >= min);
+ }
+ if (filters.ratingMax) {
+ const max = parseFloat(filters.ratingMax);
+ result = result.filter((e) => (e.entryRatings?.user_rating || e.entryRatings?.tmdb_rating || 0) <= max);
+ }
+ if (filters.yearMin) {
+ const min = parseInt(filters.yearMin);
+ result = result.filter((e) => e.release_date && new Date(e.release_date).getFullYear() >= min);
+ }
+ if (filters.yearMax) {
+ const max = parseInt(filters.yearMax);
+ result = result.filter((e) => e.release_date && new Date(e.release_date).getFullYear() <= max);
+ }
+
+ return sortEntries(result, sortField, sortDir);
+ }, [watchlist, search, filters, sortField, sortDir]);
+
+ const clearFilters = useCallback(() => setFilters(defaultFilters), []);
+
+ return (
+
+
Watchlist
+
+
+ {/* Search */}
+
+
+ setSearch(e.target.value)}
+ className="pl-10"
+ />
+
+
+ {/* Spacer */}
+
+
+ {/* Sort */}
+
+
+
+
+
+
+ {/* Filter */}
+
+
+
+
+
+
+
+
+
+
+
+ {hasActiveFilters && (
+
+ )}
+
+
+
+
+
+
+ );
+}
diff --git a/react_frontend/src/router.tsx b/react_frontend/src/router.tsx
new file mode 100644
index 0000000..3710220
--- /dev/null
+++ b/react_frontend/src/router.tsx
@@ -0,0 +1,189 @@
+import { createBrowserRouter } from 'react-router-dom';
+import { lazy, Suspense } from 'react';
+import { AppLayout } from '@/components/layout/AppLayout';
+import { Skeleton } from '@/components/ui/skeleton';
+
+// Lazy-loaded pages
+const HomePage = lazy(() =>
+ import('@/pages/HomePage').then((m) => ({ default: m.HomePage }))
+);
+const DashboardPage = lazy(() =>
+ import('@/pages/DashboardPage').then((m) => ({ default: m.DashboardPage }))
+);
+const LibraryPage = lazy(() =>
+ import('@/pages/LibraryPage').then((m) => ({ default: m.LibraryPage }))
+);
+const WatchlistPage = lazy(() =>
+ import('@/pages/WatchlistPage').then((m) => ({ default: m.WatchlistPage }))
+);
+const CollectionsPage = lazy(() =>
+ import('@/pages/CollectionsPage').then((m) => ({
+ default: m.CollectionsPage,
+ }))
+);
+const CollectionDetailsPage = lazy(() =>
+ import('@/pages/CollectionDetailsPage').then((m) => ({
+ default: m.CollectionDetailsPage,
+ }))
+);
+const MediaPage = lazy(() =>
+ import('@/pages/MediaPage').then((m) => ({ default: m.MediaPage }))
+);
+const CalendarPage = lazy(() =>
+ import('@/pages/CalendarPage').then((m) => ({ default: m.CalendarPage }))
+);
+const EntryDetailsPage = lazy(() =>
+ import('@/pages/EntryDetailsPage').then((m) => ({
+ default: m.EntryDetailsPage,
+ }))
+);
+const SeasonPage = lazy(() =>
+ import('@/pages/SeasonPage').then((m) => ({ default: m.SeasonPage }))
+);
+const EpisodePage = lazy(() =>
+ import('@/pages/EpisodePage').then((m) => ({ default: m.EpisodePage }))
+);
+const PeoplePage = lazy(() =>
+ import('@/pages/PeoplePage').then((m) => ({ default: m.PeoplePage }))
+);
+const PersonDetailsPage = lazy(() =>
+ import('@/pages/PersonDetailsPage').then((m) => ({
+ default: m.PersonDetailsPage,
+ }))
+);
+const SettingsPage = lazy(() =>
+ import('@/pages/SettingsPage').then((m) => ({ default: m.SettingsPage }))
+);
+
+function PageFallback() {
+ return (
+
+
+
+
+ );
+}
+
+function SuspensePage({ children }: { children: React.ReactNode }) {
+ return }>{children};
+}
+
+export const router = createBrowserRouter([
+ {
+ element: ,
+ children: [
+ {
+ path: '/',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/dashboard',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/library',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/watchlist',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/collections',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/collections/:id',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/media',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/calendar',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/entry/:id',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/entry/:entryId/season/:seasonId',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/entry/:entryId/season/:seasonId/episode/:episodeId',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/people',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/people/:id',
+ element: (
+
+
+
+ ),
+ },
+ {
+ path: '/settings',
+ element: (
+
+
+
+ ),
+ },
+ ],
+ },
+]);
diff --git a/react_frontend/src/stores/useLibraryStore.ts b/react_frontend/src/stores/useLibraryStore.ts
new file mode 100644
index 0000000..5dad9bd
--- /dev/null
+++ b/react_frontend/src/stores/useLibraryStore.ts
@@ -0,0 +1,59 @@
+import { create } from 'zustand';
+import type { Entry } from '@/types';
+
+interface LibraryState {
+ entries: Map;
+ isLoaded: boolean;
+
+ // Actions
+ setEntries: (entries: Entry[]) => void;
+ addEntry: (entry: Entry) => void;
+ updateEntry: (id: number, data: Partial) => void;
+ removeEntry: (id: number) => void;
+}
+
+export const useLibraryStore = create((set) => ({
+ entries: new Map(),
+ isLoaded: false,
+
+ setEntries: (entries) => {
+ const map = new Map();
+ entries.forEach((entry) => {
+ map.set(entry.id, { ...entry, isInLibrary: true });
+ });
+ set({ entries: map, isLoaded: true });
+ },
+
+ addEntry: (entry) => {
+ set((state) => {
+ const newEntries = new Map(state.entries);
+ newEntries.set(entry.id, { ...entry, isInLibrary: true });
+ return { entries: newEntries };
+ });
+ },
+
+ updateEntry: (id, data) => {
+ set((state) => {
+ const existing = state.entries.get(id);
+ if (!existing) return state;
+ const newEntries = new Map(state.entries);
+ newEntries.set(id, { ...existing, ...data });
+ return { entries: newEntries };
+ });
+ },
+
+ removeEntry: (id) => {
+ set((state) => {
+ const newEntries = new Map(state.entries);
+ newEntries.delete(id);
+ return { entries: newEntries };
+ });
+ },
+}));
+
+// Derived selectors — call these outside of Zustand selectors
+// Use with: const entries = useLibraryEntries();
+export function useLibraryEntries() {
+ const entries = useLibraryStore((s) => s.entries);
+ return Array.from(entries.values());
+}
diff --git a/react_frontend/src/types/index.ts b/react_frontend/src/types/index.ts
new file mode 100644
index 0000000..fe25f68
--- /dev/null
+++ b/react_frontend/src/types/index.ts
@@ -0,0 +1,232 @@
+// Entry types
+export interface EntryIds {
+ tmdb_id: number | null;
+ imdb_id: string | null;
+ tvdb_id: number | null;
+}
+
+export interface EntryRatings {
+ user_rating: number | null;
+ tmdb_rating: number | null;
+ imdb_rating: number | null;
+ rotten_tomatoes_rating: number | null;
+}
+
+export interface Media {
+ id: number;
+ mediaable: 'entry' | 'people' | 'collection' | 'season' | 'episode';
+ mediaable_id: number;
+ type: 'poster' | 'backdrop' | 'logo' | 'still' | 'profile';
+ path: string;
+ is_local: boolean;
+ is_selected: boolean;
+ is_custom: boolean;
+ is_favorit: boolean;
+}
+
+export interface Entry {
+ id: number;
+ title: string;
+ original_title: string | null;
+ release_date: string | null;
+ runtime: number | null;
+ storyline: string | null;
+ country: string | null;
+ is_tvseries: boolean;
+ status: string | null;
+ poster_path: string | null;
+ banner_path: string | null;
+ watchlist: boolean;
+ favorit: boolean;
+ hidden: boolean;
+ note: string | null;
+ date_first_seen: string | null;
+ date_last_seen: string | null;
+ createdAt: string;
+ updatedAt: string;
+ // Relations
+ entryIds?: EntryIds;
+ entryRatings?: EntryRatings;
+ medias?: Media[];
+ genres?: Genre[];
+ credits?: Credit[];
+ seasons?: Season[];
+ entrySeens?: EntrySeen[];
+ episodeSeens?: EpisodeSeen[];
+ networks?: Network[];
+ // Computed for library
+ isInLibrary?: boolean;
+ isInWatchlist?: boolean;
+}
+
+export interface Season {
+ id: number;
+ entry_id: number;
+ name: string;
+ season_number: number;
+ episode_count: number;
+ air_date: string | null;
+ user_rating: number | null;
+ tmdb_rating: number | null;
+ imdb_rating: number | null;
+ poster_path: string | null;
+ banner_path: string | null;
+ overview: string | null;
+ createdAt: string;
+ updatedAt: string;
+ episodes?: Episode[];
+}
+
+export interface Episode {
+ id: number;
+ season_id: number;
+ name: string;
+ episode_number: number;
+ episode_type: string | null;
+ runtime: number | null;
+ air_date: string | null;
+ user_rating: number | null;
+ tmdb_rating: number | null;
+ still_path: string | null;
+ overview: string | null;
+ date_first_seen: string | null;
+ date_last_seen: string | null;
+ createdAt: string;
+ updatedAt: string;
+ episodeSeens?: EpisodeSeen[];
+ guest_stars?: Credit[];
+}
+
+export interface EntrySeen {
+ id: number;
+ entry_id: number;
+ date_seen: string;
+ seen_with: string | null;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface EpisodeSeen {
+ id: number;
+ entry_id: number;
+ episode_id: number;
+ date_seen: string;
+ seen_with: string | null;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface Collection {
+ id: number;
+ tmdb_id: number | null;
+ name: string;
+ description: string | null;
+ user_rating: number | null;
+ poster_path: string | null;
+ backdrop_path: string | null;
+ is_local: boolean;
+ is_user_collection: boolean;
+ createdAt: string;
+ updatedAt: string;
+ entries?: Entry[];
+ medias?: Media[];
+}
+
+export interface People {
+ id: number;
+ tmdb_id: number;
+ name: string;
+ birthday: string | null;
+ deathday: string | null;
+ gender: number;
+ biography: string | null;
+ place_of_birth: string | null;
+ known_for_department: string | null;
+ fully_fetched: boolean;
+ profile_path: string | null;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export interface Credit {
+ id: number;
+ entry_id: number;
+ people_id: number;
+ character: string | null;
+ cast_type: 'cast' | 'crew';
+ department: string | null;
+ job: string | null;
+ order: number | null;
+ people?: People;
+}
+
+export interface Genre {
+ id: number;
+ name: string;
+}
+
+export interface Network {
+ id: number;
+ name: string;
+ origin_country: string | null;
+ homepage: string | null;
+ logo_path: string | null;
+}
+
+export interface Settings {
+ userDataPath: string;
+ tmdbApiUrl: string;
+ tmdbApiKey: string;
+ frontPort: string;
+ backPort: number;
+ portableMode: string;
+ libraryViewMode: string;
+ favoritViewMode: string;
+ watchlistViewMode: string;
+ CollectionsViewMode: string;
+ CollectionItemsViewMode: string;
+ favoritsViewMode: string;
+}
+
+export interface Statistics {
+ totalMovies: number;
+ totalTvSeries: number;
+ totalFavorites: number;
+ totalWatchlist: number;
+ totalWatchTime: number;
+}
+
+// TMDB types for discover/search
+export interface TmdbEntry {
+ id: number;
+ title?: string;
+ name?: string;
+ original_title?: string;
+ original_name?: string;
+ release_date?: string;
+ first_air_date?: string;
+ overview: string;
+ poster_path: string | null;
+ backdrop_path: string | null;
+ vote_average: number;
+ vote_count: number;
+ genre_ids: number[];
+ media_type?: string;
+ popularity: number;
+}
+
+export interface TmdbPerson {
+ id: number;
+ name: string;
+ profile_path: string | null;
+ known_for_department: string | null;
+ popularity: number;
+ known_for?: TmdbEntry[];
+}
+
+export interface TmdbPaginatedResponse {
+ page: number;
+ results: T[];
+ total_pages: number;
+ total_results: number;
+}
diff --git a/react_frontend/vite.config.ts b/react_frontend/vite.config.ts
index 0cca23e..cdeddfe 100644
--- a/react_frontend/vite.config.ts
+++ b/react_frontend/vite.config.ts
@@ -11,4 +11,12 @@ export default defineConfig({
'@': path.resolve(__dirname, './src'),
},
},
+ server: {
+ proxy: {
+ '/api': {
+ target: 'http://showyback.coolguy.space',
+ changeOrigin: true,
+ },
+ },
+ },
})
Connect with us
-Join the Vite community
---
-
-
- GitHub
-
-
- -
-
-
- Discord
-
-
- -
-
-
- X.com
-
-
- -
-
-
- Bluesky
-
-
-
-