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

adding missing enterprise check (#2635)

This commit is contained in:
Mateusz Kwasniewski 2022-12-08 12:37:20 +01:00 committed by GitHub
parent 9b10b26ba4
commit fb2c30244c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,8 @@
import useSWR from 'swr';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { formatApiPath } from 'utils/formatPath'; import { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler'; import handleErrorResponses from '../httpErrorResponseHandler';
import useUiConfig from '../useUiConfig/useUiConfig'; import useUiConfig from '../useUiConfig/useUiConfig';
import { useEnterpriseSWR } from '../useEnterpriseSWR/useEnterpriseSWR';
const fetcher = (path: string) => { const fetcher = (path: string) => {
return fetch(path) return fetch(path)
@ -11,17 +11,17 @@ const fetcher = (path: string) => {
}; };
export const useProjectChangeRequests = (project: string) => { export const useProjectChangeRequests = (project: string) => {
const { isOss } = useUiConfig(); const { data, error, mutate } = useEnterpriseSWR(
const { data, error, mutate } = useSWR( [],
formatApiPath(`api/admin/projects/${project}/change-requests`), formatApiPath(`api/admin/projects/${project}/change-requests`),
isOss() ? () => Promise.resolve([]) : fetcher fetcher
); );
return useMemo( return useMemo(
() => ({ () => ({
changeRequests: data, changeRequests: data,
loading: !error && !data, loading: !error && !data,
refetch: () => mutate(), refetch: mutate,
error, error,
}), }),
[data, error, mutate] [data, error, mutate]