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

typescript-vite: fix(frontend): various further fixes/cleanups #6697

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading