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:
parent
956bad4474
commit
3e48866909
@ -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('/')
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user