From 48109b584c1b1094a615790324d0e0040c57bf12 Mon Sep 17 00:00:00 2001 From: Art Date: Mon, 22 May 2023 18:34:02 +0200 Subject: [PATCH] fix(ui-toolkit): test toast configuration (#3877) --- .../src/components/toast/toast-position-setter.tsx | 5 +++-- libs/ui-toolkit/src/components/toast/use-toasts.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx b/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx index a4a06bf92..ac10ed138 100644 --- a/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx +++ b/libs/ui-toolkit/src/components/toast/toast-position-setter.tsx @@ -7,10 +7,11 @@ import { ToastPosition, useToastsConfiguration, useToasts } from './use-toasts'; import { useCallback } from 'react'; import { Intent } from '../../utils/intent'; -const testToast = { +const TEST_TOAST = { id: 'test-toast', intent: Intent.Primary, content: <>{t('This is an example of a toast notification')}, + onClose: () => useToasts.getState().remove('test-toast'), }; export const ToastPositionSetter = () => { @@ -20,7 +21,7 @@ export const ToastPositionSetter = () => { const handleChange = useCallback( (position: ToastPosition) => { setPostion(position); - setToast(testToast); + setToast(TEST_TOAST); }, [setToast, setPostion] ); diff --git a/libs/ui-toolkit/src/components/toast/use-toasts.ts b/libs/ui-toolkit/src/components/toast/use-toasts.ts index 1f0652ac3..8aff3306c 100644 --- a/libs/ui-toolkit/src/components/toast/use-toasts.ts +++ b/libs/ui-toolkit/src/components/toast/use-toasts.ts @@ -109,12 +109,12 @@ export enum ToastPosition { BottomCenter, } -type ToastConfiguration = { +type ToastsConfiguration = { position: ToastPosition; setPosition: (position: ToastPosition) => void; }; -export const useToastsConfiguration = create()( +export const useToastsConfiguration = create()( persist( immer((set) => ({ position: ToastPosition.BottomRight,