removed custome hook for loading state, becuase react-hook provide own state

This commit is contained in:
Pramod Mahajan 2025-07-09 16:04:39 +05:30
parent fca3f03a44
commit 710af87db1

View File

@ -32,7 +32,7 @@ const ProjectList = () => {
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT); const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
const [HasManageProject, setHasManageProject] = useState(HasManageProjectPermission); const [HasManageProject, setHasManageProject] = useState(HasManageProjectPermission);
const { mutate: createProject } = useCreateProject({ const { mutate: createProject,isPending } = useCreateProject({
onSuccessCallback: () => { onSuccessCallback: () => {
setShowModal(false); setShowModal(false);
}, },
@ -78,20 +78,14 @@ const ProjectList = () => {
if (!loading && projects) { if (!loading && projects) {
sortingProject(projects); sortingProject(projects);
} }
}, [projects, loading, selectedStatuses]); // Include selectedStatuses if it changes filtering }, [projects, loading, selectedStatuses]);
useEffect(() => { useEffect(() => {
setHasManageProject(loginUser ? HasManageProjectPermission : false); setHasManageProject(loginUser ? HasManageProjectPermission : false);
}, [loginUser, HasManageProjectPermission]); }, [loginUser, HasManageProjectPermission]);
const handleSubmitForm = (newProject, setLoading, reset) => { const handleSubmitForm = (newProject) => {
setLoading(true); createProject(newProject);
createProject(newProject, {
onSettled: () => {
setLoading(false);
reset();
},
});
}; };
const handleStatusChange = (statusId) => { const handleStatusChange = (statusId) => {
@ -140,6 +134,7 @@ const ProjectList = () => {
project={null} project={null}
handleSubmitForm={handleSubmitForm} handleSubmitForm={handleSubmitForm}
onClose={handleClose} onClose={handleClose}
isPending={isPending}
/> />
</GlobalModel> </GlobalModel>
)} )}