@omegabigdata/honoplay-redux-helper
Version:
honoplay-redux-helper
77 lines (70 loc) • 2.1 kB
JavaScript
import {
CREATING_CONTENT_FILE,
CREATE_CONTENT_FILE_SUCCESS,
CREATE_CONTENT_FILE_FAILED,
UPDATING_CONTENT_FILE,
UPDATE_CONTENT_FILE_SUCCESS,
UPDATE_CONTENT_FILE_FAILED,
FETCHING_CONTENT_FILE_LIST,
FETCH_CONTENT_FILE_LIST_SUCCESS,
FETCH_CONTENT_FILE_LIST_FAILED,
FETCHING_CONTENT_FILE,
FETCH_CONTENT_FILE_SUCCESS,
FETCH_CONTENT_FILE_FAILED
} from '../helpers/ActionTypes/ContentFile';
import { ContentFile } from '@omegabigdata/honoplay-api-helper-node';
const createContentFile = contentFileModel => dispatch => {
dispatch({ type: CREATING_CONTENT_FILE });
ContentFile.postContentFile(
contentFileModel,
success => {
dispatch({ type: CREATE_CONTENT_FILE_SUCCESS, data: success.data });
},
error => {
dispatch({ type: CREATE_CONTENT_FILE_FAILED, data: { error } });
}
);
};
const updateContentFile = contentFileModel => dispatch => {
dispatch({ type: UPDATING_CONTENT_FILE });
ContentFile.putContentFile(
contentFileModel,
success => {
dispatch({ type: UPDATE_CONTENT_FILE_SUCCESS, data: success.data });
},
error => {
dispatch({ type: UPDATE_CONTENT_FILE_FAILED, data: { error } });
}
);
};
const fetchContentFileList = (skip = null, take = null) => dispatch => {
dispatch({ type: FETCHING_CONTENT_FILE_LIST });
ContentFile.getContentFiles(
skip,
take,
success => {
dispatch({ type: FETCH_CONTENT_FILE_LIST_SUCCESS, data: success.data });
},
error => {
dispatch({ type: FETCH_CONTENT_FILE_LIST_FAILED, data: { error } });
}
);
};
const fetchContentFile = contentFileId => dispatch => {
dispatch({ type: FETCHING_CONTENT_FILE });
ContentFile.getContentFile(
contentFileId,
success => {
dispatch({ type: FETCH_CONTENT_FILE_SUCCESS, data: success.data });
},
error => {
dispatch({ type: FETCH_CONTENT_FILE_FAILED, data: { error } });
}
);
};
export {
createContentFile,
updateContentFile,
fetchContentFileList,
fetchContentFile
};