Propagate filter/entity errors properly to the table

This commit is contained in:
Fredrik Adelöw
2020-06-27 21:42:36 +02:00
parent f32e13c6c6
commit 0d4a76fbf0
4 changed files with 8 additions and 2 deletions
@@ -61,10 +61,12 @@ export const CatalogTabs = ({ tabs, onChange }: Props) => {
const [currentTabIndex, setCurrentTabIndex] = useState<number>(0);
// Hold a reference to the callback
const onChangeRef = useRef<OnChangeCallback>();
useEffect(() => {
onChangeRef.current = onChange;
}, [onChange]);
useEffect(() => {
onChangeRef.current?.(tabs[currentTabIndex]);
}, [tabs, currentTabIndex]);
@@ -113,6 +113,8 @@ function useProvideEntityFilters(): FilterGroupsContext {
register,
unregister,
setGroupSelectedFilters,
loading: !error && !entities,
error,
filterGroupStates,
matchingEntities,
};
+2
View File
@@ -26,6 +26,8 @@ export type FilterGroupsContext = {
) => void;
unregister: (filterGroupId: string) => void;
setGroupSelectedFilters: (filterGroupId: string, filterIds: string[]) => void;
loading: boolean;
error?: Error;
filterGroupStates: { [filterGroupId: string]: FilterGroupStates };
matchingEntities: Entity[];
};
@@ -27,8 +27,8 @@ export function useFilteredEntities() {
}
return {
loading: false,
error: undefined,
loading: context.loading,
error: context.error,
matchingEntities: context.matchingEntities,
};
}