-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselectUser.js
29 lines (25 loc) · 1.03 KB
/
selectUser.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
import React from "react";
import { Picker, View } from "react-native";
import PropTypes from "prop-types";
import { pure } from "recompose";
const SelectUser = (props) => {
const {contacts, onValueChange, value} = props;
return <View style={{maxWidth: 140}}>
<Picker value={value}
onValueChange={(val) => {
const contact = val === -1 ? null : contacts.find(x => x.CustomerContactID === val);
onValueChange(contact);
}
}
selectedValue={value}>
<Picker.Item label="Vem är du?" value={-1} />
{contacts.map(x => <Picker.Item key={x.CustomerContactID} label={x.ContactName} value={x.CustomerContactID} />)}
</Picker>
</View>;
};
SelectUser.propTypes = {
contacts : PropTypes.array.isRequired,
onValueChange : PropTypes.func.isRequired,
value : PropTypes.number.isRequired
};
export default pure(SelectUser);