Background gradients, migrate from CSS to SCSS, remove !important

This commit is contained in:
Maksim Eltyshev
2020-05-29 19:31:19 +05:00
parent 196121bd38
commit ff95a12578
312 changed files with 4295 additions and 2989 deletions

View File

@@ -0,0 +1,16 @@
import { call, select } from 'redux-saga/effects';
import { fetchActionsRequest } from '../requests';
import { lastActionIdByCardIdSelector, pathSelector } from '../../../selectors';
export function* fetchActionsService(cardId) {
const lastId = yield select(lastActionIdByCardIdSelector, cardId);
yield call(fetchActionsRequest, cardId, lastId);
}
export function* fetchActionsInCurrentCardService() {
const { cardId } = yield select(pathSelector);
yield call(fetchActionsService, cardId);
}

View File

@@ -0,0 +1,40 @@
import { call, put, select } from 'redux-saga/effects';
import {
createAttachmentRequest,
deleteAttachmentRequest,
updateAttachmentRequest,
} from '../requests';
import { pathSelector } from '../../../selectors';
import { createAttachment, deleteAttachment, updateAttachment } from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
export function* createAttachmentService(cardId, data) {
const localId = yield call(createLocalId);
yield put(
createAttachment({
cardId,
id: localId,
name: data.file.name,
}),
);
yield call(createAttachmentRequest, cardId, localId, data);
}
export function* createAttachmentInCurrentCardService(data) {
const { cardId } = yield select(pathSelector);
yield call(createAttachmentService, cardId, data);
}
export function* updateAttachmentService(id, data) {
yield put(updateAttachment(id, data));
yield call(updateAttachmentRequest, id, data);
}
export function* deleteAttachmentService(id) {
yield put(deleteAttachment(id));
yield call(deleteAttachmentRequest, id);
}

View File

@@ -0,0 +1,73 @@
import { call, put, select } from 'redux-saga/effects';
import { goToBoardService, goToProjectService } from './router';
import {
createBoardRequest,
deleteBoardRequest,
fetchBoardRequest,
updateBoardRequest,
} from '../requests';
import { boardByIdSelector, nextBoardPositionSelector, pathSelector } from '../../../selectors';
import { createBoard, deleteBoard, updateBoard } from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
export function* createBoardService(projectId, data) {
const nextData = {
...data,
position: yield select(nextBoardPositionSelector, projectId),
};
const localId = yield call(createLocalId);
yield put(
createBoard({
...nextData,
projectId,
id: localId,
}),
);
const {
success,
payload: { board },
} = yield call(createBoardRequest, projectId, localId, nextData);
if (success) {
yield call(goToBoardService, board.id);
}
}
export function* createBoardInCurrentProjectService(data) {
const { projectId } = yield select(pathSelector);
yield call(createBoardService, projectId, data);
}
export function* fetchBoard(id) {
yield call(fetchBoardRequest, id);
}
export function* updateBoardService(id, data) {
yield put(updateBoard(id, data));
yield call(updateBoardRequest, id, data);
}
export function* moveBoardService(id, index) {
const { projectId } = yield select(boardByIdSelector, id);
const position = yield select(nextBoardPositionSelector, projectId, index, id);
yield call(updateBoardService, id, {
position,
});
}
export function* deleteBoardService(id) {
const { boardId, projectId } = yield select(pathSelector);
if (id === boardId) {
yield call(goToProjectService, projectId);
}
yield put(deleteBoard(id));
yield call(deleteBoardRequest, id);
}

View File

