1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-22 14:49:43 +02:00

feat: Version 2

Closes #627, closes #1047
This commit is contained in:
Maksim Eltyshev 2025-05-10 02:09:06 +02:00
parent ad7fb51cfa
commit 2ee1166747
1557 changed files with 76832 additions and 47042 deletions

View file

@ -1,15 +1,21 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
import omit from 'lodash/omit';
import socket from './socket';
import { transformUser } from './users';
import { transformCard } from './cards';
import { transformActivity } from './activities';
/* Transformers */
export const transformNotification = (notification) => ({
...omit(notification, 'actionId'),
activityId: notification.actionId,
...(notification.actionId
? {
...omit(notification, 'actionId'),
activityId: notification.actionId,
}
: notification),
});
/* Actions */
@ -18,28 +24,25 @@ const getNotifications = (headers) =>
socket.get('/notifications', undefined, headers).then((body) => ({
...body,
items: body.items.map(transformNotification),
included: {
...omit(body.included, 'actions'),
users: body.included.users.map(transformUser),
cards: body.included.cards.map(transformCard),
activities: body.included.actions.map(transformActivity),
},
}));
const getNotification = (id, headers) =>
/* const getNotification = (id, headers) =>
socket.get(`/notifications/${id}`, undefined, headers).then((body) => ({
...body,
item: transformNotification(body.item),
included: {
...omit(body.included, 'actions'),
users: body.included.users.map(transformUser),
cards: body.included.cards.map(transformCard),
activities: body.included.actions.map(transformActivity),
},
})); */
const updateNotification = (id, data, headers) =>
socket.patch(`/notifications/${id}`, data, headers).then((body) => ({
...body,
item: transformNotification(body.item),
}));
const updateNotifications = (ids, data, headers) =>
socket.patch(`/notifications/${ids.join(',')}`, data, headers).then((body) => ({
const readAllNotifications = (headers) =>
socket.post('/notifications/read-all', undefined, headers).then((body) => ({
...body,
items: body.items.map(transformNotification),
}));
@ -57,8 +60,9 @@ const makeHandleNotificationUpdate = makeHandleNotificationCreate;
export default {
getNotifications,
getNotification,
updateNotifications,
// getNotification,
updateNotification,
readAllNotifications,
makeHandleNotificationCreate,
makeHandleNotificationUpdate,
};