1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-25 16:19:47 +02:00
planka/client/src/api/actions.js

37 lines
726 B
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
import socket from './socket';
/* Transformers */
2020-03-25 00:15:47 +05:00
export const transformAction = (action) => ({
2019-08-31 04:07:25 +05:00
...action,
createdAt: new Date(action.createdAt),
});
/* Actions */
const getActions = (cardId, data, headers) =>
2020-03-25 00:15:47 +05:00
socket.get(`/cards/${cardId}/actions`, data, headers).then((body) => ({
...body,
items: body.items.map(transformAction),
}));
2019-08-31 04:07:25 +05:00
/* Event handlers */
2020-03-25 00:15:47 +05:00
const makeHandleActionCreate = (next) => (body) => {
2019-08-31 04:07:25 +05:00
next({
...body,
item: transformAction(body.item),
});
};
const makeHandleActionUpdate = makeHandleActionCreate;
const makeHandleActionDelete = makeHandleActionCreate;
export default {
getActions,
makeHandleActionCreate,
makeHandleActionUpdate,
makeHandleActionDelete,
};