Skip to content

Commit

Permalink
fix(frontend): submission map chloropeth updating (#1716)
Browse files Browse the repository at this point in the history
* fix(taskSubmissionsMap): change taskId accessor key to fid

* fix(taskSubmission): update name to appropriate names
  • Loading branch information
NSUWAL123 authored Jul 29, 2024
1 parent ff8175c commit ef2a4a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ import GeoJSON from 'ol/format/GeoJSON';
import { get } from 'ol/proj';
import environment from '@/environment';
import { getStyles } from '@/components/MapComponent/OpenLayersComponent/helpers/styleUtils';
import { ProjectActions } from '@/store/slices/ProjectSlice';
import { basicGeojsonTemplate } from '@/utilities/mapUtils';
import TaskSubmissionsMapLegend from '@/components/ProjectSubmissions/TaskSubmissionsMapLegend';
import Accordion from '@/components/common/Accordion';
import AsyncPopup from '@/components/MapComponent/OpenLayersComponent/AsyncPopup/AsyncPopup';
import {
colorCodesType,
federalWiseProjectCount,
taskWiseSubmissionCount,
legendColorArrayType,
taskBoundariesType,
taskFeaturePropertyType,
taskSubmissionInfoType,
} from '@/models/task/taskModel';
import { isValidUrl } from '@/utilfunctions/urlChecker';
import { projectInfoType, projectTaskBoundriesType } from '@/models/project/projectModel';
Expand Down Expand Up @@ -122,13 +120,13 @@ const TaskSubmissionsMap = () => {
);

const taskInfo = useAppSelector((state) => state.task.taskInfo);
const federalWiseProjectCount: federalWiseProjectCount[] = taskInfo?.map((task) => ({
const taskWiseSubmissionCount: taskWiseSubmissionCount[] = taskInfo?.map((task) => ({
code: task.task_id,
count: task.submission_count,
}));

const selectedTask: number = CoreModules.useAppSelector((state) => state.task.selectedTask);
const legendColorArray: legendColorArrayType[] = colorRange(federalWiseProjectCount, '4');
const legendColorArray: legendColorArrayType[] = colorRange(taskWiseSubmissionCount, '4');
const { mapRef, map } = useOLMap({
center: [0, 0],
zoom: 4,
Expand Down Expand Up @@ -191,21 +189,19 @@ const TaskSubmissionsMap = () => {
(style, feature, resolution) => {
const stylex = { ...style };
stylex.fillOpacity = 80;
const getFederal = federalWiseProjectCount?.find((d) => d.code == feature.getProperties().uid);
const getFederalCount = getFederal?.count;
const getTask = taskWiseSubmissionCount?.find((d) => d.code == feature.getProperties().fid);
const getTaskSubmissionCount = getTask?.count;
stylex.labelMaxResolution = 1000;
stylex.showLabel = true;
// stylex.labelField = 'district_code';
// stylex.customLabelText = getFederalName;
const choroplethColor = getChoroplethColor(getFederalCount, legendColorArray);
const choroplethColor = getChoroplethColor(getTaskSubmissionCount, legendColorArray);
stylex.fillColor = choroplethColor;
return getStyles({
style: stylex,
feature,
resolution,
});
},
[federalWiseProjectCount],
[taskWiseSubmissionCount],
);

map?.on('loadstart', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/models/task/taskModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type taskFeaturePropertyType = {
uid: number;
};

export type federalWiseProjectCount = {
export type taskWiseSubmissionCount = {
code: string;
count: number;
};
Expand Down

0 comments on commit ef2a4a5

Please sign in to comment.