Last active
December 26, 2017 14:11
-
-
Save DScheglov/a4c456666c63cabe4a7eaa44b7ecd176 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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