- clean up
- origins
This commit is contained in:
1 parent
f6af594a8f
commit
5e345d20e5
8 files changed
+2104
-21
No files matched your search
@@ -8,17 +8,18 @@ export const useAPIService = (
|
||||
) => {
|
||||
// state
|
||||
const [state, setState] = useDefaultApiState();
|
||||
const {reload, wrapCall} = makeReloadAutomations(automationAPI, state, setState);
|
||||
|
||||
const { reload, wrapCall } = makeReloadAutomations(automationAPI, state, setState);
|
||||
|
||||
|
||||
// initial load of autos
|
||||
useEffect(() => {
|
||||
reload();
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
|
||||
return {
|
||||
state,
|
||||
removeAutomation: wrapCall(automationAPI.remove),
|
||||
updateAutomation: wrapCall(automationAPI.update),
|
||||
removeAutomation: wrapCall(automationAPI.remove),
|
||||
updateAutomation: wrapCall(automationAPI.update),
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,16 @@ import { AutomationData } from 'types/automations';
|
||||
import { makeAutomationAPI } from './automations';
|
||||
import { makeRemoteAPI } from "./base";
|
||||
import { useAPIService } from './core';
|
||||
import {useMockAPI} from "./mock";
|
||||
import { useMockAPI } from "./mock";
|
||||
|
||||
const locationPrefixWeb = window.location.pathname.match(/(.+)\/web/i);
|
||||
console.log(process.env)
|
||||
|
||||
export const useConnectedApiService = () => useAPIService(
|
||||
makeAutomationAPI(makeRemoteAPI(
|
||||
(!locationPrefixWeb ? '' : locationPrefixWeb[1]) + "/automations"
|
||||
process.env.NODE_ENV === 'development' ?
|
||||
"http://localhost:8000/automations" :
|
||||
(!locationPrefixWeb ? '' : locationPrefixWeb[1]) + "/automations"
|
||||
))
|
||||
);
|
||||
export const useMockApiService = (initialAutos: AutomationData[]) => useAPIService(
|
||||
|
||||
Reference in new issue
Block a user