From 9cd44f0cd52d19e95bb5a40cb8727b4984687841 Mon Sep 17 00:00:00 2001 From: Gilles Dubreuil Date: Tue, 25 Jul 2023 12:21:28 +0200 Subject: [PATCH] Use onClose to simplify Signed-off-by: Gilles Dubreuil --- .../applications-table-analyze.tsx | 8 +------- .../applications-table-assessment.tsx | 8 +------- .../__tests__/application-form.test.tsx | 4 +--- .../components/application-form/application-form.tsx | 10 ++++------ 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/client/src/app/pages/applications/applications-table-analyze/applications-table-analyze.tsx b/client/src/app/pages/applications/applications-table-analyze/applications-table-analyze.tsx index 81b7d9a397..8b4de32472 100644 --- a/client/src/app/pages/applications/applications-table-analyze/applications-table-analyze.tsx +++ b/client/src/app/pages/applications/applications-table-analyze/applications-table-analyze.tsx @@ -180,11 +180,6 @@ export const ApplicationsTableAnalyze: React.FC = () => { close: closeApplicationModal, } = useEntityModal(); - const onApplicationModalSaved = () => { - closeApplicationModal(); - refetch(); - }; - // Delete const onDeleteApplicationSuccess = (appIDCount: number) => { @@ -630,8 +625,7 @@ export const ApplicationsTableAnalyze: React.FC = () => { > diff --git a/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx b/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx index 4a1b7ef165..c458a4a7f7 100644 --- a/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx +++ b/client/src/app/pages/applications/applications-table-assessment/applications-table-assessment.tsx @@ -177,11 +177,6 @@ export const ApplicationsTable: React.FC = () => { close: closeApplicationModal, } = useEntityModal(); - const onApplicationModalSaved = () => { - closeApplicationModal(); - fetchApplications(); - }; - // Delete const onDeleteApplicationSuccess = (appIDCount: number) => { pushNotification({ @@ -800,8 +795,7 @@ export const ApplicationsTable: React.FC = () => { > { mock.onGet(`${BUSINESS_SERVICES}`).reply(200, businessServices); - render( - - ); + render(); const nameInput = await screen.findByLabelText("Name *"); fireEvent.change(nameInput, { target: { value: "app-name" }, diff --git a/client/src/app/pages/applications/components/application-form/application-form.tsx b/client/src/app/pages/applications/components/application-form/application-form.tsx index 7b961cc488..f47067a6e1 100644 --- a/client/src/app/pages/applications/components/application-form/application-form.tsx +++ b/client/src/app/pages/applications/components/application-form/application-form.tsx @@ -62,14 +62,12 @@ export interface FormValues { export interface ApplicationFormProps { application?: Application; - onSaved: () => void; - onCancel: () => void; + onClose: () => void; } export const ApplicationForm: React.FC = ({ application, - onSaved, - onCancel, + onClose, }) => { const { t } = useTranslation(); const { pushNotification } = React.useContext(NotificationsContext); @@ -295,7 +293,7 @@ export const ApplicationForm: React.FC = ({ variant: "success", }); } - onSaved(); + onClose(); }; const onCreateUpdateApplicationError = (error: AxiosError) => { @@ -702,7 +700,7 @@ export const ApplicationForm: React.FC = ({ aria-label="cancel" variant={ButtonVariant.link} isDisabled={isSubmitting || isValidating} - onClick={onCancel} + onClick={onClose} > {t("actions.cancel")}