@@ -0,0 +1,95 @@
import { call, put, select } from 'redux-saga/effects';
import { goToBoardService } from './router';
import { createCardRequest, deleteCardRequest, updateCardRequest } from '../requests';
import { listByIdSelector, nextCardPositionSelector, pathSelector } from '../../../selectors';
import { createCard, deleteCard, updateCard } from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
export function* createCardService(listId, data) {
const { boardId } = yield select(listByIdSelector, listId);
const nextData = {
...data,
position: yield select(nextCardPositionSelector, listId),
};
const localId = yield call(createLocalId);
yield put(
createCard({
...nextData,
listId,
boardId,
id: localId,
}),
);
yield call(createCardRequest, listId, localId, nextData);
}
export function* updateCardService(id, data) {
yield put(updateCard(id, data));
yield call(updateCardRequest, id, data);
}
export function* updateCurrentCardService(data) {
const { cardId } = yield select(pathSelector);
yield call(updateCardService, cardId, data);
}
export function* moveCardService(id, listId, index) {
const position = yield select(nextCardPositionSelector, listId, index, id);
yield call(updateCardService, id, {
listId,
position,
});
}
export function* moveCurrentCardService(listId, index) {
const { cardId } = yield select(pathSelector);
yield call(moveCardService, cardId, listId, index);
}
export function* transferCardService(id, boardId, listId, index) {
const { cardId: currentCardId, boardId: currentBoardId } = yield select(pathSelector);
const position = yield select(nextCardPositionSelector, listId, index, id);
if (id === currentCardId) {
yield call(goToBoardService, currentBoardId);
}
yield put(deleteCard(id));
yield call(updateCardRequest, id, {
listId,
boardId,
position,
});
}
export function* transferCurrentCardService(boardId, listId, index) {
const { cardId } = yield select(pathSelector);
yield call(transferCardService, cardId, boardId, listId, index);
}
export function* deleteCardService(id) {
const { cardId, boardId } = yield select(pathSelector);
if (id === cardId) {
yield call(goToBoardService, boardId);
}
yield put(deleteCard(id));
yield call(deleteCardRequest, id);
}
export function* deleteCurrentCardService() {
const { cardId } = yield select(pathSelector);
yield call(deleteCardService, cardId);
}

View File

@@ -0,0 +1,44 @@
import { call, put, select } from 'redux-saga/effects';
import {
createCommentActionRequest,
deleteCommentActionRequest,
updateCommentActionRequest,
} from '../requests';
import { currentUserIdSelector, pathSelector } from '../../../selectors';
import { createCommentAction, deleteCommentAction, updateCommentAction } from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
import { ActionTypes } from '../../../constants/Enums';
export function* createCommentActionService(cardId, data) {
const localId = yield call(createLocalId);
const userId = yield select(currentUserIdSelector);
yield put(
createCommentAction({
cardId,
userId,
data,
id: localId,
type: ActionTypes.COMMENT_CARD,
}),
);
yield call(createCommentActionRequest, cardId, localId, data);
}
export function* createCommentActionInCurrentCardService(data) {
const { cardId } = yield select(pathSelector);
yield call(createCommentActionService, cardId, data);
}
export function* updateCommentActionService(id, data) {
yield put(updateCommentAction(id, data));
yield call(updateCommentActionRequest, id, data);
}
export function* deleteCommentActionService(id) {
yield put(deleteCommentAction(id));
yield call(deleteCommentActionRequest, id);
}

View File

@@ -0,0 +1,44 @@
import { call, put, select } from 'redux-saga/effects';
import { runPathActionsService } from './router';
import {
fetchCardRequest,
fetchCurrentUserRequest,
fetchNotificationsRequest,
fetchProjectsRequest,
fetchUsersRequest,
} from '../requests';
import { pathsMatchSelector } from '../../../selectors';
import { coreInitialized } from '../../../actions';
import i18n from '../../../i18n';
import Paths from '../../../constants/Paths';
export function* loadLocaleService(language) {
yield call(i18n.loadCoreLocale, language);
}
export function* initializeCoreService() {
const {
payload: {
user: { isAdmin },
},
} = yield call(fetchCurrentUserRequest); // TODO: success check
if (isAdmin) {
yield call(fetchUsersRequest);
}
yield call(fetchProjectsRequest);
const pathsMatch = yield select(pathsMatchSelector);
if (pathsMatch && pathsMatch.path === Paths.CARDS) {
yield call(fetchCardRequest, pathsMatch.params.id);
}
yield call(fetchNotificationsRequest);
yield call(runPathActionsService, pathsMatch);
yield call(loadLocaleService, i18n.language);
yield put(coreInitialized());
}

View File

@@ -0,0 +1,18 @@
export * from './router';
export * from './socket';
export * from './login';
export * from './core';
export * from './modal';
export * from './user';
export * from './project';
export * from './project-membership';
export * from './board';
export * from './list';
export * from './label';
export * from './card';
export * from './task';
export * from './attachment';
export * from './actions';
export * from './comment-action';
export * from './notifications';
export * from './notification';

