2023-12-02 20:19:23 +00:00
|
|
|
import React, { useContext } from 'react';
|
2024-07-12 10:57:09 +00:00
|
|
|
import { MemoryRouter, BrowserRouter } from 'react-router-dom';
|
|
|
|
import { Box, Typography, styled } from '@mui/material';
|
2023-10-27 10:01:59 +00:00
|
|
|
import { type UseAppStoreType, AppContext, closeAll } from '../contexts/AppContext';
|
2022-10-20 18:06:16 +00:00
|
|
|
|
2024-07-12 10:57:09 +00:00
|
|
|
import { NavBar, MainDialogs } from './';
|
2022-10-30 19:13:01 +00:00
|
|
|
import RobotAvatar from '../components/RobotAvatar';
|
2023-10-27 10:01:59 +00:00
|
|
|
import Notifications from '../components/Notifications';
|
2022-10-20 18:06:16 +00:00
|
|
|
|
2022-11-07 16:45:05 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-10-27 11:00:53 +00:00
|
|
|
import { GarageContext, type UseGarageStoreType } from '../contexts/GarageContext';
|
2024-07-12 10:57:09 +00:00
|
|
|
import Routes from './Routes';
|
2022-10-22 14:32:33 +00:00
|
|
|
|
2023-04-16 18:10:48 +00:00
|
|
|
const Router = window.NativeRobosats === undefined ? BrowserRouter : MemoryRouter;
|
|
|
|
|
2023-04-23 19:03:38 +00:00
|
|
|
const TestnetTypography = styled(Typography)({
|
|
|
|
height: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
interface MainBoxProps {
|
|
|
|
navbarHeight: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
const MainBox = styled(Box)<MainBoxProps>((props) => ({
|
|
|
|
position: 'absolute',
|
|
|
|
top: '50%',
|
|
|
|
left: '50%',
|
|
|
|
transform: `translate(-50%, -50%) translate(0, -${props.navbarHeight / 2}em)`,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const Main: React.FC = () => {
|
2022-11-07 16:45:05 +00:00
|
|
|
const { t } = useTranslation();
|
2023-12-02 20:19:23 +00:00
|
|
|
const { settings, page, slideDirection, setOpen, windowSize, navbarHeight } =
|
2023-10-27 10:01:59 +00:00
|
|
|
useContext<UseAppStoreType>(AppContext);
|
|
|
|
const { garage } = useContext<UseGarageStoreType>(GarageContext);
|
2022-10-30 19:13:01 +00:00
|
|
|
|
2022-10-20 18:06:16 +00:00
|
|
|
return (
|
2023-04-16 18:10:48 +00:00
|
|
|
<Router>
|
2023-12-15 15:17:46 +00:00
|
|
|
<RobotAvatar style={{ display: 'none' }} hashId={garage.getSlot()?.hashId} />
|
2022-11-21 12:56:29 +00:00
|
|
|
<Notifications
|
|
|
|
page={page}
|
2023-05-09 00:37:23 +00:00
|
|
|
openProfile={() => {
|
|
|
|
setOpen({ ...closeAll, profile: true });
|
|
|
|
}}
|
2023-11-21 17:36:59 +00:00
|
|
|
rewards={garage.getSlot()?.getRobot()?.earnedRewards}
|
2023-10-27 10:01:59 +00:00
|
|
|
windowWidth={windowSize?.width}
|
2022-11-21 12:56:29 +00:00
|
|
|
/>
|
2022-11-07 16:45:05 +00:00
|
|
|
{settings.network === 'testnet' ? (
|
2023-04-23 19:03:38 +00:00
|
|
|
<TestnetTypography color='secondary' align='center'>
|
|
|
|
<i>{t('Using Testnet Bitcoin')}</i>
|
|
|
|
</TestnetTypography>
|
2022-11-07 16:45:05 +00:00
|
|
|
) : (
|
|
|
|
<></>
|
|
|
|
)}
|
|
|
|
|
2023-04-23 19:03:38 +00:00
|
|
|
<MainBox navbarHeight={navbarHeight}>
|
2024-07-12 10:57:09 +00:00
|
|
|
<Routes />
|
2023-04-23 19:03:38 +00:00
|
|
|
</MainBox>
|
2023-10-27 10:01:59 +00:00
|
|
|
<NavBar />
|
2023-03-02 11:01:06 +00:00
|
|
|
<MainDialogs />
|
2022-10-20 18:06:16 +00:00
|
|
|
</Router>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Main;
|