fix: projects editor to selected project editor, moved attributes editor
This commit is contained in:
		
							
								
								
									
										26
									
								
								src/hooks/useProjects.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/hooks/useProjects.tsx
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
import { useEffect, useState } from "react";
 | 
			
		||||
import { type FullProjectSchema, ProjectService } from "../client";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const useProjects = () => {
 | 
			
		||||
    const [projects, setProjects] = useState<FullProjectSchema[]>([]);
 | 
			
		||||
 | 
			
		||||
    const refetchProjects = () => {
 | 
			
		||||
        ProjectService.getProjects()
 | 
			
		||||
            .then(data => {
 | 
			
		||||
                setProjects(data.projects);
 | 
			
		||||
            })
 | 
			
		||||
            .catch(e => console.log(e));
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        refetchProjects();
 | 
			
		||||
    }, []);
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
        projects,
 | 
			
		||||
        refetchProjects,
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default useProjects;
 | 
			
		||||
		Reference in New Issue
	
	Block a user