Skip to content

Commit

Permalink
Merge pull request #6697 from JoltCode/typescript-vite
Browse files Browse the repository at this point in the history
typescript-vite: fix(frontend): various further fixes/cleanups
  • Loading branch information
spwoodcock authored Jan 20, 2025
2 parents b43b3b5 + d49f72e commit 8fc6852
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions frontend/src/api/teams.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/projects/downloadAsCSV.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ export default function DownloadAsCSV({ allQueryParams }) {
}

DownloadAsCSV.propTypes = {
allQueryParams: PropTypes.string.isRequired,
allQueryParams: PropTypes.object.isRequired,
};
16 changes: 8 additions & 8 deletions frontend/src/components/taskSelection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function TaskSelection({
const { data: userTeams, isLoading: isUserTeamsLoading } = useTeamsQuery(
{
omitMemberList: true,
member: user.id,
member: user?.id,
},
{
useErrorBoundary: true,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -287,7 +287,7 @@ export function TaskSelection({
{(close) => (
<UserPermissionErrorContent
project={project}
userLevel={user.mappingLevel}
userLevel={user?.mappingLevel}
close={close}
/>
)}
Expand Down Expand Up @@ -382,7 +382,7 @@ export function TaskSelection({
<div className="cf w-100 bt b--grey-light fixed bottom-0 left-0 z-4">
<Suspense fallback={<div>Loading...</div>}>
<TaskSelectionFooter
defaultUserEditor={user ? user.defaultEditor : 'iD'}
defaultUserEditor={user ? user?.defaultEditor : 'iD'}
project={project}
tasks={tasks}
taskAction={taskAction}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/taskSelection/lockedTasks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8fc6852

Please sign in to comment.