mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 05:05:38 -04:00
- Delete 10 API routes (stats, system-health, update-check, jobs/trigger, backup/restore, person, titles import/resolve, registration/status) and move logic into server actions in lib/actions/settings.ts and lib/actions/watchlist.ts - Refactor SystemHealthCards to accept initialData prop and hydrate Jotai atoms via useHydrateAtoms; replace useSystemHealth SWR hook with a lightweight useSystemHealthRefresh that calls getSystemHealthAction - Convert BackupRestoreSection to use restoreBackupAction + useTransition instead of a raw fetch call - Split SystemStatusCard, BackgroundJobsCard, and StorageCard into standalone components reading from systemHealthDataAtom - Make SetupPage async with connection() to opt into dynamic rendering
21 lines
717 B
TypeScript
21 lines
717 B
TypeScript
import { atom } from "jotai";
|
|
import { unwrap } from "jotai/utils";
|
|
import { getStatsAction } from "@/lib/actions/watchlist";
|
|
import type { TimePeriod } from "@/lib/services/discovery";
|
|
|
|
export const moviePeriodAtom = atom<TimePeriod>("this_month");
|
|
export const episodePeriodAtom = atom<TimePeriod>("this_week");
|
|
|
|
const movieStatsAsyncAtom = atom(async (get) => {
|
|
const period = get(moviePeriodAtom);
|
|
return getStatsAction("movies", period);
|
|
});
|
|
|
|
const episodeStatsAsyncAtom = atom(async (get) => {
|
|
const period = get(episodePeriodAtom);
|
|
return getStatsAction("episodes", period);
|
|
});
|
|
|
|
export const movieStatsAtom = unwrap(movieStatsAsyncAtom);
|
|
export const episodeStatsAtom = unwrap(episodeStatsAsyncAtom);
|