1
0
mirror of https://github.com/Unleash/unleash.git synced 2026-02-04 20:10:52 +01:00

introduce conditional project overview hook

This commit is contained in:
Thomas Heartman 2026-01-23 09:24:20 +01:00
parent 956bad4474
commit 3e48866909
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78
2 changed files with 9 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
import AccessContext from 'contexts/AccessContext';
import { useContext } from 'react';
import { styled } from '@mui/material';
import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview';
import { useConditionalProjectOverview } from 'hooks/api/getters/useProjectOverview/useProjectOverview';
import { useOptionalPathParam } from 'hooks/useOptionalPathParam';
import { Truncator } from '../Truncator/Truncator';
@ -39,7 +39,7 @@ const BreadcrumbNav = () => {
const location = useLocation();
const projectId = useOptionalPathParam('projectId');
const { project } = useProjectOverview(projectId || '');
const { project } = useConditionalProjectOverview(projectId);
let paths = location.pathname
.split('/')

View File

@ -31,6 +31,13 @@ const fallbackProject: ProjectOverviewSchema = {
};
const useProjectOverview = (id: string, options: SWRConfiguration = {}) => {
return useConditionalProjectOverview(id, options);
};
export const useConditionalProjectOverview = (
id: string = '',
options: SWRConfiguration = {},
) => {
const { KEY, fetcher } = getProjectOverviewFetcher(id);
const { data, error, mutate } = useConditionalSWR<ProjectOverviewSchema>(
!!id,