View File

@@ -0,0 +1,92 @@
import { call, put, select } from 'redux-saga/effects';
import {
createCardLabelRequest,
createLabelRequest,
deleteCardLabelRequest,
deleteLabelRequest,
updateLabelRequest,
} from '../requests';
import { pathSelector } from '../../../selectors';
import {
addLabelToBoardFilter,
addLabelToCard,
createLabel,
deleteLabel,
removeLabelFromBoardFilter,
removeLabelFromCard,
updateLabel,
} from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
export function* createLabelService(boardId, data) {
const localId = yield call(createLocalId);
yield put(
createLabel({
...data,
boardId,
id: localId,
}),
);
yield call(createLabelRequest, boardId, localId, data);
}
export function* createLabelInCurrentBoardService(data) {
const { boardId } = yield select(pathSelector);
yield call(createLabelService, boardId, data);
}
export function* updateLabelService(id, data) {
yield put(updateLabel(id, data));
yield call(updateLabelRequest, id, data);
}
export function* deleteLabelService(id) {
yield put(deleteLabel(id));
yield call(deleteLabelRequest, id);
}
export function* addLabelToCardService(id, cardId) {
yield put(addLabelToCard(id, cardId));
yield call(createCardLabelRequest, cardId, id);
}
export function* addLabelToCurrentCardService(id) {
const { cardId } = yield select(pathSelector);
yield call(addLabelToCardService, id, cardId);
}
export function* removeLabelFromCardService(id, cardId) {
yield put(removeLabelFromCard(id, cardId));
yield call(deleteCardLabelRequest, cardId, id);
}
export function* removeLabelFromCurrentCardService(id) {
const { cardId } = yield select(pathSelector);
yield call(removeLabelFromCardService, id, cardId);
}
export function* addLabelToBoardFilterService(id, boardId) {
yield put(addLabelToBoardFilter(id, boardId));
}
export function* addLabelToFilterInCurrentBoardService(id) {
const { boardId } = yield select(pathSelector);
yield call(addLabelToBoardFilterService, id, boardId);
}
export function* removeLabelFromBoardFilterService(id, boardId) {
yield put(removeLabelFromBoardFilter(id, boardId));
}
export function* removeLabelFromFilterInCurrentBoardService(id) {
const { boardId } = yield select(pathSelector);
yield call(removeLabelFromBoardFilterService, id, boardId);
}

View File

@@ -0,0 +1,50 @@
import { call, put, select } from 'redux-saga/effects';
import { createListRequest, deleteListRequest, updateListRequest } from '../requests';
import { listByIdSelector, nextListPositionSelector, pathSelector } from '../../../selectors';
import { createList, deleteList, updateList } from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
export function* createListService(boardId, data) {
const nextData = {
...data,
position: yield select(nextListPositionSelector, boardId),
};
const localId = yield call(createLocalId);
yield put(
createList({
...nextData,
boardId,
id: localId,
}),
);
yield call(createListRequest, boardId, localId, nextData);
}
export function* createListInCurrentBoardService(data) {
const { boardId } = yield select(pathSelector);
yield call(createListService, boardId, data);
}
export function* updateListService(id, data) {
yield put(updateList(id, data));
yield call(updateListRequest, id, data);
}
export function* moveListService(id, index) {
const { boardId } = yield select(listByIdSelector, id);
const position = yield select(nextListPositionSelector, boardId, index, id);
yield call(updateListService, id, {
position,
});
}
export function* deleteListService(id) {
yield put(deleteList(id));
yield call(deleteListRequest, id);
}

View File

@@ -0,0 +1,8 @@
import { put } from 'redux-saga/effects';
import { logout } from '../../../actions';
// eslint-disable-next-line import/prefer-default-export
export function* logoutService() {
yield put(logout());
}

View File

@@ -0,0 +1,11 @@
import { put } from 'redux-saga/effects';
import { closeModal, openModal } from '../../../actions';
export function* openModalService(type) {
yield put(openModal(type));
}
export function* closeModalService() {
yield put(closeModal());
}

View File

