diff --git a/packages/admin-panel/package.json b/packages/admin-panel/package.json index 263d09a98c..53a680437c 100644 --- a/packages/admin-panel/package.json +++ b/packages/admin-panel/package.json @@ -31,6 +31,8 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.47", "@material-ui/styles": "^4.9.10", + "@tanstack/react-query": "4.36.1", + "@tanstack/react-query-devtools": "4.36.1", "@tupaia/access-policy": "workspace:*", "@tupaia/types": "workspace:*", "@tupaia/ui-chart-components": "workspace:*", @@ -64,7 +66,6 @@ "react-hook-form": "^6.8.3", "react-icons": "^2.2.7", "react-password-strength-bar": "^0.3.2", - "react-query": "^3.19.0", "react-redux": "^5.0.6", "react-router": "6.3.0", "react-router-dom": "6.3.0", diff --git a/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportDashboardVisualisation.js b/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportDashboardVisualisation.js index 20f2d44719..ef43c59be4 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportDashboardVisualisation.js +++ b/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportDashboardVisualisation.js @@ -1,9 +1,9 @@ /** * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { download } from '../api'; export const useExportDashboardVisualisation = config => diff --git a/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportMapOverlayVisualisation.js b/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportMapOverlayVisualisation.js index 316bbfa554..9f06a33aae 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportMapOverlayVisualisation.js +++ b/packages/admin-panel/src/VizBuilderApp/api/mutations/useExportMapOverlayVisualisation.js @@ -1,9 +1,9 @@ /** * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { download } from '../api'; export const useExportMapOverlayVisualisation = config => diff --git a/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveDashboardVisualisation.js b/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveDashboardVisualisation.js index aba4f7aa28..e8583ac6d5 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveDashboardVisualisation.js +++ b/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveDashboardVisualisation.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 20211Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd * */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post, put } from '../api'; export const useSaveDashboardVisualisation = config => diff --git a/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveMapOverlayVisualisation.js b/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveMapOverlayVisualisation.js index 0918d41436..2f11d3b941 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveMapOverlayVisualisation.js +++ b/packages/admin-panel/src/VizBuilderApp/api/mutations/useSaveMapOverlayVisualisation.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 20211Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd * */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post, put } from '../api'; export const useSaveMapOverlayVisualisation = config => diff --git a/packages/admin-panel/src/VizBuilderApp/api/mutations/useUploadTestData.js b/packages/admin-panel/src/VizBuilderApp/api/mutations/useUploadTestData.js index 388a822c5c..678c5a14a0 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/mutations/useUploadTestData.js +++ b/packages/admin-panel/src/VizBuilderApp/api/mutations/useUploadTestData.js @@ -1,13 +1,13 @@ /** * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { upload } from '../api'; // Must match the file name expected by the back-end const FILE_NAME = 'testData'; export const useUploadTestData = () => - useMutation('uploadTestData', file => upload('uploadTestData', {}, FILE_NAME, file)); + useMutation(['uploadTestData'], file => upload('uploadTestData', {}, FILE_NAME, file)); diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useCountries.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useCountries.js index df232bb419..11070e5536 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useCountries.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useCountries.js @@ -1,8 +1,8 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useDashboardVisualisation.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useDashboardVisualisation.js index 2c2d5d90e1..987bfb6047 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useDashboardVisualisation.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useDashboardVisualisation.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useEntities.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useEntities.js index ee6fc40413..6850135457 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useEntities.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useEntities.js @@ -1,8 +1,8 @@ /** * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { stringifyQuery } from '@tupaia/utils'; import { get } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useLocations.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useLocations.js index 8da34e1367..516bea7b73 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useLocations.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useLocations.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ import { useEffect } from 'react'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import debounce from 'lodash.debounce'; import { get } from '../api'; diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlayVisualisation.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlayVisualisation.js index 017db2e280..8bf50b3e92 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlayVisualisation.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlayVisualisation.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlays.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlays.js index 537eb85e88..f4b4b99ba1 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlays.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useMapOverlays.js @@ -1,13 +1,13 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; export const useMapOverlays = () => - useQuery('mapOverlays', () => get('mapOverlays'), { + useQuery(['mapOverlays'], () => get('mapOverlays'), { ...DEFAULT_REACT_QUERY_OPTIONS, }); diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useProject.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useProject.js index f53c96a304..34eb087cbe 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useProject.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useProject.js @@ -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 { stringifyQuery } from '@tupaia/utils'; diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useProjects.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useProjects.js index e8166ace2b..1c22dbc202 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useProjects.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useProjects.js @@ -1,8 +1,8 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { stringifyQuery } from '@tupaia/utils'; @@ -11,7 +11,7 @@ import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; export const useProjects = columns => useQuery( - 'projects', + ['projects'], async () => { const defaultColumns = ['project.code', 'entity.name']; const endpoint = stringifyQuery(undefined, 'projects', { 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/admin-panel/src/VizBuilderApp/api/queries/useSearchPermissionGroups.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useSearchPermissionGroups.js index 85d044e737..e8920cc2fb 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useSearchPermissionGroups.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useSearchPermissionGroups.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ import { stringifyQuery } from '@tupaia/utils'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; diff --git a/packages/admin-panel/src/VizBuilderApp/api/queries/useSearchTransformSchemas.js b/packages/admin-panel/src/VizBuilderApp/api/queries/useSearchTransformSchemas.js index 3f795b9c7d..9095ca1439 100644 --- a/packages/admin-panel/src/VizBuilderApp/api/queries/useSearchTransformSchemas.js +++ b/packages/admin-panel/src/VizBuilderApp/api/queries/useSearchTransformSchemas.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 2022 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ import { stringifyQuery } from '@tupaia/utils'; -import { useQuery, QueryClient } from 'react-query'; +import { useQuery, QueryClient } from '@tanstack/react-query'; import { get } from '../api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../constants'; diff --git a/packages/admin-panel/src/api/mutations/useEditSurveyResponse.js b/packages/admin-panel/src/api/mutations/useEditSurveyResponse.js index e542311339..5de1e29fb2 100644 --- a/packages/admin-panel/src/api/mutations/useEditSurveyResponse.js +++ b/packages/admin-panel/src/api/mutations/useEditSurveyResponse.js @@ -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 { useApiContext } from '../../utilities/ApiProvider'; export const useEditSurveyResponse = (surveyResponseId, updatedSurveyResponse) => { diff --git a/packages/admin-panel/src/api/mutations/useLogin.js b/packages/admin-panel/src/api/mutations/useLogin.js index 1644725b17..63cdf6d9cd 100644 --- a/packages/admin-panel/src/api/mutations/useLogin.js +++ b/packages/admin-panel/src/api/mutations/useLogin.js @@ -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 { useLocation, useNavigate } from 'react-router-dom'; import { post } from '../../VizBuilderApp/api'; diff --git a/packages/admin-panel/src/api/mutations/useLogout.js b/packages/admin-panel/src/api/mutations/useLogout.js index 0479bcb937..acf5256f7a 100644 --- a/packages/admin-panel/src/api/mutations/useLogout.js +++ b/packages/admin-panel/src/api/mutations/useLogout.js @@ -3,13 +3,13 @@ * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { post } from '../../VizBuilderApp/api'; export const useLogout = onSuccess => { const queryClient = useQueryClient(); - return useMutation('logout', () => post('logout'), { + return useMutation(['logout'], () => post('logout'), { onSuccess: () => { queryClient.invalidateQueries(); if (onSuccess) onSuccess(); diff --git a/packages/admin-panel/src/api/mutations/useOneTimeLogin.js b/packages/admin-panel/src/api/mutations/useOneTimeLogin.js index c3989ab853..e942352658 100644 --- a/packages/admin-panel/src/api/mutations/useOneTimeLogin.js +++ b/packages/admin-panel/src/api/mutations/useOneTimeLogin.js @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { post } from '../../VizBuilderApp/api'; export const useOneTimeLogin = () => { diff --git a/packages/admin-panel/src/api/mutations/useRequestResetPassword.js b/packages/admin-panel/src/api/mutations/useRequestResetPassword.js index 20fe926659..222e460642 100644 --- a/packages/admin-panel/src/api/mutations/useRequestResetPassword.js +++ b/packages/admin-panel/src/api/mutations/useRequestResetPassword.js @@ -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 { post } from '../../VizBuilderApp/api'; export const useRequestResetPassword = () => { diff --git a/packages/admin-panel/src/api/mutations/useResetPassword.js b/packages/admin-panel/src/api/mutations/useResetPassword.js index 887a039120..9b2bfae7e8 100644 --- a/packages/admin-panel/src/api/mutations/useResetPassword.js +++ b/packages/admin-panel/src/api/mutations/useResetPassword.js @@ -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 { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; import { post } from '../../VizBuilderApp/api'; import { PASSWORD_RESET_TOKEN_PARAM } from '../../authentication'; diff --git a/packages/admin-panel/src/api/mutations/useUpdateProfile.js b/packages/admin-panel/src/api/mutations/useUpdateProfile.js index f5f67d0654..16252568fd 100644 --- a/packages/admin-panel/src/api/mutations/useUpdateProfile.js +++ b/packages/admin-panel/src/api/mutations/useUpdateProfile.js @@ -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 { put } from '../../VizBuilderApp/api'; export const useUpdateProfile = () => { diff --git a/packages/admin-panel/src/api/queries/useResourceDetails.js b/packages/admin-panel/src/api/queries/useResourceDetails.js index 2fe9813af3..deaabec3c1 100644 --- a/packages/admin-panel/src/api/queries/useResourceDetails.js +++ b/packages/admin-panel/src/api/queries/useResourceDetails.js @@ -1,8 +1,8 @@ /** * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../../VizBuilderApp/api/api'; export const useItemDetails = (params, parent) => { diff --git a/packages/admin-panel/src/api/queries/useSurveyResponses.js b/packages/admin-panel/src/api/queries/useSurveyResponses.js index 1a533faa0b..d0a7ab0bb8 100644 --- a/packages/admin-panel/src/api/queries/useSurveyResponses.js +++ b/packages/admin-panel/src/api/queries/useSurveyResponses.js @@ -1,8 +1,8 @@ /** * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../../VizBuilderApp/api/api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../../VizBuilderApp/api/constants'; diff --git a/packages/admin-panel/src/api/queries/useUser.js b/packages/admin-panel/src/api/queries/useUser.js index 6ba99258dd..9aa6103bc3 100644 --- a/packages/admin-panel/src/api/queries/useUser.js +++ b/packages/admin-panel/src/api/queries/useUser.js @@ -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 { get } from '../../VizBuilderApp/api'; export const useUser = () => { diff --git a/packages/admin-panel/src/dataTables/query/useDataTablePreview.js b/packages/admin-panel/src/dataTables/query/useDataTablePreview.js index f4eac23ae6..430beb7de0 100644 --- a/packages/admin-panel/src/dataTables/query/useDataTablePreview.js +++ b/packages/admin-panel/src/dataTables/query/useDataTablePreview.js @@ -1,8 +1,8 @@ /* * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { post } from '../../VizBuilderApp/api/api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../../VizBuilderApp/api/constants'; diff --git a/packages/admin-panel/src/dataTables/query/useExternalDatabaseConnections.js b/packages/admin-panel/src/dataTables/query/useExternalDatabaseConnections.js index 1d82f1d044..13a4a902ab 100644 --- a/packages/admin-panel/src/dataTables/query/useExternalDatabaseConnections.js +++ b/packages/admin-panel/src/dataTables/query/useExternalDatabaseConnections.js @@ -1,8 +1,8 @@ /* * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../../VizBuilderApp/api/api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../../VizBuilderApp/api/constants'; diff --git a/packages/admin-panel/src/dataTables/query/useFetchDataTableBuiltInParams.js b/packages/admin-panel/src/dataTables/query/useFetchDataTableBuiltInParams.js index ea43c3457c..9617b2d77a 100644 --- a/packages/admin-panel/src/dataTables/query/useFetchDataTableBuiltInParams.js +++ b/packages/admin-panel/src/dataTables/query/useFetchDataTableBuiltInParams.js @@ -1,8 +1,8 @@ /* * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../../VizBuilderApp/api/api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../../VizBuilderApp/api/constants'; diff --git a/packages/admin-panel/src/main.jsx b/packages/admin-panel/src/main.jsx index 892485f594..d36538f916 100644 --- a/packages/admin-panel/src/main.jsx +++ b/packages/admin-panel/src/main.jsx @@ -1,9 +1,9 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ import React, { lazy, Suspense } from 'react'; -import { QueryClient, QueryClientProvider } from 'react-query'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; import { render as renderReactApp } from 'react-dom'; import styled, { ThemeProvider } from 'styled-components'; diff --git a/packages/admin-panel/src/pages/resources/PermissionGroupsViewerPage.jsx b/packages/admin-panel/src/pages/resources/PermissionGroupsViewerPage.jsx index 7ec409c92b..630e739569 100644 --- a/packages/admin-panel/src/pages/resources/PermissionGroupsViewerPage.jsx +++ b/packages/admin-panel/src/pages/resources/PermissionGroupsViewerPage.jsx @@ -5,7 +5,7 @@ import React from 'react'; import styled from 'styled-components'; import { HorizontalTree } from '@tupaia/ui-components'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { PageHeader, PageBody } from '../../widgets'; import { LogsModal } from '../../logsTable'; import { get } from '../../VizBuilderApp/api'; diff --git a/packages/admin-panel/src/surveyResponse/useGetExistingData.js b/packages/admin-panel/src/surveyResponse/useGetExistingData.js index 9b52d5ee22..180d37e5cd 100644 --- a/packages/admin-panel/src/surveyResponse/useGetExistingData.js +++ b/packages/admin-panel/src/surveyResponse/useGetExistingData.js @@ -4,7 +4,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 '../VizBuilderApp/api/api'; import { DEFAULT_REACT_QUERY_OPTIONS } from '../VizBuilderApp/api/constants'; diff --git a/packages/admin-panel/src/surveys/useSuggestSurveyCode.js b/packages/admin-panel/src/surveys/useSuggestSurveyCode.js index dee1e5c239..dc76e51c64 100644 --- a/packages/admin-panel/src/surveys/useSuggestSurveyCode.js +++ b/packages/admin-panel/src/surveys/useSuggestSurveyCode.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; /** * @param {TupaiaApi} api diff --git a/packages/admin-panel/src/utilities/StoreProvider.jsx b/packages/admin-panel/src/utilities/StoreProvider.jsx index 2344ca544d..94006be40f 100644 --- a/packages/admin-panel/src/utilities/StoreProvider.jsx +++ b/packages/admin-panel/src/utilities/StoreProvider.jsx @@ -1,14 +1,14 @@ /* * Tupaia - * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ import React from 'react'; import PropTypes from 'prop-types'; import { createStore, applyMiddleware, compose } from 'redux'; import { Provider } from 'react-redux'; -import { QueryClient, QueryClientProvider } from 'react-query'; -import { ReactQueryDevtools } from 'react-query/devtools'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import thunk from 'redux-thunk'; import { rootReducer } from '../rootReducer'; diff --git a/packages/admin-panel/src/widgets/InputField/CheckboxListField.jsx b/packages/admin-panel/src/widgets/InputField/CheckboxListField.jsx index 7c2fd144b5..86d1911825 100644 --- a/packages/admin-panel/src/widgets/InputField/CheckboxListField.jsx +++ b/packages/admin-panel/src/widgets/InputField/CheckboxListField.jsx @@ -5,7 +5,7 @@ import React, { useMemo, useState } from 'react'; import PropTypes from 'prop-types'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import styled from 'styled-components'; import { FormControl as MuiFormControl, diff --git a/packages/central-server/src/dhis/pushLatest.js b/packages/central-server/src/dhis/pushLatest.js index b06cb4b31d..ed3c00b5af 100644 --- a/packages/central-server/src/dhis/pushLatest.js +++ b/packages/central-server/src/dhis/pushLatest.js @@ -19,6 +19,7 @@ export async function pushLatest(models, syncQueue, dataBroker, batchSize) { if (successfullyPushed) { await syncQueue.use(change); } else { + await syncQueue.registerBadRequest(change); await syncQueue.deprioritise(change); } } diff --git a/packages/central-server/src/dhis/pushers/entity/TrackedEntityPusher.js b/packages/central-server/src/dhis/pushers/entity/TrackedEntityPusher.js index de63b1fb12..f6d1eb38ca 100644 --- a/packages/central-server/src/dhis/pushers/entity/TrackedEntityPusher.js +++ b/packages/central-server/src/dhis/pushers/entity/TrackedEntityPusher.js @@ -74,6 +74,10 @@ export class TrackedEntityPusher extends EntityPusher { filter: { displayName: this.entityToTypeName(entity) }, }); + if (!trackedEntityType) { + throw new Error(`Tracked entity type not found for ${type}`); + } + return trackedEntityType.id; } diff --git a/packages/central-server/src/externalApiSync/ExternalApiSyncQueue.js b/packages/central-server/src/externalApiSync/ExternalApiSyncQueue.js index 113c243e79..1ca59e2fbe 100644 --- a/packages/central-server/src/externalApiSync/ExternalApiSyncQueue.js +++ b/packages/central-server/src/externalApiSync/ExternalApiSyncQueue.js @@ -165,11 +165,11 @@ export class ExternalApiSyncQueue { } registerBadRequest(change) { - // Update also causes change_time to be reset to current time - // so it will slot in at the back of its new priority group + // If the bad request count is over the limit, mark it as a dead letter if (change.bad_request_count > BAD_REQUEST_LIMIT) { return this.syncQueueModel.updateById(change.id, { is_dead_letter: true }); - } // Cap the priority + } + // Otherwise, increment the bad request count return this.syncQueueModel.updateById(change.id, { bad_request_count: change.bad_request_count + 1, }); diff --git a/packages/datatrak-web/package.json b/packages/datatrak-web/package.json index 1cbea0f9e2..04af35655d 100644 --- a/packages/datatrak-web/package.json +++ b/packages/datatrak-web/package.json @@ -15,6 +15,8 @@ "@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:*", "@tupaia/ui-components": "workspace:*", @@ -32,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/__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' }); 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'; 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/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..5f522213f1 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'; @@ -35,15 +35,13 @@ export const useLogin = () => { }, onSuccess: async ({ user }) => { await queryClient.invalidateQueries(); + await queryClient.removeQueries(); + if (from) { - navigate(from, { - state: null, - }); + navigate(from, { state: null }); } else { const path = user.projectId ? ROUTES.HOME : ROUTES.PROJECT_SELECT; - navigate(path, { - state: from, - }); + navigate(path, { state: from }); } }, meta: { 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/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/lesmis/package.json b/packages/lesmis/package.json index 5bc2c312a4..3468c269bc 100644 --- a/packages/lesmis/package.json +++ b/packages/lesmis/package.json @@ -28,6 +28,8 @@ "@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", + "@tanstack/react-query-devtools": "4.36.1", "@tupaia/access-policy": "workspace:*", "@tupaia/admin-panel": "workspace:*", "@tupaia/ui-chart-components": "workspace:*", @@ -49,7 +51,6 @@ "react-hook-form": "^6.15.1", "react-leaflet": "^3.2.1", "react-password-strength-bar": "^0.3.3", - "react-query": "^3.19.0", "react-redux": "^5.0.6", "react-router": "6.3.0", "react-router-dom": "6.3.0", diff --git a/packages/lesmis/src/AppProviders.jsx b/packages/lesmis/src/AppProviders.jsx index 567f1c85fb..026f7c4475 100755 --- a/packages/lesmis/src/AppProviders.jsx +++ b/packages/lesmis/src/AppProviders.jsx @@ -4,7 +4,7 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import { QueryClient, QueryClientProvider } from 'react-query'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { MuiThemeProvider, StylesProvider } from '@material-ui/core/styles'; import { ThemeProvider } from 'styled-components'; import CssBaseline from '@material-ui/core/CssBaseline'; diff --git a/packages/lesmis/src/api/mutations/useLogin.js b/packages/lesmis/src/api/mutations/useLogin.js index c6ab368167..e54399af51 100644 --- a/packages/lesmis/src/api/mutations/useLogin.js +++ b/packages/lesmis/src/api/mutations/useLogin.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 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 { useUser } from '../queries'; diff --git a/packages/lesmis/src/api/mutations/useLogout.js b/packages/lesmis/src/api/mutations/useLogout.js index 3cc351cf54..c1bbbc4c86 100644 --- a/packages/lesmis/src/api/mutations/useLogout.js +++ b/packages/lesmis/src/api/mutations/useLogout.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { post } from '../api'; import { useHomeUrl } from '../../utils/useHomeUrl'; diff --git a/packages/lesmis/src/api/mutations/useRegisterUser.js b/packages/lesmis/src/api/mutations/useRegisterUser.js index 8a6305b0ec..1ff23a573d 100644 --- a/packages/lesmis/src/api/mutations/useRegisterUser.js +++ b/packages/lesmis/src/api/mutations/useRegisterUser.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; import { post } from '../api'; export const useRegisterUser = () => { diff --git a/packages/lesmis/src/api/mutations/useUpdateFavouriteDashboardItem.js b/packages/lesmis/src/api/mutations/useUpdateFavouriteDashboardItem.js index ae8f9a6200..9ca3b8228a 100644 --- a/packages/lesmis/src/api/mutations/useUpdateFavouriteDashboardItem.js +++ b/packages/lesmis/src/api/mutations/useUpdateFavouriteDashboardItem.js @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2022 Beyond Essential Systems Pty Ltd */ -import { useMutation, useQueryClient } from 'react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; import { post } from '../api'; const updateExistingDashboardData = async (queryClient, { entityCode }) => { diff --git a/packages/lesmis/src/api/queries/useDashboardData.js b/packages/lesmis/src/api/queries/useDashboardData.js index b3c0268d25..676a5389d1 100644 --- a/packages/lesmis/src/api/queries/useDashboardData.js +++ b/packages/lesmis/src/api/queries/useDashboardData.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { QUERY_OPTIONS } from './constants'; diff --git a/packages/lesmis/src/api/queries/useDashboardReportData.js b/packages/lesmis/src/api/queries/useDashboardReportData.js index 0800ad473b..352e96e741 100644 --- a/packages/lesmis/src/api/queries/useDashboardReportData.js +++ b/packages/lesmis/src/api/queries/useDashboardReportData.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { useDashboardData } from './useDashboardData'; import { combineQueries } from './utils'; diff --git a/packages/lesmis/src/api/queries/useEmailVerification.js b/packages/lesmis/src/api/queries/useEmailVerification.js index cd3e45d691..4ea2bf6eff 100644 --- a/packages/lesmis/src/api/queries/useEmailVerification.js +++ b/packages/lesmis/src/api/queries/useEmailVerification.js @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { useUrlSearchParams } from '../../utils/useUrlSearchParams'; import { get } from '../api'; diff --git a/packages/lesmis/src/api/queries/useEntitiesData.js b/packages/lesmis/src/api/queries/useEntitiesData.js index 0171209d52..a2a0a67f06 100644 --- a/packages/lesmis/src/api/queries/useEntitiesData.js +++ b/packages/lesmis/src/api/queries/useEntitiesData.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import keyBy from 'lodash.keyby'; import { get } from '../api'; import { PROJECT_CODE } from '../../constants'; @@ -41,7 +41,7 @@ const PROJECT_PARAMS = { export const useProjectEntitiesData = () => { const query = useQuery( - 'entities', + ['entities'], () => get(`entities/${PROJECT_CODE}`, { params: PROJECT_PARAMS }), { staleTime: 1000 * 60 * 60 * 1, diff --git a/packages/lesmis/src/api/queries/useEntityData.js b/packages/lesmis/src/api/queries/useEntityData.js index ed0aeb1883..2ce8b4aecf 100644 --- a/packages/lesmis/src/api/queries/useEntityData.js +++ b/packages/lesmis/src/api/queries/useEntityData.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; import { useValidatedQuery } from './useValidatedQuery'; diff --git a/packages/lesmis/src/api/queries/useMapOverlayReportData.js b/packages/lesmis/src/api/queries/useMapOverlayReportData.js index 9f4b601ca5..a1f7e6b514 100644 --- a/packages/lesmis/src/api/queries/useMapOverlayReportData.js +++ b/packages/lesmis/src/api/queries/useMapOverlayReportData.js @@ -5,7 +5,7 @@ */ import { useState, useEffect, useCallback } from 'react'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import camelCase from 'camelcase'; import { autoAssignColors, diff --git a/packages/lesmis/src/api/queries/useMapOverlaysData.js b/packages/lesmis/src/api/queries/useMapOverlaysData.js index dfa666cf13..958f64610a 100644 --- a/packages/lesmis/src/api/queries/useMapOverlaysData.js +++ b/packages/lesmis/src/api/queries/useMapOverlaysData.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import camelCase from 'camelcase'; import { get } from '../api'; import { useEntitiesData } from './useEntitiesData'; diff --git a/packages/lesmis/src/api/queries/useUser.js b/packages/lesmis/src/api/queries/useUser.js index 494fb1bd21..efd21f01af 100644 --- a/packages/lesmis/src/api/queries/useUser.js +++ b/packages/lesmis/src/api/queries/useUser.js @@ -3,11 +3,11 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../api'; export const useUser = options => { - const query = useQuery('user', () => get('user'), { + const query = useQuery(['user'], () => get('user'), { retry: 0, // should be refetched in the background every hour staleTime: 1000 * 60 * 60 * 1, diff --git a/packages/lesmis/src/api/queries/useVitalsData.js b/packages/lesmis/src/api/queries/useVitalsData.js index 29c23321d6..f2630dd76f 100644 --- a/packages/lesmis/src/api/queries/useVitalsData.js +++ b/packages/lesmis/src/api/queries/useVitalsData.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd * */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { utcMoment } from '@tupaia/utils'; import { post } from '../api'; import { useProjectEntitiesData } from './useEntitiesData'; diff --git a/packages/lesmis/src/components/DashboardExportModal/DashboardExportModal.jsx b/packages/lesmis/src/components/DashboardExportModal/DashboardExportModal.jsx index 47e2a60ff5..c9cd7ba5cd 100644 --- a/packages/lesmis/src/components/DashboardExportModal/DashboardExportModal.jsx +++ b/packages/lesmis/src/components/DashboardExportModal/DashboardExportModal.jsx @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2022 Beyond Essential Systems Pty Ltd */ import React, { useState } from 'react'; -import { useIsFetching } from 'react-query'; +import { useIsFetching } from '@tanstack/react-query'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import DownloadIcon from '@material-ui/icons/GetApp'; diff --git a/packages/lesmis/src/components/LocaleMenu.jsx b/packages/lesmis/src/components/LocaleMenu.jsx index 09b356a00a..95b83528a1 100644 --- a/packages/lesmis/src/components/LocaleMenu.jsx +++ b/packages/lesmis/src/components/LocaleMenu.jsx @@ -4,7 +4,7 @@ * */ import React, { useState } from 'react'; -import { useQueryClient } from 'react-query'; +import { useQueryClient } from '@tanstack/react-query'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import { generatePath, useNavigate, useLocation } from 'react-router-dom'; diff --git a/packages/lesmis/src/main.jsx b/packages/lesmis/src/main.jsx index 1022a1ce6f..5efa2199df 100755 --- a/packages/lesmis/src/main.jsx +++ b/packages/lesmis/src/main.jsx @@ -4,7 +4,7 @@ */ import React from 'react'; import { render as renderReactApp } from 'react-dom'; -import { ReactQueryDevtools } from 'react-query/devtools'; +import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { EnvBanner } from '@tupaia/ui-components'; import { App } from './App'; import { AppProviders } from './AppProviders'; @@ -21,4 +21,3 @@ const render = () => { }; render(App); - diff --git a/packages/lesmis/src/views/AdminPanel/api/useUpdateSurveyResponseStatus.js b/packages/lesmis/src/views/AdminPanel/api/useUpdateSurveyResponseStatus.js index 61747e76b8..72b3f03fe6 100644 --- a/packages/lesmis/src/views/AdminPanel/api/useUpdateSurveyResponseStatus.js +++ b/packages/lesmis/src/views/AdminPanel/api/useUpdateSurveyResponseStatus.js @@ -2,7 +2,7 @@ * Tupaia * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd */ -import { useMutation } from 'react-query'; +import { useMutation } from '@tanstack/react-query'; export const useApproveSurveyResponseStatus = api => useMutation(id => api.post(`surveyResponse/${id}/resubmit`, {}, { approval_status: 'approved' })); diff --git a/packages/lesmis/src/views/DashboardView.jsx b/packages/lesmis/src/views/DashboardView.jsx index 8aaae607cf..b41b9e5575 100644 --- a/packages/lesmis/src/views/DashboardView.jsx +++ b/packages/lesmis/src/views/DashboardView.jsx @@ -6,7 +6,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import styled from 'styled-components'; -import { useIsFetching } from 'react-query'; +import { useIsFetching } from '@tanstack/react-query'; import { Select } from '@tupaia/ui-components'; import MuiBox from '@material-ui/core/Box'; import { VitalsView } from './VitalsView'; diff --git a/packages/psss/package.json b/packages/psss/package.json index bcf458cb18..76c2c80e7a 100644 --- a/packages/psss/package.json +++ b/packages/psss/package.json @@ -28,6 +28,8 @@ "@material-ui/lab": "^4.0.0-alpha.57", "@material-ui/pickers": "^3.2.10", "@material-ui/styles": "^4.9.10", + "@tanstack/react-query": "4.36.1", + "@tanstack/react-query-devtools": "4.36.1", "@tupaia/ui-components": "workspace:*", "@tupaia/utils": "workspace:*", "axios": "^1.6.8", @@ -44,7 +46,6 @@ "react-dom": "^16.13.1", "react-hook-form": "^6.0.0", "react-password-strength-bar": "^0.3.3", - "react-query": "^3.19.0", "react-redux": "^7.1.0", "react-router-dom": "^5.1.2", "redux": "^4.0.2", diff --git a/packages/psss/src/AppProviders.jsx b/packages/psss/src/AppProviders.jsx index f753f5abf6..f071d670de 100644 --- a/packages/psss/src/AppProviders.jsx +++ b/packages/psss/src/AppProviders.jsx @@ -5,7 +5,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Provider } from 'react-redux'; -import { QueryClient, QueryClientProvider } from 'react-query'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { MuiThemeProvider, StylesProvider } from '@material-ui/core/styles'; import { ThemeProvider } from 'styled-components'; import CssBaseline from '@material-ui/core/CssBaseline'; diff --git a/packages/psss/src/api/mutations.js b/packages/psss/src/api/mutations.js index 75a7680c41..58cc9ac059 100644 --- a/packages/psss/src/api/mutations.js +++ b/packages/psss/src/api/mutations.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd */ -import { useQueryClient, useMutation } from 'react-query'; +import { useQueryClient, useMutation } from '@tanstack/react-query'; import { remove, put, post } from './api'; export const useConfirmWeeklyReport = (countryCode, period) => { diff --git a/packages/psss/src/api/queries/helpers/query.js b/packages/psss/src/api/queries/helpers/query.js index f8a552a593..2e55002afb 100644 --- a/packages/psss/src/api/queries/helpers/query.js +++ b/packages/psss/src/api/queries/helpers/query.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { get } from '../../api'; const COMMON_QUERY_OPTIONS = { diff --git a/packages/psss/src/api/queries/useAlerts.js b/packages/psss/src/api/queries/useAlerts.js index d03d845bcc..b14395e49a 100644 --- a/packages/psss/src/api/queries/useAlerts.js +++ b/packages/psss/src/api/queries/useAlerts.js @@ -4,7 +4,7 @@ */ import orderBy from 'lodash.orderby'; -import { useQueryClient, useMutation } from 'react-query'; +import { useQueryClient, useMutation } from '@tanstack/react-query'; import { MIN_DATE, SYNDROMES } from '../../constants'; import { getPeriodByDate } from '../../utils'; import { useData } from './helpers'; diff --git a/packages/psss/src/api/queries/useSingleWeeklyReport.js b/packages/psss/src/api/queries/useSingleWeeklyReport.js index 551562b8c7..396a26dd70 100644 --- a/packages/psss/src/api/queries/useSingleWeeklyReport.js +++ b/packages/psss/src/api/queries/useSingleWeeklyReport.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd */ -import { useQueryClient } from 'react-query'; +import { useQueryClient } from '@tanstack/react-query'; import { calculateWeekStatus } from '../../utils'; import { REPORT_STATUSES } from '../../constants'; import { EMPTY_SYNDROME_DATA, getSyndromeData, useReport } from './helpers'; diff --git a/packages/psss/src/api/queries/useUpcomingReport.js b/packages/psss/src/api/queries/useUpcomingReport.js index bad7e061ec..e84e307999 100644 --- a/packages/psss/src/api/queries/useUpcomingReport.js +++ b/packages/psss/src/api/queries/useUpcomingReport.js @@ -3,7 +3,7 @@ * Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd */ -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { subtractWeeksFromPeriod, getDaysTillDueDay, getCurrentPeriod } from '../../utils'; import { get } from '../api'; import { REPORT_STATUSES } from '../../constants'; diff --git a/packages/psss/src/api/useTableQuery.js b/packages/psss/src/api/useTableQuery.js index 484ace7ce5..d5f35058a4 100644 --- a/packages/psss/src/api/useTableQuery.js +++ b/packages/psss/src/api/useTableQuery.js @@ -4,7 +4,7 @@ */ import { useState } from 'react'; -import { useQuery } from 'react-query'; +import { useQuery } from '@tanstack/react-query'; import { FakeAPI } from './FakeApi'; export const useTableQuery = (endpoint, options) => { diff --git a/packages/psss/src/components/DateToolbar/DateToolbar.jsx b/packages/psss/src/components/DateToolbar/DateToolbar.jsx index 09a39dc3af..884f78ec53 100644 --- a/packages/psss/src/components/DateToolbar/DateToolbar.jsx +++ b/packages/psss/src/components/DateToolbar/DateToolbar.jsx @@ -5,7 +5,7 @@ import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { useIsFetching } from 'react-query'; +import { useIsFetching } from '@tanstack/react-query'; import { comparePeriods } from '@tupaia/utils'; import { connect } from 'react-redux'; import Typography from '@material-ui/core/Typography'; diff --git a/packages/psss/src/main.jsx b/packages/psss/src/main.jsx index c99b11a23f..0d322c26da 100644 --- a/packages/psss/src/main.jsx +++ b/packages/psss/src/main.jsx @@ -4,7 +4,7 @@ */ import React from 'react'; import { render as renderReactApp } from 'react-dom'; -import { ReactQueryDevtools } from 'react-query/devtools'; +import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { EnvBanner } from '@tupaia/ui-components'; import App from './App'; import { AppProviders } from './AppProviders'; @@ -22,5 +22,3 @@ const render = () => { }; render(App); - - \ No newline at end of file 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/CheckboxList.tsx b/packages/tupaia-web/src/components/CheckboxList.tsx index 29e2d5554c..4f57fcbf44 100644 --- a/packages/tupaia-web/src/components/CheckboxList.tsx +++ b/packages/tupaia-web/src/components/CheckboxList.tsx @@ -22,7 +22,7 @@ const Error = styled(Typography).attrs({ `; interface CheckboxListProps { - options: { value: string; label: string }[]; + options: { value: string; label?: string }[]; legend: string; name: string; required?: boolean; @@ -38,7 +38,7 @@ export const CheckboxList = ({ options, legend, name, required }: CheckboxListPr { + const { + mutateAsync: fetchDownloadData, + isLoading, + error, + data: downloadResponse, + } = useDownloadRawData(report?.downloadUrl); + + const { data } = report; + + return ( + ({ + label: name, + value, + })) ?? [] + } + isLoading={isLoading} + onDownload={fetchDownloadData} + isEnlarged={isEnlarged} + error={error as Error} + > + {downloadResponse?.emailTimeoutHit && ( + + This export is taking a while, and will continue in the background. You will be emailed + when the export process completes. + + )} + + ); +}; diff --git a/packages/tupaia-web/src/features/Visuals/View/Download/DownloadFiles.tsx b/packages/tupaia-web/src/features/Visuals/View/Download/DownloadFiles.tsx new file mode 100644 index 0000000000..0959416441 --- /dev/null +++ b/packages/tupaia-web/src/features/Visuals/View/Download/DownloadFiles.tsx @@ -0,0 +1,39 @@ +/* + * Tupaia + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd + */ + +import React from 'react'; +import { ViewConfig, ViewReport } from '@tupaia/types'; +import { useDownloadFiles } from '../../../../api/mutations'; +import { DownloadVisual } from './DownloadVisual'; + +interface DownloadFilesVisualProps { + report: ViewReport; + config: ViewConfig; + isEnlarged?: boolean; +} + +export const DownloadFiles = ({ report, isEnlarged }: DownloadFilesVisualProps) => { + const { mutate: download, error, reset, isLoading } = useDownloadFiles(); + const options = + report?.data?.map(({ label, uniqueFileName }) => ({ + value: uniqueFileName, + label, + })) ?? []; + + const downloadSelectedFiles = selectedValues => { + download(Array.isArray(selectedValues) ? selectedValues : [selectedValues]); + }; + + return ( + + ); +}; diff --git a/packages/tupaia-web/src/features/Visuals/View/DataDownload.tsx b/packages/tupaia-web/src/features/Visuals/View/Download/DownloadVisual.tsx similarity index 56% rename from packages/tupaia-web/src/features/Visuals/View/DataDownload.tsx rename to packages/tupaia-web/src/features/Visuals/View/Download/DownloadVisual.tsx index 46b639f4ce..ef74b682e8 100644 --- a/packages/tupaia-web/src/features/Visuals/View/DataDownload.tsx +++ b/packages/tupaia-web/src/features/Visuals/View/Download/DownloadVisual.tsx @@ -1,17 +1,15 @@ /** * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd */ import React from 'react'; import styled from 'styled-components'; -import { useSearchParams } from 'react-router-dom'; import { useForm } from 'react-hook-form'; -import { Alert, Button, SpinningLoader } from '@tupaia/ui-components'; +import { useSearchParams } from 'react-router-dom'; import { List, Typography } from '@material-ui/core'; -import { ViewReport } from '@tupaia/types'; -import { CheckboxList, Form as BaseForm } from '../../../components'; -import { URL_SEARCH_PARAMS } from '../../../constants'; -import { useDownloadRawData } from '../../../api/mutations'; +import { Button, SpinningLoader } from '@tupaia/ui-components'; +import { CheckboxList, Form as BaseForm } from '../../../../components'; +import { URL_SEARCH_PARAMS } from '../../../../constants'; const ListItem = styled.li` text-align: center; @@ -54,6 +52,7 @@ const FormButton = styled(Button)` const CheckboxListWrapper = styled.div` width: 30rem; max-width: 100%; + flex-grow: 1; `; const ErrorMessage = styled(Typography).attrs({ @@ -63,67 +62,53 @@ const ErrorMessage = styled(Typography).attrs({ margin-bottom: 1rem; `; -const EmailDownloadAlert = styled(Alert).attrs({ - severity: 'info', -})` - margin-bottom: 1rem; -`; - -interface DataDownloadProps { - report: ViewReport; +interface DownloadVisualProps { + options: { label?: string; value: any }[]; + isLoading: boolean; + onDownload: (selectedValues: string[]) => void; isEnlarged?: boolean; + children?: React.ReactNode; + error?: Error; + onClose?: () => void; } -export const DataDownload = ({ report, isEnlarged }: DataDownloadProps) => { +/** + * @description Component for downloading data from a visual. This component is used in the DataDownload and DownloadFiles visuals. + */ +export const DownloadVisual = ({ + options, + isLoading, + onDownload, + isEnlarged, + children, + error, + onClose, +}: DownloadVisualProps) => { const [urlSearchParams, setUrlSearchParams] = useSearchParams(); const reportCode = urlSearchParams.get(URL_SEARCH_PARAMS.REPORT); const formContext = useForm({ mode: 'onChange', }); - const selectedCodes = formContext.watch(reportCode!); - const { - mutateAsync: fetchDownloadData, - isLoading, - error, - data: downloadResponse, - } = useDownloadRawData(report?.downloadUrl); + const selectedValues = formContext.watch(reportCode!); - const { data } = report; if (!isEnlarged) - return ( - - {data?.map(({ name }) => ( - {name} - ))} - - ); + return {options?.map(({ label }) => {label})}; const closeModal = () => { urlSearchParams.delete(URL_SEARCH_PARAMS.REPORT); urlSearchParams.delete(URL_SEARCH_PARAMS.REPORT_PERIOD); setUrlSearchParams(urlSearchParams); + if (onClose) onClose(); }; return isLoading ? ( ) : (
- {downloadResponse?.emailTimeoutHit && ( - - This export is taking a while, and will continue in the background. You will be emailed - when the export process completes. - - )} + {children} {error && {error.message}} ({ - label: name, - value: value as string, - })) - : [] - } + options={options} name={reportCode!} legend="Select the data you wish to download" required @@ -135,8 +120,8 @@ export const DataDownload = ({ report, isEnlarged }: DataDownloadProps) => { Cancel fetchDownloadData(selectedCodes)} + disabled={!selectedValues || selectedValues.length === 0 || isLoading} + onClick={() => onDownload(selectedValues)} > Download diff --git a/packages/tupaia-web/src/features/Visuals/View/Download/index.ts b/packages/tupaia-web/src/features/Visuals/View/Download/index.ts new file mode 100644 index 0000000000..15d46b2263 --- /dev/null +++ b/packages/tupaia-web/src/features/Visuals/View/Download/index.ts @@ -0,0 +1,7 @@ +/** + * Tupaia + * Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd + */ + +export { DownloadFiles } from './DownloadFiles'; +export { DataDownload } from './DataDownload'; diff --git a/packages/tupaia-web/src/features/Visuals/View/DownloadFiles.tsx b/packages/tupaia-web/src/features/Visuals/View/DownloadFiles.tsx deleted file mode 100644 index 58f601aeb4..0000000000 --- a/packages/tupaia-web/src/features/Visuals/View/DownloadFiles.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd - */ - -import React from 'react'; -import styled from 'styled-components'; -import { darken } from '@material-ui/core'; -import { useSearchParams } from 'react-router-dom'; -import { ViewConfig, ViewReport } from '@tupaia/types'; -import { DownloadFilesVisual } from '@tupaia/ui-components'; -import { useDownloadFiles } from '../../../api/mutations'; -import { URL_SEARCH_PARAMS } from '../../../constants'; - -const StyledDownloadFilesVisual = styled(DownloadFilesVisual)` - .filename { - color: ${({ theme }) => darken(theme.palette.common.white, 0.1)}; - } - .checkbox-icon { - color: ${({ theme }) => darken(theme.palette.common.white, 0.1)}; - } - button { - text-transform: none; - font-size: 1rem; - padding: 0.5rem 1rem; - } - // override button styles from @tupaia/ui-components to match the theme of the app - .MuiButton-text { - border: 1px solid ${({ theme }) => theme.palette.primary.main}; - color: ${({ theme }) => theme.palette.primary.main}; - } - .MuiButton-containedPrimary { - box-shadow: none; - border: 1px solid ${({ theme }) => theme.palette.primary.main}; - &:hover { - border-color: ${({ theme }) => darken(theme.palette.primary.main, 0.3)}; - } - } -`; - -interface DownloadFilesVisualProps { - report: ViewReport; - config: ViewConfig; - isEnlarged?: boolean; -} - -export const DownloadFiles = ({ report, config, isEnlarged }: DownloadFilesVisualProps) => { - const [urlSearchParams, setUrlSearchParams] = useSearchParams(); - - const { mutateAsync: download, error, reset, isLoading } = useDownloadFiles(); - - const onClose = () => { - reset(); - urlSearchParams.delete(URL_SEARCH_PARAMS.REPORT); - setUrlSearchParams(urlSearchParams); - }; - - const errorObj = error as Error; - - return ( - Promise} - error={errorObj?.message} - isEnlarged={isEnlarged} - onClose={onClose} - isLoading={isLoading} - /> - ); -}; diff --git a/packages/tupaia-web/src/features/Visuals/View/View.tsx b/packages/tupaia-web/src/features/Visuals/View/View.tsx index b947ebc3be..9c776cab62 100644 --- a/packages/tupaia-web/src/features/Visuals/View/View.tsx +++ b/packages/tupaia-web/src/features/Visuals/View/View.tsx @@ -12,8 +12,7 @@ import { SingleDate } from './SingleDate'; import { SingleValue } from './SingleValue'; import { MultiValue } from './MultiValue'; import { MultiValueRow } from './MultiValueRow'; -import { DataDownload } from './DataDownload'; -import { DownloadFiles } from './DownloadFiles'; +import { DataDownload, DownloadFiles } from './Download'; import { QRCode } from './QRCode'; import { MultiPhotograph } from './MultiPhotograph'; 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/packages/ui-components/src/components/DownloadFilesVisual.tsx b/packages/ui-components/src/components/DownloadFilesVisual.tsx deleted file mode 100644 index 0d40fd6436..0000000000 --- a/packages/ui-components/src/components/DownloadFilesVisual.tsx +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Tupaia - * Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd - */ - -import React, { useState } from 'react'; -import styled from 'styled-components'; -import { - Button, - Checkbox, - DialogActions, - FormControl, - FormControlLabel, - FormGroup, -} from '@material-ui/core'; -import { ViewConfig, ViewReport } from '@tupaia/types'; -import CheckboxIcon from '@material-ui/icons/CheckBox'; -import { NoData } from './NoData'; - -const Container = styled.div` - display: flex; - flex-direction: column; - flex: 1; - justify-content: space-between; -`; - -const FormContainer = styled.div` - display: flex; - justify-content: center; - padding: 20px 40px 30px 40px; -`; - -const FileName = styled.span` - flex: 1; - margin-top: 10px; - font-size: 20px; - text-align: center; - display: block; - color: ${props => props.theme.palette.primary.contrastText}; -`; - -const Error = styled.div` - color: ${props => props.theme.palette.error.main}; - margin-top: 10px; - text-align: center; -`; - -interface DownloadFilesVisualProps { - downloadFiles: (uniqueFileNames: string[]) => Promise; - config?: ViewConfig; - report?: ViewReport; - isLoading?: boolean; - isEnlarged?: boolean; - onClose?: () => void; - className?: string; - error?: string; -} - -export const DownloadFilesVisual = ({ - downloadFiles, - config, - isLoading, - isEnlarged, - onClose, - className, - error, - report, -}: DownloadFilesVisualProps) => { - const options = report?.data ?? []; - // selectedFiles: Map of uniqueFileName: string => isSelected: bool - const noneSelected = Object.fromEntries( - options.map(({ uniqueFileName }) => [uniqueFileName, false]), - ); - const [selectedFiles, setSelectedFiles] = useState(noneSelected); - - const toggleSelectFile = (uniqueFileName: string) => - setSelectedFiles({ ...selectedFiles, [uniqueFileName]: !selectedFiles[uniqueFileName] }); - - const [isDownloading, setIsDownloading] = useState(false); - - const downloadSelectedFiles = async () => { - setIsDownloading(true); - const selectedUniqueFilenames = Object.entries(selectedFiles) - .filter(([, isSelected]) => isSelected) - .map(([name]) => name); - await downloadFiles(selectedUniqueFilenames); - setIsDownloading(false); - }; - - if (!isEnlarged) { - return ( - - {options.map(({ label, uniqueFileName }) => ( - - {label} - - ))} - - ); - } - - if (!isLoading && options.length === 0) { - return ( - - - - ); - } - - if (error) { - return ( - - {error} - - - - - ); - } - - return ( - - - - - {options.map(({ uniqueFileName, label }) => ( - } - onChange={() => toggleSelectFile(uniqueFileName)} - value={uniqueFileName} - /> - } - label={label} - /> - ))} - - - - - - - - - ); -}; diff --git a/packages/ui-components/src/components/index.ts b/packages/ui-components/src/components/index.ts index ceaaa522b8..6846547476 100644 --- a/packages/ui-components/src/components/index.ts +++ b/packages/ui-components/src/components/index.ts @@ -16,7 +16,6 @@ export * from './DataGrid'; export * from './DataTable'; export * from './DateRangePicker'; export * from './Dialog'; -export * from './DownloadFilesVisual'; export * from './Editor'; export * from './EnvBanner'; export * from './ErrorBoundary'; diff --git a/yarn.lock b/yarn.lock index 76b08061a4..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: @@ -9550,6 +9550,56 @@ __metadata: languageName: node linkType: hard +"@tanstack/match-sorter-utils@npm:^8.7.0": + version: 8.19.4 + resolution: "@tanstack/match-sorter-utils@npm:8.19.4" + dependencies: + remove-accents: 0.5.0 + checksum: 7ec302d75be1f65a3e91dd30b567e47e56c13577937276ef3a3ac7c8560a0b9f6dcaca44dd877189375ce9e7401d250895265adb0741ec867eda4e47d0f07dc0 + 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-devtools@npm:4.36.1": + version: 4.36.1 + resolution: "@tanstack/react-query-devtools@npm:4.36.1" + dependencies: + "@tanstack/match-sorter-utils": ^8.7.0 + superjson: ^1.10.0 + use-sync-external-store: ^1.2.0 + peerDependencies: + "@tanstack/react-query": ^4.36.1 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 + checksum: d4f7da4121a933be0d0406fb75f682b193a33e7d4ba9a4d54ff19e04db823d00513fbe86230c43d34aae55f6d0d1f8be17315f19d515b298b6bb0dabd0c5d261 + 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" @@ -9760,6 +9810,8 @@ __metadata: "@material-ui/icons": ^4.9.1 "@material-ui/lab": ^4.0.0-alpha.47 "@material-ui/styles": ^4.9.10 + "@tanstack/react-query": 4.36.1 + "@tanstack/react-query-devtools": 4.36.1 "@tupaia/access-policy": "workspace:*" "@tupaia/types": "workspace:*" "@tupaia/ui-chart-components": "workspace:*" @@ -9794,7 +9846,6 @@ __metadata: react-hook-form: ^6.8.3 react-icons: ^2.2.7 react-password-strength-bar: ^0.3.2 - react-query: ^3.19.0 react-redux: ^5.0.6 react-router: 6.3.0 react-router-dom: 6.3.0 @@ -10073,6 +10124,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 "@testing-library/user-event": ^13.5.0 @@ -10099,7 +10151,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 @@ -10237,6 +10288,8 @@ __metadata: "@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 + "@tanstack/react-query-devtools": 4.36.1 "@tupaia/access-policy": "workspace:*" "@tupaia/admin-panel": "workspace:*" "@tupaia/ui-chart-components": "workspace:*" @@ -10259,7 +10312,6 @@ __metadata: react-hook-form: ^6.15.1 react-leaflet: ^3.2.1 react-password-strength-bar: ^0.3.3 - react-query: ^3.19.0 react-redux: ^5.0.6 react-router: 6.3.0 react-router-dom: 6.3.0 @@ -10395,6 +10447,8 @@ __metadata: "@material-ui/lab": ^4.0.0-alpha.57 "@material-ui/pickers": ^3.2.10 "@material-ui/styles": ^4.9.10 + "@tanstack/react-query": 4.36.1 + "@tanstack/react-query-devtools": 4.36.1 "@tupaia/auth": "workspace:*" "@tupaia/database": "workspace:*" "@tupaia/ui-components": "workspace:*" @@ -10416,7 +10470,6 @@ __metadata: react-dom: ^16.13.1 react-hook-form: ^6.0.0 react-password-strength-bar: ^0.3.3 - react-query: ^3.19.0 react-redux: ^7.1.0 react-router-dom: ^5.1.2 redux: ^4.0.2 @@ -10575,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:*" @@ -10598,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 @@ -14163,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" @@ -14380,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" @@ -16015,6 +16045,15 @@ __metadata: languageName: node linkType: hard +"copy-anything@npm:^3.0.2": + version: 3.0.5 + resolution: "copy-anything@npm:3.0.5" + dependencies: + is-what: ^4.1.8 + checksum: d39f6601c16b7cbd81cdb1c1f40f2bf0f2ca0297601cf7bfbb4ef1d85374a6a89c559502329f5bada36604464df17623e111fe19a9bb0c3f6b1c92fe2cbe972f + languageName: node + linkType: hard + "copy-descriptor@npm:^0.1.0": version: 0.1.1 resolution: "copy-descriptor@npm:0.1.1" @@ -17301,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" @@ -22741,6 +22766,13 @@ __metadata: languageName: node linkType: hard +"is-what@npm:^4.1.8": + version: 4.1.16 + resolution: "is-what@npm:4.1.16" + checksum: baf99e4b9f06003ceb3b2eea4a1e17179524ee3a6310dc44903eb675cfe3c0a17819ab057bb1ae6ba7ca4939ae4bdfcc6a0c4210a8457aff1756abd3607b713c + languageName: node + linkType: hard + "is-windows@npm:^1.0.2": version: 1.0.2 resolution: "is-windows@npm:1.0.2" @@ -23742,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" @@ -25643,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" @@ -26173,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" @@ -26812,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" @@ -27786,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" @@ -30599,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" @@ -31605,10 +31561,10 @@ __metadata: languageName: node linkType: hard -"remove-accents@npm:0.4.2": - version: 0.4.2 - resolution: "remove-accents@npm:0.4.2" - checksum: 84a6988555dea24115e2d1954db99509588d43fe55a1590f0b5894802776f7b488b3151c37ceb9e4f4b646f26b80b7325dcea2fae58bc3865df146e1fa606711 +"remove-accents@npm:0.5.0": + version: 0.5.0 + resolution: "remove-accents@npm:0.5.0" + checksum: 7045b37015acb03df406d21f9cbe93c3fcf2034189f5d2e33b1dace9c7d6bdcd839929905ced21a5d76c58553557e1a42651930728702312a5774179d5b9147b languageName: node linkType: hard @@ -33869,6 +33825,15 @@ __metadata: languageName: node linkType: hard +"superjson@npm:^1.10.0": + version: 1.13.3 + resolution: "superjson@npm:1.13.3" + dependencies: + copy-anything: ^3.0.2 + checksum: f5aeb010f24163cb871a4bc402d9164112201c059afc247a75b03131c274aea6eec9cf08be9e4a9465fe4961689009a011584528531d52f7cc91c077e07e5c75 + languageName: node + linkType: hard + "supertest@npm:^3.1.0": version: 3.4.2 resolution: "supertest@npm:3.4.2" @@ -35285,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" @@ -35525,6 +35480,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"