-
Notifications
You must be signed in to change notification settings - Fork 295
/
VotingRegistrationDialog.tsx
105 lines (98 loc) · 3.09 KB
/
VotingRegistrationDialog.tsx
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// @flow
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import type { Node } from 'react';
import classnames from 'classnames';
import { Stepper } from 'react-polymorph/lib/components/Stepper';
import { StepperSkin } from 'react-polymorph/lib/skins/simple/StepperSkin';
import { defineMessages, FormattedMessage, intlShape } from 'react-intl';
import styles from './VotingRegistrationDialog.scss';
import Dialog from '../../../widgets/Dialog';
import DialogCloseButton from '../../../widgets/DialogCloseButton';
import DialogBackButton from '../../../widgets/DialogBackButton';
import type { DialogActions } from '../../../widgets/Dialog';
import { NEXT_VOTING_FUND_NUMBER } from '../../../../config/votingConfig';
const messages = defineMessages({
dialogTitle: {
id: 'voting.votingRegistration.dialog.dialogTitle',
defaultMessage: '!!!Register for Fund{nextVotingFundNumber} voting',
description: 'Tile "Register to vote" for voting registration',
},
subtitle: {
id: 'voting.votingRegistration.dialog.subtitle',
defaultMessage: '!!!Step {step} of {stepCount}',
description: 'Sub title for voting registration',
},
});
type Props = {
children: Node,
stepsList: Array<string>,
activeStep: number,
actions: DialogActions,
onClose: Function,
onBack?: Function,
containerClassName?: ?string,
contentClassName?: ?string,
hideCloseButton?: boolean,
hideSteps?: boolean,
};
@observer
export default class VotingRegistrationDialog extends Component<Props> {
static contextTypes = {
intl: intlShape.isRequired,
};
static defaultProps = {
children: null,
};
render() {
const { intl } = this.context;
const {
children,
activeStep,
stepsList,
actions,
onClose,
onBack,
containerClassName,
contentClassName,
hideCloseButton,
hideSteps,
} = this.props;
const containerStyles = classnames([styles.container, containerClassName]);
const contentStyles = classnames([styles.content, contentClassName]);
const stepsIndicatorLabel = (
<FormattedMessage
{...messages.subtitle}
values={{ step: activeStep, stepCount: stepsList.length }}
/>
);
return (
<Dialog
className={styles.component}
title={intl.formatMessage(messages.dialogTitle, {
nextVotingFundNumber: NEXT_VOTING_FUND_NUMBER,
})}
subtitle={!hideSteps && stepsIndicatorLabel}
onClose={onClose}
closeOnOverlayClick={false}
closeButton={hideCloseButton ? null : <DialogCloseButton />}
backButton={onBack && <DialogBackButton onBack={onBack} />}
actions={actions}
>
{!hideSteps && (
<div className={styles.votingRegistrationStepsIndicatorWrapper}>
<Stepper
steps={stepsList}
activeStep={activeStep}
skin={StepperSkin}
labelDisabled
/>
</div>
)}
<div className={containerStyles}>
<div className={contentStyles}>{children}</div>
</div>
</Dialog>
);
}
}