Skip to content

Commit

Permalink
Fix/task history tab order (#1514)
Browse files Browse the repository at this point in the history
* fix(customDrawer/primaryAppBar): replace img_url key with profile_img key to display profile picture

* fix(taskSubmissionMap): replace comparision with taskId with task index

* fix(submissionDetails): replace decodedProjectId with projectId

* fix(submissionDetails): replace decodedProjectId with projectId & show recieved status by defualt if no reviewState

* fix(projectSubmissions): statuses endpoint fetch to display taskList and display taskList options

* fix(taskSubmission): replace uid with fid

* fix(projectDetailsV2): order taskHistory tab to first & defult show taskHistory tab on task click

* fix(taskSelectionPopup): use task index instead of taskId

* fix(dialogTaskActions): use taskId instead of task index on api fetch, post

* fix(activitiesPanel): zoom to task using taskIndex

* fix(projectModel): add index type to taskBoudriesTypes

* fix(comments): use taskId instead of index for get & post api
  • Loading branch information
NSUWAL123 authored May 9, 2024
1 parent 237846b commit 820e813
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
20 changes: 14 additions & 6 deletions src/frontend/src/components/ProjectDetailsV2/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,26 @@ import { CommonActions } from '@/store/slices/CommonSlice';
const Comments = () => {
const dispatch = useDispatch();
const params = useParams();
const projectId: any = params.id;

const [comment, setComment] = useState('');
const [isEditorEmpty, setIsEditorEmpty] = useState(true);
const projectCommentsList = useAppSelector((state) => state?.project?.projectCommentsList);
const projectGetCommentsLoading = useAppSelector((state) => state?.project?.projectGetCommentsLoading);
const projectPostCommentsLoading = useAppSelector((state) => state?.project?.projectPostCommentsLoading);
const selectedTask = useAppSelector((state) => state.task.selectedTask);

const projectId = params.id;
const projectData = useAppSelector((state) => state.project.projectTaskBoundries);
const projectIndex = projectData.findIndex((project) => project.id == +projectId);
const taskBoundaryData = useAppSelector((state) => state.project.projectTaskBoundries);
const currentStatus = {
...taskBoundaryData?.[projectIndex]?.taskBoundries?.filter((task) => {
return task?.index == selectedTask;
})?.[0],
};

useEffect(() => {
dispatch(GetProjectComments(`${import.meta.env.VITE_API_URL}/tasks/${selectedTask}/history/?comment=true`));
}, [selectedTask, projectId]);
dispatch(GetProjectComments(`${import.meta.env.VITE_API_URL}/tasks/${currentStatus?.id}/history/?comment=true`));
}, [selectedTask, projectId, currentStatus?.id]);

const clearComment = () => {
dispatch(ProjectActions.ClearEditorContent(true));
Expand All @@ -44,8 +52,8 @@ const Comments = () => {
return;
}
dispatch(
PostProjectComments(`${import.meta.env.VITE_API_URL}/tasks/task-comments/`, {
task_id: selectedTask,
PostProjectComments(`${import.meta.env.VITE_API_URL}/tasks/task-comments/?project_id=${projectId}`, {
task_id: currentStatus?.id,
project_id: projectId,
comment,
}),
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/models/project/projectModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export type taskBoundriesTypes = {
};
task_history: taskHistoryTypes[];
task_status: string;
index: number;
};

export type taskBoundriesGeojson = {
Expand Down
14 changes: 7 additions & 7 deletions src/frontend/src/views/ProjectDetailsV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const Home = () => {

useEffect(() => {
if (taskModalStatus) {
setViewState('comments');
setViewState('task_activity');
} else {
setViewState('project_info');
}
Expand Down Expand Up @@ -340,25 +340,25 @@ const Home = () => {
{taskModalStatus && (
<button
className={`fmtm-rounded-none fmtm-border-none fmtm-text-base ${
viewState === 'comments'
viewState === 'task_activity'
? 'fmtm-bg-primaryRed fmtm-text-white hover:fmtm-bg-red-700'
: 'fmtm-bg-white fmtm-text-[#706E6E] hover:fmtm-bg-grey-50'
} fmtm-py-1`}
onClick={() => setViewState('comments')}
onClick={() => setViewState('task_activity')}
>
Comments
Task Activity
</button>
)}
{taskModalStatus && (
<button
className={`fmtm-rounded-none fmtm-border-none fmtm-text-base ${
viewState === 'task_activity'
viewState === 'comments'
? 'fmtm-bg-primaryRed fmtm-text-white hover:fmtm-bg-red-700'
: 'fmtm-bg-white fmtm-text-[#706E6E] hover:fmtm-bg-grey-50'
} fmtm-py-1`}
onClick={() => setViewState('task_activity')}
onClick={() => setViewState('comments')}
>
Task Activity
Comments
</button>
)}
<button
Expand Down

0 comments on commit 820e813

Please sign in to comment.