diff --git a/src/frontend/src/api/HomeService.ts b/src/frontend/src/api/HomeService.ts index bda9eccd0a..de3ece8b3d 100755 --- a/src/frontend/src/api/HomeService.ts +++ b/src/frontend/src/api/HomeService.ts @@ -10,7 +10,9 @@ export const HomeSummaryService: Function = (url: string) => { const fetchHomeSummaries = async (url) => { try { const fetchHomeData = await axios.get(url); - const resp: any = fetchHomeData.data; + const resp: any = fetchHomeData.data.results; + const paginationResp = fetchHomeData.data.pagination; + dispatch(HomeActions.SetHomeProjectPagination(paginationResp)); const fetchProjectCentroid = await axios.get(`${import.meta.env.VITE_API_URL}/projects/centroid/`); const projectCentroidResp: any = fetchProjectCentroid.data; const addedProjectCentroidOnSummary = resp.map((project) => { diff --git a/src/frontend/src/components/home/HomePageFilters.tsx b/src/frontend/src/components/home/HomePageFilters.tsx index 2918b9db6c..85fa0fa40b 100755 --- a/src/frontend/src/components/home/HomePageFilters.tsx +++ b/src/frontend/src/components/home/HomePageFilters.tsx @@ -12,6 +12,7 @@ const HomePageFilters = ({ onSearch, filteredProjectCount, totalProjectCount }) const defaultTheme: any = CoreModules.useAppSelector((state) => state.theme.hotTheme); const showMapStatus: boolean = CoreModules.useAppSelector((state) => state.home.showMapStatus); + const homeProjectPagination = CoreModules.useAppSelector((state) => state.home.homeProjectPagination); const { windowSize } = windowDimention(); const searchableInnerStyle: any = { @@ -141,7 +142,7 @@ const HomePageFilters = ({ onSearch, filteredProjectCount, totalProjectCount })

- Showing {filteredProjectCount} {filteredProjectCount > 1 ? 'projects' : 'project'} + Showing {filteredProjectCount} of {homeProjectPagination.total} projects

{/*
{ const defaultTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme); const showMapStatus = CoreModules.useAppSelector((state) => state.home.showMapStatus); + const homeProjectPagination = CoreModules.useAppSelector((state) => state.home.homeProjectPagination); // const state:any = CoreModules.useAppSelector(state=>state.project.projectData) // console.log('state main :',state) @@ -34,7 +35,8 @@ const Home = () => { const theme = CoreModules.useAppSelector((state) => state.theme.hotTheme); useEffect(() => { - dispatch(HomeSummaryService(`${import.meta.env.VITE_API_URL}/projects/summaries?skip=0&limit=100`)); + // dispatch(HomeSummaryService(`${import.meta.env.VITE_API_URL}/projects/summaries?skip=0&limit=100`)); + dispatch(HomeSummaryService(`${import.meta.env.VITE_API_URL}/projects/summaries?page=1&results_per_page=12`)); //creating a manual thunk that will make an API call then autamatically perform state mutation whenever we navigate to home page }, []); @@ -62,16 +64,39 @@ const Home = () => {
{filteredProjectCards.length > 0 ? (
-
- {filteredProjectCards.map((value, index) => ( - - ))} +
+
+ {filteredProjectCards.map((value, index) => ( + + ))} +
+
+
+ { + dispatch( + HomeSummaryService( + `${import.meta.env.VITE_API_URL}/projects/summaries?page=${page}&results_per_page=12`, + ), + ); + }} + />
) : (