1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-23 15:19:44 +02:00
planka/client/src/api/activities.js

45 lines
1,010 B
JavaScript
Raw Normal View History

/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
2022-08-04 13:31:14 +02:00
import socket from './socket';
/* Transformers */
export const transformActivity = (activity) => ({
...activity,
...(activity.createdAt && {
createdAt: new Date(activity.createdAt),
}),
2022-08-04 13:31:14 +02:00
});
/* Actions */
2025-05-22 23:14:46 +02:00
const getActivitiesInBoard = (boardId, data, headers) =>
socket.get(`/boards/${boardId}/actions`, data, headers).then((body) => ({
...body,
items: body.items.map(transformActivity),
}));
const getActivitiesInCard = (cardId, data, headers) =>
socket.get(`/cards/${cardId}/actions`, data, headers).then((body) => ({
2022-08-04 13:31:14 +02:00
...body,
items: body.items.map(transformActivity),
}));
/* Event handlers */
const makeHandleActivityCreate = (next) => (body) => {
next({
...body,
item: transformActivity(body.item),
});
};
export default {
2025-05-22 23:14:46 +02:00
getActivitiesInBoard,
getActivitiesInCard,
2022-08-04 13:31:14 +02:00
makeHandleActivityCreate,
};