-
Notifications
You must be signed in to change notification settings - Fork 295
/
WalletTokenPickerCheckbox.tsx
45 lines (42 loc) · 1.16 KB
/
WalletTokenPickerCheckbox.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
// @flow
import React, { useCallback } from 'react';
import { injectIntl } from 'react-intl';
import { PopOver } from 'react-polymorph/lib/components/PopOver';
import { Checkbox } from 'react-polymorph/lib/components/Checkbox';
import { messages } from './WalletTokenPicker.messages';
import { MAX_TOKENS } from './const';
import type { ItemProps as Props } from './types';
const WalletTokenPickerCheckbox = ({
intl,
className,
isChecked,
isMaxCount,
isPreviouslyChecked,
uniqueId,
toggleCheckbox,
}: Props) => {
const checked = isChecked || isPreviouslyChecked;
const toolTipDisabled = !isMaxCount || checked;
const onChange = useCallback(() => toggleCheckbox(uniqueId), [
toggleCheckbox,
uniqueId,
]);
return (
<div className={className}>
<PopOver
maxWidth={315}
disabled={toolTipDisabled}
content={intl.formatMessage(messages.maxTokensWarning, {
maxTokens: MAX_TOKENS,
})}
>
<Checkbox
checked={checked}
onChange={onChange}
disabled={isPreviouslyChecked}
/>
</PopOver>
</div>
);
};
export default injectIntl(WalletTokenPickerCheckbox);