Implemented issue drag and drop

This commit is contained in:
ireic
2019-12-14 01:20:54 +01:00
parent 73b4ff97b2
commit f48b2a9d40
17 changed files with 453 additions and 181 deletions

View File

@@ -14,6 +14,12 @@ const useApi = (method, url, paramsOrData = {}, { lazy = false } = {}) => {
variables: {},
});
const setLocalData = useCallback(
set => setState(currentState => ({ ...currentState, data: set(currentState.data) })),
[],
);
const updateState = newState => setState(currentState => ({ ...currentState, ...newState }));
const wasCalledRef = useRef(false);
const paramsOrDataMemoized = useDeepCompareMemoize(paramsOrData);
@@ -23,7 +29,6 @@ const useApi = (method, url, paramsOrData = {}, { lazy = false } = {}) => {
const makeRequest = useCallback(
(newVariables = {}) =>
new Promise((resolve, reject) => {
const updateState = newState => setState({ ...stateRef.current, ...newState });
const variables = { ...stateRef.current.variables, ...newVariables };
if (!isCalledAutomatically || wasCalledRef.current) {
@@ -57,6 +62,7 @@ const useApi = (method, url, paramsOrData = {}, { lazy = false } = {}) => {
...state,
wasCalled: wasCalledRef.current,
variables: { ...paramsOrDataMemoized, ...state.variables },
setLocalData,
},
makeRequest,
];