import { HookEnableParam } from '../../../shared/hooks/types'; import { GetHierarchyModelsOptions } from './get-hierarchy-models'; import { HierarchyModel } from './hierarchy-model'; /** * Parameters for {@link useGetHierarchyModels} hook. */ export interface GetHierarchyModelsParams extends GetHierarchyModelsOptions, HookEnableParam { } /** * States of hierarchy models load. */ export type HierarchyModelsState = HierarchyModelsLoadingState | HierarchyModelsErrorState | HierarchyModelsSuccessState; /** * State of hierarchy models that is loading. */ export type HierarchyModelsLoadingState = { /** Whether the hierarchy models is loading */ isLoading: true; /** Whether the hierarchy models load has failed */ isError: false; /** Whether the hierarchy models load has succeeded */ isSuccess: false; /** Error, if one occurred */ error: undefined; /** Hierarchy models, if the load succeeded */ hierarchies: HierarchyModel[] | undefined; /** Loading status */ status: 'loading'; }; /** * State of a hierarchy models load that has failed. */ export type HierarchyModelsErrorState = { /** Whether the hierarchy models is loading */ isLoading: false; /** Whether the hierarchy models load has failed */ isError: true; /** Whether the hierarchy models load has succeeded */ isSuccess: false; /** Error, if one occurred */ error: Error; /** Hierarchy models, if the load succeeded */ hierarchies: undefined; /** Loading status */ status: 'error'; }; /** * State of a hierarchy models load that has succeeded. */ export type HierarchyModelsSuccessState = { /** Whether the hierarchy models is loading */ isLoading: false; /** Whether the hierarchy models load has failed */ isError: false; /** Whether the hierarchy models load has succeeded */ isSuccess: true; /** Error, if one occurred */ error: undefined; /** Hierarchy models, if the load succeeded */ hierarchies: HierarchyModel[]; /** Loading status */ status: 'success'; }; /** * React hook that retrieves existing hierarchy models from a Fusion instance. * * @example * Retrieve the hierarchy models and render their counts. ```tsx const { hierarchies, isLoading, isError } = useGetHierarchyModels({ dataSource: DM.DataSource, dimension: DM.Commerce.AgeRange, }); if (isLoading) { return