Replace server actions with API routes and add SWR data-fetching hooks

- Convert discover, stats, status, and system-health server actions to
  proper API route handlers under `app/api/`; delete `lib/actions/explore.ts`,
  `lib/actions/settings.ts`, and `lib/actions/setup.ts`
- Add `use-discover`, `use-stats`, and `use-system-health` SWR hooks
  that call the new routes; update `command-palette`, `title-card`,
  `update-toast`, and `stats-display` to consume them
- Lift auth centering wrapper from individual login/register pages into
  `(auth)/layout.tsx`; switch both pages from `auth.api.getSession` to
  the cached `getSession()` helper
- Relocate setup wizard from `app/(auth)/setup/` to `app/setup/` (outside
  auth group) with dedicated `copy-button` and `refresh-button` client
  components
- Move `not-found.tsx` and `error.tsx` to app root so they apply
  globally instead of only within the pages route group
This commit is contained in:
2026-03-08 19:09:21 -04:00
parent 1f3e5e976f
commit 271069cc0c
32 changed files with 616 additions and 618 deletions
+12 -5
View File
@@ -16,6 +16,7 @@ import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect, useState, useTransition } from "react";
import { toast } from "sonner";
import { useProgress } from "@/components/navigation-progress";
import {
Tooltip,
@@ -324,11 +325,17 @@ export function TitleCard({
onClick={() => {
progress.start();
startTransition(async () => {
const resolvedId = await resolveTitle(
tmdbId,
type as "movie" | "tv",
);
if (resolvedId) router.push(`/titles/${resolvedId}`);
try {
const resolvedId = await resolveTitle(
tmdbId,
type as "movie" | "tv",
);
if (resolvedId) router.push(`/titles/${resolvedId}`);
else progress.done();
} catch {
progress.done();
toast.error("Failed to load title");
}
});
}}
>