From 1534a47adc730def470515999ae45ca37845f508 Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Sun, 15 Jan 2023 10:45:41 -0800 Subject: [PATCH 1/3] Fixed the redirectbug with adding a new workspace --- frontend/components/basic/Layout.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/frontend/components/basic/Layout.tsx b/frontend/components/basic/Layout.tsx index de58a90fab..7246836bc1 100644 --- a/frontend/components/basic/Layout.tsx +++ b/frontend/components/basic/Layout.tsx @@ -43,8 +43,7 @@ const crypto = require("crypto"); export default function Layout({ children }: LayoutProps) { const router = useRouter(); - const [workspaceList, setWorkspaceList] = useState([]); - const [workspaceMapping, setWorkspaceMapping] = useState([{ "1": "2" }]); + const [workspaceMapping, setWorkspaceMapping] = useState[]>([]); const [workspaceSelected, setWorkspaceSelected] = useState("∞"); const [newWorkspaceName, setNewWorkspaceName] = useState(""); const [isOpen, setIsOpen] = useState(false); @@ -140,7 +139,11 @@ export default function Layout({ children }: LayoutProps) { } }); } - router.push("/dashboard/" + newWorkspaceId); + setWorkspaceMapping((prevState) => ({ + ...prevState, + [workspaceName]: newWorkspaceId + })) + setWorkspaceSelected(workspaceName); setIsOpen(false); setNewWorkspaceName(""); } else { @@ -227,9 +230,7 @@ export default function Layout({ children }: LayoutProps) { ) { router.push("/dashboard/" + userWorkspaces[0]._id); } else { - setWorkspaceList( - userWorkspaces.map((workspace: any) => workspace.name) - ); + console.log(99, Object.keys(workspaceMapping)) setWorkspaceMapping( Object.fromEntries( userWorkspaces.map((workspace: any) => [ @@ -297,11 +298,11 @@ export default function Layout({ children }: LayoutProps) {
{t("nav:menu.project")}
- {workspaceList.length > 0 ? ( + {Object.keys(workspaceMapping).length > 0 ? (
    - {workspaceList.length > 0 && + {Object.keys(workspaceMapping).length > 0 && menuItems.map(({ href, title, emoji }) => (
  • {router.asPath.split("/")[1] === href.split("/")[1] && From b1f7505f304b026ec73d3272f69be31fc3db5d6c Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Sun, 15 Jan 2023 13:31:57 -0800 Subject: [PATCH 2/3] Fixed the redirectbug with deleting a certain workspace --- frontend/components/basic/Layout.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/components/basic/Layout.tsx b/frontend/components/basic/Layout.tsx index 7246836bc1..76e6076aef 100644 --- a/frontend/components/basic/Layout.tsx +++ b/frontend/components/basic/Layout.tsx @@ -256,7 +256,7 @@ export default function Layout({ children }: LayoutProps) { }; putUserInWorkSpace(); onboardingCheck({ setTotalOnboardingActionsDone }); - }, []); + }, [router.query.id]); useEffect(() => { try { @@ -301,11 +301,10 @@ export default function Layout({ children }: LayoutProps) { {Object.keys(workspaceMapping).length > 0 ? ( ) : (