Skip to content

Conversation

@zalexa19
Copy link
Contributor

This is still wip

Copilot AI review requested due to automatic review settings January 30, 2026 21:59
@HackYourFutures HackYourFutures had a problem deploying to dojo-frontend-issue-92--76tkab January 30, 2026 21:59 Failure
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the project from react-query v3 to @tanstack/react-query v5, addressing breaking API changes and introducing a centralized query provider with global error handling.

Changes:

  • Replaced react-query with @tanstack/react-query v5 and updated all import statements
  • Created a new TanStackQueryProvider component with global error handling for 401 responses
  • Updated all useQuery and useMutation hooks to use the new v5 object-based configuration syntax

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
client/src/routes/root.tsx Replaced QueryClientProvider setup with new TanStackQueryProvider component
client/src/pages/SearchPage.tsx Updated to use new useSearchTrainee hook from data layer
client/src/hooks/useTraineeSearchData.tsx Commented out old implementation (should be deleted)
client/src/hooks/useTraineeInfoData.tsx Migrated useQuery and useMutation to v5 object syntax
client/src/hooks/useDashboardData.tsx Migrated useQuery to v5 object syntax with inline data extraction
client/src/hooks/useCohortsData.tsx Migrated useQuery to v5 object syntax with inline data extraction
client/src/hooks/interactions/interaction-queries.ts Migrated all hooks to v5 syntax and improved error handling
client/src/hooks/education/test-queries.ts Migrated all hooks to v5 object syntax
client/src/hooks/education/strike-queries.ts Migrated useQuery to v5 object syntax
client/src/data/trainee/queries.ts New file with useSearchTrainee hook implementation
client/src/data/tanstack/TanStackQueryProvider.tsx New centralized provider with global error handling
client/src/components/education/TestsComponent.tsx Updated import to use @tanstack/react-query
client/src/components/education/StrikesComponent.tsx Updated import to use @tanstack/react-query
client/src/components/TraineeProfile.tsx Updated import to use @tanstack/react-query
client/package.json Added @tanstack/react-query packages and removed react-query
client/package-lock.json Updated dependencies for the migration
Files not reviewed (1)
  • client/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


export const useSearchTrainee = (search: string) => {
return useQuery({
queryKey: [queryKey],
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The queryKey for the search results is missing the 'search' parameter. This means all searches will use the same cache key, causing incorrect data to be returned. The queryKey should include the search parameter to ensure different searches have different cache entries.

Suggested change
queryKey: [queryKey],
queryKey: [queryKey, search],

Copilot uses AI. Check for mistakes.
queryKey: [queryKey],
queryFn: async () => {
const response = await axios.get(`/api/search?q=${search}&limit=20`);
console.log(response);
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.log statement should be removed. Debug logging should not be present in production code.

Suggested change
console.log(response);

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +13
const resonse = await axios.get<Cohort[]>(`/api/cohorts`);
return resonse.data;
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: 'resonse' should be 'response'.

Suggested change
const resonse = await axios.get<Cohort[]>(`/api/cohorts`);
return resonse.data;
const response = await axios.get<Cohort[]>(`/api/cohorts`);
return response.data;

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +27
// /**
// * A React Query hook that fetches trainee search results form api.
// *
// * @param {string} search search keyword
// */
// export const useTraineeSearchData = (search: string) => {
// return useQuery(
// {
// queryKey: ['search-results', search],
// }
// ['search-results', search],
// () => {
// return axios.get(`/api/search?q=${search}&limit=20`);
// },
// {
// enabled: search.length > 1, // Query runs only if search string has more than 1 character
// select: (response) => {
// const trainees: SearchResult[] = response.data.hits.data.map((trainee: SearchResult) => trainee);
// return trainees;
// },
// }
// );
// };
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire file contains only commented-out code. Since the functionality has been moved to client/src/data/trainee/queries.ts, this file should be deleted rather than left with commented code. Keeping dead code increases maintenance burden and can cause confusion.

Copilot uses AI. Check for mistakes.
import { StrikeDetailsModal } from './StrikeDetailsModal';
import { StrikesList } from './StrikesList';
import { useQueryClient } from 'react-query';
import { useQueryClient } from '@tanstack/react-query';
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalidateQueries API has changed in TanStack Query v5. Instead of passing an array directly, you should pass an object with a queryKey property. This should be: queryClient.invalidateQueries({ queryKey: ['strikes', traineeId] })

Copilot uses AI. Check for mistakes.
}
);
onSuccess: () => {
queryClient.invalidateQueries(['interactions', traineeId]);
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalidateQueries API has changed in TanStack Query v5. Instead of passing an array directly, you should pass an object with a queryKey property. This should be: queryClient.invalidateQueries({ queryKey: ['interactions', traineeId] })

Copilot uses AI. Check for mistakes.
}
);
onSuccess: () => {
queryClient.invalidateQueries(['interactions', traineeId]);
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalidateQueries API has changed in TanStack Query v5. Instead of passing an array directly, you should pass an object with a queryKey property. This should be: queryClient.invalidateQueries({ queryKey: ['interactions', traineeId] })

Copilot uses AI. Check for mistakes.
refetchOnWindowFocus: false,
}
);

Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the extra blank line. The query options should be consistently formatted without blank lines between properties.

Suggested change

Copilot uses AI. Check for mistakes.
import { useQuery } from 'react-query';
import axios from 'axios';
import { SearchResult } from '../models';
import axios from 'axios';
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import axios.

Suggested change
import axios from 'axios';

Copilot uses AI. Check for mistakes.
import axios from 'axios';
import { SearchResult } from '../models';
import axios from 'axios';
import { useQuery } from '@tanstack/react-query';
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import useQuery.

Suggested change
import { useQuery } from '@tanstack/react-query';

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants