diff --git a/src/components/common/Drawer/Drawer.tsx b/src/components/common/Drawer/Drawer.tsx index 1b2307e..ae87944 100644 --- a/src/components/common/Drawer/Drawer.tsx +++ b/src/components/common/Drawer/Drawer.tsx @@ -31,6 +31,7 @@ import { clearSemester, clearStudentName, } from 'src/redux/slices/filter'; +import { setOpen, setPinned } from 'src/redux/slices/drawer'; const drawerWidth = 240; @@ -94,14 +95,30 @@ export default function MiniDrawer() { dispatch(clearDepartment()); }; const theme = useTheme(); - const [open, setOpen] = React.useState(false); + + const pinned = useSelector((state) => state.drawer.pinned); + const open = useSelector((state) => state.drawer.open); + const drawerPinnedOff = () => dispatch(setPinned(false)); + const drawerPinnedOn = () => dispatch(setPinned(true)); + const drawerOpen = () => dispatch(setOpen(true)); + const drawerClose = () => dispatch(setOpen(false)); const handleDrawerOpen = () => { - setOpen(true); + drawerOpen(); }; const handleDrawerClose = () => { - setOpen(false); + if (!pinned) drawerClose(); + }; + + const handleDrawerPinOn = () => { + handleDrawerOpen(); + drawerPinnedOn(); + }; + + const handleDrawerPinOff = () => { + handleDrawerClose(); + drawerPinnedOff(); }; const linkConverter = (num) => { @@ -135,11 +152,11 @@ export default function MiniDrawer() { {/* 메뉴 아이콘과 제목을 가지고 있는 헤더 */} - + {/* 사이드바 */} - + {theme.direction === 'rtl' ? : } diff --git a/src/layouts/main/MainLayout.js b/src/layouts/main/MainLayout.js index 6bda86d..dac126f 100644 --- a/src/layouts/main/MainLayout.js +++ b/src/layouts/main/MainLayout.js @@ -7,6 +7,7 @@ import Header from 'src/components/common/Header'; // @mui import { Box } from '@mui/material'; import ExcelExport from 'src/components/excel/ExcelExport'; +import { useSelector } from 'react-redux'; // // const Header = dynamic(() => import('./Header'), { ssr: false }); @@ -19,25 +20,25 @@ MainLayout.propTypes = { }; export default function MainLayout({ children }) { - // const { pathname } = useRouter(); - - // const isHome = pathname === '/'; - return ( - +
- - - - {children} - - + + + + + + {children} + + + {/*