feat: create slice for pair device

This commit is contained in:
RadoslavDimchev 2024-01-04 10:43:33 +02:00
parent a0ac3f819a
commit 115d139457
2 changed files with 42 additions and 0 deletions

View File

@ -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

View File

@ -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,
},
})