@@ -0,0 +1,8 @@
import { call } from 'redux-saga/effects';
import { deleteNotificationsService } from './notifications';
// eslint-disable-next-line import/prefer-default-export
export function* deleteNotificationService(id) {
yield call(deleteNotificationsService, [id]);
}

View File

@@ -0,0 +1,18 @@
import { call, put, select } from 'redux-saga/effects';
import { deleteNotificationsRequest } from '../requests';
import { notificationIdsForCurrentCardSelector } from '../../../selectors';
import { deleteNotifications } from '../../../actions';
export function* deleteNotificationsService(ids) {
yield put(deleteNotifications(ids));
yield call(deleteNotificationsRequest, ids);
}
export function* deleteNotificationsInCurrentCardService() {
const notificationIds = yield select(notificationIdsForCurrentCardSelector);
if (notificationIds && notificationIds.length > 0) {
yield call(deleteNotificationsService, notificationIds);
}
}

View File

@@ -0,0 +1,31 @@
import { call, put, select } from 'redux-saga/effects';
import { createProjectMembershipRequest, deleteProjectMembershipRequest } from '../requests';
import { pathSelector } from '../../../selectors';
import { createProjectMembership, deleteProjectMembership } from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
export function* createProjectMembershipService(projectId, data) {
const localId = yield call(createLocalId);
yield put(
createProjectMembership({
...data,
projectId,
id: localId,
}),
);
yield call(createProjectMembershipRequest, projectId, localId, data);
}
export function* createMembershipInCurrentProjectService(data) {
const { projectId } = yield select(pathSelector);
yield call(createProjectMembershipService, projectId, data);
}
export function* deleteProjectMembershipService(id) {
yield put(deleteProjectMembership(id));
yield call(deleteProjectMembershipRequest, id);
}

View File

@@ -0,0 +1,62 @@
import { call, put, select } from 'redux-saga/effects';
import { goToProjectService, goToRootService } from './router';
import {
createProjectRequest,
deleteProjectRequest,
updateProjectBackgroundImageRequest,
updateProjectRequest,
} from '../requests';
import { pathSelector } from '../../../selectors';
import { createProject, deleteProject, updateProject } from '../../../actions';
export function* createProjectService(data) {
yield put(createProject(data));
const {
success,
payload: { project },
} = yield call(createProjectRequest, data);
if (success) {
yield call(goToProjectService, project.id);
}
}
export function* updateProjectService(id, data) {
yield put(updateProject(id, data));
yield call(updateProjectRequest, id, data);
}
export function* updateCurrentProjectService(data) {
const { projectId } = yield select(pathSelector);
yield call(updateProjectService, projectId, data);
}
export function* updateProjectBackgroundImageService(id, data) {
yield call(updateProjectBackgroundImageRequest, id, data);
}
export function* updateCurrentProjectBackgroundImageService(data) {
const { projectId } = yield select(pathSelector);
yield call(updateProjectBackgroundImageService, projectId, data);
}
export function* deleteProjectService(id) {
const { projectId } = yield select(pathSelector);
if (id === projectId) {
yield call(goToRootService);
}
yield put(deleteProject(id));
yield call(deleteProjectRequest, id);
}
export function* deleteCurrentProjectService() {
const { projectId } = yield select(pathSelector);
yield call(deleteProjectService, projectId);
}

View File

@@ -0,0 +1,71 @@
import { call, put, select } from 'redux-saga/effects';
import { push } from 'connected-react-router';
import { deleteNotificationsInCurrentCardService } from './notifications';
import { fetchBoardRequest } from '../requests';
import {
currentBoardSelector,
isCoreInitializingSelector,
pathsMatchSelector,
} from '../../../selectors';
import Paths from '../../../constants/Paths';
export function* goToRootService() {
yield put(push(Paths.ROOT));
}
export function* goToProjectService(projectId) {
yield put(push(Paths.PROJECTS.replace(':id', projectId)));
}
export function* goToBoardService(boardId) {
yield put(push(Paths.BOARDS.replace(':id', boardId)));
}
export function* goToCardService(cardId) {
yield put(push(Paths.CARDS.replace(':id', cardId)));
}
export function* runPathActionsService(pathsMatch) {
if (!pathsMatch) {
return;
}
switch (pathsMatch.path) {
case Paths.BOARDS:
case Paths.CARDS: {
const currentBoard = yield select(currentBoardSelector); // TODO: move to services
if (currentBoard && currentBoard.isFetching === null) {
yield call(fetchBoardRequest, currentBoard.id);
}
if (pathsMatch.path === Paths.CARDS) {
yield call(deleteNotificationsInCurrentCardService);
}
break;
}
default:
}
}
export function* locationChangedService() {
const pathsMatch = yield select(pathsMatchSelector);
if (pathsMatch) {
switch (pathsMatch.path) {
case Paths.LOGIN:
yield call(goToRootService);
break;
default:
}
}
const isCoreInitializing = yield select(isCoreInitializingSelector);
if (!isCoreInitializing) {
yield call(runPathActionsService, pathsMatch);
}
}

