1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-27 00:59:44 +02:00
planka/client/src/api/boards.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
import socket from './socket';
import http from './http';
2019-08-31 04:07:25 +05:00
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 */
const createBoard = (projectId, data, headers) =>
socket.post(`/projects/${projectId}/boards`, data, headers);
2019-08-31 04:07:25 +05:00
const createBoardWithImport = (projectId, data, requestId, headers) =>
http.post(`/projects/${projectId}/boards?requestId=${requestId}`, data, headers);
2023-01-05 15:03:06 +01:00
const getBoard = (id, subscribe, headers) =>
socket
.get(`/boards/${id}${subscribe ? '?subscribe=true' : ''}`, undefined, headers)
.then((body) => ({
...body,
included: {
...body.included,
cards: body.included.cards.map(transformCard),
attachments: body.included.attachments.map(transformAttachment),
},
}));
2019-08-31 04:07:25 +05:00
const updateBoard = (id, data, headers) => socket.patch(`/boards/${id}`, data, headers);
2019-08-31 04:07:25 +05:00
const deleteBoard = (id, headers) => socket.delete(`/boards/${id}`, undefined, headers);
2019-08-31 04:07:25 +05:00
export default {
createBoard,
createBoardWithImport,
2019-08-31 04:07:25 +05:00
getBoard,
updateBoard,
deleteBoard,
};