You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
708 B
JavaScript
37 lines
708 B
JavaScript
import socket from './socket';
|
|
|
|
/* Transformers */
|
|
|
|
export const transformAction = (action) => ({
|
|
...action,
|
|
createdAt: new Date(action.createdAt),
|
|
});
|
|
|
|
/* Actions */
|
|
|
|
const getActions = (cardId, data) =>
|
|
socket.get(`/cards/${cardId}/actions`, data).then((body) => ({
|
|
...body,
|
|
items: body.items.map(transformAction),
|
|
}));
|
|
|
|
/* Event handlers */
|
|
|
|
const makeHandleActionCreate = (next) => (body) => {
|
|
next({
|
|
...body,
|
|
item: transformAction(body.item),
|
|
});
|
|
};
|
|
|
|
const makeHandleActionUpdate = makeHandleActionCreate;
|
|
|
|
const makeHandleActionDelete = makeHandleActionCreate;
|
|
|
|
export default {
|
|
getActions,
|
|
makeHandleActionCreate,
|
|
makeHandleActionUpdate,
|
|
makeHandleActionDelete,
|
|
};
|