1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/client/src/sagas/app/services/attachment.js
2020-04-21 05:44:12 +05:00

40 lines
1.1 KiB
JavaScript

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);
}