File tree Expand file tree Collapse file tree 5 files changed +34
-11
lines changed Expand file tree Collapse file tree 5 files changed +34
-11
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { RouterProvider } from 'react-router-dom';
4
4
import { ReactQueryDevtools } from '@tanstack/react-query-devtools' ;
5
5
import { QueryClient , QueryClientProvider , QueryCache } from '@tanstack/react-query' ;
6
6
import { ScreenshotProvider , ThemeProvider , useApiErrorBoundary } from './hooks' ;
7
+ import { ToastProvider } from './Providers' ;
7
8
import Toast from './components/ui/Toast' ;
8
9
import { router } from './routes' ;
9
10
@@ -25,10 +26,12 @@ const App = () => {
25
26
< RecoilRoot >
26
27
< ThemeProvider >
27
28
< RadixToast . Provider >
28
- < RouterProvider router = { router } />
29
- < ReactQueryDevtools initialIsOpen = { false } position = "top-right" />
30
- < Toast />
31
- < RadixToast . Viewport className = "pointer-events-none fixed inset-0 z-[60] mx-auto my-2 flex max-w-[560px] flex-col items-stretch justify-start md:pb-5" />
29
+ < ToastProvider >
30
+ < RouterProvider router = { router } />
31
+ < ReactQueryDevtools initialIsOpen = { false } position = "top-right" />
32
+ < Toast />
33
+ < RadixToast . Viewport className = "pointer-events-none fixed inset-0 z-[60] mx-auto my-2 flex max-w-[560px] flex-col items-stretch justify-start md:pb-5" />
34
+ </ ToastProvider >
32
35
</ RadixToast . Provider >
33
36
</ ThemeProvider >
34
37
</ RecoilRoot >
Original file line number Diff line number Diff line change
1
+ import { createContext } from 'react' ;
2
+ import type { TShowToast } from '~/common' ;
3
+ import { useToast } from '~/hooks' ;
4
+
5
+ type ToastContextType = {
6
+ showToast : ( { message, severity, showIcon } : TShowToast ) => void ;
7
+ } ;
8
+
9
+ export const ToastContext = createContext < ToastContextType > ( {
10
+ showToast : ( ) => ( { } ) ,
11
+ } ) ;
12
+
13
+ export default function ToastProvider ( { children } ) {
14
+ const { showToast } = useToast ( ) ;
15
+
16
+ return < ToastContext . Provider value = { { showToast } } > { children } </ ToastContext . Provider > ;
17
+ }
Original file line number Diff line number Diff line change
1
+ export { default as ToastProvider } from './ToastContext' ;
2
+ export * from './ToastContext' ;
Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ export enum NotificationSeverity {
28
28
ERROR = 'error' ,
29
29
}
30
30
31
+ export type TShowToast = {
32
+ message : string ;
33
+ severity ?: NotificationSeverity ;
34
+ showIcon ?: boolean ;
35
+ } ;
36
+
31
37
export type TBaseSettingsProps = {
32
38
conversation : TConversation | TPreset | null ;
33
39
className ?: string ;
Original file line number Diff line number Diff line change 1
- import { useRef , useEffect } from 'react' ;
2
1
import { useRecoilState } from 'recoil' ;
2
+ import { useRef , useEffect } from 'react' ;
3
+ import type { TShowToast } from '~/common' ;
3
4
import { NotificationSeverity } from '~/common' ;
4
5
import store from '~/store' ;
5
6
@@ -15,12 +16,6 @@ export default function useToast(timeoutDuration = 100) {
15
16
} ;
16
17
} , [ ] ) ;
17
18
18
- type TShowToast = {
19
- message : string ;
20
- severity ?: NotificationSeverity ;
21
- showIcon ?: boolean ;
22
- } ;
23
-
24
19
const showToast = ( {
25
20
message,
26
21
severity = NotificationSeverity . SUCCESS ,
You can’t perform that action at this time.
0 commit comments