2019-08-31 04:07:25 +05:00
|
|
|
import socket from './socket';
|
|
|
|
import { transformCard } from './cards';
|
|
|
|
import { transformAction } from './actions';
|
|
|
|
|
|
|
|
/* Actions */
|
|
|
|
|
2022-04-26 18:01:55 +05:00
|
|
|
const getNotifications = () =>
|
|
|
|
socket.get('/notifications').then((body) => ({
|
2020-02-03 18:42:31 +05:00
|
|
|
...body,
|
|
|
|
included: {
|
|
|
|
...body.included,
|
|
|
|
cards: body.included.cards.map(transformCard),
|
|
|
|
actions: body.included.actions.map(transformAction),
|
|
|
|
},
|
|
|
|
}));
|
2019-08-31 04:07:25 +05:00
|
|
|
|
2022-04-26 18:01:55 +05:00
|
|
|
const getNotification = (id) =>
|
|
|
|
socket.get(`/notifications/${id}`).then((body) => ({
|
2019-08-31 04:07:25 +05:00
|
|
|
...body,
|
|
|
|
included: {
|
|
|
|
...body.included,
|
|
|
|
cards: body.included.cards.map(transformCard),
|
|
|
|
actions: body.included.actions.map(transformAction),
|
|
|
|
},
|
2021-06-24 01:05:22 +05:00
|
|
|
}));
|
|
|
|
|
2022-04-26 18:01:55 +05:00
|
|
|
const updateNotifications = (ids, data) => socket.patch(`/notifications/${ids.join(',')}`, data);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
getNotifications,
|
2021-06-24 01:05:22 +05:00
|
|
|
getNotification,
|
2019-08-31 04:07:25 +05:00
|
|
|
updateNotifications,
|
|
|
|
};
|