1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00
planka/client/src/containers/CardContainer.js

75 lines
2.7 KiB
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
2022-08-04 13:31:14 +02:00
import selectors from '../selectors';
import entryActions from '../entry-actions';
2019-08-31 04:07:25 +05:00
import Card from '../components/Card';
const makeMapStateToProps = () => {
2022-08-04 13:31:14 +02:00
const selectCardById = selectors.makeSelectCardById();
const selectUsersByCardId = selectors.makeSelectUsersByCardId();
const selectLabelsByCardId = selectors.makeSelectLabelsByCardId();
const selectTasksByCardId = selectors.makeSelectTasksByCardId();
const selectNotificationsTotalByCardId = selectors.makeSelectNotificationsTotalByCardId();
2019-08-31 04:07:25 +05:00
return (state, { id, index }) => {
2022-08-04 13:31:14 +02:00
const { projectId } = selectors.selectPath(state);
const allProjectsToLists = selectors.selectProjectsToListsForCurrentUser(state);
const allBoardMemberships = selectors.selectMembershipsForCurrentBoard(state);
const allLabels = selectors.selectLabelsForCurrentBoard(state);
const isCurrentUserMember = selectors.selectIsCurrentUserMemberForCurrentBoard(state);
2019-08-31 04:07:25 +05:00
2022-08-04 13:31:14 +02:00
const { name, dueDate, timer, coverUrl, boardId, listId, isPersisted } = selectCardById(
2020-05-05 01:30:06 +05:00
state,
id,
);
2019-08-31 04:07:25 +05:00
2022-08-04 13:31:14 +02:00
const users = selectUsersByCardId(state, id);
const labels = selectLabelsByCardId(state, id);
const tasks = selectTasksByCardId(state, id);
const notificationsTotal = selectNotificationsTotalByCardId(state, id);
2019-08-31 04:07:25 +05:00
return {
id,
index,
name,
dueDate,
2019-08-31 04:07:25 +05:00
timer,
2020-04-23 03:02:53 +05:00
coverUrl,
2020-05-05 01:30:06 +05:00
boardId,
listId,
2020-05-05 01:30:06 +05:00
projectId,
2019-08-31 04:07:25 +05:00
isPersisted,
notificationsTotal,
users,
labels,
tasks,
2020-05-05 01:30:06 +05:00
allProjectsToLists,
allBoardMemberships,
2019-08-31 04:07:25 +05:00
allLabels,
canEdit: isCurrentUserMember,
2019-08-31 04:07:25 +05:00
};
};
};
const mapDispatchToProps = (dispatch, { id }) =>
bindActionCreators(
{
2022-08-04 13:31:14 +02:00
onUpdate: (data) => entryActions.updateCard(id, data),
onMove: (listId, index) => entryActions.moveCard(id, listId, index),
onTransfer: (boardId, listId) => entryActions.transferCard(id, boardId, listId),
onDelete: () => entryActions.deleteCard(id),
onUserAdd: (userId) => entryActions.addUserToCard(userId, id),
onUserRemove: (userId) => entryActions.removeUserFromCard(userId, id),
onBoardFetch: entryActions.fetchBoard,
onLabelAdd: (labelId) => entryActions.addLabelToCard(labelId, id),
onLabelRemove: (labelId) => entryActions.removeLabelFromCard(labelId, id),
onLabelCreate: (data) => entryActions.createLabelInCurrentBoard(data),
onLabelUpdate: (labelId, data) => entryActions.updateLabel(labelId, data),
onLabelDelete: (labelId) => entryActions.deleteLabel(labelId),
},
dispatch,
);
2019-08-31 04:07:25 +05:00
export default connect(makeMapStateToProps, mapDispatchToProps)(Card);