Fix home page navigation and add TMDB cast page
Home page cards now check library store and link directly to EntryDetailsPage when the entry is already added. Created useTmdbEntryLink hook for shared library-check logic. Added TmdbCastsPage with filter/search/sort for TMDB preview cast & crew, and limited credits to 12 on TmdbPreviewPage.
This commit is contained in:
1 parent
6c2fd3837b
commit
8671184dc5
9 files changed
+540
-136
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { createBrowserRouter, createHashRouter } from 'react-router-dom';
|
||||
import { lazy, Suspense, type ReactNode } from 'react';
|
||||
import { AppLayout } from '@/components/layout/AppLayout';
|
||||
import { createBrowserRouter, createHashRouter } from "react-router-dom";
|
||||
import { lazy, Suspense, type ReactNode } from "react";
|
||||
import { AppLayout } from "@/components/layout/AppLayout";
|
||||
import {
|
||||
DashboardSkeleton,
|
||||
HomeSkeleton,
|
||||
@@ -16,81 +16,94 @@ import {
|
||||
MediaSkeleton,
|
||||
CalendarSkeleton,
|
||||
SettingsSkeleton,
|
||||
} from '@/components/skeletons/PageSkeletons';
|
||||
} from "@/components/skeletons/PageSkeletons";
|
||||
|
||||
// Lazy-loaded pages
|
||||
const HomePage = lazy(() =>
|
||||
import('@/pages/HomePage').then((m) => ({ default: m.HomePage }))
|
||||
import("@/pages/HomePage").then((m) => ({ default: m.HomePage })),
|
||||
);
|
||||
const DashboardPage = lazy(() =>
|
||||
import('@/pages/DashboardPage').then((m) => ({ default: m.DashboardPage }))
|
||||
import("@/pages/DashboardPage").then((m) => ({ default: m.DashboardPage })),
|
||||
);
|
||||
const LibraryPage = lazy(() =>
|
||||
import('@/pages/LibraryPage').then((m) => ({ default: m.LibraryPage }))
|
||||
import("@/pages/LibraryPage").then((m) => ({ default: m.LibraryPage })),
|
||||
);
|
||||
const WatchlistPage = lazy(() =>
|
||||
import('@/pages/WatchlistPage').then((m) => ({ default: m.WatchlistPage }))
|
||||
import("@/pages/WatchlistPage").then((m) => ({ default: m.WatchlistPage })),
|
||||
);
|
||||
const CollectionsPage = lazy(() =>
|
||||
import('@/pages/CollectionsPage').then((m) => ({
|
||||
import("@/pages/CollectionsPage").then((m) => ({
|
||||
default: m.CollectionsPage,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
const CollectionDetailsPage = lazy(() =>
|
||||
import('@/pages/CollectionDetailsPage').then((m) => ({
|
||||
import("@/pages/CollectionDetailsPage").then((m) => ({
|
||||
default: m.CollectionDetailsPage,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
const MediaPage = lazy(() =>
|
||||
import('@/pages/MediaPage').then((m) => ({ default: m.MediaPage }))
|
||||
import("@/pages/MediaPage").then((m) => ({ default: m.MediaPage })),
|
||||
);
|
||||
const CalendarPage = lazy(() =>
|
||||
import('@/pages/CalendarPage').then((m) => ({ default: m.CalendarPage }))
|
||||
import("@/pages/CalendarPage").then((m) => ({ default: m.CalendarPage })),
|
||||
);
|
||||
const EntryDetailsPage = lazy(() =>
|
||||
import('@/pages/EntryDetailsPage').then((m) => ({
|
||||
import("@/pages/EntryDetailsPage").then((m) => ({
|
||||
default: m.EntryDetailsPage,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
const TmdbPreviewPage = lazy(() =>
|
||||
import('@/pages/TmdbPreviewPage').then((m) => ({
|
||||
import("@/pages/TmdbPreviewPage").then((m) => ({
|
||||
default: m.TmdbPreviewPage,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
const TmdbCastsPage = lazy(() =>
|
||||
import("@/pages/TmdbCastsPage").then((m) => ({
|
||||
default: m.TmdbCastsPage,
|
||||
})),
|
||||
);
|
||||
const SeasonPage = lazy(() =>
|
||||
import('@/pages/SeasonPage').then((m) => ({ default: m.SeasonPage }))
|
||||
import("@/pages/SeasonPage").then((m) => ({ default: m.SeasonPage })),
|
||||
);
|
||||
const EpisodePage = lazy(() =>
|
||||
import('@/pages/EpisodePage').then((m) => ({ default: m.EpisodePage }))
|
||||
import("@/pages/EpisodePage").then((m) => ({ default: m.EpisodePage })),
|
||||
);
|
||||
const EntryCastsPage = lazy(() =>
|
||||
import('@/pages/EntryCastsPage').then((m) => ({
|
||||
import("@/pages/EntryCastsPage").then((m) => ({
|
||||
default: m.EntryCastsPage,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
const PeoplePage = lazy(() =>
|
||||
import('@/pages/PeoplePage').then((m) => ({ default: m.PeoplePage }))
|
||||
import("@/pages/PeoplePage").then((m) => ({ default: m.PeoplePage })),
|
||||
);
|
||||
const PersonDetailsPage = lazy(() =>
|
||||
import('@/pages/PersonDetailsPage').then((m) => ({
|
||||
import("@/pages/PersonDetailsPage").then((m) => ({
|
||||
default: m.PersonDetailsPage,
|
||||
}))
|
||||
})),
|
||||
);
|
||||
const SettingsPage = lazy(() =>
|
||||
import('@/pages/SettingsPage').then((m) => ({ default: m.SettingsPage }))
|
||||
import("@/pages/SettingsPage").then((m) => ({ default: m.SettingsPage })),
|
||||
);
|
||||
const DiscoverPage = lazy(() =>
|
||||
import('@/pages/DiscoverPage').then((m) => ({ default: m.DiscoverPage }))
|
||||
import("@/pages/DiscoverPage").then((m) => ({ default: m.DiscoverPage })),
|
||||
);
|
||||
const SearchPage = lazy(() =>
|
||||
import('@/pages/SearchPage').then((m) => ({ default: m.SearchPage }))
|
||||
import("@/pages/SearchPage").then((m) => ({ default: m.SearchPage })),
|
||||
);
|
||||
|
||||
function SuspensePage({ children, fallback }: { children: ReactNode; fallback?: ReactNode }) {
|
||||
return <Suspense fallback={fallback ?? <HomeSkeleton />}>{children}</Suspense>;
|
||||
function SuspensePage({
|
||||
children,
|
||||
fallback,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
fallback?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Suspense fallback={fallback ?? <HomeSkeleton />}>{children}</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
const isElectron = import.meta.env.VITE_ELECTRON === 'true';
|
||||
const isElectron = import.meta.env.VITE_ELECTRON === "true";
|
||||
const createRouter = isElectron ? createHashRouter : createBrowserRouter;
|
||||
|
||||
export const router = createRouter([
|
||||
@@ -98,7 +111,7 @@ export const router = createRouter([
|
||||
element: <AppLayout />,
|
||||
children: [
|
||||
{
|
||||
path: '/',
|
||||
path: "/",
|
||||
element: (
|
||||
<SuspensePage fallback={<HomeSkeleton />}>
|
||||
<HomePage />
|
||||
@@ -106,7 +119,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/search',
|
||||
path: "/search",
|
||||
element: (
|
||||
<SuspensePage fallback={<HomeSkeleton />}>
|
||||
<SearchPage />
|
||||
@@ -114,7 +127,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/dashboard',
|
||||
path: "/dashboard",
|
||||
element: (
|
||||
<SuspensePage fallback={<DashboardSkeleton />}>
|
||||
<DashboardPage />
|
||||
@@ -122,7 +135,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/library',
|
||||
path: "/library",
|
||||
element: (
|
||||
<SuspensePage fallback={<LibrarySkeleton />}>
|
||||
<LibraryPage />
|
||||
@@ -130,7 +143,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/discover/:category',
|
||||
path: "/discover/:category",
|
||||
element: (
|
||||
<SuspensePage fallback={<HomeSkeleton />}>
|
||||
<DiscoverPage />
|
||||
@@ -138,7 +151,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/watchlist',
|
||||
path: "/watchlist",
|
||||
element: (
|
||||
<SuspensePage fallback={<WatchlistSkeleton />}>
|
||||
<WatchlistPage />
|
||||
@@ -146,7 +159,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/collections',
|
||||
path: "/collections",
|
||||
element: (
|
||||
<SuspensePage fallback={<CollectionsSkeleton />}>
|
||||
<CollectionsPage />
|
||||
@@ -154,7 +167,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/collections/:id',
|
||||
path: "/collections/:id",
|
||||
element: (
|
||||
<SuspensePage fallback={<CollectionDetailsSkeleton />}>
|
||||
<CollectionDetailsPage />
|
||||
@@ -162,7 +175,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/media',
|
||||
path: "/media",
|
||||
element: (
|
||||
<SuspensePage fallback={<MediaSkeleton />}>
|
||||
<MediaPage />
|
||||
@@ -170,7 +183,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/calendar',
|
||||
path: "/calendar",
|
||||
element: (
|
||||
<SuspensePage fallback={<CalendarSkeleton />}>
|
||||
<CalendarPage />
|
||||
@@ -178,7 +191,15 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/entry/tmdb/:type/:tmdbId',
|
||||
path: "/entry/tmdb/:type/:tmdbId/cast",
|
||||
element: (
|
||||
<SuspensePage fallback={<PeopleSkeleton />}>
|
||||
<TmdbCastsPage />
|
||||
</SuspensePage>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/entry/tmdb/:type/:tmdbId",
|
||||
element: (
|
||||
<SuspensePage fallback={<EntryDetailsSkeleton />}>
|
||||
<TmdbPreviewPage />
|
||||
@@ -186,7 +207,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/entry/:id',
|
||||
path: "/entry/:id",
|
||||
element: (
|
||||
<SuspensePage fallback={<EntryDetailsSkeleton />}>
|
||||
<EntryDetailsPage />
|
||||
@@ -194,7 +215,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/entry/:id/cast',
|
||||
path: "/entry/:id/cast",
|
||||
element: (
|
||||
<SuspensePage fallback={<PeopleSkeleton />}>
|
||||
<EntryCastsPage />
|
||||
@@ -202,7 +223,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/entry/:entryId/season/:seasonId',
|
||||
path: "/entry/:entryId/season/:seasonId",
|
||||
element: (
|
||||
<SuspensePage fallback={<SeasonSkeleton />}>
|
||||
<SeasonPage />
|
||||
@@ -210,7 +231,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/entry/:entryId/season/:seasonId/episode/:episodeId',
|
||||
path: "/entry/:entryId/season/:seasonId/episode/:episodeId",
|
||||
element: (
|
||||
<SuspensePage fallback={<EpisodeSkeleton />}>
|
||||
<EpisodePage />
|
||||
@@ -218,7 +239,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/people',
|
||||
path: "/people",
|
||||
element: (
|
||||
<SuspensePage fallback={<PeopleSkeleton />}>
|
||||
<PeoplePage />
|
||||
@@ -226,7 +247,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/people/tmdb/:tmdbId',
|
||||
path: "/people/tmdb/:tmdbId",
|
||||
element: (
|
||||
<SuspensePage fallback={<PersonDetailsSkeleton />}>
|
||||
<PersonDetailsPage />
|
||||
@@ -234,7 +255,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/people/:id',
|
||||
path: "/people/:id",
|
||||
element: (
|
||||
<SuspensePage fallback={<PersonDetailsSkeleton />}>
|
||||
<PersonDetailsPage />
|
||||
@@ -242,7 +263,7 @@ export const router = createRouter([
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
path: "/settings",
|
||||
element: (
|
||||
<SuspensePage fallback={<SettingsSkeleton />}>
|
||||
<SettingsPage />
|
||||
|
||||
Reference in new issue
Block a user