shrub/pkg/grid/src/app.tsx

38 lines
855 B
TypeScript
Raw Normal View History

import React, { useEffect } from 'react';
import Mousetrap from 'mousetrap';
import { BrowserRouter, Switch, Route, useHistory } from 'react-router-dom';
import { Grid } from './pages/Grid';
2021-08-23 07:58:29 +03:00
import useDocketState from './state/docket';
const AppRoutes = () => {
const { push } = useHistory();
useEffect(() => {
window.name = 'grid';
2021-08-23 07:58:29 +03:00
const { fetchAllies, fetchCharges } = useDocketState.getState();
fetchCharges();
fetchAllies();
Mousetrap.bind(['command+/', 'ctrl+/'], () => {
push('/leap/search');
});
}, []);
return (
<Switch>
<Route path={['/leap/:menu', '/']} component={Grid} />
</Switch>
);
};
export function App() {
const base = import.meta.env.MODE === 'mock' ? undefined : '/apps/grid';
return (
2021-08-19 06:08:05 +03:00
<BrowserRouter basename={base}>
<AppRoutes />
</BrowserRouter>
);
}