Skip to content

Commit

Permalink
reset forms on cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
usavkov-epam committed Dec 19, 2024
1 parent ca5c5db commit 93b9d26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import PropTypes from 'prop-types';
import { useCallback } from 'react';
import { useForm } from 'react-final-form';
import {
FormattedMessage,
useIntl,
Expand All @@ -23,16 +25,22 @@ const DelayClaimsModal = ({
onCancel,
open,
}) => {
const { reset } = useForm();
const intl = useIntl();
const modalLabel = intl.formatMessage(
{ id: 'stripes-acq-components.claiming.modal.delayClaim.heading' },
{ count: claimsCount },
);

const handleCancel = useCallback(() => {
onCancel();
reset();
}, [onCancel, reset]);

const start = (
<Button
marginBottom0
onClick={onCancel}
onClick={handleCancel}
>
<FormattedMessage id="stripes-acq-components.FormFooter.cancel" />
</Button>
Expand Down
14 changes: 12 additions & 2 deletions lib/claiming/components/modals/SendClaimsModal/SendClaimsModal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import identity from 'lodash/identity';
import PropTypes from 'prop-types';
import { Field } from 'react-final-form';
import { useCallback } from 'react';
import {
Field,
useForm,
} from 'react-final-form';
import {
FormattedMessage,
useIntl,
Expand All @@ -26,16 +30,22 @@ const SendClaimsModal = ({
open,
message,
}) => {
const { reset } = useForm();
const intl = useIntl();
const modalLabel = intl.formatMessage(
{ id: 'stripes-acq-components.claiming.modal.sendClaim.heading' },
{ count: claimsCount },
);

const handleCancel = useCallback(() => {
onCancel();
reset();
}, [onCancel, reset]);

const start = (
<Button
marginBottom0
onClick={onCancel}
onClick={handleCancel}
>
<FormattedMessage id="stripes-acq-components.FormFooter.cancel" />
</Button>
Expand Down

0 comments on commit 93b9d26

Please sign in to comment.