2019-08-31 04:07:25 +05:00
|
|
|
import socket from './socket';
|
|
|
|
import { transformCard } from './cards';
|
|
|
|
import { transformAction } from './actions';
|
|
|
|
|
|
|
|
/* Actions */
|
|
|
|
|
2020-03-25 00:15:47 +05:00
|
|
|
const getNotifications = (headers) =>
|
|
|
|
socket.get('/notifications', undefined, headers).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
|
|
|
|
2020-02-03 18:42:31 +05:00
|
|
|
const updateNotifications = (ids, data, headers) =>
|
|
|
|
socket.patch(`/notifications/${ids.join(',')}`, data, headers);
|
2019-08-31 04:07:25 +05:00
|
|
|
|
|
|
|
/* Event handlers */
|
|
|
|
|
2020-03-25 00:15:47 +05:00
|
|
|
const makeHandleNotificationCreate = (next) => (body) => {
|
2019-08-31 04:07:25 +05:00
|
|
|
next({
|
|
|
|
...body,
|
|
|
|
included: {
|
|
|
|
...body.included,
|
|
|
|
cards: body.included.cards.map(transformCard),
|
|
|
|
actions: body.included.actions.map(transformAction),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
getNotifications,
|
|
|
|
updateNotifications,
|
|
|
|
makeHandleNotificationCreate,
|
|
|
|
};
|