mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
25 lines
725 B
TypeScript
25 lines
725 B
TypeScript
|
|
"use client";
|
||
|
|
import { useAtomValue } from "jotai";
|
||
|
|
import { automationsListAtom } from "@/atoms/automations/automations-query.atoms";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* List automations in the active search space (first page).
|
||
|
|
* Pagination knobs live in detail/list hooks below; v1 surfaces only the
|
||
|
|
* first page since automation counts are expected to be small.
|
||
|
|
*/
|
||
|
|
export function useAutomations() {
|
||
|
|
const { data, isLoading, error, refetch } = useAutomationsRaw();
|
||
|
|
return {
|
||
|
|
automations: data?.items ?? [],
|
||
|
|
total: data?.total ?? 0,
|
||
|
|
loading: isLoading,
|
||
|
|
error,
|
||
|
|
refresh: refetch,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
// Exposed for callers that prefer the raw react-query result shape.
|
||
|
|
export function useAutomationsRaw() {
|
||
|
|
return useAtomValue(automationsListAtom);
|
||
|
|
}
|