import { useDispatch, useSelector } from "react-redux"; import type { RootState } from "../store"; import { appActions } from "./app.slice"; import type { IAppStore } from "./app-store.types"; export const useAppStore = () => { const appStore = useSelector((state) => state.app); const dispatch = useDispatch(); function setAppStrategy(strategy: IAppStore["data"]["strategy"]) { dispatch(appActions.setStrategy(strategy)); } function setData(data: IAppStore["data"]) { dispatch(appActions.setData(data)); } return { isReady: appStore.status === "done", data: appStore.data, setAppStrategy, setAppData: setData, }; };