frontend/stores/useToastStore.ts (view raw)
1import {ReactNode} from 'react';
2import {create} from 'zustand';
3
4type State = {
5 toast?: string;
6 action?: ReactNode;
7 addToast: (message: string, action?: ReactNode) => void;
8 clearToast: () => void;
9};
10
11const useToastStore = create<State>(set => ({
12 toast: null,
13 action: null,
14 addToast: (toast, action = null) => set({toast, action}),
15 clearToast: () => set({toast: null, action: null}),
16}));
17
18export default useToastStore;