import { useDispatch, useSelector } from "react-redux"; import type { RootState } from "../store"; import type { INotifyStore } from "./notify.slice"; import { notifyActions } from "./notify.slice"; export const useNotifyStore = () => { const notifyState = useSelector( (state) => state.notify, ); const dispatch = useDispatch(); function setNotify(payload: INotifyStore["notifies"][0]) { dispatch(notifyActions.setNotify(payload)); } function clearNotify(title: string) { dispatch(notifyActions.clearNotify(title)); } function clearNotifies() { dispatch(notifyActions.clearNotifies()); } return { ...notifyState, setNotify, clearNotifies, clearNotify, }; };