Skip to main content

useAdministeredProjects

Loads a paginated list of projects the current client can administer.

When to use it​

Use page and count to move through the Slim page response.

Setup​

Call it from a client-side React component below OvokProvider so it uses the client configured at that provider boundary.

Hook arguments​

ArgumentTypeDetails
params (optional){ page?: number; count?: number; }Optional page and count controls.

TypeScript signature​

(params?: { page?: number; count?: number; }): OvokRequestState<SlimPage<OvokAdministeredProject>>

Request state​

The response payload is SlimPage<OvokAdministeredProject>. A successful empty result, a failed request, and a request that has not returned data are distinct states.

FieldMeaning
dataLatest successful response, or undefined before one is available.
loadingWhether the request is in progress.
errorRequest error as an Error, or undefined when no request has failed.
reloadRepeats the request with the current arguments.

Request behavior​

The hook loads when its required inputs are available and reloads when those inputs change. Use reload for an explicit refresh; render loading, error, and successful no-result states separately.

Example​

Handle the hook's loading and error states before rendering the result.

import { useAdministeredProjects } from '@ovok/core';

export function AdministeredProjectsExample({ params }: { params?: Parameters<typeof useAdministeredProjects>[0] }) {
const { data, loading, error, reload } = useAdministeredProjects(params);
if (loading) return <p>Loading…</p>;
if (error) return <p role="alert">{error.message}</p>;
return <section><button onClick={reload}>Reload</button><pre>{JSON.stringify(data, null, 2)}</pre></section>;
}