From 7ad7a95156ea824e836f3aa5d1f7979c334a0391 Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 3 Sep 2024 09:57:10 +1000 Subject: [PATCH 01/12] Bumping react-query --- packages/datatrak-web/package.json | 2 +- packages/datatrak-web/src/AppProviders.tsx | 2 +- .../src/api/mutations/useEditUser.ts | 6 +-- .../api/mutations/useExportSurveyResponses.ts | 2 +- .../src/api/mutations/useLogin.ts | 2 +- .../src/api/mutations/useLogout.ts | 4 +- .../src/api/mutations/useOneTimeLogin.ts | 2 +- .../src/api/mutations/useRegister.ts | 2 +- .../api/mutations/useRequestDeleteAccount.ts | 2 +- .../api/mutations/useRequestProjectAccess.ts | 2 +- .../api/mutations/useRequestResetPassword.ts | 2 +- .../mutations/useResendVerificationEmail.ts | 2 +- .../src/api/mutations/useResetPassword.ts | 2 +- .../mutations/useResubmitSurveyResponse.ts | 2 +- .../api/mutations/useSubmitSurveyResponse.ts | 12 +++--- .../src/api/mutations/useTupaiaRedirect.ts | 2 +- .../src/api/queries/useActivityFeed.ts | 2 +- .../src/api/queries/useAutocompleteOptions.ts | 2 +- .../src/api/queries/useCountryAccessList.ts | 2 +- .../src/api/queries/useEntities.ts | 2 +- .../datatrak-web/src/api/queries/useEntity.ts | 2 +- .../src/api/queries/useLeaderboard.ts | 2 +- .../src/api/queries/useProject.ts | 2 +- .../src/api/queries/useProjectEntities.ts | 2 +- .../src/api/queries/useProjectSurveys.ts | 2 +- .../src/api/queries/useProjects.ts | 4 +- .../src/api/queries/useRecentSurveys.ts | 2 +- .../datatrak-web/src/api/queries/useSurvey.ts | 2 +- .../src/api/queries/useSurveyResponse.ts | 2 +- .../src/api/queries/useSurveyResponses.ts | 2 +- .../src/api/queries/useSurveys.ts | 2 +- .../datatrak-web/src/api/queries/useUser.ts | 4 +- .../src/api/queries/useUserRewards.ts | 2 +- .../AccessGrantedCountryList.tsx | 2 +- .../RequestCountryAccessForm.tsx | 2 +- yarn.lock | 37 ++++++++++++++++++- 36 files changed, 81 insertions(+), 46 deletions(-) diff --git a/packages/datatrak-web/package.json b/packages/datatrak-web/package.json index e1a2be2301..19ca7259d6 100644 --- a/packages/datatrak-web/package.json +++ b/packages/datatrak-web/package.json @@ -15,6 +15,7 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.57", "@material-ui/styles": "^4.9.10", + "@tanstack/react-query": "4.36.1", "@testing-library/react-hooks": "^8.0.1", "@tupaia/expression-parser": "workspace:*", "@tupaia/types": "workspace:*", @@ -33,7 +34,6 @@ "react-dom": "^16.13.1", "react-hook-form": "^6.15.1", "react-leaflet": "^3.2.1", - "react-query": "^3.39.3", "react-router": "6.3.0", "react-router-dom": "6.3.0", "styled-components": "^5.1.0", diff --git a/packages/datatrak-web/src/AppProviders.tsx b/packages/datatrak-web/src/AppProviders.tsx index 2823f853be..fc98ee1f4f 100755 --- a/packages/datatrak-web/src/AppProviders.tsx +++ b/packages/datatrak-web/src/AppProviders.tsx @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ import React, { ReactNode } from 'react'; -import { MutationCache, QueryCache, QueryClient, QueryClientProvider } from 'react-query'; +import { MutationCache, QueryCache, QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ThemeProvider as MuiThemeProvider, StylesProvider } from '@material-ui/core/styles'; import CssBaseline from '@material-ui/core/CssBaseline'; import { ThemeProvider } from 'styled-components'; diff --git a/packages/datatrak-web/src/api/mutations/useEditUser.ts b/packages/datatrak-web/src/api/mutations/useEditUser.ts index ce44980794..8740c9d26f 100644 --- a/packages/datatrak-web/src/api/mutations/useEditUser.ts +++ b/packages/datatrak-web/src/api/mutations/useEditUser.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { UserAccountDetails } from '../../types'; import { put } from '../api'; @@ -41,10 +41,10 @@ export const useEditUser = (onSuccess?: () => void) => { }, { onSuccess: (_, variables) => { - queryClient.invalidateQueries('getUser'); + queryClient.invalidateQueries(['getUser']); // If the user changes their project, we need to invalidate the entity descendants query so that recent entities are updated if they change back to the previous project without refreshing the page if (variables.projectId) { - queryClient.invalidateQueries('entityDescendants'); + queryClient.invalidateQueries(['entityDescendants']); } if (onSuccess) onSuccess(); }, diff --git a/packages/datatrak-web/src/api/mutations/useExportSurveyResponses.ts b/packages/datatrak-web/src/api/mutations/useExportSurveyResponses.ts index b77612b103..a592e83fa2 100644 --- a/packages/datatrak-web/src/api/mutations/useExportSurveyResponses.ts +++ b/packages/datatrak-web/src/api/mutations/useExportSurveyResponses.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import axios from 'axios'; import downloadJs from 'downloadjs'; import { API_URL, timeout } from '../api'; diff --git a/packages/datatrak-web/src/api/mutations/useLogin.ts b/packages/datatrak-web/src/api/mutations/useLogin.ts index 8206366ccd..ae164a4032 100644 --- a/packages/datatrak-web/src/api/mutations/useLogin.ts +++ b/packages/datatrak-web/src/api/mutations/useLogin.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { gaEvent, useFromLocation } from '../../utils'; import { useNavigate } from 'react-router-dom'; import { post } from '../api'; diff --git a/packages/datatrak-web/src/api/mutations/useLogout.ts b/packages/datatrak-web/src/api/mutations/useLogout.ts index c8b593af54..8db3bb0e27 100644 --- a/packages/datatrak-web/src/api/mutations/useLogout.ts +++ b/packages/datatrak-web/src/api/mutations/useLogout.ts @@ -3,13 +3,13 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { post } from '../api'; export const useLogout = () => { const queryClient = useQueryClient(); - return useMutation('logout', () => post('logout'), { + return useMutation(['logout'], () => post('logout'), { onSuccess: () => { queryClient.invalidateQueries(); }, diff --git a/packages/datatrak-web/src/api/mutations/useOneTimeLogin.ts b/packages/datatrak-web/src/api/mutations/useOneTimeLogin.ts index df8298e33f..df4cf04023 100644 --- a/packages/datatrak-web/src/api/mutations/useOneTimeLogin.ts +++ b/packages/datatrak-web/src/api/mutations/useOneTimeLogin.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { post } from '../api'; type OneTimeLoginToken = string; diff --git a/packages/datatrak-web/src/api/mutations/useRegister.ts b/packages/datatrak-web/src/api/mutations/useRegister.ts index 4e18c13a28..d06ff797a2 100644 --- a/packages/datatrak-web/src/api/mutations/useRegister.ts +++ b/packages/datatrak-web/src/api/mutations/useRegister.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; // Todo: replace with request body type from backend diff --git a/packages/datatrak-web/src/api/mutations/useRequestDeleteAccount.ts b/packages/datatrak-web/src/api/mutations/useRequestDeleteAccount.ts index aa11c95ab0..5d386b6b26 100644 --- a/packages/datatrak-web/src/api/mutations/useRequestDeleteAccount.ts +++ b/packages/datatrak-web/src/api/mutations/useRequestDeleteAccount.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; import { useEditUser } from '.'; diff --git a/packages/datatrak-web/src/api/mutations/useRequestProjectAccess.ts b/packages/datatrak-web/src/api/mutations/useRequestProjectAccess.ts index 26c3d0b6dc..ef42466ab8 100644 --- a/packages/datatrak-web/src/api/mutations/useRequestProjectAccess.ts +++ b/packages/datatrak-web/src/api/mutations/useRequestProjectAccess.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { Country, Project } from '@tupaia/types'; import { post } from '../api'; diff --git a/packages/datatrak-web/src/api/mutations/useRequestResetPassword.ts b/packages/datatrak-web/src/api/mutations/useRequestResetPassword.ts index 89c3fde15d..bc69b0f3cc 100644 --- a/packages/datatrak-web/src/api/mutations/useRequestResetPassword.ts +++ b/packages/datatrak-web/src/api/mutations/useRequestResetPassword.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; type ResetPasswordParams = { diff --git a/packages/datatrak-web/src/api/mutations/useResendVerificationEmail.ts b/packages/datatrak-web/src/api/mutations/useResendVerificationEmail.ts index ac455ce47e..557c6facab 100644 --- a/packages/datatrak-web/src/api/mutations/useResendVerificationEmail.ts +++ b/packages/datatrak-web/src/api/mutations/useResendVerificationEmail.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; type RequestBody = { diff --git a/packages/datatrak-web/src/api/mutations/useResetPassword.ts b/packages/datatrak-web/src/api/mutations/useResetPassword.ts index dedf4d3de8..88b84e0239 100644 --- a/packages/datatrak-web/src/api/mutations/useResetPassword.ts +++ b/packages/datatrak-web/src/api/mutations/useResetPassword.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; import { post } from '../api'; import { PASSWORD_RESET_TOKEN_PARAM } from '../../constants'; diff --git a/packages/datatrak-web/src/api/mutations/useResubmitSurveyResponse.ts b/packages/datatrak-web/src/api/mutations/useResubmitSurveyResponse.ts index c03060a4e5..65e7033fef 100644 --- a/packages/datatrak-web/src/api/mutations/useResubmitSurveyResponse.ts +++ b/packages/datatrak-web/src/api/mutations/useResubmitSurveyResponse.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { generatePath, useNavigate, useParams } from 'react-router'; import { post } from '../api'; import { useSurveyResponse } from '../queries'; diff --git a/packages/datatrak-web/src/api/mutations/useSubmitSurveyResponse.ts b/packages/datatrak-web/src/api/mutations/useSubmitSurveyResponse.ts index 72b4b05ee8..13f7193f4c 100644 --- a/packages/datatrak-web/src/api/mutations/useSubmitSurveyResponse.ts +++ b/packages/datatrak-web/src/api/mutations/useSubmitSurveyResponse.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { generatePath, useNavigate, useParams } from 'react-router'; import { getBrowserTimeZone } from '@tupaia/utils'; import { Coconut } from '../../components'; @@ -64,11 +64,11 @@ export const useSubmitSurveyResponse = () => { gaEvent('submit_survey_by_user', user.id!); }, onSuccess: data => { - queryClient.invalidateQueries('surveyResponses'); - queryClient.invalidateQueries('recentSurveys'); - queryClient.invalidateQueries('rewards'); - queryClient.invalidateQueries('leaderboard'); - queryClient.invalidateQueries('entityDescendants'); // Refresh recent entities + queryClient.invalidateQueries(['surveyResponses']); + queryClient.invalidateQueries(['recentSurveys']); + queryClient.invalidateQueries(['rewards']); + queryClient.invalidateQueries(['leaderboard']); + queryClient.invalidateQueries(['entityDescendants']); // Refresh recent entities const createNewAutocompleteQuestions = surveyResponseData?.questions?.filter( question => question?.config?.autocomplete?.createNew, diff --git a/packages/datatrak-web/src/api/mutations/useTupaiaRedirect.ts b/packages/datatrak-web/src/api/mutations/useTupaiaRedirect.ts index 7cb318570b..8af4a80df8 100644 --- a/packages/datatrak-web/src/api/mutations/useTupaiaRedirect.ts +++ b/packages/datatrak-web/src/api/mutations/useTupaiaRedirect.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { useCurrentUserContext } from '../CurrentUserContext'; import { post } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useActivityFeed.ts b/packages/datatrak-web/src/api/queries/useActivityFeed.ts index 66e764df43..d60713f376 100644 --- a/packages/datatrak-web/src/api/queries/useActivityFeed.ts +++ b/packages/datatrak-web/src/api/queries/useActivityFeed.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useInfiniteQuery } from 'react-query'; +import { useInfiniteQuery } from '@tanstack/react-query'; import { DatatrakWebActivityFeedRequest, Project } from '@tupaia/types'; import { get } from '../api'; import { useCurrentUserContext } from '..'; diff --git a/packages/datatrak-web/src/api/queries/useAutocompleteOptions.ts b/packages/datatrak-web/src/api/queries/useAutocompleteOptions.ts index ab358b0b11..df2a05438a 100644 --- a/packages/datatrak-web/src/api/queries/useAutocompleteOptions.ts +++ b/packages/datatrak-web/src/api/queries/useAutocompleteOptions.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { Option } from '@tupaia/types'; import { get } from '../api'; import { useSurveyForm } from '../../features'; diff --git a/packages/datatrak-web/src/api/queries/useCountryAccessList.ts b/packages/datatrak-web/src/api/queries/useCountryAccessList.ts index fbfdcc5718..38e4193aa6 100644 --- a/packages/datatrak-web/src/api/queries/useCountryAccessList.ts +++ b/packages/datatrak-web/src/api/queries/useCountryAccessList.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { Project, ProjectCountryAccessListRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useEntities.ts b/packages/datatrak-web/src/api/queries/useEntities.ts index bde6d7867f..ab216a381e 100644 --- a/packages/datatrak-web/src/api/queries/useEntities.ts +++ b/packages/datatrak-web/src/api/queries/useEntities.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebEntitiesRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useEntity.ts b/packages/datatrak-web/src/api/queries/useEntity.ts index 881eec74b3..640a1b83e6 100644 --- a/packages/datatrak-web/src/api/queries/useEntity.ts +++ b/packages/datatrak-web/src/api/queries/useEntity.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; export const useEntityByCode = (entityCode, options?) => { diff --git a/packages/datatrak-web/src/api/queries/useLeaderboard.ts b/packages/datatrak-web/src/api/queries/useLeaderboard.ts index c16ae488d0..6efefa4d9e 100644 --- a/packages/datatrak-web/src/api/queries/useLeaderboard.ts +++ b/packages/datatrak-web/src/api/queries/useLeaderboard.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebLeaderboardRequest, Project } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useProject.ts b/packages/datatrak-web/src/api/queries/useProject.ts index fa0d80b0e2..0e951245c0 100644 --- a/packages/datatrak-web/src/api/queries/useProject.ts +++ b/packages/datatrak-web/src/api/queries/useProject.ts @@ -4,7 +4,7 @@ * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { WebServerProjectRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useProjectEntities.ts b/packages/datatrak-web/src/api/queries/useProjectEntities.ts index 7f6afde00e..be556a3d56 100644 --- a/packages/datatrak-web/src/api/queries/useProjectEntities.ts +++ b/packages/datatrak-web/src/api/queries/useProjectEntities.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebEntityDescendantsRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useProjectSurveys.ts b/packages/datatrak-web/src/api/queries/useProjectSurveys.ts index a35e7f7c30..cc668e034d 100644 --- a/packages/datatrak-web/src/api/queries/useProjectSurveys.ts +++ b/packages/datatrak-web/src/api/queries/useProjectSurveys.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebSurveyRequest, Project } from '@tupaia/types'; import { get } from '../api'; import { Entity } from '../../types'; diff --git a/packages/datatrak-web/src/api/queries/useProjects.ts b/packages/datatrak-web/src/api/queries/useProjects.ts index 15d0c66492..7459a1121d 100644 --- a/packages/datatrak-web/src/api/queries/useProjects.ts +++ b/packages/datatrak-web/src/api/queries/useProjects.ts @@ -3,10 +3,10 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebProjectsRequest } from '@tupaia/types'; import { get } from '../api'; export const useProjects = () => { - return useQuery('projects', (): Promise => get('projects')); + return useQuery(['projects'], (): Promise => get('projects')); }; diff --git a/packages/datatrak-web/src/api/queries/useRecentSurveys.ts b/packages/datatrak-web/src/api/queries/useRecentSurveys.ts index be8cba7ac5..00214082ac 100644 --- a/packages/datatrak-web/src/api/queries/useRecentSurveys.ts +++ b/packages/datatrak-web/src/api/queries/useRecentSurveys.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebRecentSurveysRequest, Project, UserAccount } from '@tupaia/types'; import { get } from '../api'; import { useCurrentUserContext } from '../CurrentUserContext'; diff --git a/packages/datatrak-web/src/api/queries/useSurvey.ts b/packages/datatrak-web/src/api/queries/useSurvey.ts index 1ea3a84269..944423ce74 100644 --- a/packages/datatrak-web/src/api/queries/useSurvey.ts +++ b/packages/datatrak-web/src/api/queries/useSurvey.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebSurveyRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useSurveyResponse.ts b/packages/datatrak-web/src/api/queries/useSurveyResponse.ts index 6f0fd29f4f..ea8b444535 100644 --- a/packages/datatrak-web/src/api/queries/useSurveyResponse.ts +++ b/packages/datatrak-web/src/api/queries/useSurveyResponse.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { useNavigate } from 'react-router'; import { DatatrakWebSingleSurveyResponseRequest, QuestionType } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useSurveyResponses.ts b/packages/datatrak-web/src/api/queries/useSurveyResponses.ts index fb52bf1e6d..cdf6ca87f4 100644 --- a/packages/datatrak-web/src/api/queries/useSurveyResponses.ts +++ b/packages/datatrak-web/src/api/queries/useSurveyResponses.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebSurveyResponsesRequest, UserAccount, Project } from '@tupaia/types'; import { useCurrentUserContext } from '../CurrentUserContext'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useSurveys.ts b/packages/datatrak-web/src/api/queries/useSurveys.ts index 3cb3ef4387..fd5cf9be34 100644 --- a/packages/datatrak-web/src/api/queries/useSurveys.ts +++ b/packages/datatrak-web/src/api/queries/useSurveys.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebSurveyRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/datatrak-web/src/api/queries/useUser.ts b/packages/datatrak-web/src/api/queries/useUser.ts index 1458325ec4..668bc34ef9 100644 --- a/packages/datatrak-web/src/api/queries/useUser.ts +++ b/packages/datatrak-web/src/api/queries/useUser.ts @@ -3,10 +3,10 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { DatatrakWebUserRequest } from '@tupaia/types'; import { get } from '../api'; export const useUser = () => { - return useQuery('getUser', (): Promise => get('getUser')); + return useQuery(['getUser'], (): Promise => get('getUser')); }; diff --git a/packages/datatrak-web/src/api/queries/useUserRewards.ts b/packages/datatrak-web/src/api/queries/useUserRewards.ts index 81b9e959d5..eb9ee49759 100644 --- a/packages/datatrak-web/src/api/queries/useUserRewards.ts +++ b/packages/datatrak-web/src/api/queries/useUserRewards.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { Project } from '@tupaia/types'; import { get } from '../api'; import { UserRewards } from '../../types'; diff --git a/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/AccessGrantedCountryList.tsx b/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/AccessGrantedCountryList.tsx index a41702597a..d889fac3a8 100644 --- a/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/AccessGrantedCountryList.tsx +++ b/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/AccessGrantedCountryList.tsx @@ -16,7 +16,7 @@ import { Typography, } from '@material-ui/core'; import { ProjectCountryAccessListRequest } from '@tupaia/types'; -import { UseQueryResult } from 'react-query'; +import { UseQueryResult } from '@tanstack/react-query'; const StyledTableContainer = styled(TableContainer).attrs({ elevation: 0, diff --git a/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/RequestCountryAccessForm.tsx b/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/RequestCountryAccessForm.tsx index 4a1cdd3e51..d89570a156 100644 --- a/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/RequestCountryAccessForm.tsx +++ b/packages/datatrak-web/src/views/AccountSettingsPage/RequestCountryAccessSection/RequestCountryAccessForm.tsx @@ -6,7 +6,7 @@ import React, { useState } from 'react'; import styled from 'styled-components'; import { useForm } from 'react-hook-form'; -import { UseQueryResult } from 'react-query'; +import { UseQueryResult } from '@tanstack/react-query'; import { FormLabel, useMediaQuery, useTheme } from '@material-ui/core'; import { Entity, ProjectCountryAccessListRequest, ProjectResponse } from '@tupaia/types'; import { Form, FormInput, TextField } from '@tupaia/ui-components'; diff --git a/yarn.lock b/yarn.lock index 8a83fa8007..0cf3fc7506 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11539,6 +11539,32 @@ __metadata: languageName: node linkType: hard +"@tanstack/query-core@npm:4.36.1": + version: 4.36.1 + resolution: "@tanstack/query-core@npm:4.36.1" + checksum: 47672094da20d89402d9fe03bb7b0462be73a76ff9ca715169738bc600a719d064d106d083a8eedae22a2c22de22f87d5eb5d31ef447aba771d9190f2117ed10 + languageName: node + linkType: hard + +"@tanstack/react-query@npm:4.36.1": + version: 4.36.1 + resolution: "@tanstack/react-query@npm:4.36.1" + dependencies: + "@tanstack/query-core": 4.36.1 + use-sync-external-store: ^1.2.0 + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-native: "*" + peerDependenciesMeta: + react-dom: + optional: true + react-native: + optional: true + checksum: 1aff0a476859386f8d32253fa0d0bde7b81769a6d4d4d9cbd78778f0f955459a3bdb7ee27a0d2ee7373090f12998b45df80db0b5b313bd0a7a39d36c6e8e51c5 + languageName: node + linkType: hard + "@testing-library/cypress@npm:^7.0.0": version: 7.0.1 resolution: "@testing-library/cypress@npm:7.0.1" @@ -12061,6 +12087,7 @@ __metadata: "@material-ui/lab": ^4.0.0-alpha.57 "@material-ui/styles": ^4.9.10 "@mui/types": ^7.2.4 + "@tanstack/react-query": 4.36.1 "@testing-library/react": 12.1.2 "@testing-library/react-hooks": ^8.0.1 "@tupaia/expression-parser": "workspace:*" @@ -12086,7 +12113,6 @@ __metadata: react-dom: ^16.13.1 react-hook-form: ^6.15.1 react-leaflet: ^3.2.1 - react-query: ^3.39.3 react-router: 6.3.0 react-router-dom: 6.3.0 styled-components: ^5.1.0 @@ -42326,6 +42352,15 @@ __metadata: languageName: node linkType: hard +"use-sync-external-store@npm:^1.2.0": + version: 1.2.2 + resolution: "use-sync-external-store@npm:1.2.2" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + checksum: fe07c071c4da3645f112c38c0e57beb479a8838616ff4e92598256ecce527f2888c08febc7f9b2f0ce2f0e18540ba3cde41eb2035e4fafcb4f52955037098a81 + languageName: node + linkType: hard + "use@npm:^3.1.0": version: 3.1.1 resolution: "use@npm:3.1.1" From 46a80e14287172ff799855fb4d50b399df5b153c Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:29:07 +1000 Subject: [PATCH 02/12] Bumping react-query to v4 --- packages/tupaia-web/package.json | 2 +- packages/tupaia-web/src/AppProviders.tsx | 2 +- .../src/api/mutations/useDownloadFiles.ts | 2 +- .../src/api/mutations/useDownloadRawData.ts | 2 +- .../src/api/mutations/useEmailDashboard.tsx | 2 +- .../src/api/mutations/useExportDashboard.tsx | 2 +- .../src/api/mutations/useExportMapOverlay.ts | 2 +- .../src/api/mutations/useExportToExcel.ts | 2 +- .../tupaia-web/src/api/mutations/useLogin.ts | 2 +- .../tupaia-web/src/api/mutations/useLogout.ts | 4 +- .../src/api/mutations/useOneTimeLogin.ts | 2 +- .../src/api/mutations/useRegister.ts | 2 +- .../api/mutations/useRequestCountryAccess.ts | 2 +- .../api/mutations/useRequestResetPassword.ts | 2 +- .../mutations/useResendVerificationEmail.ts | 2 +- .../src/api/mutations/useResetPassword.ts | 2 +- .../api/mutations/useSubscribeDashboard.ts | 2 +- .../api/mutations/useUnsubscribeDashboard.ts | 2 +- .../useUnsubscribeDashboardMailingList.ts | 2 +- .../src/api/queries/useDashboards.ts | 2 +- .../tupaia-web/src/api/queries/useEntities.ts | 2 +- .../tupaia-web/src/api/queries/useEntity.ts | 2 +- .../src/api/queries/useEntityAncestors.ts | 2 +- .../src/api/queries/useEntitySearch.ts | 2 +- .../src/api/queries/useLandingPage.ts | 2 +- .../src/api/queries/useMapOverlayReport.ts | 2 +- .../src/api/queries/useMapOverlays.ts | 2 +- .../tupaia-web/src/api/queries/useProject.ts | 2 +- .../queries/useProjectCountryAccessList.ts | 2 +- .../tupaia-web/src/api/queries/useProjects.ts | 4 +- .../tupaia-web/src/api/queries/useReport.ts | 2 +- .../tupaia-web/src/api/queries/useUser.ts | 4 +- .../src/components/FetchErrorAlert.tsx | 2 +- .../DashboardItem/DashboardItemContext.ts | 2 +- .../Map/utils/useDefaultMapOverlay.ts | 2 +- .../Map/utils/useMapOverlayTableData.ts | 4 +- .../src/views/EmailVerificationModal.tsx | 2 +- .../ProjectAccessForm.tsx | 2 +- yarn.lock | 37 ++++++++++++++++++- 39 files changed, 78 insertions(+), 43 deletions(-) diff --git a/packages/tupaia-web/package.json b/packages/tupaia-web/package.json index 078999e979..a3244ae005 100644 --- a/packages/tupaia-web/package.json +++ b/packages/tupaia-web/package.json @@ -26,6 +26,7 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.57", "@material-ui/styles": "^4.9.10", + "@tanstack/react-query": "4.36.1", "@tupaia/types": "workspace:*", "@tupaia/ui-chart-components": "workspace:*", "@tupaia/ui-components": "workspace:*", @@ -40,7 +41,6 @@ "react-dom": "^16.13.1", "react-hook-form": "^6.15.1", "react-leaflet": "^3.2.1", - "react-query": "^3.39.3", "react-router": "6.3.0", "react-router-dom": "6.3.0", "react-slick": "^0.30.2", diff --git a/packages/tupaia-web/src/AppProviders.tsx b/packages/tupaia-web/src/AppProviders.tsx index 2d19459454..793074bb83 100644 --- a/packages/tupaia-web/src/AppProviders.tsx +++ b/packages/tupaia-web/src/AppProviders.tsx @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ import React, { ReactNode } from 'react'; -import { QueryClient, QueryClientProvider } from 'react-query'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ThemeProvider as MuiThemeProvider, StylesProvider } from '@material-ui/core/styles'; import CssBaseline from '@material-ui/core/CssBaseline'; import { ThemeProvider } from 'styled-components'; diff --git a/packages/tupaia-web/src/api/mutations/useDownloadFiles.ts b/packages/tupaia-web/src/api/mutations/useDownloadFiles.ts index c9e4ef7f5d..d104905a33 100644 --- a/packages/tupaia-web/src/api/mutations/useDownloadFiles.ts +++ b/packages/tupaia-web/src/api/mutations/useDownloadFiles.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import downloadJs from 'downloadjs'; import { getUniqueFileNameParts } from '@tupaia/utils'; import { get } from '../api'; diff --git a/packages/tupaia-web/src/api/mutations/useDownloadRawData.ts b/packages/tupaia-web/src/api/mutations/useDownloadRawData.ts index b4db62fec9..32ae13f08e 100644 --- a/packages/tupaia-web/src/api/mutations/useDownloadRawData.ts +++ b/packages/tupaia-web/src/api/mutations/useDownloadRawData.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import downloadJs from 'downloadjs'; import { get } from '..'; diff --git a/packages/tupaia-web/src/api/mutations/useEmailDashboard.tsx b/packages/tupaia-web/src/api/mutations/useEmailDashboard.tsx index 883e2a76cd..865ac6f426 100644 --- a/packages/tupaia-web/src/api/mutations/useEmailDashboard.tsx +++ b/packages/tupaia-web/src/api/mutations/useEmailDashboard.tsx @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { TupaiaWebEmailDashboardRequest } from '@tupaia/types'; import { API_URL, post } from '../api'; import { Dashboard, DashboardItem, EntityCode, ProjectCode } from '../../types'; diff --git a/packages/tupaia-web/src/api/mutations/useExportDashboard.tsx b/packages/tupaia-web/src/api/mutations/useExportDashboard.tsx index 550b452b96..27f1036bca 100644 --- a/packages/tupaia-web/src/api/mutations/useExportDashboard.tsx +++ b/packages/tupaia-web/src/api/mutations/useExportDashboard.tsx @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { TupaiaWebExportDashboardRequest } from '@tupaia/types'; import { API_URL, post } from '../api'; import { DashboardName, EntityCode, ProjectCode } from '../../types'; diff --git a/packages/tupaia-web/src/api/mutations/useExportMapOverlay.ts b/packages/tupaia-web/src/api/mutations/useExportMapOverlay.ts index 3abefa0d4c..c4762c2c2a 100644 --- a/packages/tupaia-web/src/api/mutations/useExportMapOverlay.ts +++ b/packages/tupaia-web/src/api/mutations/useExportMapOverlay.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { LatLng } from 'leaflet'; import { MapOverlay } from '@tupaia/types'; import { LegendProps } from '@tupaia/ui-map-components'; diff --git a/packages/tupaia-web/src/api/mutations/useExportToExcel.ts b/packages/tupaia-web/src/api/mutations/useExportToExcel.ts index 1ba82a2298..2a815be9d3 100644 --- a/packages/tupaia-web/src/api/mutations/useExportToExcel.ts +++ b/packages/tupaia-web/src/api/mutations/useExportToExcel.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { getBrowserTimeZone } from '@tupaia/utils'; import { DashboardItem, EntityCode, ProjectCode } from '../../types'; import { get } from '..'; diff --git a/packages/tupaia-web/src/api/mutations/useLogin.ts b/packages/tupaia-web/src/api/mutations/useLogin.ts index 18ba4df1ff..bf5fa0f726 100644 --- a/packages/tupaia-web/src/api/mutations/useLogin.ts +++ b/packages/tupaia-web/src/api/mutations/useLogin.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { Location, useLocation, useNavigate } from 'react-router'; import { gaEvent, useModal } from '../../utils'; import { post } from '../api'; diff --git a/packages/tupaia-web/src/api/mutations/useLogout.ts b/packages/tupaia-web/src/api/mutations/useLogout.ts index 398445cd3c..677134ef9a 100644 --- a/packages/tupaia-web/src/api/mutations/useLogout.ts +++ b/packages/tupaia-web/src/api/mutations/useLogout.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { useLocation, useNavigate } from 'react-router-dom'; import { post } from '../api'; import { gaEvent } from '../../utils'; @@ -16,7 +16,7 @@ export const useLogout = () => { const queryClient = useQueryClient(); const navigate = useNavigate(); - return useMutation('logout', () => post('logout'), { + return useMutation(['logout'], () => post('logout'), { onMutate: () => { gaEvent('User', 'Log out'); }, diff --git a/packages/tupaia-web/src/api/mutations/useOneTimeLogin.ts b/packages/tupaia-web/src/api/mutations/useOneTimeLogin.ts index 0d386ab200..fe30230bb7 100644 --- a/packages/tupaia-web/src/api/mutations/useOneTimeLogin.ts +++ b/packages/tupaia-web/src/api/mutations/useOneTimeLogin.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { post } from '../api'; type LoginCredentials = { diff --git a/packages/tupaia-web/src/api/mutations/useRegister.ts b/packages/tupaia-web/src/api/mutations/useRegister.ts index 7bdda0cee7..771c1c4754 100644 --- a/packages/tupaia-web/src/api/mutations/useRegister.ts +++ b/packages/tupaia-web/src/api/mutations/useRegister.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; // Todo: replace with request body type from backend diff --git a/packages/tupaia-web/src/api/mutations/useRequestCountryAccess.ts b/packages/tupaia-web/src/api/mutations/useRequestCountryAccess.ts index 20ce5d569f..e5fcd5b927 100644 --- a/packages/tupaia-web/src/api/mutations/useRequestCountryAccess.ts +++ b/packages/tupaia-web/src/api/mutations/useRequestCountryAccess.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { useParams, useSearchParams } from 'react-router-dom'; import { post } from '../api'; import { URL_SEARCH_PARAMS } from '../../constants'; diff --git a/packages/tupaia-web/src/api/mutations/useRequestResetPassword.ts b/packages/tupaia-web/src/api/mutations/useRequestResetPassword.ts index bfe5b64f9b..2f3766dc43 100644 --- a/packages/tupaia-web/src/api/mutations/useRequestResetPassword.ts +++ b/packages/tupaia-web/src/api/mutations/useRequestResetPassword.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; type ResetPasswordParams = { diff --git a/packages/tupaia-web/src/api/mutations/useResendVerificationEmail.ts b/packages/tupaia-web/src/api/mutations/useResendVerificationEmail.ts index 099cf36290..1095f7a6b0 100644 --- a/packages/tupaia-web/src/api/mutations/useResendVerificationEmail.ts +++ b/packages/tupaia-web/src/api/mutations/useResendVerificationEmail.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; type RequestBody = { diff --git a/packages/tupaia-web/src/api/mutations/useResetPassword.ts b/packages/tupaia-web/src/api/mutations/useResetPassword.ts index 1b068fcbd6..751f209cee 100644 --- a/packages/tupaia-web/src/api/mutations/useResetPassword.ts +++ b/packages/tupaia-web/src/api/mutations/useResetPassword.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; import { post } from '../api'; import { URL_SEARCH_PARAMS } from '../../constants'; diff --git a/packages/tupaia-web/src/api/mutations/useSubscribeDashboard.ts b/packages/tupaia-web/src/api/mutations/useSubscribeDashboard.ts index 86adbf8e33..ca445fa5d3 100644 --- a/packages/tupaia-web/src/api/mutations/useSubscribeDashboard.ts +++ b/packages/tupaia-web/src/api/mutations/useSubscribeDashboard.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { TupaiaWebSubscribeDashboardRequest } from '@tupaia/types'; import { post } from '../api'; diff --git a/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboard.ts b/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboard.ts index e0bb2628ca..c123332757 100644 --- a/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboard.ts +++ b/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboard.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { TupaiaWebUnsubscribeDashboardRequest } from '@tupaia/types'; import { put } from '../api'; diff --git a/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboardMailingList.ts b/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboardMailingList.ts index dd512bd23c..aab149ecce 100644 --- a/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboardMailingList.ts +++ b/packages/tupaia-web/src/api/mutations/useUnsubscribeDashboardMailingList.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { TupaiaWebUnsubscribeDashboardMailingListRequest } from '@tupaia/types'; import { put } from '../api'; diff --git a/packages/tupaia-web/src/api/queries/useDashboards.ts b/packages/tupaia-web/src/api/queries/useDashboards.ts index 459504f92d..3d35331fac 100644 --- a/packages/tupaia-web/src/api/queries/useDashboards.ts +++ b/packages/tupaia-web/src/api/queries/useDashboards.ts @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { TupaiaWebDashboardsRequest } from '@tupaia/types'; import { EntityCode, ProjectCode } from '../../types'; import { get } from '../api'; diff --git a/packages/tupaia-web/src/api/queries/useEntities.ts b/packages/tupaia-web/src/api/queries/useEntities.ts index 95af4b613f..45f1d2e1a7 100644 --- a/packages/tupaia-web/src/api/queries/useEntities.ts +++ b/packages/tupaia-web/src/api/queries/useEntities.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ import { AxiosRequestConfig } from 'axios'; -import { useQuery, QueryObserverOptions } from 'react-query'; +import { useQuery, QueryObserverOptions } from '@tanstack/react-query'; import { get } from '../api'; import { Entity } from '../../types'; diff --git a/packages/tupaia-web/src/api/queries/useEntity.ts b/packages/tupaia-web/src/api/queries/useEntity.ts index 9dfef79ac9..e1775b683c 100644 --- a/packages/tupaia-web/src/api/queries/useEntity.ts +++ b/packages/tupaia-web/src/api/queries/useEntity.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { useLocation } from 'react-router'; import { EntityCode, ProjectCode, Entity } from '../../types'; import { get } from '../api'; diff --git a/packages/tupaia-web/src/api/queries/useEntityAncestors.ts b/packages/tupaia-web/src/api/queries/useEntityAncestors.ts index cd9fb5aa69..2da433e727 100644 --- a/packages/tupaia-web/src/api/queries/useEntityAncestors.ts +++ b/packages/tupaia-web/src/api/queries/useEntityAncestors.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { Entity, EntityCode, ProjectCode } from '../../types'; import { get } from '../api'; diff --git a/packages/tupaia-web/src/api/queries/useEntitySearch.ts b/packages/tupaia-web/src/api/queries/useEntitySearch.ts index 54e75bbccd..facd47d31c 100644 --- a/packages/tupaia-web/src/api/queries/useEntitySearch.ts +++ b/packages/tupaia-web/src/api/queries/useEntitySearch.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { ProjectCode, Entity } from '../../types'; import { get } from '../api'; import { useDebounce } from '../../utils'; diff --git a/packages/tupaia-web/src/api/queries/useLandingPage.ts b/packages/tupaia-web/src/api/queries/useLandingPage.ts index 41cd5f4293..82ed832399 100644 --- a/packages/tupaia-web/src/api/queries/useLandingPage.ts +++ b/packages/tupaia-web/src/api/queries/useLandingPage.ts @@ -4,7 +4,7 @@ * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { useParams } from 'react-router'; import { get } from '../api'; import { SingleLandingPage } from '../../types'; diff --git a/packages/tupaia-web/src/api/queries/useMapOverlayReport.ts b/packages/tupaia-web/src/api/queries/useMapOverlayReport.ts index 90ff37a873..3b42a0bb08 100644 --- a/packages/tupaia-web/src/api/queries/useMapOverlayReport.ts +++ b/packages/tupaia-web/src/api/queries/useMapOverlayReport.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ import moment, { Moment } from 'moment'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { momentToDateString } from '@tupaia/utils'; import { TupaiaWebMapOverlaysRequest } from '@tupaia/types'; import { diff --git a/packages/tupaia-web/src/api/queries/useMapOverlays.ts b/packages/tupaia-web/src/api/queries/useMapOverlays.ts index a80addee9d..d341cb8711 100644 --- a/packages/tupaia-web/src/api/queries/useMapOverlays.ts +++ b/packages/tupaia-web/src/api/queries/useMapOverlays.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ import { useSearchParams } from 'react-router-dom'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { POLYGON_MEASURE_TYPES } from '@tupaia/ui-map-components'; import { TupaiaWebMapOverlaysRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/tupaia-web/src/api/queries/useProject.ts b/packages/tupaia-web/src/api/queries/useProject.ts index 47e4f1d3f9..571695e080 100644 --- a/packages/tupaia-web/src/api/queries/useProject.ts +++ b/packages/tupaia-web/src/api/queries/useProject.ts @@ -4,7 +4,7 @@ * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { SingleProject } from '../../types'; import { get } from '../api'; import { useUser } from './useUser'; diff --git a/packages/tupaia-web/src/api/queries/useProjectCountryAccessList.ts b/packages/tupaia-web/src/api/queries/useProjectCountryAccessList.ts index 3aea27dc3c..f4534c3952 100644 --- a/packages/tupaia-web/src/api/queries/useProjectCountryAccessList.ts +++ b/packages/tupaia-web/src/api/queries/useProjectCountryAccessList.ts @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { ProjectCountryAccessListRequest } from '@tupaia/types'; import { get } from '../api'; import { ProjectCode } from '../../types'; diff --git a/packages/tupaia-web/src/api/queries/useProjects.ts b/packages/tupaia-web/src/api/queries/useProjects.ts index 85a29ab432..226f140446 100644 --- a/packages/tupaia-web/src/api/queries/useProjects.ts +++ b/packages/tupaia-web/src/api/queries/useProjects.ts @@ -3,12 +3,12 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; export const useProjects = () => { return useQuery( - 'projects', + ['projects'], () => get('projects', { params: { diff --git a/packages/tupaia-web/src/api/queries/useReport.ts b/packages/tupaia-web/src/api/queries/useReport.ts index 48319bc5f6..aeebe0b889 100644 --- a/packages/tupaia-web/src/api/queries/useReport.ts +++ b/packages/tupaia-web/src/api/queries/useReport.ts @@ -4,7 +4,7 @@ * */ import moment, { Moment } from 'moment'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { formatDateForApi, getBrowserTimeZone } from '@tupaia/utils'; import { TupaiaWebReportRequest } from '@tupaia/types'; import { get } from '../api'; diff --git a/packages/tupaia-web/src/api/queries/useUser.ts b/packages/tupaia-web/src/api/queries/useUser.ts index ed8f63d45e..445808c279 100644 --- a/packages/tupaia-web/src/api/queries/useUser.ts +++ b/packages/tupaia-web/src/api/queries/useUser.ts @@ -3,13 +3,13 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { TupaiaWebUserRequest } from '@tupaia/types'; import { get } from '../api'; export const useUser = () => { const userResponse = useQuery( - 'getUser', + ['getUser'], (): Promise => get('getUser'), ); const { data: user } = userResponse; diff --git a/packages/tupaia-web/src/components/FetchErrorAlert.tsx b/packages/tupaia-web/src/components/FetchErrorAlert.tsx index d680291a6a..65dd9209b0 100644 --- a/packages/tupaia-web/src/components/FetchErrorAlert.tsx +++ b/packages/tupaia-web/src/components/FetchErrorAlert.tsx @@ -7,7 +7,7 @@ import React from 'react'; import styled from 'styled-components'; import { Typography, Link } from '@material-ui/core'; import { Alert as BaseAlert, TextButton } from '@tupaia/ui-components'; -import { UseQueryResult } from 'react-query'; +import { UseQueryResult } from '@tanstack/react-query'; const ErrorLink = styled(Link)` color: inherit; diff --git a/packages/tupaia-web/src/features/DashboardItem/DashboardItemContext.ts b/packages/tupaia-web/src/features/DashboardItem/DashboardItemContext.ts index dcdfad58fa..3cec178e8d 100644 --- a/packages/tupaia-web/src/features/DashboardItem/DashboardItemContext.ts +++ b/packages/tupaia-web/src/features/DashboardItem/DashboardItemContext.ts @@ -4,7 +4,7 @@ */ import { createContext } from 'react'; -import { UseQueryResult } from 'react-query'; +import { UseQueryResult } from '@tanstack/react-query'; import { DashboardItemConfig, DashboardItemReport } from '@tupaia/types'; import { DashboardItem } from '../../types'; diff --git a/packages/tupaia-web/src/features/Map/utils/useDefaultMapOverlay.ts b/packages/tupaia-web/src/features/Map/utils/useDefaultMapOverlay.ts index 6646ef7ddc..9f53146f9c 100644 --- a/packages/tupaia-web/src/features/Map/utils/useDefaultMapOverlay.ts +++ b/packages/tupaia-web/src/features/Map/utils/useDefaultMapOverlay.ts @@ -4,7 +4,7 @@ */ import { useEffect } from 'react'; -import { useQueryClient } from 'react-query'; +import { useQueryClient } from '@tanstack/react-query'; import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; import { useMapOverlays, useProject } from '../../../api/queries'; import { diff --git a/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts b/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts index a13549756e..249a20a7b1 100644 --- a/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts +++ b/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts @@ -110,7 +110,7 @@ export const useMapOverlayTableData = ({ isLoading, isFetched, isFetching, - isIdle, + fetchStatus, isPreviousData, error: mapOverlayReportError, refetch: refetchMapOverlayReport, @@ -134,7 +134,7 @@ export const useMapOverlayTableData = ({ hiddenValues: hiddenValues ? hiddenValues : {}, }); - const loadingData = isLoading || isFetching || (!isFetched && !isIdle); + const loadingData = isLoading || isFetching || (!isFetched && fetchStatus != 'idle'); const isLoadingDifferentMeasureLevel = (!isPreviousData || data?.measureLevel !== selectedOverlay?.measureLevel) && loadingData; diff --git a/packages/tupaia-web/src/views/EmailVerificationModal.tsx b/packages/tupaia-web/src/views/EmailVerificationModal.tsx index 4995b91254..f086114e33 100644 --- a/packages/tupaia-web/src/views/EmailVerificationModal.tsx +++ b/packages/tupaia-web/src/views/EmailVerificationModal.tsx @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd */ import React, { useState } from 'react'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { useNavigate, useSearchParams } from 'react-router-dom'; import styled from 'styled-components'; import Typography from '@material-ui/core/Typography'; diff --git a/packages/tupaia-web/src/views/RequestProjectAccessModal/ProjectAccessForm.tsx b/packages/tupaia-web/src/views/RequestProjectAccessModal/ProjectAccessForm.tsx index fb7c6b229e..f144bd3724 100644 --- a/packages/tupaia-web/src/views/RequestProjectAccessModal/ProjectAccessForm.tsx +++ b/packages/tupaia-web/src/views/RequestProjectAccessModal/ProjectAccessForm.tsx @@ -16,7 +16,7 @@ import { TextField, } from '../../components'; import { useRequestCountryAccess } from '../../api/mutations'; -import { useQueryClient } from 'react-query'; +import { useQueryClient } from '@tanstack/react-query'; const Note = styled.p` text-align: left; diff --git a/yarn.lock b/yarn.lock index 8a83fa8007..adeaebf133 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11539,6 +11539,32 @@ __metadata: languageName: node linkType: hard +"@tanstack/query-core@npm:4.36.1": + version: 4.36.1 + resolution: "@tanstack/query-core@npm:4.36.1" + checksum: 47672094da20d89402d9fe03bb7b0462be73a76ff9ca715169738bc600a719d064d106d083a8eedae22a2c22de22f87d5eb5d31ef447aba771d9190f2117ed10 + languageName: node + linkType: hard + +"@tanstack/react-query@npm:4.36.1": + version: 4.36.1 + resolution: "@tanstack/react-query@npm:4.36.1" + dependencies: + "@tanstack/query-core": 4.36.1 + use-sync-external-store: ^1.2.0 + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-native: "*" + peerDependenciesMeta: + react-dom: + optional: true + react-native: + optional: true + checksum: 1aff0a476859386f8d32253fa0d0bde7b81769a6d4d4d9cbd78778f0f955459a3bdb7ee27a0d2ee7373090f12998b45df80db0b5b313bd0a7a39d36c6e8e51c5 + languageName: node + linkType: hard + "@testing-library/cypress@npm:^7.0.0": version: 7.0.1 resolution: "@testing-library/cypress@npm:7.0.1" @@ -12570,6 +12596,7 @@ __metadata: "@storybook/react": ^7.0.18 "@storybook/react-vite": ^7.0.18 "@storybook/testing-library": ^0.0.14-next.2 + "@tanstack/react-query": 4.36.1 "@tupaia/types": "workspace:*" "@tupaia/ui-chart-components": "workspace:*" "@tupaia/ui-components": "workspace:*" @@ -12593,7 +12620,6 @@ __metadata: react-dom: ^16.13.1 react-hook-form: ^6.15.1 react-leaflet: ^3.2.1 - react-query: ^3.39.3 react-router: 6.3.0 react-router-dom: 6.3.0 react-slick: ^0.30.2 @@ -42326,6 +42352,15 @@ __metadata: languageName: node linkType: hard +"use-sync-external-store@npm:^1.2.0": + version: 1.2.2 + resolution: "use-sync-external-store@npm:1.2.2" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + checksum: fe07c071c4da3645f112c38c0e57beb479a8838616ff4e92598256ecce527f2888c08febc7f9b2f0ce2f0e18540ba3cde41eb2035e4fafcb4f52955037098a81 + languageName: node + linkType: hard + "use@npm:^3.1.0": version: 3.1.1 resolution: "use@npm:3.1.1" From 05dd6083822ed7a3d5e47ea4c98a8323bbcee7bd Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 3 Sep 2024 10:37:54 +1000 Subject: [PATCH 03/12] Update render.tsx --- packages/datatrak-web/src/__tests__/helpers/render.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/datatrak-web/src/__tests__/helpers/render.tsx b/packages/datatrak-web/src/__tests__/helpers/render.tsx index 390710e12e..a20a22605d 100644 --- a/packages/datatrak-web/src/__tests__/helpers/render.tsx +++ b/packages/datatrak-web/src/__tests__/helpers/render.tsx @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ import React from 'react'; -import { UseMutationResult, QueryClient } from 'react-query'; +import { UseMutationResult, QueryClient } from '@tanstack/react-query'; import { MemoryRouter, Routes as Router } from 'react-router-dom'; import { renderHook } from '@testing-library/react-hooks'; import '@testing-library/jest-dom'; From 9cbab4492a2626a80c634d0d8bc74e79f1669e7e Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:52:45 +1000 Subject: [PATCH 04/12] GitAction fix --- packages/tupaia-web/src/types/react-query.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tupaia-web/src/types/react-query.d.ts b/packages/tupaia-web/src/types/react-query.d.ts index 1001855dae..3886f6ff77 100644 --- a/packages/tupaia-web/src/types/react-query.d.ts +++ b/packages/tupaia-web/src/types/react-query.d.ts @@ -1,9 +1,9 @@ -import { UseQueryResult as ReactQueryUseQueryResult } from 'react-query'; +import { UseQueryResult as ReactQueryUseQueryResult } from '@tanstack/react-query'; -declare module 'react-query' { +declare module '@tanstack/react-query' { export type UseQueryResult = Omit & { error?: ReactQueryUseQueryResult['error'] & { code?: number; - }; // override this to make code a valid type, as it is not present in types with react-query + }; // override this to make code a valid type, as it is not present in types with @tanstack/react-query }; } From a0242458635718f32bd42ad6dba09d3d64168ba3 Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Wed, 4 Sep 2024 18:35:57 +1000 Subject: [PATCH 05/12] fixing Reports.test.tsx --- .../features/Reports/Reports.test.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/datatrak-web/src/__tests__/features/Reports/Reports.test.tsx b/packages/datatrak-web/src/__tests__/features/Reports/Reports.test.tsx index b497ec1b3f..8354dad3ed 100644 --- a/packages/datatrak-web/src/__tests__/features/Reports/Reports.test.tsx +++ b/packages/datatrak-web/src/__tests__/features/Reports/Reports.test.tsx @@ -184,10 +184,10 @@ describe('Reports', () => { ); renderComponent(); await userEvent.click(await screen.findByPlaceholderText('Select survey...')); - await userEvent.click(screen.getByText('Basic clinic data - Demo Land')); + await userEvent.click(await screen.findByText('Basic clinic data - Demo Land')); await userEvent.click(await screen.findByLabelText('Country')); - await userEvent.click(screen.getByPlaceholderText('Select country...')); - await userEvent.click(screen.getByText('Demo Land')); + await userEvent.click(await screen.getByPlaceholderText('Select country...')); + await userEvent.click(await screen.findByText('Demo Land')); const submitButton = await screen.findByRole('button', { name: 'Export' }); @@ -217,10 +217,10 @@ describe('Reports', () => { ); renderComponent(); await userEvent.click(await screen.findByPlaceholderText('Select survey...')); - await userEvent.click(screen.getByText('Basic clinic data - Demo Land')); + await userEvent.click(await screen.findByText('Basic clinic data - Demo Land')); await userEvent.click(await screen.findByLabelText('Country')); - await userEvent.click(screen.getByPlaceholderText('Select country...')); - await userEvent.click(screen.getByText('Demo Land')); + await userEvent.click(await screen.getByPlaceholderText('Select country...')); + await userEvent.click(await screen.findByText('Demo Land')); const submitButton = await screen.findByRole('button', { name: 'Export' }); @@ -244,10 +244,10 @@ describe('Reports', () => { ); renderComponent(); await userEvent.click(await screen.findByPlaceholderText('Select survey...')); - await userEvent.click(screen.getByText('Basic clinic data - Demo Land')); + await userEvent.click(await screen.findByText('Basic clinic data - Demo Land')); await userEvent.click(await screen.findByLabelText('Country')); - await userEvent.click(screen.getByPlaceholderText('Select country...')); - await userEvent.click(screen.getByText('Demo Land')); + await userEvent.click(await screen.getByPlaceholderText('Select country...')); + await userEvent.click(await screen.findByText('Demo Land')); const submitButton = await screen.findByRole('button', { name: 'Export' }); From 0bb849d1a22718390e9312fa3b64826d7424b48c Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Sat, 7 Sep 2024 20:06:16 +1000 Subject: [PATCH 06/12] navigation bug fix --- packages/datatrak-web/src/api/CurrentUserContext.tsx | 2 +- packages/datatrak-web/src/api/mutations/useLogin.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/datatrak-web/src/api/CurrentUserContext.tsx b/packages/datatrak-web/src/api/CurrentUserContext.tsx index 205c769cb6..6c425b671c 100644 --- a/packages/datatrak-web/src/api/CurrentUserContext.tsx +++ b/packages/datatrak-web/src/api/CurrentUserContext.tsx @@ -22,7 +22,7 @@ export const useCurrentUserContext = (): CurrentUserContextType => { export const CurrentUserContextProvider = ({ children }: { children: React.ReactNode }) => { const currentUserQuery = useUser(); - if (currentUserQuery.isLoading) { + if (currentUserQuery.isLoading || currentUserQuery.isFetching) { return ; } diff --git a/packages/datatrak-web/src/api/mutations/useLogin.ts b/packages/datatrak-web/src/api/mutations/useLogin.ts index ae164a4032..e16798d518 100644 --- a/packages/datatrak-web/src/api/mutations/useLogin.ts +++ b/packages/datatrak-web/src/api/mutations/useLogin.ts @@ -35,15 +35,15 @@ export const useLogin = () => { }, onSuccess: async ({ user }) => { await queryClient.invalidateQueries(); + await queryClient.removeQueries(); + if (from) { - navigate(from, { - state: null, - }); + console.log('Navigating to from:', from); + navigate(from, { state: null }); } else { const path = user.projectId ? ROUTES.HOME : ROUTES.PROJECT_SELECT; - navigate(path, { - state: from, - }); + console.log('Navigating to path:', path); + navigate(path, { state: from }); } }, meta: { From 22b44a00926383d7982201cad9eb8f85f94a185a Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:44:41 +1000 Subject: [PATCH 07/12] review update --- .../tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts b/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts index 249a20a7b1..f51744fbf6 100644 --- a/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts +++ b/packages/tupaia-web/src/features/Map/utils/useMapOverlayTableData.ts @@ -134,7 +134,7 @@ export const useMapOverlayTableData = ({ hiddenValues: hiddenValues ? hiddenValues : {}, }); - const loadingData = isLoading || isFetching || (!isFetched && fetchStatus != 'idle'); + const loadingData = isLoading || isFetching || (!isFetched && fetchStatus !== 'idle'); const isLoadingDifferentMeasureLevel = (!isPreviousData || data?.measureLevel !== selectedOverlay?.measureLevel) && loadingData; From 1f27a2768c573896b9d75b2449b059f5d3130e48 Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:51:21 +1000 Subject: [PATCH 08/12] removed logging --- packages/datatrak-web/src/api/mutations/useLogin.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/datatrak-web/src/api/mutations/useLogin.ts b/packages/datatrak-web/src/api/mutations/useLogin.ts index e16798d518..5f522213f1 100644 --- a/packages/datatrak-web/src/api/mutations/useLogin.ts +++ b/packages/datatrak-web/src/api/mutations/useLogin.ts @@ -38,11 +38,9 @@ export const useLogin = () => { await queryClient.removeQueries(); if (from) { - console.log('Navigating to from:', from); navigate(from, { state: null }); } else { const path = user.projectId ? ROUTES.HOME : ROUTES.PROJECT_SELECT; - console.log('Navigating to path:', path); navigate(path, { state: from }); } }, From 64c9f66262c25232648d809ad5a606286ea88daa Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:21:52 +1000 Subject: [PATCH 09/12] Update yarn.lock --- yarn.lock | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 76b08061a4..de2b7afa11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9550,6 +9550,32 @@ __metadata: languageName: node linkType: hard +"@tanstack/query-core@npm:4.36.1": + version: 4.36.1 + resolution: "@tanstack/query-core@npm:4.36.1" + checksum: 47672094da20d89402d9fe03bb7b0462be73a76ff9ca715169738bc600a719d064d106d083a8eedae22a2c22de22f87d5eb5d31ef447aba771d9190f2117ed10 + languageName: node + linkType: hard + +"@tanstack/react-query@npm:4.36.1": + version: 4.36.1 + resolution: "@tanstack/react-query@npm:4.36.1" + dependencies: + "@tanstack/query-core": 4.36.1 + use-sync-external-store: ^1.2.0 + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-native: "*" + peerDependenciesMeta: + react-dom: + optional: true + react-native: + optional: true + checksum: 1aff0a476859386f8d32253fa0d0bde7b81769a6d4d4d9cbd78778f0f955459a3bdb7ee27a0d2ee7373090f12998b45df80db0b5b313bd0a7a39d36c6e8e51c5 + languageName: node + linkType: hard + "@testing-library/cypress@npm:^7.0.0": version: 7.0.1 resolution: "@testing-library/cypress@npm:7.0.1" @@ -10575,6 +10601,7 @@ __metadata: "@material-ui/lab": ^4.0.0-alpha.57 "@material-ui/styles": ^4.9.10 "@mui/types": ^7.2.4 + "@tanstack/react-query": 4.36.1 "@tupaia/types": "workspace:*" "@tupaia/ui-chart-components": "workspace:*" "@tupaia/ui-components": "workspace:*" @@ -10598,7 +10625,6 @@ __metadata: react-dom: ^16.13.1 react-hook-form: ^6.15.1 react-leaflet: ^3.2.1 - react-query: ^3.39.3 react-router: 6.3.0 react-router-dom: 6.3.0 react-slick: ^0.30.2 @@ -35525,6 +35551,15 @@ __metadata: languageName: node linkType: hard +"use-sync-external-store@npm:^1.2.0": + version: 1.2.2 + resolution: "use-sync-external-store@npm:1.2.2" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + checksum: fe07c071c4da3645f112c38c0e57beb479a8838616ff4e92598256ecce527f2888c08febc7f9b2f0ce2f0e18540ba3cde41eb2035e4fafcb4f52955037098a81 + languageName: node + linkType: hard + "use@npm:^3.1.0": version: 3.1.1 resolution: "use@npm:3.1.1" From 317d7c776f7e961f4ee4a8ec57aa7b5ed92ab5e0 Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:33:58 +1000 Subject: [PATCH 10/12] Update yarn.lock --- yarn.lock | 134 +----------------------------------------------------- 1 file changed, 2 insertions(+), 132 deletions(-) diff --git a/yarn.lock b/yarn.lock index 85f7242862..9d1a5105ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6381,7 +6381,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.10.3, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.4.4, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.0, @babel/runtime@npm:^7.6.2, @babel/runtime@npm:^7.6.3, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.3, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2": +"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.10.3, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.14.8, @babel/runtime@npm:^7.3.1, @babel/runtime@npm:^7.4.4, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.0, @babel/runtime@npm:^7.6.3, @babel/runtime@npm:^7.7.6, @babel/runtime@npm:^7.8.3, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.9.2": version: 7.15.4 resolution: "@babel/runtime@npm:7.15.4" dependencies: @@ -10628,6 +10628,7 @@ __metadata: "@material-ui/lab": ^4.0.0-alpha.57 "@material-ui/styles": ^4.9.10 "@mui/types": ^7.2.4 + "@tanstack/react-query": 4.36.1 "@tupaia/types": "workspace:*" "@tupaia/ui-chart-components": "workspace:*" "@tupaia/ui-components": "workspace:*" @@ -10651,7 +10652,6 @@ __metadata: react-dom: ^16.13.1 react-hook-form: ^6.15.1 react-leaflet: ^3.2.1 - react-query: ^3.39.3 react-router: 6.3.0 react-router-dom: 6.3.0 react-slick: ^0.30.2 @@ -14216,13 +14216,6 @@ __metadata: languageName: node linkType: hard -"big-integer@npm:^1.6.16": - version: 1.6.48 - resolution: "big-integer@npm:1.6.48" - checksum: fc43ae12ebf2b2a58d6da92ef7069666d131fa993be4020cb1a11e384f6d8e7a69dced7f69d27b65a6aff2e6abb548fb823303bde138eab60b556100c17761f3 - languageName: node - linkType: hard - "big.js@npm:^3.1.3": version: 3.2.0 resolution: "big.js@npm:3.2.0" @@ -14433,22 +14426,6 @@ __metadata: languageName: node linkType: hard -"broadcast-channel@npm:^3.4.1": - version: 3.7.0 - resolution: "broadcast-channel@npm:3.7.0" - dependencies: - "@babel/runtime": ^7.7.2 - detect-node: ^2.1.0 - js-sha3: 0.8.0 - microseconds: 0.2.0 - nano-time: 1.0.0 - oblivious-set: 1.0.0 - rimraf: 3.0.2 - unload: 2.2.0 - checksum: 803794c48dcce7f03aca69797430bd8b1c4cfd70b7de22079cd89567eeffaa126a1db98c7c2d86af8131d9bb41ed367c0fef96dfb446151c927b831572c621fc - languageName: node - linkType: hard - "browser-assert@npm:^1.2.1": version: 1.2.1 resolution: "browser-assert@npm:1.2.1" @@ -17363,20 +17340,6 @@ __metadata: languageName: node linkType: hard -"detect-node@npm:^2.0.4": - version: 2.0.4 - resolution: "detect-node@npm:2.0.4" - checksum: c06ae40fefbad8cb8cbb6ca819c93568b2a809e747bfc9c71f3524b027f5e988163b0ac0517fd65288b375360b30bc4822172eb05d211f99003d73cf8ec22911 - languageName: node - linkType: hard - -"detect-node@npm:^2.1.0": - version: 2.1.0 - resolution: "detect-node@npm:2.1.0" - checksum: 832184ec458353e41533ac9c622f16c19f7c02d8b10c303dfd3a756f56be93e903616c0bb2d4226183c9351c15fc0b3dba41a17a2308262afabcfa3776e6ae6e - languageName: node - linkType: hard - "devtools-protocol@npm:0.0.1011705": version: 0.0.1011705 resolution: "devtools-protocol@npm:0.0.1011705" @@ -23811,13 +23774,6 @@ __metadata: languageName: node linkType: hard -"js-sha3@npm:0.8.0": - version: 0.8.0 - resolution: "js-sha3@npm:0.8.0" - checksum: 75df77c1fc266973f06cce8309ce010e9e9f07ec35ab12022ed29b7f0d9c8757f5a73e1b35aa24840dced0dea7059085aa143d817aea9e188e2a80d569d9adce - languageName: node - linkType: hard - "js-sql-parser@npm:^1.4.1": version: 1.4.1 resolution: "js-sql-parser@npm:1.4.1" @@ -25712,16 +25668,6 @@ __metadata: languageName: node linkType: hard -"match-sorter@npm:^6.0.2": - version: 6.1.0 - resolution: "match-sorter@npm:6.1.0" - dependencies: - "@babel/runtime": ^7.12.5 - remove-accents: 0.4.2 - checksum: dd8a49a5ce866cf90773b5dc7d2dce29e0fcc87097cf6d51e81ac2c84028058a5724398bb6c3c1e889a8c40790fac0ea6382c2f077ce0bb7c54f90f529a2e8be - languageName: node - linkType: hard - "math-expression-evaluator@npm:^1.2.14": version: 1.4.0 resolution: "math-expression-evaluator@npm:1.4.0" @@ -26242,13 +26188,6 @@ __metadata: languageName: node linkType: hard -"microseconds@npm:0.2.0": - version: 0.2.0 - resolution: "microseconds@npm:0.2.0" - checksum: 22bfa8553f92c7d95afff6de0aeb2aecf750680d41b8c72b02098ccc5bbbb0a384380ff539292dbd3788f5dfc298682f9d38a2b4c101f5ee2c9471d53934c5fa - languageName: node - linkType: hard - "mime-db@npm:1.42.0, mime-db@npm:>= 1.40.0 < 2": version: 1.42.0 resolution: "mime-db@npm:1.42.0" @@ -26881,15 +26820,6 @@ __metadata: languageName: node linkType: hard -"nano-time@npm:1.0.0": - version: 1.0.0 - resolution: "nano-time@npm:1.0.0" - dependencies: - big-integer: ^1.6.16 - checksum: eef8548546cc1020625f8e44751a7263e9eddf0412a6a1a6c80a8d2be2ea7973622804a977cdfe796807b85b20ff6c8ba340e8dd20effcc7078193ed5edbb5d4 - languageName: node - linkType: hard - "nanoclone@npm:^0.2.1": version: 0.2.1 resolution: "nanoclone@npm:0.2.1" @@ -27855,13 +27785,6 @@ __metadata: languageName: node linkType: hard -"oblivious-set@npm:1.0.0": - version: 1.0.0 - resolution: "oblivious-set@npm:1.0.0" - checksum: f31740ea9c3a8242ad2324e4ebb9a35359fbc2e6e7131731a0fc1c8b7b1238eb07e4c8c631a38535243a7b8e3042b7e89f7dc2a95d2989afd6f80bd5793b0aab - languageName: node - linkType: hard - "on-finished@npm:2.4.1": version: 2.4.1 resolution: "on-finished@npm:2.4.1" @@ -30668,42 +30591,6 @@ __metadata: languageName: node linkType: hard -"react-query@npm:^3.19.0": - version: 3.19.0 - resolution: "react-query@npm:3.19.0" - dependencies: - "@babel/runtime": ^7.5.5 - broadcast-channel: ^3.4.1 - match-sorter: ^6.0.2 - peerDependencies: - react: ^16.8.0 || ^17.0.0 - peerDependenciesMeta: - react-dom: - optional: true - react-native: - optional: true - checksum: 4723a24b0b00e23d065328d495b714c8fdf90d399752958b06f623a5865619636a43ab52f3b89bd2c7ab36c98c916716692d7fc3d4ed9fcf758502ee0d27a9b4 - languageName: node - linkType: hard - -"react-query@npm:^3.39.3": - version: 3.39.3 - resolution: "react-query@npm:3.39.3" - dependencies: - "@babel/runtime": ^7.5.5 - broadcast-channel: ^3.4.1 - match-sorter: ^6.0.2 - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - react-dom: - optional: true - react-native: - optional: true - checksum: d2de6a0992dbf039ff2de564de1ae6361f8ac7310159dae42ec16f833b79c05caedced187235c42373ac331cc5f2fe9e2b31b14ae75a815e86d86e30ca9887ad - languageName: node - linkType: hard - "react-redux@npm:^5.0.6": version: 5.1.2 resolution: "react-redux@npm:5.1.2" @@ -31674,13 +31561,6 @@ __metadata: languageName: node linkType: hard -"remove-accents@npm:0.4.2": - version: 0.4.2 - resolution: "remove-accents@npm:0.4.2" - checksum: 84a6988555dea24115e2d1954db99509588d43fe55a1590f0b5894802776f7b488b3151c37ceb9e4f4b646f26b80b7325dcea2fae58bc3865df146e1fa606711 - languageName: node - linkType: hard - "remove-accents@npm:0.5.0": version: 0.5.0 resolution: "remove-accents@npm:0.5.0" @@ -35370,16 +35250,6 @@ __metadata: languageName: node linkType: hard -"unload@npm:2.2.0": - version: 2.2.0 - resolution: "unload@npm:2.2.0" - dependencies: - "@babel/runtime": ^7.6.2 - detect-node: ^2.0.4 - checksum: 88ba950c5ff83ab4f9bbd8f63bbf19ba09687ed3c434efd43b7338cc595bc574df8f9b155ee6eee7a435de3d3a4a226726988428977a68ba4907045f1fac5d41 - languageName: node - linkType: hard - "unpipe@npm:1.0.0, unpipe@npm:~1.0.0": version: 1.0.0 resolution: "unpipe@npm:1.0.0" From 4b1214c5b012b1fc91fe5ec0eea34662f260da46 Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:14:28 +1000 Subject: [PATCH 11/12] Update VerifyEmailPage.tsx --- packages/datatrak-web/src/views/VerifyEmailPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/datatrak-web/src/views/VerifyEmailPage.tsx b/packages/datatrak-web/src/views/VerifyEmailPage.tsx index c45691328a..2ab39f7c6d 100644 --- a/packages/datatrak-web/src/views/VerifyEmailPage.tsx +++ b/packages/datatrak-web/src/views/VerifyEmailPage.tsx @@ -4,7 +4,7 @@ */ import React, { useState } from 'react'; import { useNavigate, useSearchParams } from 'react-router-dom'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { EMAIL_VERIFICATION_STATUS } from '@tupaia/ui-components'; import { get } from '../api'; import { LoginPage } from '.'; From ba3f7ed092d197898aede907676c4877256e39c1 Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:44:57 +1000 Subject: [PATCH 12/12] Update useReportPreview.js --- .../src/VizBuilderApp/api/queries/useReportPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useReportPreview.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useReportPreview.js index 8aecefc140..c8187bab2b 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useReportPreview.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useReportPreview.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd */ import moment from 'moment'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { post } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants';