mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
* ChangesetTable initial * ChangesetTable bug fixes * Added tabs * Add Applied and Cancelled badges * fix alignment * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * cleanup * replace updatedAt with createdAt * bug fix * bug fix
28 lines
745 B
TypeScript
28 lines
745 B
TypeScript
import useSWR from 'swr';
|
|
import { useMemo } from 'react';
|
|
import { formatApiPath } from 'utils/formatPath';
|
|
import handleErrorResponses from '../httpErrorResponseHandler';
|
|
|
|
const fetcher = (path: string) => {
|
|
return fetch(path)
|
|
.then(handleErrorResponses('SuggestedChanges'))
|
|
.then(res => res.json());
|
|
};
|
|
|
|
export const useProjectSuggestedChanges = (project: string) => {
|
|
const { data, error, mutate } = useSWR(
|
|
formatApiPath(`api/admin/projects/${project}/suggest-changes`),
|
|
fetcher
|
|
);
|
|
|
|
return useMemo(
|
|
() => ({
|
|
changesets: data,
|
|
loading: !error && !data,
|
|
refetch: () => mutate(),
|
|
error,
|
|
}),
|
|
[data, error, mutate]
|
|
);
|
|
};
|