From 50a9e554bd1d0475b95d13357b38006572f65a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Dombya?= <135591453+hervedombya@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:38:26 +0200 Subject: [PATCH] fix theme issue --- .../CoreUiThemeProvider.tsx | 3 +++ .../toast/useMutationsHandler.test.tsx | 21 +++++++++++++----- .../components/toast/useMutationsHandler.ts | 22 +++++++++---------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx b/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx index b7ff7a537f..6526e2522f 100644 --- a/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx +++ b/src/lib/components/coreuithemeprovider/CoreUiThemeProvider.tsx @@ -7,8 +7,11 @@ import { space, fontSize } from '../../style/theme'; */ type Theme = { statusHealthy: string; + statusHealthyRGB: string; statusWarning: string; + statusWarningRGB: string; statusCritical: string; + statusCriticalRGB: string; selectedActive: string; highlight: string; border: string; diff --git a/src/lib/components/toast/useMutationsHandler.test.tsx b/src/lib/components/toast/useMutationsHandler.test.tsx index efc55a377f..5fb5d6eff3 100644 --- a/src/lib/components/toast/useMutationsHandler.test.tsx +++ b/src/lib/components/toast/useMutationsHandler.test.tsx @@ -11,13 +11,24 @@ const mockUseToast = useToast as jest.MockedFunction; describe('useMutationsHandler', () => { const mainMutation = { mutation: { - isLoading: false, - isSuccess: true, + context: undefined, + data: [], + failureCount: 0, + error: null, isError: false, isIdle: false, + isLoading: false, + isPaused: false, + isSuccess: true, + mutate: jest.fn(), + mutateAsync: jest.fn(), + reset: jest.fn(), + status: 'success', + variables: undefined, }, name: 'mutation1', - } as MutationConfig; + } as MutationConfig; + const dependantMutations = [ { mutation: { @@ -38,7 +49,7 @@ describe('useMutationsHandler', () => { name: 'mutation3', isPrimary: false, }, - ] as MutationConfig[]; + ] as MutationConfig[]; const messageDescriptionBuilder = jest.fn(() => 'message'); @@ -108,7 +119,7 @@ describe('useMutationsHandler', () => { }, name: 'mutation4', }, - ] as MutationConfig[]; + ] as MutationConfig[]; const { waitFor } = renderHook(() => useMutationsHandler({ diff --git a/src/lib/components/toast/useMutationsHandler.ts b/src/lib/components/toast/useMutationsHandler.ts index c74dbbdfc4..542551fe75 100644 --- a/src/lib/components/toast/useMutationsHandler.ts +++ b/src/lib/components/toast/useMutationsHandler.ts @@ -2,35 +2,35 @@ import { ReactNode, useCallback, useEffect } from 'react'; import { UseMutationResult } from 'react-query'; import { useToast } from './ToastProvider'; -export type MutationConfig = { - mutation: UseMutationResult; +export type MutationConfig = { + mutation: UseMutationResult; name: string; }; -type DescriptionBuilder = { - data?: Data; +type DescriptionBuilder = { + data?: unknown; error?: unknown; name: string; }; -type MutationsHandlerProps = { - mainMutation: MutationConfig; - dependantMutations?: MutationConfig[]; +type MutationsHandlerProps = { + mainMutation: MutationConfig; + dependantMutations?: MutationConfig[]; messageDescriptionBuilder: ( - successMutations: DescriptionBuilder[], - errorMutations: DescriptionBuilder[], + successMutations: DescriptionBuilder[], + errorMutations: DescriptionBuilder[], ) => ReactNode; toastStyles?: React.CSSProperties; onMainMutationSuccess?: () => void; }; -export const useMutationsHandler = ({ +export const useMutationsHandler = ({ mainMutation, dependantMutations, messageDescriptionBuilder, toastStyles, onMainMutationSuccess, -}: MutationsHandlerProps) => { +}: MutationsHandlerProps) => { const { showToast } = useToast(); const mutations = [ mainMutation,