Explorar o código

Added checking on new project screen

jnfrati %!s(int64=4) %!d(string=hai) anos
pai
achega
4ef5b0b9af
Modificáronse 1 ficheiros con 10 adicións e 2 borrados
  1. 10 2
      dashboard/src/main/home/new-project/NewProject.tsx

+ 10 - 2
dashboard/src/main/home/new-project/NewProject.tsx

@@ -1,4 +1,4 @@
-import React, { useContext, useMemo, useState } from "react";
+import React, { useContext, useEffect, useMemo, useState } from "react";
 
 
 import { useRouting } from "shared/routing";
 import { useRouting } from "shared/routing";
 import api from "shared/api";
 import api from "shared/api";
@@ -22,12 +22,20 @@ type ValidationError = {
 };
 };
 
 
 export const NewProjectFC = () => {
 export const NewProjectFC = () => {
-  const { user, setProjects, setCurrentProject } = useContext(Context);
+  const { user, setProjects, setCurrentProject, canCreateProject } = useContext(
+    Context
+  );
   const { pushFiltered } = useRouting();
   const { pushFiltered } = useRouting();
   const [buttonStatus, setButtonStatus] = useState("");
   const [buttonStatus, setButtonStatus] = useState("");
   const [name, setName] = useState("");
   const [name, setName] = useState("");
   const { projects } = useContext(Context);
   const { projects } = useContext(Context);
 
 
+  useEffect(() => {
+    if (!canCreateProject) {
+      pushFiltered("/", []);
+    }
+  }, [canCreateProject]);
+
   const isFirstProject = useMemo(() => {
   const isFirstProject = useMemo(() => {
     return !(projects?.length >= 1);
     return !(projects?.length >= 1);
   }, [projects]);
   }, [projects]);