2021-08-14 02:11:16 +03:00
|
|
|
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';
|
2021-08-14 02:11:16 +03:00
|
|
|
|
|
|
|
const AppRoutes = () => {
|
|
|
|
const { push } = useHistory();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
window.name = 'grid';
|
|
|
|
|
2021-08-23 07:58:29 +03:00
|
|
|
const { fetchAllies, fetchCharges } = useDocketState.getState();
|
|
|
|
fetchCharges();
|
|
|
|
fetchAllies();
|
|
|
|
|
2021-08-14 02:11:16 +03:00
|
|
|
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>
|
2021-08-14 02:11:16 +03:00
|
|
|
);
|
|
|
|
}
|