From d99e21a91b648766c561e7bfa59f9e0d12f28af1 Mon Sep 17 00:00:00 2001 From: Reginald Bondoc Date: Wed, 7 Dec 2022 22:20:25 +0100 Subject: [PATCH 1/2] Fix workspace type --- frontend/components/basic/Layout.tsx | 2 +- frontend/pages/api/workspace/getWorkspaces.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/components/basic/Layout.tsx b/frontend/components/basic/Layout.tsx index 9ba11a4362..4a40fdef08 100644 --- a/frontend/components/basic/Layout.tsx +++ b/frontend/components/basic/Layout.tsx @@ -67,7 +67,7 @@ export default function Layout({ children }: LayoutProps) { try { const workspaces = await getWorkspaces(); - const currentWorkspaces = (workspaces as unknown as any[]).map((workspace: any) => workspace.name); + const currentWorkspaces = workspaces.map((workspace) => workspace.name); if (!currentWorkspaces.includes(workspaceName)) { const newWorkspace = await createWorkspace({ workspaceName, diff --git a/frontend/pages/api/workspace/getWorkspaces.ts b/frontend/pages/api/workspace/getWorkspaces.ts index 33292b6eec..01e38b83d0 100644 --- a/frontend/pages/api/workspace/getWorkspaces.ts +++ b/frontend/pages/api/workspace/getWorkspaces.ts @@ -6,7 +6,6 @@ interface Workspaces { name: string; organization: string; } -[]; /** * This route lets us get the workspaces of a certain user @@ -20,7 +19,7 @@ const getWorkspaces = () => { }, }).then(async (res) => { if (res?.status == 200) { - const data = (await res.json()) as unknown as { workspaces: Workspaces }; + const data = (await res.json()) as unknown as { workspaces: Workspaces[] }; return data.workspaces; } From 1212b5a9dbfbead4b58b692d3f09b250cb868727 Mon Sep 17 00:00:00 2001 From: Reginald Bondoc Date: Wed, 7 Dec 2022 22:23:47 +0100 Subject: [PATCH 2/2] Change name --- frontend/pages/api/workspace/getWorkspaces.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/pages/api/workspace/getWorkspaces.ts b/frontend/pages/api/workspace/getWorkspaces.ts index 01e38b83d0..a77a04751b 100644 --- a/frontend/pages/api/workspace/getWorkspaces.ts +++ b/frontend/pages/api/workspace/getWorkspaces.ts @@ -1,6 +1,6 @@ import SecurityClient from "~/utilities/SecurityClient"; -interface Workspaces { +interface Workspace { __v: number; _id: string; name: string; @@ -19,7 +19,7 @@ const getWorkspaces = () => { }, }).then(async (res) => { if (res?.status == 200) { - const data = (await res.json()) as unknown as { workspaces: Workspaces[] }; + const data = (await res.json()) as unknown as { workspaces: Workspace[] }; return data.workspaces; }