Refactor auth session handling and server actions across app

- Overhaul `lib/auth/server.ts` and `lib/auth/session.ts`; update all API
  routes and server actions to use the revised session pattern
- Refactor server actions (settings, titles, watchlist, setup) for
  consistency with new auth layer
- Extract `SetupForm` into its own client component with `useActionState`,
  animated steps, and copyable env snippets
- Move landing page redirect logic into `app/page.tsx`; slim down
  `LandingPage` component
- Add `proxy.ts` for local dev proxying
- Minor cleanup to `NavBar`, `MobileTabBar`, and `TitleCard`
This commit is contained in:
2026-03-06 17:05:49 -05:00
parent 7a3052250d
commit 73b07f5ff6
34 changed files with 443 additions and 466 deletions
+12 -9
View File
@@ -14,7 +14,7 @@ import {
import { type MotionStyle, type MotionValue, motion } from "motion/react";
import Image from "next/image";
import Link from "next/link";
import { useState } from "react";
import { useEffect, useState } from "react";
import {
Tooltip,
TooltipContent,
@@ -83,8 +83,15 @@ function QuickAddButton({
userStatus ?? null,
);
const effectiveStatus = addedStatus;
const config = effectiveStatus ? statusConfig[effectiveStatus] : null;
// Sync local state when prop changes (e.g. after navigation or SWR revalidation)
useEffect(() => {
if (userStatus) {
setState("added");
setAddedStatus(userStatus);
}
}, [userStatus]);
const config = addedStatus ? statusConfig[addedStatus] : null;
async function handleClick(e: React.MouseEvent) {
e.preventDefault();
@@ -92,13 +99,9 @@ function QuickAddButton({
if (state === "loading" || state === "added") return;
setState("loading");
try {
const result = await quickAddToWatchlist(tmdbId, type);
await quickAddToWatchlist(tmdbId, type);
setState("added");
setAddedStatus(result.alreadyAdded ? null : "watchlist");
if (result.alreadyAdded) {
// Already existed — keep as added but we don't know exact status
setAddedStatus("watchlist");
}
setAddedStatus("watchlist");
} catch {
setState("idle");
}