reconstructing dispatch payload to seperate person object and person index; also only sending uuid,status,role as props

This commit is contained in:
Alex Windett 2017-01-25 11:14:49 +00:00
parent bbdd97911c
commit c057c4a9cc
3 changed files with 21 additions and 8 deletions

View File

@ -60,9 +60,12 @@ const PersonRole = (props) => {
const toggled = toggledID;
const handleClick = () => handleRoleTooltip(person.uuid);
const handleOptionSelect = (updatedMember) => handleRoleUpdate(updatedMember);
const _person = {
...person,
personIndex
// Only send relevent info as props
const _person = {
uuid: person.uuid,
status: person.status,
role: person.role
};
return (
@ -76,6 +79,7 @@ const PersonRole = (props) => {
handleSelect={handleOptionSelect}
options={membersRolesOptions}
person={_person}
personIndex={personIndex}
/>
: null }
</StyledWrapper>

View File

@ -16,15 +16,22 @@ const arrowPosition = {
module.exports = ({
handleSelect,
person = {},
personIndex,
options = [],
}) => {
const _options = options.map( (option, i) => {
const _onClick = () => handleSelect({
...person,
role: option
});
const payload = {
person: {
uuid: person.uuid,
status: person.status,
role: option
},
personIndex
};
const _onClick = () => handleSelect(payload);
return (
<li
@ -53,4 +60,5 @@ module.exports.propTypes = {
handleSelect: React.PropTypes.func,
options: React.PropTypes.array,
person: React.PropTypes.object,
personIndex: React.PropTypes.number,
};

View File

@ -51,6 +51,7 @@ module.exports = handleActions({
// TODO:
// Change "1" to org index. At the moment only updates
// "biz-tech"
return {
...state,
ui: {
@ -64,7 +65,7 @@ module.exports = handleActions({
members: [
...state.data[1].members.slice(0, action.payload.personIndex),
{
...action.payload
...action.payload.person
},
...state.data[1].members.slice(action.payload.personIndex + 1)
]