From 115d13945739c82616c383d64d9da1af9e33ce13 Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Thu, 4 Jan 2024 10:43:33 +0200 Subject: [PATCH] feat: create slice for pair device --- src/redux/PairDevice/slice.ts | 40 +++++++++++++++++++++++++++++++++++ src/redux/store.ts | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 src/redux/PairDevice/slice.ts diff --git a/src/redux/PairDevice/slice.ts b/src/redux/PairDevice/slice.ts new file mode 100644 index 00000000..eacf915d --- /dev/null +++ b/src/redux/PairDevice/slice.ts @@ -0,0 +1,40 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit' + +type PairDeviceStateType = { + beaconPort: string + vcPort: string + nodeAddress: string + beaconAddress: string + vcAddress: string +} + +const initialState: PairDeviceStateType = { + beaconPort: '5052', + vcPort: '9000', + nodeAddress: 'http://124.0.0.1', + beaconAddress: 'http://124.0.0.1', + vcAddress: 'http://124.0.0.1', +} + +const pairDeviceSlice = createSlice({ + name: 'pairDevice', + initialState, + reducers: { + setAddress: ( + state, + action: PayloadAction<{ nodeAddress: string; beaconAddress: string; vcAddress: string }>, + ) => { + state.nodeAddress = action.payload.nodeAddress + state.beaconAddress = action.payload.beaconAddress + state.vcAddress = action.payload.vcAddress + }, + setPort: (state, action: PayloadAction<{ beaconPort: string; vcPort: string }>) => { + state.beaconPort = action.payload.beaconPort + state.vcPort = action.payload.vcPort + }, + }, +}) + +export const { setAddress, setPort } = pairDeviceSlice.actions + +export default pairDeviceSlice.reducer diff --git a/src/redux/store.ts b/src/redux/store.ts index 7fe253f7..f602e52a 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -11,6 +11,7 @@ import rightSidebarReducer from './RightSidebar/slice' import validatorOnboardingReducer from './ValidatorOnboarding/slice' import advisoriesReducer from './ValidatorOnboarding/Advisories/slice' import validatorSetupReducer from './ValidatorOnboarding/ValidatorSetup/slice' +import pairDeviceReducer from './PairDevice/slice' const store = configureStore({ reducer: { @@ -25,6 +26,7 @@ const store = configureStore({ validatorOnboarding: validatorOnboardingReducer, advisories: advisoriesReducer, validatorSetup: validatorSetupReducer, + pairDevice: pairDeviceReducer, }, })