From 9fee0bb2645f5ec02d86c8ebe1ab6c7afac72814 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Wed, 23 Nov 2022 14:36:11 +0100 Subject: [PATCH] cancel changes (#2510) --- .../ChangeRequestOverview.tsx | 34 +++++++++++++++++++ .../ReviewButton/ReviewButton.tsx | 19 ----------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx index 10d5d68481..6533629984 100644 --- a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx @@ -99,6 +99,23 @@ export const ChangeRequestOverview: FC = () => { } }; + const onCancelChanges = async () => { + try { + await changeState(projectId, Number(id), { + state: 'Cancelled', + }); + refetchChangeRequest(); + refetchChangeRequestOpen(); + setToastData({ + type: 'success', + title: 'Success', + text: 'Changes cancelled', + }); + } catch (error: unknown) { + setToastApiError(formatUnknownError(error)); + } + }; + const isSelfReview = changeRequest?.createdBy.id === user?.id && changeRequest.state === 'In review' && @@ -190,6 +207,23 @@ export const ChangeRequestOverview: FC = () => { } /> + + Cancel changes + + } + /> diff --git a/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx b/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx index ced2b01a30..f8e3673c0c 100644 --- a/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestOverview/ReviewButton/ReviewButton.tsx @@ -54,22 +54,6 @@ export const ReviewButton = () => { } }; - const onReject = async () => { - try { - await changeState(projectId, Number(id), { - state: 'Cancelled', - }); - refetchChangeRequest(); - setToastData({ - type: 'success', - title: 'Success', - text: 'Changes rejected', - }); - } catch (error: unknown) { - setToastApiError(formatUnknownError(error)); - } - }; - const onToggle = () => { setOpen(prevOpen => !prevOpen); }; @@ -132,9 +116,6 @@ export const ReviewButton = () => { Approve changes - - Reject changes -