Skip to content

Commit

Permalink
Use onClose to simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Dubreuil <[email protected]>
  • Loading branch information
gildub committed Jul 26, 2023
1 parent 07e82f4 commit 9cd44f0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ export const ApplicationsTableAnalyze: React.FC = () => {
close: closeApplicationModal,
} = useEntityModal<Application>();

const onApplicationModalSaved = () => {
closeApplicationModal();
refetch();
};

// Delete

const onDeleteApplicationSuccess = (appIDCount: number) => {
Expand Down Expand Up @@ -630,8 +625,7 @@ export const ApplicationsTableAnalyze: React.FC = () => {
>
<ApplicationForm
application={applicationToUpdate}
onSaved={onApplicationModalSaved}
onCancel={closeApplicationModal}
onClose={closeApplicationModal}
/>
</Modal>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@ export const ApplicationsTable: React.FC = () => {
close: closeApplicationModal,
} = useEntityModal<Application>();

const onApplicationModalSaved = () => {
closeApplicationModal();
fetchApplications();
};

// Delete
const onDeleteApplicationSuccess = (appIDCount: number) => {
pushNotification({
Expand Down Expand Up @@ -800,8 +795,7 @@ export const ApplicationsTable: React.FC = () => {
>
<ApplicationForm
application={applicationToUpdate}
onSaved={onApplicationModalSaved}
onCancel={closeApplicationModal}
onClose={closeApplicationModal}
/>
</Modal>
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ describe("Component: application-form", () => {

mock.onGet(`${BUSINESS_SERVICES}`).reply(200, businessServices);

render(
<ApplicationForm onCancel={mockChangeValue} onSaved={mockChangeValue} />
);
render(<ApplicationForm onClose={mockChangeValue} />);
const nameInput = await screen.findByLabelText("Name *");
fireEvent.change(nameInput, {
target: { value: "app-name" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ export interface FormValues {

export interface ApplicationFormProps {
application?: Application;
onSaved: () => void;
onCancel: () => void;
onClose: () => void;
}

export const ApplicationForm: React.FC<ApplicationFormProps> = ({
application,
onSaved,
onCancel,
onClose,
}) => {
const { t } = useTranslation();
const { pushNotification } = React.useContext(NotificationsContext);
Expand Down Expand Up @@ -295,7 +293,7 @@ export const ApplicationForm: React.FC<ApplicationFormProps> = ({
variant: "success",
});
}
onSaved();
onClose();
};

const onCreateUpdateApplicationError = (error: AxiosError) => {
Expand Down Expand Up @@ -702,7 +700,7 @@ export const ApplicationForm: React.FC<ApplicationFormProps> = ({
aria-label="cancel"
variant={ButtonVariant.link}
isDisabled={isSubmitting || isValidating}
onClick={onCancel}
onClick={onClose}
>
{t("actions.cancel")}
</Button>
Expand Down

0 comments on commit 9cd44f0

Please sign in to comment.