-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathExistingSubmissionOptions.js
56 lines (47 loc) · 1.7 KB
/
ExistingSubmissionOptions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import PropTypes from 'prop-types';
import React from 'react';
import {FormattedMessage, useIntl} from 'react-intl';
import {useNavigate} from 'react-router-dom';
import {OFButton} from 'components/Button';
import {Toolbar, ToolbarList} from 'components/Toolbar';
import Types from 'types';
const ExistingSubmissionOptions = ({form, onDestroySession}) => {
const navigate = useNavigate();
const intl = useIntl();
const firstStepRoute = `/stap/${form.steps[0].slug}`;
const confirmationMessage = intl.formatMessage({
description: 'Abort confirmation prompt',
defaultMessage:
'Are you sure that you want to abort this submission? You will lose your progress if you continue.',
});
const onFormAbort = async event => {
event.preventDefault();
if (!window.confirm(confirmationMessage)) return;
await onDestroySession();
};
return (
<Toolbar modifiers={['column']}>
<ToolbarList>
<OFButton appearance="primary-action-button" onClick={() => navigate(firstStepRoute)}>
<FormattedMessage
defaultMessage="Continue existing submission"
description="Continue existing submission button label"
/>
</OFButton>
</ToolbarList>
<ToolbarList>
<OFButton appearance="primary-action-button" hint="danger" onClick={onFormAbort}>
<FormattedMessage
defaultMessage="Abort existing submission"
description="Abort existing submission button label"
/>
</OFButton>
</ToolbarList>
</Toolbar>
);
};
ExistingSubmissionOptions.propTypes = {
form: Types.Form.isRequired,
onDestroySession: PropTypes.func.isRequired,
};
export default ExistingSubmissionOptions;