refactor: patcher context
This commit is contained in:
parent
7ea9924f9f
commit
9206fc2851
3
packages/resource-persea/src/context/json-patcher.js
Normal file
3
packages/resource-persea/src/context/json-patcher.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
import {createContext} from '@flecks/react';
|
||||
|
||||
export default createContext(undefined);
|
|
@ -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,
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue
Block a user