Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/frontend state api issues #1513

Merged
10 changes: 6 additions & 4 deletions src/frontend/src/components/DialogTaskActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ export default function Dialog({ taskId, feature, map, view }) {
const projectIndex = projectData.findIndex((project) => project.id == currentProjectId);
const currentStatus = {
...taskBoundaryData?.[projectIndex]?.taskBoundries?.filter((task) => {
return task.id == taskId;
return task?.index == taskId;
})?.[0],
};
const projectTaskActivityList = CoreModules.useAppSelector((state) => state?.project?.projectTaskActivity);

useEffect(() => {
if (taskId) {
dispatch(GetProjectTaskActivity(`${import.meta.env.VITE_API_URL}/tasks/${taskId}/history/?comment=false`));
dispatch(
GetProjectTaskActivity(`${import.meta.env.VITE_API_URL}/tasks/${currentStatus?.id}/history/?comment=false`),
);
}
}, [taskId]);

useEffect(() => {
if (taskInfo?.length === 0) return;
const currentTaskInfo = taskInfo?.filter((task) => taskId === task?.task_id);
const currentTaskInfo = taskInfo?.filter((task) => taskId == task?.index);
if (currentTaskInfo?.[0]) {
setCurrentTaskInfo(currentTaskInfo?.[0]);
}
Expand All @@ -70,7 +72,7 @@ export default function Dialog({ taskId, feature, map, view }) {
if (authDetailsCopy.hasOwnProperty('id')) {
dispatch(
ProjectTaskStatus(
`${import.meta.env.VITE_API_URL}/tasks/${taskId}/new-status/${status}`,
`${import.meta.env.VITE_API_URL}/tasks/${currentStatus?.id}/new-status/${status}`,
geoStyle,
taskBoundaryData,
currentProjectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ActivitiesPanel = ({ defaultTheme, state, params, map, view, mapDivPostion
let geojson = {};
const index = state.findIndex((project) => project.id == params.id);
if (index != -1) {
const taskIndex = state[index]?.taskBoundries.findIndex((task) => task.id == taskId);
const taskIndex = state[index]?.taskBoundries.findIndex((task) => task?.index == taskId);
if (index != -1) {
geojson = state[index]?.taskBoundries[taskIndex]?.outline_geojson;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const TaskSelectionPopup = ({ taskId, body, feature }: TaskSelectionPopupPropTyp
const authDetails = CoreModules.useAppSelector((state) => state.login.authDetails);
const selectedTask = {
...projectData?.[projectIndex]?.taskBoundries?.filter((indTask, i) => {
return indTask.id == taskId;
return indTask?.index == taskId;
})?.[0],
};
const checkIfTaskAssignedOrNot =
Expand All @@ -40,7 +40,7 @@ const TaskSelectionPopup = ({ taskId, body, feature }: TaskSelectionPopupPropTyp
if (projectIndex != -1) {
const currentStatus = {
...projectData[projectIndex].taskBoundries.filter((task) => {
return task.id == taskId;
return task?.index == taskId;
})[0],
};
const findCorrectTaskStatusIndex = environment.tasksStatus.findIndex(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ const SubmissionsTable = ({ toggleView }) => {
rowClassName="codeRow"
dataFormat={(row) => (
<div className="fmtm-w-[7rem] fmtm-overflow-hidden fmtm-truncate">
<span>{row?.__system?.reviewState ? camelToFlat(row?.__system?.reviewState) : '-'}</span>
<span>{row?.__system?.reviewState ? camelToFlat(row?.__system?.reviewState) : 'Recieved'}</span>
</div>
)}
/>
Expand Down Expand Up @@ -440,8 +440,8 @@ const SubmissionsTable = ({ toggleView }) => {
SubmissionActions.SetUpdateReviewStatusModal({
toggleModalStatus: true,
instanceId: row?.meta?.instanceID,
taskId: row?.phonenumber,
projectId: decodedId,
taskId: row?.all?.task_id,
projectId: projectId,
reviewState: row?.__system?.reviewState,
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const TaskSubmissionsMap = () => {
features: [
...projectTaskBoundries?.[0]?.taskBoundries?.map((task) => ({
...task.outline_geojson,
id: task.outline_geojson.properties.uid,
id: task?.outline_geojson?.properties?.fid,
})),
],
};
Expand All @@ -159,7 +159,7 @@ const TaskSubmissionsMap = () => {
if (!taskBoundaries) return;
const filteredSelectedTaskGeojson = {
...basicGeojsonTemplate,
features: taskBoundaries?.features?.filter((task) => task.properties.uid === selectedTask),
features: taskBoundaries?.features?.filter((task) => task?.properties?.fid === selectedTask),
};
const vectorSource = new VectorSource({
features: new GeoJSON().readFeatures(filteredSelectedTaskGeojson, {
Expand All @@ -168,7 +168,7 @@ const TaskSubmissionsMap = () => {
});
const extent = vectorSource.getExtent();

setDataExtractExtent(vectorSource.getFeatures()[0].getGeometry());
setDataExtractExtent(vectorSource.getFeatures()[0]?.getGeometry());
setDataExtractUrl(projectInfo.data_extract_url);

map.getView().fit(extent, {
Expand All @@ -184,7 +184,7 @@ const TaskSubmissionsMap = () => {
}, [selectedTask]);

const taskOnSelect = (properties, feature) => {
dispatch(CoreModules.TaskActions.SetSelectedTask(properties.uid));
dispatch(CoreModules.TaskActions.SetSelectedTask(properties?.fid));
};

const setChoropleth = useCallback(
Expand Down Expand Up @@ -216,7 +216,7 @@ const TaskSubmissionsMap = () => {
});

const taskSubmissionsPopupUI = (properties: taskFeaturePropertyType) => {
const currentTask = taskInfo?.filter((task) => +task.task_id === properties.uid);
const currentTask = taskInfo?.filter((task) => +task?.task_id === properties?.fid);
if (currentTask?.length === 0) return;
return (
<div className="fmtm-h-fit">
Expand Down Expand Up @@ -285,7 +285,7 @@ const TaskSubmissionsMap = () => {
collapsed={true}
/>
</div>
{taskInfo?.length > 0 && <AsyncPopup map={map} popupUI={taskSubmissionsPopupUI} />}
{taskInfo?.length > 0 && <AsyncPopup map={map} popupUI={taskSubmissionsPopupUI} primaryKey="fid" />}
{dataExtractUrl && isValidUrl(dataExtractUrl) && (
<VectorLayer fgbUrl={dataExtractUrl} fgbExtent={dataExtractExtent} zIndex={15} />
)}
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/utilities/CustomDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ export default function CustomDrawer({ open, placement, size, type, onClose, onS
ml={'3%'}
spacing={1}
>
{authDetails['img_url'] !== 'null' && authDetails['img_url'] ? (
{authDetails['profile_img'] !== 'null' && authDetails['profile_img'] ? (
<CoreModules.Stack
className="fmtm-w-7 fmtm-h-7 fmtm-flex fmtm-items-center fmtm-justify-center fmtm-overflow-hidden fmtm-rounded-full fmtm-border-[1px]"
sx={{ display: { xs: 'block', md: 'none' }, mt: '3%' }}
>
<img src={authDetails['img_url']} alt="Profile Picture" />
<img src={authDetails['profile_img']} alt="Profile Picture" />
</CoreModules.Stack>
) : (
<AssetModules.PersonIcon color="success" sx={{ display: { xs: 'block', md: 'none' }, mt: '1%' }} />
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/utilities/PrimaryAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ export default function PrimaryAppBar() {
alignItems="center"
className="fmtm-text-ellipsis fmtm-max-w-[9.5rem]"
>
{authDetails['img_url'] !== 'null' && authDetails['img_url'] ? (
{authDetails['profile_img'] !== 'null' && authDetails['profile_img'] ? (
<CoreModules.Stack
className="fmtm-w-7 fmtm-h-7 fmtm-flex fmtm-items-center fmtm-justify-center fmtm-overflow-hidden fmtm-rounded-full fmtm-border-[1px]"
sx={{ display: { xs: 'none', md: 'block' }, mt: '3%' }}
>
<img src={authDetails['img_url']} alt="Profile Picture" />
<img src={authDetails['profile_img']} alt="Profile Picture" />
</CoreModules.Stack>
) : (
<AssetModules.PersonIcon color="success" sx={{ mt: '3%' }} />
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/views/ProjectDetailsV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const Home = () => {
behavior: 'smooth',
});

dispatch(CoreModules.TaskActions.SetSelectedTask(properties.uid));
dispatch(CoreModules.TaskActions.SetSelectedTask(properties?.fid));
dispatch(ProjectActions.ToggleTaskModalStatus(true));

// Fit the map view to the clicked feature's extent based on the window size
Expand Down
8 changes: 7 additions & 1 deletion src/frontend/src/views/ProjectSubmissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SubmissionsInfographics from '@/components/ProjectSubmissions/Submissions
import SubmissionsTable from '@/components/ProjectSubmissions/SubmissionsTable.js';
import CoreModules from '@/shared/CoreModules';
import { ProjectActions } from '@/store/slices/ProjectSlice';
import { ProjectById } from '@/api/Project';
import { ProjectById, GetEntityInfo } from '@/api/Project';
import { GetProjectDashboard } from '@/api/Project';
import { useSearchParams } from 'react-router-dom';
import { projectInfoType } from '@/models/project/projectModel';
Expand Down Expand Up @@ -43,6 +43,12 @@ const ProjectSubmissions = () => {
dispatch(GetProjectDashboard(`${import.meta.env.VITE_API_URL}/projects/project_dashboard/${projectId}`));
}, []);

// for hot fix to diplay task-list and show option of task-list for submission table filter
// better solution needs to be researched
useEffect(() => {
dispatch(GetEntityInfo(`${import.meta.env.VITE_API_URL}/projects/${projectId}/entities/statuses`));
}, []);

useEffect(() => {
if (!searchParams.get('tab')) {
setSearchParams({ tab: 'infographics' });
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/views/SubmissionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const SubmissionDetails = () => {
SubmissionActions.SetUpdateReviewStatusModal({
toggleModalStatus: true,
instanceId: paramsInstanceId,
projectId: decodedProjectId,
projectId: projectId,
taskId: taskId,
reviewState: submissionDetails?.__system?.reviewState,
}),
Expand Down
Loading