View File

@@ -0,0 +1,252 @@
import { call, put, select } from 'redux-saga/effects';
import { goToBoardService, goToProjectService, goToRootService } from './router';
import { logoutService } from './login';
import { closeModalService } from './modal';
import { deleteNotificationsRequest, fetchUsersRequest } from '../requests';
import {
currentModalSelector,
currentUserIdSelector,
currentUserSelector,
isAttachmentWithIdExistsSelector,
pathSelector,
} from '../../../selectors';
import {
createActionReceived,
createAttachmentReceived,
createBoardReceived,
createCardLabelReceived,
createCardMembershipReceived,
createCardReceived,
createLabelReceived,
createListReceived,
createNotificationReceived,
createProjectMembershipReceived,
createProjectReceived,
createTaskReceived,
createUserReceived,
deleteActionReceived,
deleteAttachmentReceived,
deleteCardLabelReceived,
deleteCardMembershipReceived,
deleteCardReceived,
deleteBoardReceived,
deleteLabelReceived,
deleteListReceived,
deleteNotificationReceived,
deleteProjectMembershipReceived,
deleteProjectReceived,
deleteTaskReceived,
deleteUserReceived,
socketDisconnected,
socketReconnected,
updateActionReceived,
updateAttachmentReceived,
updateBoardReceived,
updateCardReceived,
updateLabelReceived,
updateListReceived,
updateProjectReceived,
updateTaskReceived,
updateUserReceived,
} from '../../../actions';
import ModalTypes from '../../../constants/ModalTypes';
export function* socketDisconnectedService() {
yield put(socketDisconnected());
}
// TODO: refetch state on reconnect
export function* socketReconnectedService() {
yield put(socketReconnected());
}
export function* createUserReceivedService(user) {
yield put(createUserReceived(user));
}
export function* updateUserReceivedService(user) {
const currentUser = yield select(currentUserSelector);
if (user.id === currentUser.id) {
if (currentUser.isAdmin) {
if (!user.isAdmin) {
const currentModal = yield select(currentModalSelector);
if (currentModal === ModalTypes.USERS) {
yield call(closeModalService);
}
}
} else if (user.isAdmin) {
yield call(fetchUsersRequest);
}
}
yield put(updateUserReceived(user));
}
export function* deleteUserReceivedService(user) {
const currentUserId = yield select(currentUserIdSelector);
if (user.id === currentUserId) {
yield call(logoutService);
}
yield put(deleteUserReceived(user));
}
export function* createProjectReceivedService(project, users, projectMemberships, boards) {
yield put(createProjectReceived(project, users, projectMemberships, boards));
}
export function* updateProjectReceivedService(project) {
yield put(updateProjectReceived(project));
}
export function* deleteProjectReceivedService(project) {
const { projectId } = yield select(pathSelector);
if (project.id === projectId) {
yield call(goToRootService);
}
yield put(deleteProjectReceived(project));
}
export function* createProjectMembershipReceivedService(projectMembership, user) {
yield put(createProjectMembershipReceived(projectMembership, user));
}
export function* deleteProjectMembershipReceivedService(projectMembership) {
yield put(deleteProjectMembershipReceived(projectMembership));
}
export function* createBoardReceivedService(board, lists, labels) {
yield put(createBoardReceived(board, lists, labels));
}
export function* updateBoardReceivedService(board) {
yield put(updateBoardReceived(board));
}
export function* deleteBoardReceivedService(board) {
const { boardId, projectId } = yield select(pathSelector);
if (board.id === boardId) {
yield call(goToProjectService, projectId);
}
yield put(deleteBoardReceived(board));
}
export function* createListReceivedService(list) {
yield put(createListReceived(list));
}
export function* updateListReceivedService(list) {
yield put(updateListReceived(list));
}
export function* deleteListReceivedService(list) {
yield put(deleteListReceived(list));
}
export function* createLabelReceivedService(label) {
yield put(createLabelReceived(label));
}
export function* updateLabelReceivedService(label) {
yield put(updateLabelReceived(label));
}
export function* deleteLabelReceivedService(label) {
yield put(deleteLabelReceived(label));
}
export function* createCardReceivedService(card, cardMemberships, cardLabels, tasks, attachments) {
yield put(createCardReceived(card, cardMemberships, cardLabels, tasks, attachments));
}
export function* updateCardReceivedService(card) {
yield put(updateCardReceived(card));
}
export function* deleteCardReceivedService(card) {
const { cardId, boardId } = yield select(pathSelector);
if (card.id === cardId) {
yield call(goToBoardService, boardId);
}
yield put(deleteCardReceived(card));
}
export function* createCardMembershipReceivedService(cardMembership) {
yield put(createCardMembershipReceived(cardMembership));
}
export function* deleteCardMembershipReceivedService(cardMembership) {
yield put(deleteCardMembershipReceived(cardMembership));
}
export function* createCardLabelReceivedService(cardLabel) {
yield put(createCardLabelReceived(cardLabel));
}
export function* deleteCardLabelReceivedService(cardLabel) {
yield put(deleteCardLabelReceived(cardLabel));
}
export function* createTaskReceivedService(task) {
yield put(createTaskReceived(task));
}
export function* updateTaskReceivedService(task) {
yield put(updateTaskReceived(task));
}
export function* deleteTaskReceivedService(task) {
yield put(deleteTaskReceived(task));
}
export function* createAttachmentReceivedService(attachment, requestId) {
const isExists = yield select(isAttachmentWithIdExistsSelector, requestId);
if (!isExists) {
yield put(createAttachmentReceived(attachment));
}
}
export function* updateAttachmentReceivedService(attachment) {
yield put(updateAttachmentReceived(attachment));
}
export function* deleteAttachmentReceivedService(attachment) {
yield put(deleteAttachmentReceived(attachment));
}
export function* createActionReceivedService(action) {
yield put(createActionReceived(action));
}
export function* updateActionReceivedService(action) {
yield put(updateActionReceived(action));
}
export function* deleteActionReceivedService(action) {
yield put(deleteActionReceived(action));
}
export function* createNotificationReceivedService(notification, user, card, action) {
const { cardId } = yield select(pathSelector);
if (card.id === cardId) {
yield call(deleteNotificationsRequest, [notification.id]);
} else {
yield put(createNotificationReceived(notification, user, card, action));
}
}
export function* deleteNotificationReceivedService(notification) {
yield put(deleteNotificationReceived(notification));
}

