From aece1387dcbc22897a5f94e20aa6523355ba0f1e Mon Sep 17 00:00:00 2001 From: Salman <114740396+hrazasalman@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:51:54 +1000 Subject: [PATCH] tweak(tupaiaWeb): RN-1440: Upgrade React Query to V4 (#5870) * Bumping react-query * Bumping react-query to v4 * Update render.tsx * GitAction fix * fixing Reports.test.tsx * navigation bug fix * review update * removed logging * Update yarn.lock * Update yarn.lock * Update VerifyEmailPage.tsx * Update useReportPreview.js --- .../api/queries/useReportPreview.js | 2 +- .../src/views/VerifyEmailPage.tsx | 2 +- 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 +- .../tupaia-web/src/types/react-query.d.ts | 6 +- .../src/views/EmailVerificationModal.tsx | 2 +- .../ProjectAccessForm.tsx | 2 +- yarn.lock | 134 +----------------- 42 files changed, 49 insertions(+), 179 deletions(-) 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'; 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 '.'; diff --git a/packages/tupaia-web/package.json b/packages/tupaia-web/package.json index d2b9f430b6..d8e46853e7 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..f51744fbf6 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/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 }; } 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 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"