Skip to content

Commit

Permalink
chore: setup Redux store (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
Koustavd18 authored Jan 15, 2025
1 parent 1c52fa6 commit 328e830
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@mantine/hooks": "^7.8.1",
"@mantine/notifications": "^7.8.1",
"@monaco-editor/react": "^4.5.1",
"@reduxjs/toolkit": "^2.5.0",
"@tabler/icons-react": "^3.3.0",
"@types/js-cookie": "^3.0.3",
"axios": "^1.4.0",
Expand All @@ -52,6 +53,7 @@
"react-grid-layout": "^1.4.4",
"react-query": "^3.39.3",
"react-querybuilder": "^6.5.5",
"react-redux": "^9.2.0",
"react-resizable": "^3.0.5",
"react-resizable-panels": "^0.0.53",
"react-router-dom": "^6.14.0",
Expand Down
81 changes: 81 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Mantine from '@/components/Mantine';
import { BrowserRouter } from 'react-router-dom';
import ErrorBoundary from './components/ErrorBoundary';
import { QueryClient, QueryClientProvider } from 'react-query';
import { Provider } from 'react-redux';
import { store } from './store';

const queryClient = new QueryClient();

Expand All @@ -21,7 +23,9 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<Mantine>
<ErrorBoundary>
<BrowserRouter>
<App />
<Provider store={store}>
<App />
</Provider>
</BrowserRouter>
</ErrorBoundary>
</Mantine>
Expand Down
16 changes: 16 additions & 0 deletions src/store/alertsSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createSlice } from '@reduxjs/toolkit';

const alertsSlice = createSlice({
name: 'alerts',
initialState: {
alertsList: [{}],
},
reducers: {
pushAlert(state, action) {
state.alertsList.push(action.payload);
},
},
});

export const { pushAlert } = alertsSlice.actions;
export const alertsReducer = alertsSlice.reducer;
13 changes: 13 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { configureStore } from '@reduxjs/toolkit';
import { alertsReducer, pushAlert } from './alertsSlice';

export const store = configureStore({
reducer: {
alerts: alertsReducer,
},
});

export { pushAlert };

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

0 comments on commit 328e830

Please sign in to comment.