Skip to content

Commit

Permalink
fix theme issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hervedombya committed Oct 16, 2023
1 parent 11c5c0f commit 50a9e55
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 16 additions & 5 deletions src/lib/components/toast/useMutationsHandler.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ const mockUseToast = useToast as jest.MockedFunction<typeof useToast>;
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<unknown, unknown>;
} as MutationConfig;

const dependantMutations = [
{
mutation: {
Expand All @@ -38,7 +49,7 @@ describe('useMutationsHandler', () => {
name: 'mutation3',
isPrimary: false,
},
] as MutationConfig<unknown, unknown>[];
] as MutationConfig[];

const messageDescriptionBuilder = jest.fn(() => 'message');

Expand Down Expand Up @@ -108,7 +119,7 @@ describe('useMutationsHandler', () => {
},
name: 'mutation4',
},
] as MutationConfig<unknown, unknown>[];
] as MutationConfig[];

const { waitFor } = renderHook(() =>
useMutationsHandler({
Expand Down
22 changes: 11 additions & 11 deletions src/lib/components/toast/useMutationsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ import { ReactNode, useCallback, useEffect } from 'react';
import { UseMutationResult } from 'react-query';
import { useToast } from './ToastProvider';

export type MutationConfig<Data = unknown, Variables = unknown> = {
mutation: UseMutationResult<Data, unknown, Variables, unknown>;
export type MutationConfig = {
mutation: UseMutationResult;
name: string;
};

type DescriptionBuilder<Data = unknown> = {
data?: Data;
type DescriptionBuilder = {
data?: unknown;
error?: unknown;
name: string;
};

type MutationsHandlerProps<Data = unknown, Variables = unknown> = {
mainMutation: MutationConfig<Data, Variables>;
dependantMutations?: MutationConfig<Data, Variables>[];
type MutationsHandlerProps = {
mainMutation: MutationConfig;
dependantMutations?: MutationConfig[];
messageDescriptionBuilder: (
successMutations: DescriptionBuilder<Data>[],
errorMutations: DescriptionBuilder<Data>[],
successMutations: DescriptionBuilder[],
errorMutations: DescriptionBuilder[],
) => ReactNode;
toastStyles?: React.CSSProperties;
onMainMutationSuccess?: () => void;
};

export const useMutationsHandler = <Data = unknown, Variables = unknown>({
export const useMutationsHandler = <Data>({
mainMutation,
dependantMutations,
messageDescriptionBuilder,
toastStyles,
onMainMutationSuccess,
}: MutationsHandlerProps<Data, Variables>) => {
}: MutationsHandlerProps) => {
const { showToast } = useToast();
const mutations = [
mainMutation,
Expand Down

0 comments on commit 50a9e55

Please sign in to comment.