import { DataState } from '../../../shared/hooks/data-load-state-reducer'; import { HookEnableParam } from '../../../shared/hooks/types'; import { DashboardModel } from './dashboard-model'; import { GetDashboardModelOptions } from './get-dashboard-model'; /** * Parameters for {@link useGetDashboardModel} hook. */ export interface GetDashboardModelParams extends GetDashboardModelOptions, HookEnableParam { /** * Dashboard identifier */ dashboardOid: string; } /** * States of a dashboard model load. */ export type DashboardModelState = DashboardModelLoadingState | DashboardModelErrorState | DashboardModelSuccessState; /** * State of a dashboard model loading. */ export type DashboardModelLoadingState = { /** Whether the dashboard model is loading */ isLoading: true; /** Whether the dashboard model load has failed */ isError: false; /** Whether the dashboard model load has succeeded */ isSuccess: false; /** The error if any occurred */ error: undefined; /** The result dashboard model if the load has succeeded */ dashboard: DashboardModel | undefined; /** The status of the dashboard model load */ status: 'loading'; }; /** * State of a dashboard model load that has failed. */ export type DashboardModelErrorState = { /** Whether the dashboard model is loading */ isLoading: false; /** Whether the dashboard model load has failed */ isError: true; /** Whether the dashboard model load has succeeded */ isSuccess: false; /** The error if any occurred */ error: Error; /** The result dashboard model if the load has succeeded */ dashboard: undefined; /** The status of the dashboard model load */ status: 'error'; }; /** * State of a dashboard model load that has succeeded. */ export type DashboardModelSuccessState = { /** Whether the dashboard model is loading */ isLoading: false; /** Whether the dashboard model load has failed */ isError: false; /** Whether the dashboard model load has succeeded */ isSuccess: true; /** The error if any occurred */ error: undefined; /** The result dashboard model if the load has succeeded */ dashboard: DashboardModel; /** The status of the dashboard model load */ status: 'success'; }; /** * React hook that retrieves an existing dashboard model from the Sisense instance. * * **Note:** Dashboard and Widget extensions based on JS scripts and add-ons in Fusion – for example, Blox and Jump To Dashboard – are not supported. * * @example * An example of retrieving an existing dashboard model from the Sisense instance and render its widgets with component `WidgetById`: ```tsx const { dashboard, isLoading, isError } = useGetDashboardModel({ dashboardOid: '6448665edac1920034bce7a8', includeWidgets: true, }); if (isLoading) { return