lr_boilerplate/web/src/App.tsx

59 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-12-13 00:21:40 +07:00
import React, { useEffect } from 'react';
2023-12-26 22:48:59 +07:00
import { useSelector } from 'react-redux';
import { AppActions, RootState } from './store';
2023-12-11 23:38:52 +07:00
import { ToastContainer } from 'react-toastify';
import { Box } from 'lr-components';
import { NextUIProvider } from '@nextui-org/react';
2023-12-11 23:41:33 +07:00
import AppActionHook from './components/AppActionHook';
2023-12-13 00:21:40 +07:00
import { isEnvBrowser } from './utils/misc';
import { fetchNui } from './utils/fetchNui';
2023-12-11 23:38:52 +07:00
function App() {
2023-12-26 22:48:59 +07:00
const show = useSelector((state: RootState) => state.main.show);
2023-12-13 00:21:40 +07:00
useEffect(() => {
if (!isEnvBrowser()) {
setTimeout(() => {
fetchNui('AppReady');
}, 2000);
}
}, []);
2023-12-11 23:38:52 +07:00
return (
show && (
<NextUIProvider>
2023-12-26 22:48:59 +07:00
<Box
display='flex'
position='absolute'
flexWrap='wrap'
justifyContent='center'
alignItems='center'
flexDirection='column'
width={'50%'}
height={'50%'}
rGap={10}
>
{Object.keys(AppActions).map((action) => {
return (
<AppActionHook
action={action as keyof typeof AppActions}
></AppActionHook>
);
})}
</Box>
<Box
width={'100%'}
height={'100%'}
display='flex'
justifyContent='center'
alignItems='center'
className='prose'
pointerEvents='none'
></Box>
2023-12-11 23:38:52 +07:00
2023-12-26 22:48:59 +07:00
<ToastContainer pauseOnFocusLoss={false} hideProgressBar={true} />
2023-12-11 23:38:52 +07:00
</NextUIProvider>
)
);
}
export default App;