diff --git a/src/frontend/src/components/ApproveOrganization/OrganizationForm.tsx b/src/frontend/src/components/ApproveOrganization/OrganizationForm.tsx index a0ecbfaf48..4b2d1a969d 100644 --- a/src/frontend/src/components/ApproveOrganization/OrganizationForm.tsx +++ b/src/frontend/src/components/ApproveOrganization/OrganizationForm.tsx @@ -9,22 +9,22 @@ import { GetIndividualOrganizationService, RejectOrganizationService, } from '@/api/OrganisationService'; -import CoreModules from '@/shared/CoreModules'; import { OrganisationAction } from '@/store/slices/organisationSlice'; +import { useAppSelector } from '@/types/reduxTypes'; const OrganizationForm = () => { const dispatch = useDispatch(); const params = useParams(); const navigate = useNavigate(); const organizationId = params.id; - const organisationFormData: any = CoreModules.useAppSelector((state) => state.organisation.organisationFormData); - const organizationApproving: any = CoreModules.useAppSelector( + const organisationFormData = useAppSelector((state) => state.organisation.organisationFormData); + const organizationApproving = useAppSelector( (state) => state.organisation.organizationApprovalStatus.organizationApproving, ); - const organizationRejecting: any = CoreModules.useAppSelector( + const organizationRejecting = useAppSelector( (state) => state.organisation.organizationApprovalStatus.organizationRejecting, ); - const organizationApprovalSuccess: any = CoreModules.useAppSelector( + const organizationApprovalSuccess = useAppSelector( (state) => state.organisation.organizationApprovalStatus.isSuccess, ); diff --git a/src/frontend/src/components/CreateEditOrganization/ConsentDetailsForm.tsx b/src/frontend/src/components/CreateEditOrganization/ConsentDetailsForm.tsx index 47bb4620da..cebc2f0f1c 100644 --- a/src/frontend/src/components/CreateEditOrganization/ConsentDetailsForm.tsx +++ b/src/frontend/src/components/CreateEditOrganization/ConsentDetailsForm.tsx @@ -1,21 +1,21 @@ -import React, { useState } from 'react'; +import React from 'react'; import { consentQuestions } from '@/constants/ConsentQuestions'; import { CustomCheckbox } from '@/components/common/Checkbox'; import RadioButton from '@/components/common/RadioButton'; import Button from '@/components/common/Button'; import useForm from '@/hooks/useForm'; -import CoreModules from '@/shared/CoreModules'; import ConsentDetailsValidation from '@/components/CreateEditOrganization/validation/ConsentDetailsValidation'; import { useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; import { OrganisationAction } from '@/store/slices/organisationSlice'; import InstructionsSidebar from '@/components/CreateEditOrganization/InstructionsSidebar'; +import { useAppSelector } from '@/types/reduxTypes'; const ConsentDetailsForm = () => { const navigate = useNavigate(); const dispatch = useDispatch(); - const consentDetailsFormData: any = CoreModules.useAppSelector((state) => state.organisation.consentDetailsFormData); + const consentDetailsFormData = useAppSelector((state) => state.organisation.consentDetailsFormData); const submission = () => { dispatch(OrganisationAction.SetConsentApproval(true)); diff --git a/src/frontend/src/components/CreateEditOrganization/CreateEditOrganizationForm.tsx b/src/frontend/src/components/CreateEditOrganization/CreateEditOrganizationForm.tsx index f86af4c15e..059d6847e3 100644 --- a/src/frontend/src/components/CreateEditOrganization/CreateEditOrganizationForm.tsx +++ b/src/frontend/src/components/CreateEditOrganization/CreateEditOrganizationForm.tsx @@ -18,14 +18,10 @@ import { import { diffObject } from '@/utilfunctions/compareUtils'; import InstructionsSidebar from '@/components/CreateEditOrganization/InstructionsSidebar'; import { CustomCheckbox } from '@/components/common/Checkbox'; +import { organizationTypeOptionsType } from '@/models/organisation/organisationModel'; +import { useAppSelector } from '@/types/reduxTypes'; -type optionsType = { - name: string; - value: string; - label: string; -}; - -const organizationTypeOptions: optionsType[] = [ +const organizationTypeOptions: organizationTypeOptionsType[] = [ { name: 'osm_community', value: 'osm_community', label: 'OSM Community' }, { name: 'company', value: 'company', label: 'Company' }, { name: 'non_profit', value: 'non_profit', label: 'Non-profit' }, @@ -33,16 +29,14 @@ const organizationTypeOptions: optionsType[] = [ { name: 'other', value: 'other', label: 'Other' }, ]; -const CreateEditOrganizationForm = ({ organizationId }) => { +const CreateEditOrganizationForm = ({ organizationId }: { organizationId: string }) => { const navigate = useNavigate(); const dispatch = useDispatch(); const [searchParams, setSearchParams] = useSearchParams(); const inputFileRef = useRef(null); - const organisationFormData: any = CoreModules.useAppSelector((state) => state.organisation.organisationFormData); - const postOrganisationDataLoading: boolean = CoreModules.useAppSelector( - (state) => state.organisation.postOrganisationDataLoading, - ); - const postOrganisationData: any = CoreModules.useAppSelector((state) => state.organisation.postOrganisationData); + const organisationFormData = useAppSelector((state) => state.organisation.organisationFormData); + const postOrganisationDataLoading = useAppSelector((state) => state.organisation.postOrganisationDataLoading); + const postOrganisationData = useAppSelector((state) => state.organisation.postOrganisationData); const [previewSource, setPreviewSource] = useState(''); const submission = () => { diff --git a/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx b/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx index a05a3168f0..538ea86261 100644 --- a/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx @@ -1,14 +1,12 @@ /* eslint-disable react/jsx-key */ import React, { useEffect, useState } from 'react'; import environment from '@/environment'; -import CoreModules from '@/shared/CoreModules'; import AssetModules from '@/shared/AssetModules'; -import { CustomSelect } from '@/components/common/Select'; -import profilePic from '@/assets/images/project_icon.png'; import { Feature } from 'ol'; import { Polygon } from 'ol/geom'; import { ActivitiesCardSkeletonLoader, ShowingCountSkeletonLoader } from '@/components/ProjectDetailsV2/SkeletonLoader'; import { taskHistoryListType } from '@/models/project/projectModel'; +import { useAppSelector } from '@/types/reduxTypes'; const sortByList = [ { id: 'activities', name: 'Activities' }, @@ -25,7 +23,7 @@ const ActivitiesPanel = ({ defaultTheme, state, params, map, view, mapDivPostion const [allActivities, setAllActivities] = useState(0); const [sortBy, setSortBy] = useState(null); const [showShortBy, setShowSortBy] = useState(false); - const projectDetailsLoading = CoreModules.useAppSelector((state) => state?.project?.projectDetailsLoading); + const projectDetailsLoading = useAppSelector((state) => state?.project?.projectDetailsLoading); const handleOnchange = (event) => { setSearchText(event.target.value); diff --git a/src/frontend/src/components/ProjectDetailsV2/MapControlComponent.tsx b/src/frontend/src/components/ProjectDetailsV2/MapControlComponent.tsx index 15f4c40c42..453794f563 100644 --- a/src/frontend/src/components/ProjectDetailsV2/MapControlComponent.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/MapControlComponent.tsx @@ -3,6 +3,7 @@ import AssetModules from '@/shared/AssetModules'; import VectorLayer from 'ol/layer/Vector'; import CoreModules from '@/shared/CoreModules.js'; import { ProjectActions } from '@/store/slices/ProjectSlice'; +import { useAppSelector } from '@/types/reduxTypes'; const MapControlComponent = ({ map }) => { const btnList = [ @@ -25,7 +26,7 @@ const MapControlComponent = ({ map }) => { ]; const dispatch = CoreModules.useAppDispatch(); const [toggleCurrentLoc, setToggleCurrentLoc] = useState(false); - const geolocationStatus = CoreModules.useAppSelector((state) => state.project.geolocationStatus); + const geolocationStatus = useAppSelector((state) => state.project.geolocationStatus); const handleOnClick = (btnId) => { if (btnId === 'add') { const actualZoom = map.getView().getZoom(); diff --git a/src/frontend/src/components/ProjectDetailsV2/MobileActivitiesContents.tsx b/src/frontend/src/components/ProjectDetailsV2/MobileActivitiesContents.tsx index cffe8e4c72..ba21bcb9bc 100644 --- a/src/frontend/src/components/ProjectDetailsV2/MobileActivitiesContents.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/MobileActivitiesContents.tsx @@ -1,11 +1,12 @@ import React from 'react'; import ActivitiesPanel from '@/components/ProjectDetailsV2/ActivitiesPanel'; import CoreModules from '@/shared/CoreModules'; +import { useAppSelector } from '@/types/reduxTypes'; const MobileActivitiesContents = ({ map, mainView, mapDivPostion }) => { const params = CoreModules.useParams(); - const state = CoreModules.useAppSelector((state) => state.project); - const defaultTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme); + const state = useAppSelector((state) => state.project); + const defaultTheme = useAppSelector((state) => state.theme.hotTheme); return (
diff --git a/src/frontend/src/components/ProjectDetailsV2/MobileFooter.tsx b/src/frontend/src/components/ProjectDetailsV2/MobileFooter.tsx index 0028a127da..4e3c280d75 100644 --- a/src/frontend/src/components/ProjectDetailsV2/MobileFooter.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/MobileFooter.tsx @@ -2,10 +2,11 @@ import React from 'react'; import AssetModules from '@/shared/AssetModules.js'; import CoreModules from '@/shared/CoreModules'; import { ProjectActions } from '@/store/slices/ProjectSlice'; +import { useAppSelector } from '@/types/reduxTypes'; const MobileFooter = () => { const dispatch = CoreModules.useAppDispatch(); - const mobileFooterSelection = CoreModules.useAppSelector((state) => state.project.mobileFooterSelection); + const mobileFooterSelection = useAppSelector((state) => state.project.mobileFooterSelection); const footerItem = [ { diff --git a/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx b/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx index ea1318329c..6193254cde 100644 --- a/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/ProjectInfo.tsx @@ -2,15 +2,16 @@ import React, { useEffect, useRef, useState } from 'react'; import AssetModules from '@/shared/AssetModules.js'; import ProjectIcon from '@/assets/images/project_icon.png'; import CoreModules from '@/shared/CoreModules'; +import { useAppSelector } from '@/types/reduxTypes'; const ProjectInfo = () => { const paraRef = useRef(null); const [seeMore, setSeeMore] = useState(false); const [descLines, setDescLines] = useState(1); - const projectInfo = CoreModules.useAppSelector((state) => state?.project?.projectInfo); - const projectDetailsLoading = CoreModules.useAppSelector((state) => state?.project?.projectDetailsLoading); - const projectDashboardDetail = CoreModules.useAppSelector((state) => state?.project?.projectDashboardDetail); - const projectDashboardLoading = CoreModules.useAppSelector((state) => state?.project?.projectDashboardLoading); + const projectInfo = useAppSelector((state) => state?.project?.projectInfo); + const projectDetailsLoading = useAppSelector((state) => state?.project?.projectDetailsLoading); + const projectDashboardDetail = useAppSelector((state) => state?.project?.projectDashboardDetail); + const projectDashboardLoading = useAppSelector((state) => state?.project?.projectDashboardLoading); useEffect(() => { if (paraRef.current) { diff --git a/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx b/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx index 8dddc937c1..a5856e49fd 100644 --- a/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx @@ -7,7 +7,7 @@ import { ProjectFilesById } from '@/api/Files'; import QrcodeComponent from '@/components/QrcodeComponent'; type TaskSectionPopupPropType = { - taskId: string | undefined | number; + taskId: number | null; body: React.JSX.Element; feature: any; }; diff --git a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx index ac18b32a15..de2e793dd4 100644 --- a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx +++ b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx @@ -18,9 +18,8 @@ import { ConvertXMLToJOSM, getDownloadProjectSubmission, getDownloadProjectSubmi import { Modal } from '@/components/common/Modal'; import { useNavigate, useSearchParams } from 'react-router-dom'; import filterParams from '@/utilfunctions/filterParams'; -import { downloadProjectFormLoadingType, projectInfoType } from '@/models/project/projectModel'; -import { submissionFormFieldsTypes } from '@/models/submission/submissionModel'; -import { taskInfoType } from '@/models/task/taskModel'; +import { projectInfoType } from '@/models/project/projectModel'; +import { useAppSelector } from '@/types/reduxTypes'; type filterType = { task_id: string | null; @@ -47,25 +46,15 @@ const SubmissionsTable = ({ toggleView }) => { const encodedId = params.projectId; const decodedId = environment.decode(encodedId); - const submissionFormFields: submissionFormFieldsTypes[] = CoreModules.useAppSelector( - (state) => state.submission.submissionFormFields, - ); - const submissionTableData: any = CoreModules.useAppSelector((state) => state.submission.submissionTableData); - const submissionFormFieldsLoading: boolean = CoreModules.useAppSelector( - (state) => state.submission.submissionFormFieldsLoading, - ); - const submissionTableDataLoading: boolean = CoreModules.useAppSelector( - (state) => state.submission.submissionTableDataLoading, - ); - const submissionTableRefreshing: boolean = CoreModules.useAppSelector( - (state) => state.submission.submissionTableRefreshing, - ); - const taskInfo: taskInfoType[] = CoreModules.useAppSelector((state) => state.task.taskInfo); + const submissionFormFields = useAppSelector((state) => state.submission.submissionFormFields); + const submissionTableData = useAppSelector((state) => state.submission.submissionTableData); + const submissionFormFieldsLoading = useAppSelector((state) => state.submission.submissionFormFieldsLoading); + const submissionTableDataLoading = useAppSelector((state) => state.submission.submissionTableDataLoading); + const submissionTableRefreshing = useAppSelector((state) => state.submission.submissionTableRefreshing); + const taskInfo = useAppSelector((state) => state.task.taskInfo); const projectInfo: projectInfoType = CoreModules.useAppSelector((state) => state.project.projectInfo); - const josmEditorError: string = CoreModules.useAppSelector((state) => state.task.josmEditorError); - const downloadSubmissionLoading: downloadProjectFormLoadingType = CoreModules.useAppSelector( - (state) => state.task.downloadSubmissionLoading, - ); + const josmEditorError = useAppSelector((state) => state.task.josmEditorError); + const downloadSubmissionLoading = useAppSelector((state) => state.task.downloadSubmissionLoading); const [numberOfFilters, setNumberOfFilters] = useState(0); const [paginationPage, setPaginationPage] = useState(1); const [submittedBy, setSubmittedBy] = useState(null); @@ -168,6 +157,7 @@ const SubmissionsTable = ({ toggleView }) => { e: React.ChangeEvent | React.KeyboardEvent, newPage: number, ) => { + if (!submissionTableData?.pagination?.pages) return; if (newPage + 1 > submissionTableData?.pagination?.pages || newPage + 1 < 1) { setPaginationPage(paginationPage); return; @@ -466,7 +456,7 @@ const SubmissionsTable = ({ toggleView }) => { { const dispatch = CoreModules.useAppDispatch(); const [searchParams, setSearchParams] = useSearchParams(); - const taskInfo: taskInfoType[] = CoreModules.useAppSelector((state) => state.task.taskInfo); - const taskLoading: boolean = CoreModules.useAppSelector((state) => state.task.taskLoading); - const [searchedTaskId, setSearchedTaskId] = useState(''); - const [debouncedSearchedTaskId, setDebouncedSearchedTaskId] = useState(''); + const taskInfo = useAppSelector((state) => state.task.taskInfo); + const taskLoading = useAppSelector((state) => state.task.taskLoading); + const [searchedTaskId, setSearchedTaskId] = useState(''); + const [debouncedSearchedTaskId, setDebouncedSearchedTaskId] = useState(''); const [filteredTaskInfo, setFilteredTaskInfo] = useState([]); const zoomToTask = (taskId) => { diff --git a/src/frontend/src/components/ProjectSubmissions/TaskSubmissionsMap.tsx b/src/frontend/src/components/ProjectSubmissions/TaskSubmissionsMap.tsx index c05e16f991..23c48e25be 100644 --- a/src/frontend/src/components/ProjectSubmissions/TaskSubmissionsMap.tsx +++ b/src/frontend/src/components/ProjectSubmissions/TaskSubmissionsMap.tsx @@ -25,6 +25,7 @@ import { } from '@/models/task/taskModel'; import { isValidUrl } from '@/utilfunctions/urlChecker'; import { projectInfoType, projectTaskBoundriesType } from '@/models/project/projectModel'; +import { useAppSelector } from '@/types/reduxTypes'; export const defaultStyles = { lineColor: '#000000', @@ -120,7 +121,7 @@ const TaskSubmissionsMap = () => { (state) => state.project.projectTaskBoundries, ); - const taskInfo: taskInfoType[] = CoreModules.useAppSelector((state) => state.task.taskInfo); + const taskInfo = useAppSelector((state) => state.task.taskInfo); const federalWiseProjectCount: federalWiseProjectCount[] = taskInfo?.map((task) => ({ code: task.task_id, count: task.submission_count, diff --git a/src/frontend/src/components/createnewproject/DataExtract.tsx b/src/frontend/src/components/createnewproject/DataExtract.tsx index 4b0a3b8bf3..1f2e0af938 100644 --- a/src/frontend/src/components/createnewproject/DataExtract.tsx +++ b/src/frontend/src/components/createnewproject/DataExtract.tsx @@ -166,8 +166,8 @@ const DataExtract = ({ flag, customLineUpload, setCustomLineUpload, customPolygo if (!file) return; // Parse file as JSON const fileReader = new FileReader(); - const fileLoaded = await new Promise((resolve) => { - fileReader.onload = (e) => resolve(e.target.result); + const fileLoaded: any = await new Promise((resolve) => { + fileReader.onload = (e) => resolve(e.target?.result); fileReader.readAsText(file, 'UTF-8'); }); const parsedJSON = JSON.parse(fileLoaded); diff --git a/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx b/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx index 066a7f462e..fae5aadd13 100644 --- a/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx +++ b/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx @@ -20,8 +20,8 @@ const ProjectDetailsForm = ({ flag }) => { const dispatch = useDispatch(); const navigate = useNavigate(); - const projectDetails: any = useAppSelector((state) => state.createproject.projectDetails); - const organisationListData: any = useAppSelector((state) => state.createproject.organisationList); + const projectDetails = useAppSelector((state) => state.createproject.projectDetails); + const organisationListData = useAppSelector((state) => state.createproject.organisationList); const organisationList: organizationDropdownType[] = organisationListData.map((item) => ({ label: item.name, value: item.id, diff --git a/src/frontend/src/components/createnewproject/SelectForm.tsx b/src/frontend/src/components/createnewproject/SelectForm.tsx index aeb9c081d9..a8f8b457d5 100644 --- a/src/frontend/src/components/createnewproject/SelectForm.tsx +++ b/src/frontend/src/components/createnewproject/SelectForm.tsx @@ -22,7 +22,7 @@ const SelectForm = ({ flag, geojsonFile, customFormFile, setCustomFormFile }) => const dispatch = useDispatch(); const navigate = useNavigate(); - const projectDetails: any = useAppSelector((state) => state.createproject.projectDetails); + const projectDetails = useAppSelector((state) => state.createproject.projectDetails); const drawnGeojson = useAppSelector((state) => state.createproject.drawnGeojson); const dataExtractGeojson = useAppSelector((state) => state.createproject.dataExtractGeojson); const customFileValidity = useAppSelector((state) => state.createproject.customFileValidity); diff --git a/src/frontend/src/components/createnewproject/UploadArea.tsx b/src/frontend/src/components/createnewproject/UploadArea.tsx index 871762f55f..668f6aa53f 100644 --- a/src/frontend/src/components/createnewproject/UploadArea.tsx +++ b/src/frontend/src/components/createnewproject/UploadArea.tsx @@ -37,7 +37,7 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se // const [uploadAreaFile, setUploadAreaFile] = useState(null); const [isGeojsonWGS84, setIsGeojsonWG84] = useState(true); - const projectDetails: any = useAppSelector((state) => state.createproject.projectDetails); + const projectDetails = useAppSelector((state) => state.createproject.projectDetails); const drawnGeojson = useAppSelector((state) => state.createproject.drawnGeojson); const uploadAreaSelection = useAppSelector((state) => state.createproject.uploadAreaSelection); const drawToggle = useAppSelector((state) => state.createproject.drawToggle); @@ -76,8 +76,8 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se const convertFileToGeojson = async (file) => { if (!file) return; const fileReader = new FileReader(); - const fileLoaded = await new Promise((resolve) => { - fileReader.onload = (e) => resolve(e.target.result); + const fileLoaded: any = await new Promise((resolve) => { + fileReader.onload = (e) => resolve(e.target?.result); fileReader.readAsText(file, 'UTF-8'); }); const parsedJSON = JSON.parse(fileLoaded); diff --git a/src/frontend/src/components/home/HomePageFilters.tsx b/src/frontend/src/components/home/HomePageFilters.tsx index 38b46869f4..e263690681 100755 --- a/src/frontend/src/components/home/HomePageFilters.tsx +++ b/src/frontend/src/components/home/HomePageFilters.tsx @@ -5,6 +5,7 @@ import AssetModules from '@/shared/AssetModules'; import Switch from '@/components/common/Switch'; import { HomeActions } from '@/store/slices/HomeSlice'; import { homeProjectPaginationTypes } from '@/models/home/homeModel'; +import { useAppSelector } from '@/types/reduxTypes'; type homePageFiltersPropType = { onSearch: (data: string) => void; @@ -17,11 +18,9 @@ const HomePageFilters = ({ onSearch, filteredProjectCount, totalProjectCount }: const [searchQuery, setSearchQuery] = useState(''); const dispatch = CoreModules.useAppDispatch(); - const defaultTheme: any = CoreModules.useAppSelector((state) => state.theme.hotTheme); - const showMapStatus: boolean = CoreModules.useAppSelector((state) => state.home.showMapStatus); - const homeProjectPagination: homeProjectPaginationTypes = CoreModules.useAppSelector( - (state) => state.home.homeProjectPagination, - ); + const defaultTheme: any = useAppSelector((state) => state.theme.hotTheme); + const showMapStatus = useAppSelector((state) => state.home.showMapStatus); + const homeProjectPagination = useAppSelector((state) => state.home.homeProjectPagination); const { windowSize } = windowDimention(); const searchableInnerStyle: any = { diff --git a/src/frontend/src/models/organisation/organisationModel.ts b/src/frontend/src/models/organisation/organisationModel.ts index 460b37697f..c6ca24fa7c 100644 --- a/src/frontend/src/models/organisation/organisationModel.ts +++ b/src/frontend/src/models/organisation/organisationModel.ts @@ -29,3 +29,9 @@ export interface GetOrganisationDataModel { url: string; approved: boolean; } + +export type organizationTypeOptionsType = { + name: string; + value: string; + label: string; +}; diff --git a/src/frontend/src/models/project/projectModel.ts b/src/frontend/src/models/project/projectModel.ts index 742581a0e6..d161211104 100644 --- a/src/frontend/src/models/project/projectModel.ts +++ b/src/frontend/src/models/project/projectModel.ts @@ -79,6 +79,7 @@ export type projectDashboardDetailTypes = { total_submission: number | null; total_contributors: number | null; last_active: string; + organisation: string; }; export type projectTaskBoundriesType = { diff --git a/src/frontend/src/models/submission/submissionModel.ts b/src/frontend/src/models/submission/submissionModel.ts index 049c0ff030..3d0d927974 100644 --- a/src/frontend/src/models/submission/submissionModel.ts +++ b/src/frontend/src/models/submission/submissionModel.ts @@ -27,3 +27,15 @@ export type taskDataTypes = { submission_count: number; task_count: number; }; + +export type submissionTableDataTypes = { + results: []; + pagination: { + total: number | null; + page: number | null; + prev_num: number | null; + next_num: number | null; + per_page: number | null; + pages: number | null; + }; +}; diff --git a/src/frontend/src/store/Store.ts b/src/frontend/src/store/Store.ts index 8a33f6dcfb..ff9dd6e6bb 100755 --- a/src/frontend/src/store/Store.ts +++ b/src/frontend/src/store/Store.ts @@ -24,7 +24,7 @@ export default function persist(key, whitelist, reducer) { } const rootReducer = combineReducers({ - project: persist('project', ['project', 'projectInfo'], ProjectSlice.reducer), + project: ProjectSlice.reducer, login: persist('login', ['loginToken', 'authDetails'], LoginSlice.reducer), //you can persist your auth reducer here similar to project reducer home: HomeSlice.reducer, diff --git a/src/frontend/src/store/slices/CommonSlice.ts b/src/frontend/src/store/slices/CommonSlice.ts index 7269cfd176..d6553c0f3e 100755 --- a/src/frontend/src/store/slices/CommonSlice.ts +++ b/src/frontend/src/store/slices/CommonSlice.ts @@ -1,4 +1,4 @@ -import CoreModules from '@/shared/CoreModules'; +import { createSlice } from '@reduxjs/toolkit'; import { CommonStateTypes } from '@/store/types/ICommon'; const initialState: CommonStateTypes = { @@ -17,7 +17,7 @@ const initialState: CommonStateTypes = { }, }; -const CommonSlice = CoreModules.createSlice({ +const CommonSlice = createSlice({ name: 'common', initialState: initialState, reducers: { diff --git a/src/frontend/src/store/slices/CreateProjectSlice.ts b/src/frontend/src/store/slices/CreateProjectSlice.ts index 8176633b0e..552f6066e7 100755 --- a/src/frontend/src/store/slices/CreateProjectSlice.ts +++ b/src/frontend/src/store/slices/CreateProjectSlice.ts @@ -40,7 +40,7 @@ export const initialState: CreateProjectStateTypes = { drawToggle: false, validateCustomFormLoading: false, validateCustomFormResponse: null, - uploadAreaSelection: null, + uploadAreaSelection: '', totalAreaSelection: null, splitTasksSelection: null, dataExtractGeojson: null, @@ -89,7 +89,7 @@ const CreateProject = createSlice({ state.generateProjectLog = null; state.generateProjectLogLoading = false; state.isUnsavedChanges = false; - state.uploadAreaSelection = null; + state.uploadAreaSelection = ''; state.dividedTaskGeojson = null; state.dividedTaskLoading = false; }, diff --git a/src/frontend/src/store/slices/HomeSlice.ts b/src/frontend/src/store/slices/HomeSlice.ts index 1cc344d8df..da1f348b48 100755 --- a/src/frontend/src/store/slices/HomeSlice.ts +++ b/src/frontend/src/store/slices/HomeSlice.ts @@ -1,7 +1,7 @@ -import CoreModules from '@/shared/CoreModules'; +import { createSlice } from '@reduxjs/toolkit'; import { HomeStateTypes } from '@/store/types/IHome'; -const initialState: HomeStateTypes = { +export const initialState: HomeStateTypes = { homeProjectSummary: [], homeProjectLoading: true, selectedProject: {}, @@ -26,7 +26,7 @@ const initialState: HomeStateTypes = { }, }; -const HomeSlice = CoreModules.createSlice({ +const HomeSlice = createSlice({ name: 'home', initialState: initialState, reducers: { diff --git a/src/frontend/src/store/slices/SubmissionSlice.ts b/src/frontend/src/store/slices/SubmissionSlice.ts index ce3053aad9..58d256fd0d 100644 --- a/src/frontend/src/store/slices/SubmissionSlice.ts +++ b/src/frontend/src/store/slices/SubmissionSlice.ts @@ -9,7 +9,17 @@ const initialState: SubmissionStateTypes = { submissionContributors: [], submissionContributorsLoading: true, submissionFormFields: [], - submissionTableData: [], + submissionTableData: { + results: [], + pagination: { + total: null, + page: null, + prev_num: null, + next_num: null, + per_page: null, + pages: null, + }, + }, submissionFormFieldsLoading: false, submissionTableDataLoading: false, submissionTableRefreshing: false, diff --git a/src/frontend/src/store/slices/ThemeSlice.ts b/src/frontend/src/store/slices/ThemeSlice.ts index 70051fcd2f..0fac18638d 100755 --- a/src/frontend/src/store/slices/ThemeSlice.ts +++ b/src/frontend/src/store/slices/ThemeSlice.ts @@ -1,6 +1,6 @@ -import CoreModules from '@/shared/CoreModules'; +import { createSlice } from '@reduxjs/toolkit'; -const ThemeSlice = CoreModules.createSlice({ +const ThemeSlice = createSlice({ name: 'theme', initialState: { hotTheme: { diff --git a/src/frontend/src/store/slices/organisationSlice.ts b/src/frontend/src/store/slices/organisationSlice.ts index cd98e10e2e..cd55bb55a6 100644 --- a/src/frontend/src/store/slices/organisationSlice.ts +++ b/src/frontend/src/store/slices/organisationSlice.ts @@ -1,7 +1,8 @@ -import CoreModules from '@/shared/CoreModules.js'; +// import CoreModules from '@/shared/CoreModules.js'; +import { createSlice } from '@reduxjs/toolkit'; import { IOrganisationState } from '../types/IOrganisation'; -const initialState: IOrganisationState = { +export const initialState: IOrganisationState = { organisationFormData: {}, organisationData: [], myOrganisationData: [], @@ -22,7 +23,7 @@ const initialState: IOrganisationState = { organizationRejecting: false, }, }; -const OrganisationSlice = CoreModules.createSlice({ +const OrganisationSlice = createSlice({ name: 'organisation', initialState: initialState, reducers: { diff --git a/src/frontend/src/store/types/ICreateProject.ts b/src/frontend/src/store/types/ICreateProject.ts index 23baca2266..95e345dede 100644 --- a/src/frontend/src/store/types/ICreateProject.ts +++ b/src/frontend/src/store/types/ICreateProject.ts @@ -7,7 +7,7 @@ export type CreateProjectStateTypes = { editProjectDetailsLoading: boolean; projectArea: ProjectAreaTypes | null; projectAreaLoading: boolean; - formCategoryList: FormCategoryListTypes | []; + formCategoryList: FormCategoryListTypes[] | []; formCategoryLoading: boolean; generateQrLoading: boolean; organisationList: OrganisationListTypes[]; @@ -26,10 +26,10 @@ export type CreateProjectStateTypes = { drawToggle: boolean; validateCustomFormLoading: boolean; validateCustomFormResponse: ValidateCustomFormResponse | null; - uploadAreaSelection: string | null; + uploadAreaSelection: string; totalAreaSelection: string | null; splitTasksSelection: string | null; - dataExtractGeojson: null; + dataExtractGeojson: GeoJSONFeatureTypes | null; createProjectValidations: {}; isUnsavedChanges: boolean; canSwitchCreateProjectSteps: boolean; @@ -135,6 +135,7 @@ export type OrganisationListTypes = { name: string; description: string; type: 1; + odk_central_url: string | null; }; export type GenerateProjectLogTypes = { diff --git a/src/frontend/src/store/types/IOrganisation.ts b/src/frontend/src/store/types/IOrganisation.ts index 9dc4f1d1e8..ac050bde9f 100644 --- a/src/frontend/src/store/types/IOrganisation.ts +++ b/src/frontend/src/store/types/IOrganisation.ts @@ -1,12 +1,12 @@ import { GetOrganisationDataModel } from '@/models/organisation/organisationModel'; export interface IOrganisationState { - organisationFormData: any; + organisationFormData: Record; organisationData: GetOrganisationDataModel[]; myOrganisationData: GetOrganisationDataModel[]; - postOrganisationData: any; - organisationDataLoading: Boolean; - postOrganisationDataLoading: Boolean; + postOrganisationData: Record | null; + organisationDataLoading: boolean; + postOrganisationDataLoading: boolean; myOrganisationDataLoading: false; consentDetailsFormData: { give_consent: any; @@ -14,10 +14,10 @@ export interface IOrganisationState { log_into: any; participated_in: any; }; - consentApproval: Boolean; + consentApproval: boolean; organizationApprovalStatus: { - isSuccess: Boolean; - organizationApproving: Boolean; - organizationRejecting: Boolean; + isSuccess: boolean; + organizationApproving: boolean; + organizationRejecting: boolean; }; } diff --git a/src/frontend/src/store/types/IProject.ts b/src/frontend/src/store/types/IProject.ts index 2066586325..53e3f345b0 100644 --- a/src/frontend/src/store/types/IProject.ts +++ b/src/frontend/src/store/types/IProject.ts @@ -9,7 +9,7 @@ export type ProjectStateTypes = { projectLoading: boolean; projectTaskBoundries: projectTaskBoundriesType[]; newProjectTrigger: boolean; - projectInfo: projectInfoType | {}; + projectInfo: projectInfoType | Record; projectSubmissionLoading: boolean; projectSubmission: []; projectDataExtractLoading: boolean; diff --git a/src/frontend/src/store/types/ISubmissions.ts b/src/frontend/src/store/types/ISubmissions.ts index d33f1d282e..ed48aa86e4 100644 --- a/src/frontend/src/store/types/ISubmissions.ts +++ b/src/frontend/src/store/types/ISubmissions.ts @@ -2,6 +2,7 @@ import { submissionContributorsTypes, submissionFormFieldsTypes, submissionInfographicsTypes, + submissionTableDataTypes, validatedVsMappedInfographicsTypes, } from '@/models/submission/submissionModel'; @@ -13,34 +14,10 @@ export type SubmissionStateTypes = { submissionContributors: submissionContributorsTypes[]; submissionContributorsLoading: boolean; submissionFormFields: submissionFormFieldsTypes[]; - submissionTableData: []; + submissionTableData: submissionTableDataTypes; submissionFormFieldsLoading: boolean; submissionTableDataLoading: boolean; submissionTableRefreshing: boolean; validatedVsMappedInfographics: validatedVsMappedInfographicsTypes[]; validatedVsMappedLoading: boolean; }; - -type submissionInfographicsTypes = { - date: string; - count: 1; -}; - -type submissionContributorsTypes = { - user: string; - contributions: number; -}; - -type submissionFormFieldsTypes = { - path: string; - name: string; - type: string; - binary: any; - selectMultiple: any; -}; - -type validatedVsMappedInfographicsTypes = { - date: string; - validated: number; - mapped: number; -}; diff --git a/src/frontend/src/views/CreateEditOrganization.tsx b/src/frontend/src/views/CreateEditOrganization.tsx index ff7c7b30e5..6b4146212b 100644 --- a/src/frontend/src/views/CreateEditOrganization.tsx +++ b/src/frontend/src/views/CreateEditOrganization.tsx @@ -5,12 +5,13 @@ import ConsentDetailsForm from '@/components/CreateEditOrganization/ConsentDetai import CreateEditOrganizationForm from '@/components/CreateEditOrganization/CreateEditOrganizationForm'; import { useDispatch } from 'react-redux'; import { OrganisationAction } from '@/store/slices/organisationSlice'; +import { useAppSelector } from '@/types/reduxTypes'; const CreateEditOrganization = () => { const params = CoreModules.useParams(); const dispatch = useDispatch(); - const organizationId = params.id; - const consentApproval: any = CoreModules.useAppSelector((state) => state.organisation.consentApproval); + const organizationId: string = params.id; + const consentApproval = useAppSelector((state) => state.organisation.consentApproval); useEffect(() => { // clear consent form on new org add diff --git a/src/frontend/src/views/CreateNewProject.tsx b/src/frontend/src/views/CreateNewProject.tsx index 3bdf163ee7..4307c8de4f 100644 --- a/src/frontend/src/views/CreateNewProject.tsx +++ b/src/frontend/src/views/CreateNewProject.tsx @@ -98,7 +98,6 @@ const CreateNewProject = () => { customLineUpload={customLineUpload} customPolygonUpload={customPolygonUpload} customFormFile={customFormFile} - dataExtractFile={dataExtractFile} /> ); default: diff --git a/src/frontend/src/views/CreateOrganisation.tsx b/src/frontend/src/views/CreateOrganisation.tsx index 81578c3f58..28563deb83 100644 --- a/src/frontend/src/views/CreateOrganisation.tsx +++ b/src/frontend/src/views/CreateOrganisation.tsx @@ -8,15 +8,16 @@ import OrganisationAddValidation from '@/components/organisation/Validation/Orga import { PostOrganisationDataService } from '@/api/OrganisationService'; import { useNavigate, useSearchParams } from 'react-router-dom'; import { OrganisationAction } from '@/store/slices/organisationSlice'; +import { useAppSelector } from '@/types/reduxTypes'; const CreateOrganisationForm = () => { const dispatch = CoreModules.useAppDispatch(); const navigate = useNavigate(); const [searchParams, setSearchParams] = useSearchParams(); - const defaultTheme: any = CoreModules.useAppSelector((state) => state.theme.hotTheme); - const postOrganisationData: any = CoreModules.useAppSelector((state) => state.organisation.postOrganisationData); + const defaultTheme: any = useAppSelector((state) => state.theme.hotTheme); + const postOrganisationData = useAppSelector((state) => state.organisation.postOrganisationData); - const organisationFormData: any = CoreModules.useAppSelector((state) => state.organisation.organisationFormData); + const organisationFormData = useAppSelector((state) => state.organisation.organisationFormData); const submission = () => { dispatch(PostOrganisationDataService(`${import.meta.env.VITE_API_URL}/organisation/`, values)); diff --git a/src/frontend/src/views/Home.tsx b/src/frontend/src/views/Home.tsx index b5a52b6673..77b1bfac2d 100755 --- a/src/frontend/src/views/Home.tsx +++ b/src/frontend/src/views/Home.tsx @@ -7,28 +7,26 @@ import ProjectCardSkeleton from '@/components/home/ProjectCardSkeleton'; import HomePageFilters from '@/components/home/HomePageFilters'; import CoreModules from '@/shared/CoreModules'; import ProjectListMap from '@/components/home/ProjectListMap'; -import { homeProjectPaginationTypes, projectType } from '@/models/home/homeModel'; -import { HomeStateTypes } from '@/store/types/IHome'; +import { projectType } from '@/models/home/homeModel'; +import { useAppSelector } from '@/types/reduxTypes'; const Home = () => { const dispatch = CoreModules.useAppDispatch(); const { type } = windowDimention(); - const [searchQuery, setSearchQuery] = useState(''); - const [debouncedSearch, setDebouncedSearch] = useState(''); - const [paginationPage, setPaginationPage] = useState(1); + const [searchQuery, setSearchQuery] = useState(''); + const [debouncedSearch, setDebouncedSearch] = useState(''); + const [paginationPage, setPaginationPage] = useState(1); - const defaultTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme); - const showMapStatus: boolean = CoreModules.useAppSelector((state) => state.home.showMapStatus); - const homeProjectPagination: homeProjectPaginationTypes = CoreModules.useAppSelector( - (state) => state.home.homeProjectPagination, - ); + const defaultTheme = useAppSelector((state) => state.theme.hotTheme); + const showMapStatus = useAppSelector((state) => state.home.showMapStatus); + const homeProjectPagination = useAppSelector((state) => state.home.homeProjectPagination); - const stateHome: HomeStateTypes = CoreModules.useAppSelector((state) => state.home); + const stateHome = useAppSelector((state) => state.home); //we use use selector from redux to get all state of home from home slice - const filteredProjectCards: projectType[] = stateHome.homeProjectSummary; + const filteredProjectCards = stateHome.homeProjectSummary; let cardsPerRow = new Array( type == 'xl' ? 7 : type == 'lg' ? 5 : type == 'md' ? 4 : type == 'sm' ? 3 : type == 's' ? 2 : 1, diff --git a/src/frontend/src/views/ManageProject.tsx b/src/frontend/src/views/ManageProject.tsx index f061e31663..f7b5221bb2 100644 --- a/src/frontend/src/views/ManageProject.tsx +++ b/src/frontend/src/views/ManageProject.tsx @@ -6,6 +6,7 @@ import CoreModules from '@/shared/CoreModules'; import environment from '@/environment'; import { GetIndividualProjectDetails } from '@/api/CreateProjectService'; import { useNavigate } from 'react-router-dom'; +import { useAppSelector } from '@/types/reduxTypes'; const tabList = [ { id: 'users', name: 'USERS', icon: }, @@ -18,7 +19,7 @@ const ManageProject = () => { const encodedProjectId = params.id; const decodedProjectId = environment.decode(encodedProjectId); const [tabView, setTabView] = useState<'users' | 'edit' | string>('users'); - const editProjectDetails: any = CoreModules.useAppSelector((state) => state.createproject.editProjectDetails); + const editProjectDetails = useAppSelector((state) => state.createproject.editProjectDetails); useEffect(() => { dispatch(GetIndividualProjectDetails(`${import.meta.env.VITE_API_URL}/projects/${decodedProjectId}`)); diff --git a/src/frontend/src/views/NewDefineAreaMap.tsx b/src/frontend/src/views/NewDefineAreaMap.tsx index 61b70fb753..8c1f7b76ea 100644 --- a/src/frontend/src/views/NewDefineAreaMap.tsx +++ b/src/frontend/src/views/NewDefineAreaMap.tsx @@ -3,14 +3,14 @@ import useOLMap from '@/hooks/useOlMap'; import { MapContainer as MapComponent } from '@/components/MapComponent/OpenLayersComponent'; import LayerSwitcherControl from '@/components/MapComponent/OpenLayersComponent/LayerSwitcher/index.js'; import { VectorLayer } from '@/components/MapComponent/OpenLayersComponent/Layers'; -import { GeoJSONFeatureTypes } from '@/store/types/ICreateProject'; +import { DrawnGeojsonTypes, GeoJSONFeatureTypes } from '@/store/types/ICreateProject'; import MapControlComponent from '@/components/createnewproject/MapControlComponent'; type NewDefineAreaMapProps = { drawToggle?: boolean; - splittedGeojson: GeoJSONFeatureTypes | null; - uploadedOrDrawnGeojsonFile: GeoJSONFeatureTypes; - buildingExtractedGeojson?: GeoJSONFeatureTypes; + splittedGeojson?: GeoJSONFeatureTypes | null; + uploadedOrDrawnGeojsonFile: DrawnGeojsonTypes | null; + buildingExtractedGeojson?: GeoJSONFeatureTypes | null; lineExtractedGeojson?: GeoJSONFeatureTypes; onDraw?: ((geojson: any, area: number) => void) | null; onModify?: ((geojson: any, area?: number) => void) | null; @@ -28,7 +28,7 @@ const NewDefineAreaMap = ({ hasEditUndo, getAOIArea, }: NewDefineAreaMapProps) => { - const { mapRef, map } = useOLMap({ + const { mapRef, map }: { mapRef: any; map: any } = useOLMap({ // center: fromLonLat([85.3, 27.7]), center: [0, 0], zoom: 1, diff --git a/src/frontend/src/views/Organisation.tsx b/src/frontend/src/views/Organisation.tsx index 501a8f7969..8f183dcf1f 100644 --- a/src/frontend/src/views/Organisation.tsx +++ b/src/frontend/src/views/Organisation.tsx @@ -5,12 +5,11 @@ import { MyOrganisationDataService, OrganisationDataService } from '@/api/Organi import { user_roles } from '@/types/enums'; import { GetOrganisationDataModel } from '@/models/organisation/organisationModel'; import OrganisationGridCard from '@/components/organisation/OrganisationGridCard'; -import { useNavigate } from 'react-router-dom'; import OrganisationCardSkeleton from '@/components/organisation/OrganizationCardSkeleton'; import windowDimention from '@/hooks/WindowDimension'; +import { useAppSelector } from '@/types/reduxTypes'; const Organisation = () => { - const navigate = useNavigate(); const dispatch = CoreModules.useAppDispatch(); //dispatch function to perform redux state mutation @@ -22,17 +21,13 @@ const Organisation = () => { const [verifiedTab, setVerifiedTab] = useState(true); const [myOrgsLoaded, setMyOrgsLoaded] = useState(false); const token = CoreModules.useAppSelector((state) => state.login.loginToken); - const defaultTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme); + const defaultTheme = useAppSelector((state) => state.theme.hotTheme); - const organisationData: GetOrganisationDataModel[] = CoreModules.useAppSelector( - (state) => state.organisation.organisationData, - ); - const myOrganisationData: GetOrganisationDataModel[] = CoreModules.useAppSelector( - (state) => state.organisation.myOrganisationData, - ); + const organisationData = useAppSelector((state) => state.organisation.organisationData); + const myOrganisationData = useAppSelector((state) => state.organisation.myOrganisationData); - const organisationDataLoading = CoreModules.useAppSelector((state) => state.organisation.organisationDataLoading); - const myOrganisationDataLoading = CoreModules.useAppSelector((state) => state.organisation.myOrganisationDataLoading); + const organisationDataLoading = useAppSelector((state) => state.organisation.organisationDataLoading); + const myOrganisationDataLoading = useAppSelector((state) => state.organisation.myOrganisationDataLoading); // loading states for the organisations from selector let cardsPerRow = new Array( @@ -43,7 +38,7 @@ const Organisation = () => { const handleSearchChange = (event) => { setSearchKeyword(event.target.value); }; - const filteredBySearch = (data, searchKeyword) => { + const filteredBySearch = (data: GetOrganisationDataModel[], searchKeyword: string) => { const filteredCardData: GetOrganisationDataModel[] = data?.filter((d) => d.name.toLowerCase().includes(searchKeyword.toLowerCase()), ); diff --git a/src/frontend/src/views/ProjectDetailsV2.tsx b/src/frontend/src/views/ProjectDetailsV2.tsx index 9bc1ea1667..5228f889aa 100644 --- a/src/frontend/src/views/ProjectDetailsV2.tsx +++ b/src/frontend/src/views/ProjectDetailsV2.tsx @@ -43,7 +43,7 @@ import ProjectInfo from '@/components/ProjectDetailsV2/ProjectInfo'; import useOutsideClick from '@/hooks/useOutsideClick'; import { dataExtractPropertyType } from '@/models/project/projectModel'; import { isValidUrl } from '@/utilfunctions/urlChecker'; -import { projectType, snackbarTypes } from '@/models/home/homeModel'; +import { useAppSelector } from '@/types/reduxTypes'; const Home = () => { const dispatch = CoreModules.useAppDispatch(); @@ -54,24 +54,28 @@ const Home = () => { const [mainView, setView] = useState(); const [featuresLayer, setFeaturesLayer] = useState(); + const [toggleGenerateModal, setToggleGenerateModal] = useState(false); const [dataExtractUrl, setDataExtractUrl] = useState(null); const [dataExtractExtent, setDataExtractExtent] = useState(null); const [taskBoundariesLayer, setTaskBoundariesLayer] = useState>(null); - const [currentCoordinate, setCurrentCoordinate] = useState({ latitude: null, longitude: null }); + const [currentCoordinate, setCurrentCoordinate] = useState<{ latitude: null | number; longitude: null | number }>({ + latitude: null, + longitude: null, + }); const [positionGeojson, setPositionGeojson] = useState(null); const [deviceRotation, setDeviceRotation] = useState(0); const [viewState, setViewState] = useState('project_info'); const encodedId: string = params.id; const decodedId: number = environment.decode(encodedId); - const defaultTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme); + const defaultTheme = useAppSelector((state) => state.theme.hotTheme); const state = CoreModules.useAppSelector((state) => state.project); - const projectInfo: projectType = CoreModules.useAppSelector((state) => state.home.selectedProject); - const selectedTask: number = CoreModules.useAppSelector((state) => state.task.selectedTask); - const stateSnackBar: snackbarTypes = CoreModules.useAppSelector((state) => state.home.snackbar); - const mobileFooterSelection: string = CoreModules.useAppSelector((state) => state.project.mobileFooterSelection); - const mapTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme); - const geolocationStatus: boolean = CoreModules.useAppSelector((state) => state.project.geolocationStatus); - const projectDetailsLoading: boolean = CoreModules.useAppSelector((state) => state?.project?.projectDetailsLoading); + const projectInfo = useAppSelector((state) => state.home.selectedProject); + const selectedTask = useAppSelector((state) => state.task.selectedTask); + const stateSnackBar = useAppSelector((state) => state.home.snackbar); + const mobileFooterSelection = useAppSelector((state) => state.project.mobileFooterSelection); + const mapTheme = useAppSelector((state) => state.theme.hotTheme); + const geolocationStatus = useAppSelector((state) => state.project.geolocationStatus); + const projectDetailsLoading = useAppSelector((state) => state?.project?.projectDetailsLoading); //snackbar handle close funtion const handleClose = (event, reason) => { @@ -87,6 +91,7 @@ const Home = () => { }), ); }; + //Fetch project for the first time useEffect(() => { dispatch(ProjectActions.SetNewProjectTrigger()); diff --git a/src/frontend/src/views/SubmissionDetails.tsx b/src/frontend/src/views/SubmissionDetails.tsx index 85c82e0cb9..c115a3ef13 100644 --- a/src/frontend/src/views/SubmissionDetails.tsx +++ b/src/frontend/src/views/SubmissionDetails.tsx @@ -2,6 +2,7 @@ import CoreModules from '@/shared/CoreModules.js'; import React, { useEffect } from 'react'; import environment from '@/environment'; import { SubmissionService } from '@/api/Submission'; +import { useAppSelector } from '@/types/reduxTypes'; const SubmissionDetails = () => { const dispatch = CoreModules.useAppDispatch(); @@ -12,7 +13,7 @@ const SubmissionDetails = () => { const decodedTaskId = environment.decode(encodedTaskId); const paramsInstanceId = params.instanceId; - const submissionDetails = CoreModules.useAppSelector((state) => state.submission.submissionDetails); + const submissionDetails = useAppSelector((state) => state.submission.submissionDetails); useEffect(() => { dispatch(