瀏覽代碼

POR-1714: properly redirect users to their first project if the project they attempt to route to is non-existent (#3648)

jose-fully-ported 2 年之前
父節點
當前提交
8e745c9362
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      dashboard/src/main/home/Home.tsx

+ 7 - 0
dashboard/src/main/home/Home.tsx

@@ -140,6 +140,13 @@ const Home: React.FC<Props> = (props) => {
             Number(localStorage.getItem("currentProject")) || projectList[0].id;
             Number(localStorage.getItem("currentProject")) || projectList[0].id;
         }
         }
 
 
+        const foundProjectListEntry = projectList.find(
+          (item: ProjectListType) => item.id === id
+        );
+        if (foundProjectListEntry === undefined) {
+          id = projectList[0].id
+        }
+
         const project = await api
         const project = await api
           .getProject("<token>", {}, { id: id })
           .getProject("<token>", {}, { id: id })
           .then((res) => res.data as ProjectType);
           .then((res) => res.data as ProjectType);