From aa19ad57eb5182bcf227f10dc50647214c84bcd5 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Thu, 12 Jan 2023 12:18:11 +0200 Subject: [PATCH] Conditionally fetch change request config to fix 404 (#2874) --- .../useChangeRequestConfig/useChangeRequestConfig.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts b/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts index f3b93accf7..9f5f7b77a3 100644 --- a/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts +++ b/frontend/src/hooks/api/getters/useChangeRequestConfig/useChangeRequestConfig.ts @@ -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