Skip to content

Instantly share code, notes, and snippets.

@DScheglov
Last active December 26, 2017 14:11
Show Gist options
  • Save DScheglov/a4c456666c63cabe4a7eaa44b7ecd176 to your computer and use it in GitHub Desktop.
Save DScheglov/a4c456666c63cabe4a7eaa44b7ecd176 to your computer and use it in GitHub Desktop.
import { post } from '../api';
import * as urls from '../api/end-points';
import { logger } from '../logger';
import AC from './actions-registry';
export const saveSchema = (schemaName, schema) => async dispatch => {
const { res, err } = await post(urls.addSchema(), schema);
if (err) {
logger.error(err);
throw err;
}
logger.info({ res, err });
const schemaId = res.id;
const roleId = res.roles[0].id;
const taskId = res.tasks[0].id;
const ids = { schemaId, roleId, taskId };
logger.info(ids);
dispatch(AC.updateSchemaId(schemaName, ids));
return ids;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment