Use new UI (#8983)

* fixup build

* swap frontends
This commit is contained in:
Blake Blackshear
2023-12-16 16:20:59 +00:00
parent a2c6f45454
commit bdebb99b5a
286 changed files with 20010 additions and 20007 deletions

33
web-old/src/api/index.jsx Normal file
View File

@@ -0,0 +1,33 @@
import { h } from 'preact';
import { baseUrl } from './baseUrl';
import useSWR, { SWRConfig } from 'swr';
import { WsProvider } from './ws';
import axios from 'axios';
axios.defaults.baseURL = `${baseUrl}api/`;
axios.defaults.headers.common = {
'X-CSRF-TOKEN': 1,
'X-CACHE-BYPASS': 1,
};
export function ApiProvider({ children, options }) {
return (
<SWRConfig
value={{
fetcher: (path, params) => axios.get(path, { params }).then((res) => res.data),
...options,
}}
>
<WsWithConfig>{children}</WsWithConfig>
</SWRConfig>
);
}
function WsWithConfig({ children }) {
const { data } = useSWR('config');
return data ? <WsProvider config={data}>{children}</WsProvider> : children;
}
export function useApiHost() {
return baseUrl;
}