refactor: patcher context

This commit is contained in:
cha0s 2022-03-20 13:55:25 -05:00
parent 7ea9924f9f
commit 9206fc2851
3 changed files with 9 additions and 7 deletions

View File

@ -0,0 +1,3 @@
import {createContext} from '@flecks/react';
export default createContext(undefined);

View File

@ -1,18 +1,15 @@
import {useParams} from '@flecks/react/router';
import {useContext} from '@flecks/react';
import {useDispatch} from '@flecks/redux';
import {compare} from 'fast-json-patch';
import Context from '../context/json-patcher';
import {patchJsonResource} from '../state/json';
export default () => {
const dispatch = useDispatch();
const {uri, uuid} = useParams();
const {uri, uuid} = useContext(Context);
const patch = (opOrOps) => {
const patch = (
Array.isArray(opOrOps)
? opOrOps
: [opOrOps]
)
const patch = Array.isArray(opOrOps) ? opOrOps : [opOrOps]
.map((op) => ({
op: 'replace',
...op,

View File

@ -9,6 +9,8 @@ import reducer from './state/reducer';
export {default as JsonTabs} from './components/json-tabs';
export {default as Resource} from './components/resource';
export {default as Context} from './context/json-patcher';
export {default as useFullJson} from './hooks/use-full-json';
export {default as useJsonPatcher} from './hooks/use-json-patcher';
export {default as useResourceController} from './hooks/use-resource-controller';