diff --git a/src/frontend/src/components/home/HomePageFilters.tsx b/src/frontend/src/components/home/HomePageFilters.tsx index 1ae6f2cf5f..66da25939e 100755 --- a/src/frontend/src/components/home/HomePageFilters.tsx +++ b/src/frontend/src/components/home/HomePageFilters.tsx @@ -106,7 +106,7 @@ const HomePageFilters = ({ onSearch, filteredProjectCount, totalProjectCount }) {/* Create New Project Button */}
-
+
PROJECTS
-
-
+
-
+
onSearch(e.target.value)} > diff --git a/src/frontend/src/views/Home.jsx b/src/frontend/src/views/Home.jsx index bf7d8c7d68..af219b1ccb 100755 --- a/src/frontend/src/views/Home.jsx +++ b/src/frontend/src/views/Home.jsx @@ -66,7 +66,7 @@ const Home = () => { className={`fmtm-px-[1rem] fmtm-grid fmtm-gap-5 ${ !showMapStatus ? 'fmtm-grid-cols-1 sm:fmtm-grid-cols-2 md:fmtm-grid-cols-3 lg:fmtm-grid-cols-4 xl:fmtm-grid-cols-5 2xl:fmtm-grid-cols-6' - : 'fmtm-grid-cols-1 sm:fmtm-grid-cols-2 md:fmtm-grid-cols-3 lg:fmtm-grid-cols-2 2xl:fmtm-grid-cols-3 lg:fmtm-h-[33rem] lg:fmtm-overflow-y-scroll lg:scrollbar fmtm-pr-1' + : 'fmtm-grid-cols-1 sm:fmtm-grid-cols-2 md:fmtm-grid-cols-3 lg:fmtm-grid-cols-2 2xl:fmtm-grid-cols-3 lg:fmtm-h-[33rem] lg:fmtm-overflow-y-scroll lg:scrollbar' }`} > {filteredProjectCards.map((value, index) => ( diff --git a/src/frontend/src/views/Organization.tsx b/src/frontend/src/views/Organization.tsx index c5edb3eabd..37bbe63b81 100644 --- a/src/frontend/src/views/Organization.tsx +++ b/src/frontend/src/views/Organization.tsx @@ -6,11 +6,6 @@ import { OrganizationDataService } from '../api/OrganizationService'; const Organization = () => { const cardStyle = { - width: { - xs: 350, - sm: 440, - lg: 862, - }, padding: 2, display: 'flex', flexDirection: 'row', @@ -42,17 +37,17 @@ const Organization = () => { return ( - - MANAGE ORGANIZATIONS + +

MANAGE ORGANIZATIONS

{ ), }} - sx={{ width: '20%' }} + className="fmtm-min-w-[14rem] lg:fmtm-w-[20%]" />
- + {filteredCardData?.map((data, index) => ( { sx={{ width: '150px' }} /> - + {data.name} {data.description} diff --git a/src/frontend/src/views/ProjectInfo.tsx b/src/frontend/src/views/ProjectInfo.tsx index 223a42212d..8d3732f1d5 100644 --- a/src/frontend/src/views/ProjectInfo.tsx +++ b/src/frontend/src/views/ProjectInfo.tsx @@ -9,6 +9,7 @@ import { ConvertXMLToJOSM, fetchConvertToOsmDetails, fetchInfoTask, getDownloadP import AssetModules from '../shared/AssetModules'; import { ProjectById } from '../api/Project'; import ProjectInfoCountCard from '../components/ProjectInfo/ProjectInfoCountCard'; +import { CommonActions } from '../store/slices/CommonSlice'; const boxStyles = { animation: 'blink 1s infinite', @@ -98,19 +99,62 @@ const ProjectInfo = () => { ); }; + // useEffect(() => { + // const fetchData = () => { + // dispatch(fetchInfoTask(`${environment.baseApiUrl}/tasks/tasks-features/?project_id=${decodedId}`)); + // }; + // fetchData(); + // let interval; + // if (isMonitoring) { + // interval = setInterval(fetchData, 3000); + // } else { + // clearInterval(interval); + // } + + // return () => clearInterval(interval); + // }, [dispatch, isMonitoring]); + useEffect(() => { const fetchData = () => { dispatch(fetchInfoTask(`${import.meta.env.VITE_API_URL}/tasks/tasks-features/?project_id=${decodedId}`)); }; fetchData(); - let interval; + }, []); + + useEffect(() => { + let isFetching = false; // Flag to track whether an API call is in progress + const fetchInfoTask = async (url) => { + if (!isFetching) { + isFetching = true; // Set the flag to true to indicate an API call is in progress + dispatch(CoreModules.TaskActions.SetTaskLoading(true)); + dispatch(CommonActions.SetLoading(true)); + try { + const fetchTaskInfoDetailsResponse = await CoreModules.axios.get(url); + dispatch(CommonActions.SetLoading(false)); + dispatch(CoreModules.TaskActions.SetTaskLoading(false)); + dispatch(CoreModules.TaskActions.FetchTaskInfoDetails(fetchTaskInfoDetailsResponse.data)); + } catch (error) { + dispatch(CommonActions.SetLoading(false)); + dispatch(CoreModules.TaskActions.SetTaskLoading(false)); + } finally { + isFetching = false; // Reset the flag after the API call is completed + } + } + }; + + const url = `${environment.baseApiUrl}/tasks/tasks-features/?project_id=${decodedId}`; + + let timeout; + const fetchData = () => { + fetchInfoTask(url); + timeout = setTimeout(fetchData, 3000); // Call fetchData again after 3 seconds + }; + if (isMonitoring) { - interval = setInterval(fetchData, 3000); - } else { - clearInterval(interval); + fetchData(); // Initial call to start fetching data } - - return () => clearInterval(interval); + // Cleanup: Clear any pending setTimeout when component is unmounted + return () => clearTimeout(timeout); }, [dispatch, isMonitoring]); const handleMonitoring = () => {