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

42 lines
1.2 KiB
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
*/
import http from './http';
import socket from './socket';
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,
};