-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
81 lines (76 loc) · 2.41 KB
/
index.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import PropTypes from 'prop-types';
import React from 'react';
import {OFButton} from 'components/Button';
import Link from 'components/Link';
import {Literal, LiteralsProvider} from 'components/Literal';
import Loader from 'components/Loader';
import {Toolbar, ToolbarList} from 'components/Toolbar';
import {SUBMISSION_ALLOWED} from 'components/constants';
const ButtonsToolbar = ({
literals,
canSubmitStep,
canSubmitForm,
canSuspendForm,
isLastStep,
isCheckingLogic,
onNavigatePrevPage,
onFormSave,
previousPage,
}) => {
const showSubmitButton = !(canSubmitForm === SUBMISSION_ALLOWED.noWithoutOverview && isLastStep);
return (
<>
<LiteralsProvider literals={literals}>
<Toolbar modifiers={['mobile-reverse-order', 'bottom']}>
<ToolbarList>
{previousPage && (
<Link to={previousPage} onClick={onNavigatePrevPage}>
<Literal name="previousText" />
</Link>
)}
</ToolbarList>
<ToolbarList>
{/* TODO: refactor: `const canSuspendForm = onFormSave === undefined` - this does not
need to be its own prop */}
{canSuspendForm && (
<OFButton
type="button"
appearance="secondary-action-button"
name="save"
onClick={onFormSave}
>
<Literal name="saveText" />
</OFButton>
)}
{showSubmitButton && (
<OFButton
type="submit"
appearance="primary-action-button"
name="next"
disabled={!canSubmitStep}
>
{isCheckingLogic ? (
<Loader modifiers={['centered', 'only-child', 'small', 'gray']} />
) : (
<Literal name="nextText" />
)}
</OFButton>
)}
</ToolbarList>
</Toolbar>
</LiteralsProvider>
</>
);
};
ButtonsToolbar.propTypes = {
literals: PropTypes.object,
canSubmitStep: PropTypes.bool.isRequired,
canSubmitForm: PropTypes.string.isRequired,
canSuspendForm: PropTypes.bool.isRequired,
isLastStep: PropTypes.bool.isRequired,
isCheckingLogic: PropTypes.bool.isRequired,
onNavigatePrevPage: PropTypes.func,
onFormSave: PropTypes.func.isRequired,
previousPage: PropTypes.string,
};
export default ButtonsToolbar;