mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: only ask for project details if we have a project ID (#8339)
This switches to using conditional SWR to fetch project details only when you provide a project. This fixes an issue where we'd make requests for `api/admin/personal-dashboard/undefined` (which will be a 404 in the future).
This commit is contained in:
parent
e0ea1ff34a
commit
aa7d612934
@ -1,7 +1,7 @@
|
|||||||
import useSWR from 'swr';
|
|
||||||
import { formatApiPath } from 'utils/formatPath';
|
import { formatApiPath } from 'utils/formatPath';
|
||||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||||
import type { PersonalDashboardProjectDetailsSchema } from 'openapi';
|
import type { PersonalDashboardProjectDetailsSchema } from 'openapi';
|
||||||
|
import { useConditionalSWR } from '../useConditionalSWR/useConditionalSWR';
|
||||||
|
|
||||||
export interface IPersonalDashboardProjectDetailsOutput {
|
export interface IPersonalDashboardProjectDetailsOutput {
|
||||||
personalDashboardProjectDetails?: PersonalDashboardProjectDetailsSchema;
|
personalDashboardProjectDetails?: PersonalDashboardProjectDetailsSchema;
|
||||||
@ -13,7 +13,16 @@ export interface IPersonalDashboardProjectDetailsOutput {
|
|||||||
export const usePersonalDashboardProjectDetails = (
|
export const usePersonalDashboardProjectDetails = (
|
||||||
project: string,
|
project: string,
|
||||||
): IPersonalDashboardProjectDetailsOutput => {
|
): IPersonalDashboardProjectDetailsOutput => {
|
||||||
const { data, error, mutate } = useSWR(
|
const { data, error, mutate } = useConditionalSWR(
|
||||||
|
Boolean(project),
|
||||||
|
{
|
||||||
|
latestEvents: [],
|
||||||
|
onboardingStatus: {
|
||||||
|
status: 'onboarding-started',
|
||||||
|
},
|
||||||
|
owners: [],
|
||||||
|
roles: [],
|
||||||
|
},
|
||||||
formatApiPath(`api/admin/personal-dashboard/${project}`),
|
formatApiPath(`api/admin/personal-dashboard/${project}`),
|
||||||
fetcher,
|
fetcher,
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user