1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-19 01:17:18 +02:00
unleash.unleash/frontend/src/hooks/api/getters/useProjectSuggestedChanges/useProjectSuggestedChanges.ts
andreas-unleash d48cfc8585
Feat/frontend changeset list (#2264)
* 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
2022-10-28 10:24:13 +02:00

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]
);
};