diff --git a/web/src/App.tsx b/web/src/App.tsx index 27cbd71..4cba465 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,9 +1,10 @@ import React from 'react'; import { Provider, useSelector } from 'react-redux'; -import { RootState, store } from './store'; +import { AppActions, RootState, store } from './store'; import { ToastContainer } from 'react-toastify'; import { Box } from 'lr-components'; import { NextUIProvider } from '@nextui-org/react'; +import AppActionHook from './components/AppActionHook'; function App() { const show = useSelector((state: RootState) => state.state.show); @@ -11,6 +12,25 @@ function App() { show && ( + + {Object.keys(AppActions).map((action) => { + return ( + + ); + })} + (); + const isDev = isEnvBrowser(); + console.log('AppActionHook', props.action); + useNuiEvent(props.action, (data) => { + //dynamicDispatch(action, data); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const a = AppActions[props.action] as any; + dispatch(a(data)); + }); + + return ( + isDev && ( + + {props.action} + + ) + ); +} + +export default AppActionHook; diff --git a/web/src/store/index.ts b/web/src/store/index.ts index d848917..32ea123 100644 --- a/web/src/store/index.ts +++ b/web/src/store/index.ts @@ -4,6 +4,8 @@ export const store = configureStore({ reducer: {}, }); +export const AppActions = {}; + // Infer the `RootState` and `AppDispatch` types from the store itself export type RootState = ReturnType; // Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}