tachybase_todo/packages/client/src/route-switch/RouteSwitchProvider.tsx
chenos 2fb019c392
feat: block templates (#240)
* feat: block templates

* feat: improve code

* feat: improve code

* feat: schema  settings for block templates

* feat: improve code

* feat: transition

* feat: transition
2022-03-17 09:41:48 +08:00

21 lines
710 B
TypeScript

import { Spin } from 'antd';
import React from 'react';
import { useRequest } from '../api-client';
import { RouteSwitchContext } from './context';
import { RouteSwitchProviderProps } from './types';
export function RouteSwitchProvider(props: RouteSwitchProviderProps) {
const { children, components, routes } = props;
return <RouteSwitchContext.Provider value={{ routes, components }}>{children}</RouteSwitchContext.Provider>;
}
export function RemoteRouteSwitchProvider(props: RouteSwitchProviderProps) {
const { data, loading } = useRequest({
url: 'uiRoutes:getAccessible',
});
if (loading) {
return <Spin />;
}
return <RouteSwitchProvider {...props} routes={data?.data || []} />;
}