diff --git a/frontend/src/components/drawers/WorkspaceDrawer.tsx b/frontend/src/components/drawers/WorkspaceDrawer.tsx index 924f44be..3b98cb25 100644 --- a/frontend/src/components/drawers/WorkspaceDrawer.tsx +++ b/frontend/src/components/drawers/WorkspaceDrawer.tsx @@ -16,7 +16,7 @@ import WorkspaceListPopover from "../popovers/WorkspaceListPopover"; import PeopleIcon from "@mui/icons-material/People"; import { selectWorkspace } from "../../store/workspaceSlice"; import { DRAWER_WIDTH, WorkspaceDrawerHeader } from "../layouts/WorkspaceLayout"; -import { useNavigate, useParams } from "react-router-dom"; +import { useLocation, useNavigate, useParams } from "react-router-dom"; interface WorkspaceDrawerProps { open: boolean; @@ -24,6 +24,7 @@ interface WorkspaceDrawerProps { function WorkspaceDrawer(props: WorkspaceDrawerProps) { const { open } = props; + const location = useLocation(); const params = useParams(); const navigate = useNavigate(); const workspaceStore = useSelector(selectWorkspace); @@ -31,8 +32,8 @@ function WorkspaceDrawer(props: WorkspaceDrawerProps) { (EventTarget & Element) | null >(null); const currentPage = useMemo(() => { - return window.location.href.split("/")[4] ?? "main"; - }, []); + return location.pathname.split("/")[2] ?? "main"; + }, [location.pathname]); const handleOpenWorkspacePopover: MouseEventHandler = (event) => { setWorkspaceListAnchorEl(event.currentTarget); diff --git a/frontend/src/components/layouts/WorkspaceLayout.tsx b/frontend/src/components/layouts/WorkspaceLayout.tsx index 1a0512c0..e1abac7d 100644 --- a/frontend/src/components/layouts/WorkspaceLayout.tsx +++ b/frontend/src/components/layouts/WorkspaceLayout.tsx @@ -1,9 +1,10 @@ -import * as React from "react"; import { styled } from "@mui/material/styles"; import Box from "@mui/material/Box"; import { Outlet } from "react-router-dom"; import WorkspaceHeader from "../headers/WorkspaceHeader"; import WorkspaceDrawer from "../drawers/WorkspaceDrawer"; +import { useDispatch, useSelector } from "react-redux"; +import { selectConfig, setDrawerOpen } from "../../store/configSlice"; export const DRAWER_WIDTH = 282; @@ -36,17 +37,18 @@ export const WorkspaceDrawerHeader = styled("div")(({ theme }) => ({ })); function WorkspaceLayout() { - const [open, setOpen] = React.useState(false); + const { drawerOpen } = useSelector(selectConfig); + const dispatch = useDispatch(); const handleDrawerOpen = () => { - setOpen((prev) => !prev); + dispatch(setDrawerOpen(!drawerOpen)); }; return ( - - -
+ + +
diff --git a/frontend/src/pages/workspace/Index.tsx b/frontend/src/pages/workspace/Index.tsx index 5d152e25..4a8ea6ee 100644 --- a/frontend/src/pages/workspace/Index.tsx +++ b/frontend/src/pages/workspace/Index.tsx @@ -42,14 +42,7 @@ function WorkspaceIndex() { }; return ( - + {workspace?.title}{" "} @@ -65,31 +58,38 @@ function WorkspaceIndex() { New Note - fetchNextPage()} - hasMore={hasNextPage} - loader={ - - - - } - useWindow={false} + - - - {documentList.map((document) => ( - - - - ))} - - - + fetchNextPage()} + hasMore={hasNextPage} + loader={ + + + + } + useWindow={false} + > + + + {documentList.map((document) => ( + + + + ))} + + + + ) => { state.theme = action.payload; }, + setDrawerOpen: (state, action: PayloadAction) => { + state.drawerOpen = action.payload; + }, }, }); -export const { setTheme } = configSlice.actions; +export const { setTheme, setDrawerOpen } = configSlice.actions; export const selectConfig = (state: RootState) => state.config;