You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0KB

  1. import { Box, Typography, styled } from "@mui/material";
  2. import { Outlet } from "react-router-dom";
  3. import Navigator from "./navigator";
  4. import useResponsive from "hooks/useResponsive";
  5. import { useContext, useEffect, useMemo, useState } from "react";
  6. import Header from "./header";
  7. import useWindowSize from "hooks/useWindowSize";
  8. import {
  9. DashboardLayoutContext,
  10. DashboardLayoutContextProvider,
  11. } from "contexts/DashboardLayoutContext";
  12. import useDashboard from "hooks/useDashBoard";
  13. function Copyright() {
  14. return (
  15. <Typography variant="body2" color="text.secondary" align="center">
  16. {"Copyright ©Satellite-Technologies Co., Ltd."}
  17. {new Date().getFullYear()}. All Rights Reserved.
  18. </Typography>
  19. );
  20. }
  21. function App() {
  22. const [mobileOpen, setMobileOpen] = useState(false);
  23. const { drawerWidth, innerWidth, contentsWidth } = useDashboard();
  24. const handleDrawerToggle = () => {
  25. setMobileOpen(!mobileOpen);
  26. };
  27. return (
  28. <Box sx={{ display: "flex", minHeight: "100vh" }}>
  29. <Box
  30. component="nav"
  31. sx={{ width: { sm: drawerWidth }, flexShrink: { md: 0 } }}
  32. >
  33. <Navigator
  34. PaperProps={{ style: { width: drawerWidth } }}
  35. variant="temporary"
  36. open={mobileOpen}
  37. onClose={handleDrawerToggle}
  38. />
  39. <Navigator
  40. PaperProps={{ style: { width: drawerWidth } }}
  41. sx={{ display: { sm: "block", xs: "none" } }}
  42. />
  43. </Box>
  44. <Box
  45. sx={{
  46. flex: 1,
  47. display: "flex",
  48. flexDirection: "column",
  49. maxWidth: contentsWidth,
  50. }}
  51. >
  52. <Header onDrawerToggle={handleDrawerToggle} />
  53. <Box component="main" sx={{ flex: 1, pt: 1, pb: 6, px: 4 }}>
  54. <Outlet />
  55. </Box>
  56. <Box component="footer" sx={{ p: 2 }}>
  57. <Copyright />
  58. </Box>
  59. </Box>
  60. </Box>
  61. );
  62. }
  63. export default function DashBoardLayout() {
  64. return (
  65. <DashboardLayoutContextProvider>
  66. <App />
  67. </DashboardLayoutContextProvider>
  68. );
  69. }