View File

@@ -0,0 +1,36 @@
import { call, put, select } from 'redux-saga/effects';
import { createTaskRequest, deleteTaskRequest, updateTaskRequest } from '../requests';
import { pathSelector } from '../../../selectors';
import { createTask, deleteTask, updateTask } from '../../../actions';
import { createLocalId } from '../../../utils/local-id';
export function* createTaskService(cardId, data) {
const localId = yield call(createLocalId);
yield put(
createTask({
...data,
cardId,
id: localId,
}),
);
yield call(createTaskRequest, cardId, localId, data);
}
export function* createTaskInCurrentCardService(data) {
const { cardId } = yield select(pathSelector);
yield call(createTaskService, cardId, data);
}
export function* updateTaskService(id, data) {
yield put(updateTask(id, data));
yield call(updateTaskRequest, id, data);
}
export function* deleteTaskService(id) {
yield put(deleteTask(id));
yield call(deleteTaskRequest, id);
}

View File

@@ -0,0 +1,166 @@
import { call, put, select } from 'redux-saga/effects';
import {
createCardMembershipRequest,
createUserRequest,
deleteCardMembershipRequest,
deleteUserRequest,
updateUserAvatarRequest,
updateUserEmailRequest,
updateUserPasswordRequest,
updateUserRequest,
updateUserUsernameRequest,
} from '../requests';
import { currentUserIdSelector, pathSelector } from '../../../selectors';
import {
addUserToBoardFilter,
addUserToCard,
clearUserCreateError,
clearUserEmailUpdateError,
clearUserPasswordUpdateError,
clearUserUsernameUpdateError,
createUser,
deleteUser,
updateUser,
removeUserFromBoardFilter,
removeUserFromCard,
} from '../../../actions';
export function* createUserService(data) {
yield put(createUser(data));
yield call(createUserRequest, data);
}
export function* clearUserCreateErrorService() {
yield put(clearUserCreateError());
}
export function* updateUserService(id, data) {
yield put(updateUser(id, data));
yield call(updateUserRequest, id, data);
}
export function* updateCurrentUserService(data) {
const id = yield select(currentUserIdSelector);
yield call(updateUserService, id, data);
}
export function* updateUserEmailService(id, data) {
yield call(updateUserEmailRequest, id, data);
}
export function* updateCurrentUserEmailService(data) {
const id = yield select(currentUserIdSelector);
yield call(updateUserEmailService, id, data);
}
export function* clearUserEmailUpdateErrorService(id) {
yield put(clearUserEmailUpdateError(id));
}
export function* clearCurrentUserEmailUpdateErrorService() {
const id = yield select(currentUserIdSelector);
yield call(clearUserEmailUpdateErrorService, id);
}
export function* updateUserPasswordService(id, data) {
yield call(updateUserPasswordRequest, id, data);
}
export function* updateCurrentUserPasswordService(data) {
const id = yield select(currentUserIdSelector);
yield call(updateUserPasswordService, id, data);
}
export function* clearUserPasswordUpdateErrorService(id) {
yield put(clearUserPasswordUpdateError(id));
}
export function* clearCurrentUserPasswordUpdateErrorService() {
const id = yield select(currentUserIdSelector);
yield call(clearUserPasswordUpdateErrorService, id);
}
export function* updateUserUsernameService(id, data) {
yield call(updateUserUsernameRequest, id, data);
}
export function* updateCurrentUserUsernameService(data) {
const id = yield select(currentUserIdSelector);
yield call(updateUserUsernameService, id, data);
}
export function* clearUserUsernameUpdateErrorService(id) {
yield put(clearUserUsernameUpdateError(id));
}
export function* clearCurrentUserUsernameUpdateErrorService() {
const id = yield select(currentUserIdSelector);
yield call(clearUserUsernameUpdateErrorService, id);
}
export function* updateUserAvatarService(id, data) {
yield call(updateUserAvatarRequest, id, data);
}
export function* updateCurrentUserAvatarService(data) {
const id = yield select(currentUserIdSelector);
yield call(updateUserAvatarService, id, data);
}
export function* deleteUserService(id) {
yield put(deleteUser(id));
yield call(deleteUserRequest, id);
}
export function* addUserToCardService(id, cardId) {
const currentUserId = yield select(currentUserIdSelector);
yield put(addUserToCard(id, cardId, id === currentUserId));
yield call(createCardMembershipRequest, cardId, id);
}
export function* addUserToCurrentCardService(id) {
const { cardId } = yield select(pathSelector);
yield call(addUserToCardService, id, cardId);
}
export function* removeUserFromCardService(id, cardId) {
yield put(removeUserFromCard(id, cardId));
yield call(deleteCardMembershipRequest, cardId, id);
}
export function* removeUserFromCurrentCardService(id) {
const { cardId } = yield select(pathSelector);
yield call(removeUserFromCardService, id, cardId);
}
export function* addUserToBoardFilterService(id, boardId) {
yield put(addUserToBoardFilter(id, boardId));
}
export function* addUserToFilterInCurrentBoardService(id) {
const { boardId } = yield select(pathSelector);
yield call(addUserToBoardFilterService, id, boardId);
}
export function* removeUserFromBoardFilterService(id, boardId) {
yield put(removeUserFromBoardFilter(id, boardId));
}
export function* removeUserFromFilterInCurrentBoardService(id) {
const { boardId } = yield select(pathSelector);
yield call(removeUserFromBoardFilterService, id, boardId);
}