Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 328e830

Browse files
authored
chore: setup Redux store (#418)
1 parent 1c52fa6 commit 328e830

File tree

5 files changed

+117
-1
lines changed

5 files changed

+117
-1
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@mantine/hooks": "^7.8.1",
2727
"@mantine/notifications": "^7.8.1",
2828
"@monaco-editor/react": "^4.5.1",
29+
"@reduxjs/toolkit": "^2.5.0",
2930
"@tabler/icons-react": "^3.3.0",
3031
"@types/js-cookie": "^3.0.3",
3132
"axios": "^1.4.0",
@@ -52,6 +53,7 @@
5253
"react-grid-layout": "^1.4.4",
5354
"react-query": "^3.39.3",
5455
"react-querybuilder": "^6.5.5",
56+
"react-redux": "^9.2.0",
5557
"react-resizable": "^3.0.5",
5658
"react-resizable-panels": "^0.0.53",
5759
"react-router-dom": "^6.14.0",

pnpm-lock.yaml

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import Mantine from '@/components/Mantine';
1313
import { BrowserRouter } from 'react-router-dom';
1414
import ErrorBoundary from './components/ErrorBoundary';
1515
import { QueryClient, QueryClientProvider } from 'react-query';
16+
import { Provider } from 'react-redux';
17+
import { store } from './store';
1618

1719
const queryClient = new QueryClient();
1820

@@ -21,7 +23,9 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
2123
<Mantine>
2224
<ErrorBoundary>
2325
<BrowserRouter>
24-
<App />
26+
<Provider store={store}>
27+
<App />
28+
</Provider>
2529
</BrowserRouter>
2630
</ErrorBoundary>
2731
</Mantine>

src/store/alertsSlice.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createSlice } from '@reduxjs/toolkit';
2+
3+
const alertsSlice = createSlice({
4+
name: 'alerts',
5+
initialState: {
6+
alertsList: [{}],
7+
},
8+
reducers: {
9+
pushAlert(state, action) {
10+
state.alertsList.push(action.payload);
11+
},
12+
},
13+
});
14+
15+
export const { pushAlert } = alertsSlice.actions;
16+
export const alertsReducer = alertsSlice.reducer;

src/store/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { configureStore } from '@reduxjs/toolkit';
2+
import { alertsReducer, pushAlert } from './alertsSlice';
3+
4+
export const store = configureStore({
5+
reducer: {
6+
alerts: alertsReducer,
7+
},
8+
});
9+
10+
export { pushAlert };
11+
12+
export type RootState = ReturnType<typeof store.getState>;
13+
export type AppDispatch = typeof store.dispatch;

0 commit comments

Comments
 (0)