v1 of loaded manager
This commit is contained in:
1 parent
a9c3e9c890
commit
96617e7b0c
17 files changed
+295
-88
No files matched your search
@@ -1,22 +1,24 @@
|
||||
import { AutomationData } from 'types/automations';
|
||||
import { makeAutomationAPI } from './automations';
|
||||
import { AutomationData } from "types/automations";
|
||||
import { makeAutomationAPI } from "./automations";
|
||||
import { makeRemoteAPI } from "./base";
|
||||
import { useAPIService } from './core';
|
||||
import { useAPIService } from "./core";
|
||||
import { useMockAPI } from "./mock";
|
||||
import { useRef } from "react";
|
||||
|
||||
const locationPrefixWeb = window.location.pathname.match(/(\/.+\/)web/i);
|
||||
const baseURL = new URL(
|
||||
process.env.NODE_ENV === 'development' ?
|
||||
`http://${window.location.hostname}:8000` :
|
||||
window.location.origin + (!locationPrefixWeb ? '' : locationPrefixWeb[1])
|
||||
);
|
||||
export const wsURL = baseURL + "socket"
|
||||
export const remoteAutoAPI = makeRemoteAPI(
|
||||
baseURL + "automations"
|
||||
);
|
||||
export const useConnectedApiService = () => useAPIService(
|
||||
makeAutomationAPI(remoteAutoAPI)
|
||||
);
|
||||
export const useMockApiService = (initialAutos: AutomationData[]) => useAPIService(
|
||||
makeAutomationAPI(useMockAPI(initialAutos))
|
||||
process.env.NODE_ENV === "development"
|
||||
? `http://${window.location.hostname}:8000`
|
||||
: window.location.origin + (!locationPrefixWeb ? "" : locationPrefixWeb[1])
|
||||
);
|
||||
export const wsURL = baseURL + "socket";
|
||||
export const remoteAutoAPI = makeRemoteAPI(baseURL + "automations");
|
||||
export const useConnectedApiService = () =>
|
||||
useAPIService(makeAutomationAPI(remoteAutoAPI));
|
||||
export const useMockApiService = (
|
||||
initialAutos: AutomationData[],
|
||||
returnErrors: boolean = false
|
||||
) =>
|
||||
useAPIService(
|
||||
makeAutomationAPI(useMockAPI(initialAutos, useRef, returnErrors))
|
||||
);
|
||||
Reference in new issue
Block a user