-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathSendButton.js
40 lines (33 loc) · 988 Bytes
/
SendButton.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
import PropTypes from 'prop-types';
import React from 'react';
import { localize } from '../Localization/Localize';
import connectToWebChat from '../connectToWebChat';
import IconButton from './IconButton';
import SendIcon from './Assets/SendIcon';
const connectSendButton = (...selectors) =>
connectToWebChat(
({ disabled, language, sendBoxValue, setSendBox, submitSendBox }) => ({
click: () => {
setSendBox(sendBoxValue.trim());
submitSendBox();
},
disabled,
language
}),
...selectors
);
const SendButton = ({ click, disabled, language }) => (
<IconButton alt={localize('Send', language)} disabled={disabled} onClick={click}>
<SendIcon />
</IconButton>
);
SendButton.defaultProps = {
disabled: false
};
SendButton.propTypes = {
click: PropTypes.func.isRequired,
disabled: PropTypes.bool,
language: PropTypes.string.isRequired
};
export default connectSendButton()(SendButton);
export { connectSendButton };