Add project backgrounds

This commit is contained in:
Maksim Eltyshev
2020-05-26 00:46:04 +05:00
parent fb9ceb5db7
commit 2f7a244807
67 changed files with 774 additions and 210 deletions

View File

@@ -8,6 +8,9 @@ import {
deleteProjectFailed,
deleteProjectRequested,
deleteProjectSucceeded,
updateProjectBackgroundImageFailed,
updateProjectBackgroundImageRequested,
updateProjectBackgroundImageSucceeded,
updateProjectFailed,
updateProjectRequested,
updateProjectSucceeded,
@@ -65,6 +68,30 @@ export function* updateProjectRequest(id, data) {
}
}
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));

View File

@@ -107,7 +107,7 @@ export function* updateUserEmailRequest(id, data) {
try {
const { item } = yield call(request, api.updateUserEmail, id, data);
const action = updateUserEmailSucceeded(id, item);
const action = updateUserEmailSucceeded(item);
yield put(action);
return {
@@ -129,9 +129,9 @@ export function* updateUserPasswordRequest(id, data) {
yield put(updateUserPasswordRequested(id, data));
try {
yield call(request, api.updateUserPassword, id, data);
const { item } = yield call(request, api.updateUserPassword, id, data);
const action = updateUserPasswordSucceeded(id);
const action = updateUserPasswordSucceeded(item);
yield put(action);
return {
@@ -155,7 +155,7 @@ export function* updateUserUsernameRequest(id, data) {
try {
const { item } = yield call(request, api.updateUserUsername, id, data);
const action = updateUserUsernameSucceeded(id, item);
const action = updateUserUsernameSucceeded(item);
yield put(action);
return {
@@ -179,7 +179,7 @@ export function* updateUserAvatarRequest(id, data) {
try {
const { item } = yield call(request, api.updateUserAvatar, id, data);
const action = updateUserAvatarSucceeded(id, item);
const action = updateUserAvatarSucceeded(item);
yield put(action);
return {

View File

@@ -1,7 +1,12 @@
import { call, put, select } from 'redux-saga/effects';
import { goToProjectService, goToRootService } from './router';
import { createProjectRequest, deleteProjectRequest, updateProjectRequest } from '../requests';
import {
createProjectRequest,
deleteProjectRequest,
updateProjectBackgroundImageRequest,
updateProjectRequest,
} from '../requests';
import { pathSelector } from '../../../selectors';
import { createProject, deleteProject, updateProject } from '../../../actions';
@@ -29,6 +34,16 @@ export function* updateCurrentProjectService(data) {
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);

View File

@@ -3,6 +3,7 @@ import { all, takeLatest } from 'redux-saga/effects';
import {
createProjectService,
deleteCurrentProjectService,
updateCurrentProjectBackgroundImageService,
updateCurrentProjectService,
} from '../services';
import EntryActionTypes from '../../../constants/EntryActionTypes';
@@ -15,6 +16,9 @@ export default function* () {
takeLatest(EntryActionTypes.CURRENT_PROJECT_UPDATE, ({ payload: { data } }) =>
updateCurrentProjectService(data),
),
takeLatest(EntryActionTypes.CURRENT_PROJECT_BACKGROUND_IMAGE_UPDATE, ({ payload: { data } }) =>
updateCurrentProjectBackgroundImageService(data),
),
takeLatest(EntryActionTypes.CURRENT_PROJECT_DELETE, () => deleteCurrentProjectService()),
]);
}