From 397c106fd07e67254956099fb2c4dca3e128d3a0 Mon Sep 17 00:00:00 2001 From: Tom Caiger Date: Fri, 30 Aug 2024 16:53:28 +1200 Subject: [PATCH 1/4] Update Tile.tsx --- packages/datatrak-web/src/components/Tile.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/datatrak-web/src/components/Tile.tsx b/packages/datatrak-web/src/components/Tile.tsx index 0ad8bce8c7..92170d8f1b 100644 --- a/packages/datatrak-web/src/components/Tile.tsx +++ b/packages/datatrak-web/src/components/Tile.tsx @@ -30,6 +30,7 @@ const ButtonWrapper = styled(Wrapper).attrs({ flex-direction: row; position: relative; justify-content: flex-start; + align-items: flex-start; svg { margin-right: 0.4rem; From a01140bd0237ae7f94cb826c957c29253f279ae4 Mon Sep 17 00:00:00 2001 From: Tom Caiger Date: Fri, 30 Aug 2024 17:08:48 +1200 Subject: [PATCH 2/4] wip --- packages/datatrak-web/src/AppProviders.tsx | 5 +++-- packages/datatrak-web/src/api/mutations/useLogout.ts | 4 ++-- packages/datatrak-web/src/api/queries/useSurveyResponse.ts | 3 +++ packages/datatrak-web/src/features/SurveyResponseModal.tsx | 7 ++++++- .../src/features/Tasks/TaskDetails/TaskDetails.tsx | 6 ++++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/datatrak-web/src/AppProviders.tsx b/packages/datatrak-web/src/AppProviders.tsx index 91420be209..65e31b60dd 100755 --- a/packages/datatrak-web/src/AppProviders.tsx +++ b/packages/datatrak-web/src/AppProviders.tsx @@ -5,12 +5,12 @@ import React, { ReactNode } from 'react'; import { MutationCache, QueryCache, QueryClient, QueryClientProvider } from 'react-query'; import { ThemeProvider as MuiThemeProvider, StylesProvider } from '@material-ui/core/styles'; +import { ReactQueryDevtools } from 'react-query/devtools'; import CssBaseline from '@material-ui/core/CssBaseline'; import { ThemeProvider } from 'styled-components'; import { SnackbarProvider } from 'notistack'; import { theme } from './theme'; import { Toast } from './components'; -import { errorToast } from './utils'; import { CurrentUserContextProvider } from './api'; import { REDIRECT_ERROR_PARAM } from './constants'; @@ -21,7 +21,7 @@ const handleError = (error: any, query: any) => { } if (!query?.meta || !query?.meta?.applyCustomErrorHandling) { - errorToast(error.message); + // errorToast(error.message); } }; @@ -56,6 +56,7 @@ export const AppProviders = ({ children, queryClient = defaultQueryClient }: App + { const queryClient = useQueryClient(); return useMutation('logout', () => post('logout'), { - onSuccess: () => { - queryClient.invalidateQueries(); + onSuccess: async () => { + await queryClient.resetQueries(); removeTaskFilterSetting('all_assignees_tasks'); removeTaskFilterSetting('show_completed_tasks'); removeTaskFilterSetting('show_cancelled_tasks'); diff --git a/packages/datatrak-web/src/api/queries/useSurveyResponse.ts b/packages/datatrak-web/src/api/queries/useSurveyResponse.ts index e0ca317b41..293ce01245 100644 --- a/packages/datatrak-web/src/api/queries/useSurveyResponse.ts +++ b/packages/datatrak-web/src/api/queries/useSurveyResponse.ts @@ -16,6 +16,9 @@ export const useSurveyResponse = ( get(`surveyResponse/${surveyResponseId}`), { enabled: !!surveyResponseId && options?.enabled !== false, + meta: { + applyCustomErrorHandling: true, + }, ...options, }, ); diff --git a/packages/datatrak-web/src/features/SurveyResponseModal.tsx b/packages/datatrak-web/src/features/SurveyResponseModal.tsx index 49f4d82d01..34af86bdf6 100644 --- a/packages/datatrak-web/src/features/SurveyResponseModal.tsx +++ b/packages/datatrak-web/src/features/SurveyResponseModal.tsx @@ -123,7 +123,12 @@ export const SurveyResponseModal = () => { const surveyResponseId = urlSearchParams.get('responseId'); - const { data: surveyResponse, isLoading, error, isFetched } = useSurveyResponse(surveyResponseId); + const { + data: surveyResponse, + isLoading, + error, + isFetched, + } = useSurveyResponse(surveyResponseId, { meta: { applyCustomErrorHandling: true } }); const isLoadingSurveyResponse = isLoading || !isFetched; diff --git a/packages/datatrak-web/src/features/Tasks/TaskDetails/TaskDetails.tsx b/packages/datatrak-web/src/features/Tasks/TaskDetails/TaskDetails.tsx index 9875b89647..11a16bba74 100644 --- a/packages/datatrak-web/src/features/Tasks/TaskDetails/TaskDetails.tsx +++ b/packages/datatrak-web/src/features/Tasks/TaskDetails/TaskDetails.tsx @@ -12,7 +12,7 @@ import { LoadingContainer } from '@tupaia/ui-components'; import { useEditTask, useSurveyResponse } from '../../../api'; import { displayDate } from '../../../utils'; import { Button as BaseButton, SurveyTickIcon, Tile } from '../../../components'; -import { SingleTaskResponse } from '../../../types'; +import { SingleTaskResponse } from '../../../types'; import { RepeatScheduleInput } from '../RepeatScheduleInput'; import { DueDatePicker } from '../DueDatePicker'; import { AssigneeInput } from '../AssigneeInput'; @@ -114,7 +114,9 @@ const SectionHeading = styled(Typography).attrs({ `; const InitialRequest = ({ initialRequestId }) => { - const { data: surveyResponse, isLoading } = useSurveyResponse(initialRequestId); + const { data: surveyResponse, isLoading } = useSurveyResponse(initialRequestId, { + meta: { applyCustomErrorHandling: true }, + }); if (isLoading || !surveyResponse) { return null; } From 8a999e98728d7197e27a5917c99a084faec7f99f Mon Sep 17 00:00:00 2001 From: Tom Caiger Date: Mon, 2 Sep 2024 10:55:52 +1200 Subject: [PATCH 3/4] cleanup --- packages/datatrak-web/src/AppProviders.tsx | 5 ++--- packages/datatrak-web/src/api/queries/useSurveyResponse.ts | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/datatrak-web/src/AppProviders.tsx b/packages/datatrak-web/src/AppProviders.tsx index 65e31b60dd..91420be209 100755 --- a/packages/datatrak-web/src/AppProviders.tsx +++ b/packages/datatrak-web/src/AppProviders.tsx @@ -5,12 +5,12 @@ import React, { ReactNode } from 'react'; import { MutationCache, QueryCache, QueryClient, QueryClientProvider } from 'react-query'; import { ThemeProvider as MuiThemeProvider, StylesProvider } from '@material-ui/core/styles'; -import { ReactQueryDevtools } from 'react-query/devtools'; import CssBaseline from '@material-ui/core/CssBaseline'; import { ThemeProvider } from 'styled-components'; import { SnackbarProvider } from 'notistack'; import { theme } from './theme'; import { Toast } from './components'; +import { errorToast } from './utils'; import { CurrentUserContextProvider } from './api'; import { REDIRECT_ERROR_PARAM } from './constants'; @@ -21,7 +21,7 @@ const handleError = (error: any, query: any) => { } if (!query?.meta || !query?.meta?.applyCustomErrorHandling) { - // errorToast(error.message); + errorToast(error.message); } }; @@ -56,7 +56,6 @@ export const AppProviders = ({ children, queryClient = defaultQueryClient }: App - Date: Mon, 2 Sep 2024 11:20:25 +1200 Subject: [PATCH 4/4] Update TaskTile.tsx --- packages/datatrak-web/src/features/Tasks/TaskTile.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/datatrak-web/src/features/Tasks/TaskTile.tsx b/packages/datatrak-web/src/features/Tasks/TaskTile.tsx index 3c91307ed9..9fac9ed87a 100644 --- a/packages/datatrak-web/src/features/Tasks/TaskTile.tsx +++ b/packages/datatrak-web/src/features/Tasks/TaskTile.tsx @@ -62,6 +62,7 @@ const TileContent = styled.div` align-items: center; > span { + text-wrap: nowrap; margin-inline-end: 0.6rem; } `;