implimenting adding member to org and project

This commit is contained in:
Alex Windett 2017-01-31 11:34:15 +00:00
parent 876426739d
commit 2c61693c21
6 changed files with 88 additions and 15 deletions

View File

@ -11,9 +11,11 @@ require('react-select/dist/react-select.css');
const Invite = React.createClass({ const Invite = React.createClass({
propTypes: { propTypes: {
addMemember: React.PropTypes.func,
// UI: React.PropTypes.object, // UI: React.PropTypes.object,
handleToggle: React.PropTypes.func, handleToggle: React.PropTypes.func,
// people: React.PropTypes.array, // people: React.PropTypes.array,
parentIndex: React.PropTypes.number,
platformMembers: React.PropTypes.array, platformMembers: React.PropTypes.array,
}, },
@ -31,6 +33,22 @@ const Invite = React.createClass({
})); }));
}, },
handleSubmit(e) {
e.preventDefault();
const data = {
member: {
name: this.state.selectValue.label,
email: this.state.selectValue.value,
role: 'Unassigned',
status: 'Sent invitation',
},
parentIndex: this.props.parentIndex,
};
this.props.addMemember(data);
},
render() { render() {
const { const {
@ -69,9 +87,8 @@ const Invite = React.createClass({
<Row> <Row>
<Column xs={12}> <Column xs={12}>
{/*TODO: Fix why there are issues with webpack and nodemodules*/} <form onSubmit={this.handleSubmit}>
<Select <Select
onChange={handleSelectChange} onChange={handleSelectChange}
options={selectData} options={selectData}
placeholder="Enter an email address or password" placeholder="Enter an email address or password"
@ -81,9 +98,11 @@ const Invite = React.createClass({
<Button <Button
secondary secondary
style={AddButtonStyle} style={AddButtonStyle}
type="submit"
> >
Add Add
</Button> </Button>
</form>
</Column> </Column>
</Row> </Row>

View File

@ -17,6 +17,7 @@ const {
} = selectors; } = selectors;
const { const {
addMemberToOrg,
orgHandleInviteToggle, orgHandleInviteToggle,
orgHandlePeopleRoleTooltip, orgHandlePeopleRoleTooltip,
orgHandlePeopleStatusTooltip, orgHandlePeopleStatusTooltip,
@ -43,6 +44,7 @@ const mapStateToProps = (state, {
}); });
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
addMemember: (member) => dispatch(addMemberToOrg(member)),
handleToggle: () => dispatch(orgHandleInviteToggle()), handleToggle: () => dispatch(orgHandleInviteToggle()),
handleStatusTooltip: (id) => dispatch(orgHandlePeopleStatusTooltip(id)), handleStatusTooltip: (id) => dispatch(orgHandlePeopleStatusTooltip(id)),
handleRoleTooltip: (id) => dispatch(orgHandlePeopleRoleTooltip(id)), handleRoleTooltip: (id) => dispatch(orgHandlePeopleRoleTooltip(id)),

View File

@ -17,6 +17,7 @@ const {
} = selectors; } = selectors;
const { const {
addMemberToProject,
projectHandleInviteToggle, projectHandleInviteToggle,
projectHandlePeopleRoleTooltip, projectHandlePeopleRoleTooltip,
projectHandlePeopleStatusTooltip, projectHandlePeopleStatusTooltip,
@ -43,6 +44,7 @@ const mapStateToProps = (state, {
}); });
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
addMemember: (member) => dispatch(addMemberToProject(member)),
handleToggle: () => dispatch(projectHandleInviteToggle()), handleToggle: () => dispatch(projectHandleInviteToggle()),
handleStatusTooltip: (id) => dispatch(projectHandlePeopleStatusTooltip(id)), handleStatusTooltip: (id) => dispatch(projectHandlePeopleStatusTooltip(id)),
handleRoleTooltip: (id) => dispatch(projectHandlePeopleRoleTooltip(id)), handleRoleTooltip: (id) => dispatch(projectHandlePeopleRoleTooltip(id)),

View File

@ -8,6 +8,8 @@ const {
const APP = constantCase(process.env['APP_NAME']); const APP = constantCase(process.env['APP_NAME']);
const projectMemberActions = { const projectMemberActions = {
addMemberToProject:
createAction(`${APP}/PROJECT_ADD_MEMBER`),
projectHandleInviteToggle: projectHandleInviteToggle:
createAction(`${APP}/PROJECT_HANDLE_INVITE_MEMBER_TOGGLE`), createAction(`${APP}/PROJECT_HANDLE_INVITE_MEMBER_TOGGLE`),
projectHandlePeopleStatusTooltip: projectHandlePeopleStatusTooltip:
@ -21,6 +23,8 @@ const projectMemberActions = {
}; };
const orgMemberActions = { const orgMemberActions = {
addMemberToOrg:
createAction(`${APP}/ORG_ADD_MEMBER`),
orgHandleInviteToggle: orgHandleInviteToggle:
createAction(`${APP}/ORG_HANDLE_INVITE_MEMBER_TOGGLE`), createAction(`${APP}/ORG_HANDLE_INVITE_MEMBER_TOGGLE`),
orgHandlePeopleStatusTooltip: orgHandlePeopleStatusTooltip:

View File

@ -7,6 +7,7 @@ const {
} = ReduxActions; } = ReduxActions;
const { const {
addMemberToOrg,
orgHandleInviteToggle, orgHandleInviteToggle,
orgHandlePeopleRoleTooltip, orgHandlePeopleRoleTooltip,
orgHandlePeopleStatusTooltip, orgHandlePeopleStatusTooltip,
@ -15,6 +16,28 @@ const {
} = actions; } = actions;
module.exports = handleActions({ module.exports = handleActions({
[addMemberToOrg.toString()]: (state, action) => {
const {
parentIndex,
member,
} = action.payload;
return {
...state,
data: [
...state.data.slice(0, parentIndex),
{
...state.data[parentIndex],
members: [
...state.data[parentIndex].members,
member
]
},
...state.data.slice(parentIndex + 1),
]
};
},
[orgHandleInviteToggle.toString()]: (state, action) => { [orgHandleInviteToggle.toString()]: (state, action) => {
return { return {
...state, ...state,

View File

@ -7,6 +7,7 @@ const {
} = ReduxActions; } = ReduxActions;
const { const {
addMemberToProject,
projectHandleInviteToggle, projectHandleInviteToggle,
projectHandlePeopleRoleTooltip, projectHandlePeopleRoleTooltip,
projectHandlePeopleStatusTooltip, projectHandlePeopleStatusTooltip,
@ -15,6 +16,28 @@ const {
} = actions; } = actions;
module.exports = handleActions({ module.exports = handleActions({
[addMemberToProject.toString()]: (state, action) => {
const {
parentIndex,
member,
} = action.payload;
return {
...state,
data: [
...state.data.slice(0, parentIndex),
{
...state.data[parentIndex],
members: [
...state.data[parentIndex].members,
member
]
},
...state.data.slice(parentIndex + 1),
]
};
},
[projectHandleInviteToggle.toString()]: (state, action) => { [projectHandleInviteToggle.toString()]: (state, action) => {
return { return {
...state, ...state,