From 42d5e2afd9c22303dd11e54ed84b6d63ebd1d607 Mon Sep 17 00:00:00 2001 From: JoltCode Date: Sun, 19 Jan 2025 00:27:28 +0000 Subject: [PATCH 1/4] fix(frontend/taskSelection): conditionally check user store --- frontend/src/api/teams.ts | 3 +-- frontend/src/components/taskSelection/index.tsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/frontend/src/api/teams.ts b/frontend/src/api/teams.ts index e17ee39b7d..4f337d63f7 100644 --- a/frontend/src/api/teams.ts +++ b/frontend/src/api/teams.ts @@ -1,8 +1,7 @@ import { useSelector } from 'react-redux'; import { useQuery } from '@tanstack/react-query'; - import api from './apiClient'; -import { RootStore } from '../store'; +import type { RootStore } from '../store'; export const useTeamsQuery = (params: any, otherOptions: any) => { const token = useSelector((state: RootStore) => state.auth.token); diff --git a/frontend/src/components/taskSelection/index.tsx b/frontend/src/components/taskSelection/index.tsx index 051c6c67db..0fdc85d108 100644 --- a/frontend/src/components/taskSelection/index.tsx +++ b/frontend/src/components/taskSelection/index.tsx @@ -81,7 +81,7 @@ export function TaskSelection({ const { data: userTeams, isLoading: isUserTeamsLoading } = useTeamsQuery( { omitMemberList: true, - member: user.id, + member: user?.id, }, { useErrorBoundary: true, @@ -158,23 +158,23 @@ export function TaskSelection({ // do not redirect if user is not from project detail page if (location?.state?.from !== `/projects/${projectId}`) return; if (contributions && isFirstRender.current) { - const currentUserContributions = contributions.filter((u) => u.username === user.username); - if (textSearch || (user.isExpert && currentUserContributions.length > 0)) { + const currentUserContributions = contributions.filter((u) => u.username === user?.username); + if (textSearch || (user?.isExpert && currentUserContributions.length > 0)) { setActiveSection('tasks'); } else { setActiveSection('instructions'); } isFirstRender.current = false; } - }, [contributions, user.username, user, textSearch, setActiveSection, location, projectId]); + }, [contributions, user?.username, user, textSearch, setActiveSection, location, projectId]); useEffect(() => { // run it only when the component is initialized // it checks if the user has tasks locked on the project and suggests to resume them - if (!mapInit && activities && activities.activity && user.username && !isUserTeamsLoading) { + if (!mapInit && activities && activities.activity && user?.username && !isUserTeamsLoading) { const lockedByCurrentUser = activities.activity .filter((i) => i.taskStatus.startsWith('LOCKED_FOR_')) - .filter((i) => i.actionBy === user.username); + .filter((i) => i.actionBy === user?.username); if (lockedByCurrentUser.length) { const userLockedTasks = lockedByCurrentUser.map((i) => i.taskId); setSelectedTasks(userLockedTasks); @@ -287,7 +287,7 @@ export function TaskSelection({ {(close) => ( )} @@ -382,7 +382,7 @@ export function TaskSelection({
Loading...
}> Date: Sun, 19 Jan 2025 00:32:03 +0000 Subject: [PATCH 2/4] fix(frontend/projects): downloadAsCSV propType --- frontend/src/components/projects/downloadAsCSV.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/projects/downloadAsCSV.jsx b/frontend/src/components/projects/downloadAsCSV.jsx index 66bed73516..91020521cf 100644 --- a/frontend/src/components/projects/downloadAsCSV.jsx +++ b/frontend/src/components/projects/downloadAsCSV.jsx @@ -76,5 +76,5 @@ export default function DownloadAsCSV({ allQueryParams }) { } DownloadAsCSV.propTypes = { - allQueryParams: PropTypes.string.isRequired, + allQueryParams: PropTypes.object.isRequired, }; From 946680b397d0b387870f285f60ea9ce257511dc5 Mon Sep 17 00:00:00 2001 From: JoltCode Date: Sun, 19 Jan 2025 00:43:45 +0000 Subject: [PATCH 3/4] chore(frontend/tests): rename test file to .test.jsx --- .../tests/{task.selection.jsx => task.selection.test.jsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename frontend/src/components/taskSelection/tests/{task.selection.jsx => task.selection.test.jsx} (100%) diff --git a/frontend/src/components/taskSelection/tests/task.selection.jsx b/frontend/src/components/taskSelection/tests/task.selection.test.jsx similarity index 100% rename from frontend/src/components/taskSelection/tests/task.selection.jsx rename to frontend/src/components/taskSelection/tests/task.selection.test.jsx From d49f72e01ac91a71e260798bcf89f033f674eabe Mon Sep 17 00:00:00 2001 From: JoltCode Date: Sun, 19 Jan 2025 00:44:13 +0000 Subject: [PATCH 4/4] fix(frontend/taskSelection): missing ternary --- frontend/src/components/taskSelection/lockedTasks.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/taskSelection/lockedTasks.jsx b/frontend/src/components/taskSelection/lockedTasks.jsx index 584c0766c5..4c0e385956 100644 --- a/frontend/src/components/taskSelection/lockedTasks.jsx +++ b/frontend/src/components/taskSelection/lockedTasks.jsx @@ -162,7 +162,7 @@ function LockErrorButtons({ const handleDeselectAndValidate = () => { const userMappedTaskIds = tasks.features - .filter((feature) => feature.properties.mappedBy === user.id) + .filter((feature) => feature.properties.mappedBy === user?.id) .map((feature) => feature.properties.taskId); const remainingSelectedTasks = selectedTasks.filter(