1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

Conditionally fetch change request config to fix 404 (#2874)

This commit is contained in:
andreas-unleash 2023-01-12 12:18:11 +02:00 committed by GitHub
parent fb11a892f0
commit aa19ad57eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,15 @@
import { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler';
import { IChangeRequestEnvironmentConfig } from 'component/changeRequest/changeRequest.types';
import { useEnterpriseSWR } from '../useEnterpriseSWR/useEnterpriseSWR';
import { useConditionalSWR } from '../useConditionalSWR/useConditionalSWR';
import useUiConfig from '../useUiConfig/useUiConfig';
export const useChangeRequestConfig = (projectId: string) => {
const { data, error, mutate } = useEnterpriseSWR<
const { isEnterprise } = useUiConfig();
const { data, error, mutate } = useConditionalSWR<
IChangeRequestEnvironmentConfig[]
>(
Boolean(projectId) && isEnterprise(),
[],
formatApiPath(`api/admin/projects/${projectId}/change-requests/config`),
fetcher