You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
749 B
34 lines
749 B
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
|
import { set } from '../baseActions';
|
|
|
|
function createFetchSchemaHandler(section, url) {
|
|
return function(getState, payload, dispatch) {
|
|
dispatch(set({ section, isSchemaFetching: true }));
|
|
|
|
const promise = createAjaxRequest({
|
|
url
|
|
}).request;
|
|
|
|
promise.done((data) => {
|
|
dispatch(set({
|
|
section,
|
|
isSchemaFetching: false,
|
|
isSchemaPopulated: true,
|
|
schemaError: null,
|
|
schema: data
|
|
}));
|
|
});
|
|
|
|
promise.fail((xhr) => {
|
|
dispatch(set({
|
|
section,
|
|
isSchemaFetching: false,
|
|
isSchemaPopulated: true,
|
|
schemaError: xhr
|
|
}));
|
|
});
|
|
};
|
|
}
|
|
|
|
export default createFetchSchemaHandler;
|