|
@ -12,6 +12,10 @@ import Text from 'components/base/Text' |
|
|
|
|
|
|
|
|
import type { Account } from 'types/common' |
|
|
import type { Account } from 'types/common' |
|
|
|
|
|
|
|
|
|
|
|
function renderItem(accounts) { |
|
|
|
|
|
return item => <span>{(accounts.find(a => a.id === item) || {}).name}</span> |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const mapStateToProps: MapStateToProps<*, *, *> = state => ({ |
|
|
const mapStateToProps: MapStateToProps<*, *, *> = state => ({ |
|
|
accounts: values(getAccounts(state)), |
|
|
accounts: values(getAccounts(state)), |
|
|
}) |
|
|
}) |
|
@ -24,12 +28,13 @@ type Props = { |
|
|
|
|
|
|
|
|
const SelectAccount = ({ accounts, value, onChange }: Props) => ( |
|
|
const SelectAccount = ({ accounts, value, onChange }: Props) => ( |
|
|
<Select |
|
|
<Select |
|
|
|
|
|
itemToString={item => item} |
|
|
value={value} |
|
|
value={value} |
|
|
placeholder="Choose an account" |
|
|
placeholder="Choose an account" |
|
|
items={accounts} |
|
|
items={accounts.map(a => a.id)} |
|
|
keyProp="id" |
|
|
|
|
|
onChange={onChange} |
|
|
onChange={onChange} |
|
|
itemToString={item => (item ? item.name : '')} |
|
|
renderItem={renderItem(accounts)} |
|
|
|
|
|
renderSelected={renderItem(accounts)} |
|
|
renderHighlight={(text, key) => ( |
|
|
renderHighlight={(text, key) => ( |
|
|
<Text key={key} fontWeight="bold"> |
|
|
<Text key={key} fontWeight="bold"> |
|
|
{text} |
|
|
{text} |
|
@ -37,5 +42,4 @@ const SelectAccount = ({ accounts, value, onChange }: Props) => ( |
|
|
)} |
|
|
)} |
|
|
/> |
|
|
/> |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(SelectAccount) |
|
|
export default connect(mapStateToProps)(SelectAccount) |
|
|