1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix cr banner (#2501)

This commit is contained in:
Mateusz Kwasniewski 2022-11-22 14:59:38 +01:00 committed by GitHub
parent 4aff5ad379
commit 27cb6b742a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -21,6 +21,7 @@ import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
import AccessContext from 'contexts/AccessContext';
import { ChangeRequestComment } from './ChangeRequestComments/ChangeRequestComment';
import { AddCommentField } from './ChangeRequestComments/AddCommentField';
import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen';
const StyledAsideBox = styled(Box)(({ theme }) => ({
width: '30%',
@ -58,6 +59,8 @@ export const ChangeRequestOverview: FC = () => {
id
);
const { changeState, addComment } = useChangeRequestApi();
const { refetch: refetchChangeRequestOpen } =
useChangeRequestOpen(projectId);
const { setToastData, setToastApiError } = useToast();
if (!changeRequest) {
@ -70,6 +73,7 @@ export const ChangeRequestOverview: FC = () => {
state: 'Applied',
});
refetchChangeRequest();
refetchChangeRequestOpen();
setToastData({
type: 'success',
title: 'Success',

View File

@ -20,6 +20,7 @@ import { APPROVE_CHANGE_REQUEST } from 'component/providers/AccessProvider/permi
import PermissionButton from 'component/common/PermissionButton/PermissionButton';
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
import AccessContext from 'contexts/AccessContext';
import { useChangeRequestOpen } from 'hooks/api/getters/useChangeRequestOpen/useChangeRequestOpen';
export const ReviewButton = () => {
const { isAdmin } = useContext(AccessContext);
@ -27,6 +28,8 @@ export const ReviewButton = () => {
const id = useRequiredPathParam('id');
const { user } = useAuthUser();
const { refetchChangeRequest, data } = useChangeRequest(projectId, id);
const { refetch: refetchChangeRequestOpen } =
useChangeRequestOpen(projectId);
const { setToastApiError, setToastData } = useToast();
const { changeState } = useChangeRequestApi();
@ -40,6 +43,7 @@ export const ReviewButton = () => {
state: 'Approved',
});
refetchChangeRequest();
refetchChangeRequestOpen();
setToastData({
type: 'success',
title: 'Success',

View File

@ -1,5 +1,4 @@
import useSWR from 'swr';
import { useMemo } from 'react';
import { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler';
import { IChangeRequest } from 'component/changeRequest/changeRequest.types';
@ -18,13 +17,10 @@ export const useChangeRequestOpen = (project: string) => {
isOss() ? () => Promise.resolve([]) : fetcher
);
return useMemo(
() => ({
draft: data,
loading: !error && !data,
refetch: () => mutate(),
error,
}),
[data, error, mutate]
);
return {
draft: data,
loading: !error && !data,
refetch: mutate,
error,
};
};