1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +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 { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler';
import useUiConfig from '../useUiConfig/useUiConfig';
import { useEnterpriseSWR } from '../useEnterpriseSWR/useEnterpriseSWR';
const fetcher = (path: string) => {
return fetch(path)
@ -11,17 +11,17 @@ const fetcher = (path: string) => {
};
export const useProjectChangeRequests = (project: string) => {
const { isOss } = useUiConfig();
const { data, error, mutate } = useSWR(
const { data, error, mutate } = useEnterpriseSWR(
[],
formatApiPath(`api/admin/projects/${project}/change-requests`),
isOss() ? () => Promise.resolve([]) : fetcher
fetcher
);
return useMemo(
() => ({
changeRequests: data,
loading: !error && !data,
refetch: () => mutate(),
refetch: mutate,
error,
}),
[data, error, mutate]