2019-08-31 04:07:25 +05:00
|
|
|
import socket from './socket';
|
|
|
|
import { transformCard } from './cards';
|
2020-04-21 05:04:34 +05:00
|
|
|
import { transformAttachment } from './attachments';
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
/* Actions */
|
|
|
|
|
2022-04-26 18:01:55 +05:00
|
|
|
const createBoard = (projectId, data) => socket.post(`/projects/${projectId}/boards`, data);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2022-04-26 18:01:55 +05:00
|
|
|
const getBoard = (id) =>
|
|
|
|
socket.get(`/boards/${id}`).then((body) => ({
|
2020-02-03 18:42:31 +05:00
|
|
|
...body,
|
|
|
|
included: {
|
|
|
|
...body.included,
|
|
|
|
cards: body.included.cards.map(transformCard),
|
2020-04-21 05:04:34 +05:00
|
|
|
attachments: body.included.attachments.map(transformAttachment),
|
2020-02-03 18:42:31 +05:00
|
|
|
},
|
|
|
|
}));
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2022-04-26 18:01:55 +05:00
|
|
|
const updateBoard = (id, data) => socket.patch(`/boards/${id}`, data);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2022-04-26 18:01:55 +05:00
|
|
|
const deleteBoard = (id) => socket.delete(`/boards/${id}`);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
createBoard,
|
|
|
|
getBoard,
|
|
|
|
updateBoard,
|
|
|
|
deleteBoard,
|
|
|
|
};
|