mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
saving node and showing dialog
This commit is contained in:
parent
95443635b4
commit
05980ce440
4 changed files with 14 additions and 6 deletions
|
@ -3,20 +3,27 @@ import { NODE_ACTIONS } from './constants';
|
|||
import { nodeSave, nodeSetSaveErrors } from './actions';
|
||||
import { postNode } from './api';
|
||||
import { reqWrapper } from '../auth/sagas';
|
||||
import { flowSetNodes } from '../flow/actions';
|
||||
import { ERRORS } from '~/constants/errors';
|
||||
import { modalSetShown } from '../modal/actions';
|
||||
|
||||
function* onNodeSave({ node }: ReturnType<typeof nodeSave>) {
|
||||
yield put(nodeSetSaveErrors({}));
|
||||
|
||||
const {
|
||||
data,
|
||||
data: { errors },
|
||||
data: { errors, node: result },
|
||||
} = yield call(reqWrapper, postNode, { node });
|
||||
|
||||
if (errors && Object.values(errors).length > 0) {
|
||||
return yield put(nodeSetSaveErrors(errors));
|
||||
}
|
||||
|
||||
console.log({ data, errors });
|
||||
if (!result || !result.id) {
|
||||
return yield put(nodeSetSaveErrors({ error: ERRORS.EMPTY_RESPONSE }));
|
||||
}
|
||||
|
||||
yield put(flowSetNodes({ [result.id]: result }));
|
||||
yield put(modalSetShown(false));
|
||||
}
|
||||
|
||||
export default function* nodeSaga() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue