2018-01-02 18:04:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { AddressFieldFactory } from './AddressFieldFactory';
|
2018-01-20 20:06:28 +00:00
|
|
|
import { donationAddressMap } from 'config';
|
2018-03-01 17:53:29 +00:00
|
|
|
import translate from 'translations';
|
|
|
|
import { Input } from 'components/ui';
|
2018-04-02 19:38:54 +00:00
|
|
|
import { toChecksumAddress } from 'ethereumjs-util';
|
2018-01-02 18:04:50 +00:00
|
|
|
|
2018-01-03 03:18:10 +00:00
|
|
|
interface Props {
|
|
|
|
isReadOnly?: boolean;
|
2018-03-22 18:30:51 +00:00
|
|
|
isSelfAddress?: boolean;
|
2018-04-02 19:38:54 +00:00
|
|
|
isCheckSummed?: boolean;
|
2018-01-03 03:18:10 +00:00
|
|
|
}
|
|
|
|
|
2018-04-02 19:38:54 +00:00
|
|
|
export const AddressField: React.SFC<Props> = ({ isReadOnly, isSelfAddress, isCheckSummed }) => (
|
2018-01-02 18:04:50 +00:00
|
|
|
<AddressFieldFactory
|
2018-03-22 18:30:51 +00:00
|
|
|
isSelfAddress={isSelfAddress}
|
2018-01-15 09:57:09 +00:00
|
|
|
withProps={({ currentTo, isValid, onChange, readOnly }) => (
|
2018-03-01 17:53:29 +00:00
|
|
|
<div className="input-group-wrapper">
|
|
|
|
<label className="input-group">
|
2018-03-22 18:30:51 +00:00
|
|
|
<div className="input-group-header">
|
|
|
|
{translate(isSelfAddress ? 'X_ADDRESS' : 'SEND_ADDR')}
|
|
|
|
</div>
|
2018-03-01 17:53:29 +00:00
|
|
|
<Input
|
|
|
|
className={`input-group-input ${isValid ? '' : 'invalid'}`}
|
|
|
|
type="text"
|
2018-04-02 19:38:54 +00:00
|
|
|
value={isCheckSummed ? toChecksumAddress(currentTo.raw) : currentTo.raw}
|
2018-03-01 17:53:29 +00:00
|
|
|
placeholder={donationAddressMap.ETH}
|
|
|
|
readOnly={!!(isReadOnly || readOnly)}
|
|
|
|
spellCheck={false}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
</label>
|
|
|
|
</div>
|
2018-01-02 18:04:50 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
);
|