mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
parent
7956503a46
commit
fe91b5241e
478 changed files with 21226 additions and 19495 deletions
|
@ -1,35 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import { fetchActionsFailed, fetchActionsRequested, fetchActionsSucceeded } from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function* fetchActionsRequest(cardId, beforeId) {
|
||||
yield put(fetchActionsRequested(cardId));
|
||||
|
||||
try {
|
||||
const {
|
||||
items,
|
||||
included: { users },
|
||||
} = yield call(request, api.getActions, cardId, {
|
||||
beforeId,
|
||||
});
|
||||
|
||||
const action = fetchActionsSucceeded(cardId, items, users);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchActionsFailed(cardId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createAttachmentFailed,
|
||||
createAttachmentRequested,
|
||||
createAttachmentSucceeded,
|
||||
deleteAttachmentFailed,
|
||||
deleteAttachmentRequested,
|
||||
deleteAttachmentSucceeded,
|
||||
updateAttachmentFailed,
|
||||
updateAttachmentRequested,
|
||||
updateAttachmentSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createAttachmentRequest(cardId, localId, data) {
|
||||
yield put(
|
||||
createAttachmentRequested(localId, {
|
||||
...data,
|
||||
cardId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createAttachment, cardId, data, localId);
|
||||
|
||||
const action = createAttachmentSucceeded(localId, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createAttachmentFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateAttachmentRequest(id, data) {
|
||||
yield put(updateAttachmentRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateAttachment, id, data);
|
||||
|
||||
const action = updateAttachmentSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateAttachmentFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteAttachmentRequest(id) {
|
||||
yield put(deleteAttachmentRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteAttachment, id);
|
||||
|
||||
const action = deleteAttachmentSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteAttachmentFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,134 +1,69 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
import { call, select } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createBoardFailed,
|
||||
createBoardRequested,
|
||||
createBoardSucceeded,
|
||||
deleteBoardFailed,
|
||||
deleteBoardRequested,
|
||||
deleteBoardSucceeded,
|
||||
fetchBoardFailed,
|
||||
fetchBoardRequested,
|
||||
fetchBoardSucceeded,
|
||||
updateBoardFailed,
|
||||
updateBoardRequested,
|
||||
updateBoardSucceeded,
|
||||
} from '../../../actions';
|
||||
import request from '../request';
|
||||
import { pathsMatchSelector } from '../../../selectors';
|
||||
import api from '../../../api';
|
||||
import Paths from '../../../constants/Paths';
|
||||
|
||||
export function* createBoardRequest(projectId, localId, data) {
|
||||
yield put(
|
||||
createBoardRequested(localId, {
|
||||
...data,
|
||||
projectId,
|
||||
}),
|
||||
);
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function* fetchBoardByCurrentPathRequest() {
|
||||
const pathsMatch = yield select(pathsMatchSelector);
|
||||
|
||||
try {
|
||||
const {
|
||||
item,
|
||||
included: { lists, labels },
|
||||
} = yield call(request, api.createBoard, projectId, data);
|
||||
let board;
|
||||
let card;
|
||||
let users;
|
||||
let projects;
|
||||
let boardMemberships;
|
||||
let labels;
|
||||
let lists;
|
||||
let cards;
|
||||
let cardMemberships;
|
||||
let cardLabels;
|
||||
let tasks;
|
||||
let attachments;
|
||||
|
||||
const action = createBoardSucceeded(localId, item, lists, labels);
|
||||
yield put(action);
|
||||
if (pathsMatch) {
|
||||
let boardId;
|
||||
if (pathsMatch.path === Paths.BOARDS) {
|
||||
boardId = pathsMatch.params.id;
|
||||
} else if (pathsMatch.path === Paths.CARDS) {
|
||||
({
|
||||
item: card,
|
||||
item: { boardId },
|
||||
} = yield call(request, api.getCard, pathsMatch.params.id));
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createBoardFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* fetchBoardRequest(id) {
|
||||
yield put(fetchBoardRequested(id));
|
||||
|
||||
try {
|
||||
const {
|
||||
item,
|
||||
included: { labels, lists, cards, cardMemberships, cardLabels, tasks, attachments },
|
||||
} = yield call(request, api.getBoard, id);
|
||||
|
||||
const action = fetchBoardSucceeded(
|
||||
item,
|
||||
labels,
|
||||
lists,
|
||||
cards,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchBoardFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateBoardRequest(id, data) {
|
||||
yield put(updateBoardRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateBoard, id, data);
|
||||
|
||||
const action = updateBoardSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateBoardFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteBoardRequest(id) {
|
||||
yield put(deleteBoardRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteBoard, id);
|
||||
|
||||
const action = deleteBoardSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteBoardFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
if (boardId) {
|
||||
({
|
||||
item: board,
|
||||
included: {
|
||||
users,
|
||||
projects,
|
||||
boardMemberships,
|
||||
labels,
|
||||
lists,
|
||||
cards,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
},
|
||||
} = yield call(request, api.getBoard, boardId));
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
board,
|
||||
card,
|
||||
users,
|
||||
boardMemberships,
|
||||
labels,
|
||||
lists,
|
||||
cards,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
project: projects[0],
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createCardLabelFailed,
|
||||
createCardLabelRequested,
|
||||
createCardLabelSucceeded,
|
||||
deleteCardLabelFailed,
|
||||
deleteCardLabelRequested,
|
||||
deleteCardLabelSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createCardLabelRequest(cardId, labelId) {
|
||||
yield put(
|
||||
createCardLabelRequested({
|
||||
cardId,
|
||||
labelId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createCardLabel, cardId, {
|
||||
labelId,
|
||||
});
|
||||
|
||||
const action = createCardLabelSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createCardLabelFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteCardLabelRequest(cardId, labelId) {
|
||||
yield put(deleteCardLabelRequested(cardId, labelId));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteCardLabel, cardId, labelId);
|
||||
|
||||
const action = deleteCardLabelSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteCardLabelFailed(cardId, labelId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createCardMembershipFailed,
|
||||
createCardMembershipRequested,
|
||||
createCardMembershipSucceeded,
|
||||
deleteCardMembershipFailed,
|
||||
deleteCardMembershipRequested,
|
||||
deleteCardMembershipSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createCardMembershipRequest(cardId, userId) {
|
||||
yield put(
|
||||
createCardMembershipRequested({
|
||||
cardId,
|
||||
userId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createCardMembership, cardId, {
|
||||
userId,
|
||||
});
|
||||
|
||||
const action = createCardMembershipSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createCardMembershipFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteCardMembershipRequest(cardId, userId) {
|
||||
yield put(deleteCardMembershipRequested(cardId, userId));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteCardMembership, cardId, userId);
|
||||
|
||||
const action = deleteCardMembershipSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteCardMembershipFailed(cardId, userId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createCardFailed,
|
||||
createCardRequested,
|
||||
createCardSucceeded,
|
||||
deleteCardFailed,
|
||||
deleteCardRequested,
|
||||
deleteCardSucceeded,
|
||||
fetchCardFailed,
|
||||
fetchCardRequested,
|
||||
fetchCardSucceeded,
|
||||
updateCardFailed,
|
||||
updateCardRequested,
|
||||
updateCardSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createCardRequest(boardId, localId, data) {
|
||||
yield put(
|
||||
createCardRequested(localId, {
|
||||
...data,
|
||||
boardId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const {
|
||||
item,
|
||||
included: { cardMemberships, cardLabels, tasks, attachments },
|
||||
} = yield call(request, api.createCard, boardId, data);
|
||||
|
||||
const action = createCardSucceeded(
|
||||
localId,
|
||||
item,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createCardFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* fetchCardRequest(id) {
|
||||
yield put(fetchCardRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.getCard, id);
|
||||
|
||||
const action = fetchCardSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchCardFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateCardRequest(id, data) {
|
||||
yield put(updateCardRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateCard, id, data);
|
||||
|
||||
const action = updateCardSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateCardFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteCardRequest(id) {
|
||||
yield put(deleteCardRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteCard, id);
|
||||
|
||||
const action = deleteCardSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteCardFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createCommentActionFailed,
|
||||
createCommentActionRequested,
|
||||
createCommentActionSucceeded,
|
||||
deleteCommentActionFailed,
|
||||
deleteCommentActionRequested,
|
||||
deleteCommentActionSucceeded,
|
||||
updateCommentActionFailed,
|
||||
updateCommentActionRequested,
|
||||
updateCommentActionSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createCommentActionRequest(cardId, localId, data) {
|
||||
yield put(
|
||||
createCommentActionRequested(localId, {
|
||||
...data,
|
||||
cardId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createCommentAction, cardId, data);
|
||||
|
||||
const action = createCommentActionSucceeded(localId, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createCommentActionFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateCommentActionRequest(id, data) {
|
||||
yield put(
|
||||
updateCommentActionRequested(id, {
|
||||
data,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateCommentAction, id, data);
|
||||
|
||||
const action = updateCommentActionSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateCommentActionFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteCommentActionRequest(id) {
|
||||
yield put(deleteCommentActionRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteCommentAction, id);
|
||||
|
||||
const action = deleteCommentActionSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteCommentActionFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
90
client/src/sagas/core/requests/core.js
Normal file
90
client/src/sagas/core/requests/core.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
import { call } from 'redux-saga/effects';
|
||||
|
||||
import { fetchBoardByCurrentPathRequest } from './board';
|
||||
import request from '../request';
|
||||
import api from '../../../api';
|
||||
import mergeRecords from '../../../utils/merge-records';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function* fetchCoreRequest() {
|
||||
const { item: user } = yield call(request, api.getCurrentUser);
|
||||
const { items: users1 } = yield call(request, api.getUsers);
|
||||
|
||||
const {
|
||||
items: projects1,
|
||||
included: { projectManagers, boards, boardMemberships: boardMemberships1 },
|
||||
} = yield call(request, api.getProjects);
|
||||
|
||||
let board;
|
||||
let card;
|
||||
let users2;
|
||||
let projects2;
|
||||
let boardMemberships2;
|
||||
let labels;
|
||||
let lists;
|
||||
let cards1;
|
||||
let cardMemberships;
|
||||
let cardLabels;
|
||||
let tasks;
|
||||
let attachments;
|
||||
|
||||
try {
|
||||
({
|
||||
board,
|
||||
card,
|
||||
users: users2,
|
||||
projects: projects2,
|
||||
boardMemberships: boardMemberships2,
|
||||
labels,
|
||||
lists,
|
||||
cards: cards1,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
} = yield call(fetchBoardByCurrentPathRequest));
|
||||
} catch {} // eslint-disable-line no-empty
|
||||
|
||||
const body = yield call(request, api.getNotifications);
|
||||
|
||||
let { items: notifications } = body;
|
||||
|
||||
const {
|
||||
included: { users: users3, cards: cards2, actions },
|
||||
} = body;
|
||||
|
||||
if (card) {
|
||||
const notificationIds = notifications.flatMap((notification) =>
|
||||
notification.cardId === card.id ? [notification.id] : [],
|
||||
);
|
||||
|
||||
if (notificationIds.length > 0) {
|
||||
yield call(request, api.updateNotifications, notificationIds, {
|
||||
isRead: true,
|
||||
});
|
||||
|
||||
notifications = notifications.filter(
|
||||
(notification) => !notificationIds.includes(notification.id),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
user,
|
||||
board,
|
||||
projectManagers,
|
||||
boards,
|
||||
labels,
|
||||
lists,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
attachments,
|
||||
actions,
|
||||
notifications,
|
||||
users: mergeRecords(users1, users2, users3),
|
||||
projects: mergeRecords(projects1, projects2),
|
||||
boardMemberships: mergeRecords(boardMemberships1, boardMemberships2),
|
||||
cards: mergeRecords(cards1, cards2),
|
||||
};
|
||||
}
|
|
@ -1,16 +1,2 @@
|
|||
export * from './users';
|
||||
export * from './user';
|
||||
export * from './projects';
|
||||
export * from './project';
|
||||
export * from './project-membership';
|
||||
export * from './core';
|
||||
export * from './board';
|
||||
export * from './label';
|
||||
export * from './list';
|
||||
export * from './card';
|
||||
export * from './card-membership';
|
||||
export * from './card-label';
|
||||
export * from './task';
|
||||
export * from './attachment';
|
||||
export * from './actions';
|
||||
export * from './comment-action';
|
||||
export * from './notifications';
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createLabelFailed,
|
||||
createLabelRequested,
|
||||
createLabelSucceeded,
|
||||
deleteLabelFailed,
|
||||
deleteLabelRequested,
|
||||
deleteLabelSucceeded,
|
||||
updateLabelFailed,
|
||||
updateLabelRequested,
|
||||
updateLabelSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createLabelRequest(boardId, localId, data) {
|
||||
yield put(
|
||||
createLabelRequested(localId, {
|
||||
...data,
|
||||
boardId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createLabel, boardId, data);
|
||||
|
||||
const action = createLabelSucceeded(localId, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createLabelFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateLabelRequest(id, data) {
|
||||
yield put(updateLabelRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateLabel, id, data);
|
||||
|
||||
const action = updateLabelSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateLabelFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteLabelRequest(id) {
|
||||
yield put(deleteLabelRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteLabel, id);
|
||||
|
||||
const action = deleteLabelSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteLabelFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createListFailed,
|
||||
createListRequested,
|
||||
createListSucceeded,
|
||||
deleteListFailed,
|
||||
deleteListRequested,
|
||||
deleteListSucceeded,
|
||||
updateListFailed,
|
||||
updateListRequested,
|
||||
updateListSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createListRequest(boardId, localId, data) {
|
||||
yield put(
|
||||
createListRequested(localId, {
|
||||
...data,
|
||||
boardId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createList, boardId, data);
|
||||
|
||||
const action = createListSucceeded(localId, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createListFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateListRequest(id, data) {
|
||||
yield put(updateListRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateList, id, data);
|
||||
|
||||
const action = updateListSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateListFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteListRequest(id) {
|
||||
yield put(deleteListRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteList, id);
|
||||
|
||||
const action = deleteListSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteListFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
deleteNotificationsFailed,
|
||||
deleteNotificationsRequested,
|
||||
deleteNotificationsSucceeded,
|
||||
fetchNotificationsFailed,
|
||||
fetchNotificationsRequested,
|
||||
fetchNotificationsSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* fetchNotificationsRequest() {
|
||||
yield put(fetchNotificationsRequested());
|
||||
|
||||
try {
|
||||
const {
|
||||
items,
|
||||
included: { users, cards, actions },
|
||||
} = yield call(request, api.getNotifications);
|
||||
|
||||
const action = fetchNotificationsSucceeded(items, users, cards, actions);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchNotificationsFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteNotificationsRequest(ids) {
|
||||
yield put(deleteNotificationsRequested(ids));
|
||||
|
||||
try {
|
||||
const { items } = yield call(request, api.updateNotifications, ids, {
|
||||
isRead: true,
|
||||
});
|
||||
|
||||
const action = deleteNotificationsSucceeded(items);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteNotificationsFailed(ids, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createProjectMembershipFailed,
|
||||
createProjectMembershipRequested,
|
||||
createProjectMembershipSucceeded,
|
||||
deleteProjectMembershipFailed,
|
||||
deleteProjectMembershipRequested,
|
||||
deleteProjectMembershipSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createProjectMembershipRequest(projectId, localId, data) {
|
||||
yield put(
|
||||
createProjectMembershipRequested(localId, {
|
||||
...data,
|
||||
projectId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createProjectMembership, projectId, data);
|
||||
|
||||
const action = createProjectMembershipSucceeded(localId, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createProjectMembershipFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteProjectMembershipRequest(id) {
|
||||
yield put(deleteProjectMembershipRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteProjectMembership, id);
|
||||
|
||||
const action = deleteProjectMembershipSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteProjectMembershipFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createProjectFailed,
|
||||
createProjectRequested,
|
||||
createProjectSucceeded,
|
||||
deleteProjectFailed,
|
||||
deleteProjectRequested,
|
||||
deleteProjectSucceeded,
|
||||
updateProjectBackgroundImageFailed,
|
||||
updateProjectBackgroundImageRequested,
|
||||
updateProjectBackgroundImageSucceeded,
|
||||
updateProjectFailed,
|
||||
updateProjectRequested,
|
||||
updateProjectSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createProjectRequest(data) {
|
||||
yield put(createProjectRequested(data));
|
||||
|
||||
try {
|
||||
const {
|
||||
item,
|
||||
included: { users, projectMemberships, boards },
|
||||
} = yield call(request, api.createProject, data);
|
||||
|
||||
const action = createProjectSucceeded(item, users, projectMemberships, boards);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createProjectFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateProjectRequest(id, data) {
|
||||
yield put(updateProjectRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateProject, id, data);
|
||||
|
||||
const action = updateProjectSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateProjectFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateProjectBackgroundImageRequest(id, data) {
|
||||
yield put(updateProjectBackgroundImageRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateProjectBackgroundImage, id, data);
|
||||
|
||||
const action = updateProjectBackgroundImageSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateProjectBackgroundImageFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteProjectRequest(id) {
|
||||
yield put(deleteProjectRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteProject, id);
|
||||
|
||||
const action = deleteProjectSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteProjectFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
fetchProjectsFailed,
|
||||
fetchProjectsRequested,
|
||||
fetchProjectsSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function* fetchProjectsRequest() {
|
||||
yield put(fetchProjectsRequested());
|
||||
|
||||
try {
|
||||
const {
|
||||
items,
|
||||
included: { users, projectMemberships, boards },
|
||||
} = yield call(request, api.getProjects);
|
||||
|
||||
const action = fetchProjectsSucceeded(items, users, projectMemberships, boards);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchProjectsFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
import { call, put, select, take } from 'redux-saga/effects';
|
||||
|
||||
import { accessTokenSelector } from '../../../selectors';
|
||||
import { logout } from '../../../actions';
|
||||
import ErrorCodes from '../../../constants/ErrorCodes';
|
||||
|
||||
export default function* request(method, ...args) {
|
||||
try {
|
||||
const accessToken = yield select(accessTokenSelector);
|
||||
|
||||
return yield call(method, ...args, {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.code === ErrorCodes.UNAUTHORIZED) {
|
||||
yield put(logout()); // TODO: next url
|
||||
yield take();
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createTaskFailed,
|
||||
createTaskRequested,
|
||||
createTaskSucceeded,
|
||||
deleteTaskFailed,
|
||||
deleteTaskRequested,
|
||||
deleteTaskSucceeded,
|
||||
updateTaskFailed,
|
||||
updateTaskRequested,
|
||||
updateTaskSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createTaskRequest(cardId, localId, data) {
|
||||
yield put(
|
||||
createTaskRequested(localId, {
|
||||
...data,
|
||||
cardId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createTask, cardId, data);
|
||||
|
||||
const action = createTaskSucceeded(localId, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createTaskFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateTaskRequest(id, data) {
|
||||
yield put(updateTaskRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateTask, id, data);
|
||||
|
||||
const action = updateTaskSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateTaskFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteTaskRequest(id) {
|
||||
yield put(deleteTaskRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteTask, id);
|
||||
|
||||
const action = deleteTaskSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteTaskFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createUserFailed,
|
||||
createUserRequested,
|
||||
createUserSucceeded,
|
||||
deleteUserFailed,
|
||||
deleteUserRequested,
|
||||
deleteUserSucceeded,
|
||||
fetchCurrentUserFailed,
|
||||
fetchCurrentUserRequested,
|
||||
fetchCurrentUserSucceeded,
|
||||
updateUserAvatarFailed,
|
||||
updateUserAvatarRequested,
|
||||
updateUserAvatarSucceeded,
|
||||
updateUserEmailFailed,
|
||||
updateUserEmailRequested,
|
||||
updateUserEmailSucceeded,
|
||||
updateUserFailed,
|
||||
updateUserPasswordFailed,
|
||||
updateUserPasswordRequested,
|
||||
updateUserPasswordSucceeded,
|
||||
updateUserRequested,
|
||||
updateUserSucceeded,
|
||||
updateUserUsernameFailed,
|
||||
updateUserUsernameRequested,
|
||||
updateUserUsernameSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createUserRequest(data) {
|
||||
yield put(createUserRequested(data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.createUser, data);
|
||||
|
||||
const action = createUserSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createUserFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* fetchCurrentUserRequest() {
|
||||
yield put(fetchCurrentUserRequested());
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.getCurrentUser);
|
||||
|
||||
const action = fetchCurrentUserSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchCurrentUserFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserRequest(id, data) {
|
||||
yield put(updateUserRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateUser, id, data);
|
||||
|
||||
const action = updateUserSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserEmailRequest(id, data) {
|
||||
yield put(updateUserEmailRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateUserEmail, id, data);
|
||||
|
||||
const action = updateUserEmailSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserEmailFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserPasswordRequest(id, data) {
|
||||
yield put(updateUserPasswordRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateUserPassword, id, data);
|
||||
|
||||
const action = updateUserPasswordSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserPasswordFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserUsernameRequest(id, data) {
|
||||
yield put(updateUserUsernameRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateUserUsername, id, data);
|
||||
|
||||
const action = updateUserUsernameSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserUsernameFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserAvatarRequest(id, data) {
|
||||
yield put(updateUserAvatarRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateUserAvatar, id, data);
|
||||
|
||||
const action = updateUserAvatarSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserAvatarFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteUserRequest(id) {
|
||||
yield put(deleteUserRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteUser, id);
|
||||
|
||||
const action = deleteUserSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteUserFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import { fetchUsersFailed, fetchUsersRequested, fetchUsersSucceeded } from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function* fetchUsersRequest() {
|
||||
yield put(fetchUsersRequested());
|
||||
|
||||
try {
|
||||
const { items } = yield call(request, api.getUsers);
|
||||
|
||||
const action = fetchUsersSucceeded(items);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchUsersFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue