mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-20 15:18:33 +00:00
feat: add default values in slice with constants
This commit is contained in:
parent
47d7c45ba3
commit
577d7af379
@ -1,5 +1,7 @@
|
|||||||
import { createSlice } from '@reduxjs/toolkit'
|
import { createSlice } from '@reduxjs/toolkit'
|
||||||
|
|
||||||
|
import { BEACON, BEACON_PORT, DEFAULT_ADDRESS, VALIDATOR_CLIENT, VC_PORT } from '../../constants'
|
||||||
|
|
||||||
type PairDeviceStateType = {
|
type PairDeviceStateType = {
|
||||||
beaconPort: string
|
beaconPort: string
|
||||||
vcPort: string
|
vcPort: string
|
||||||
@ -15,11 +17,11 @@ type PairDeviceStateType = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const initialState: PairDeviceStateType = {
|
const initialState: PairDeviceStateType = {
|
||||||
beaconPort: '5052',
|
beaconPort: BEACON_PORT,
|
||||||
vcPort: '9000',
|
vcPort: VC_PORT,
|
||||||
nodeAddress: 'http://124.0.0.1',
|
nodeAddress: DEFAULT_ADDRESS,
|
||||||
beaconAddress: 'http://124.0.0.1',
|
beaconAddress: DEFAULT_ADDRESS,
|
||||||
vcAddress: 'http://124.0.0.1',
|
vcAddress: DEFAULT_ADDRESS,
|
||||||
isNodeSwitchOn: true,
|
isNodeSwitchOn: true,
|
||||||
isBeaconSwitchOn: true,
|
isBeaconSwitchOn: true,
|
||||||
isVcSwitchOn: true,
|
isVcSwitchOn: true,
|
||||||
@ -33,34 +35,34 @@ const pairDeviceSlice = createSlice({
|
|||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
setPort: (state, action) => {
|
setPort: (state, action) => {
|
||||||
if (action.payload.portType === 'Beacon') {
|
if (action.payload.portType === BEACON) {
|
||||||
state.beaconPort = action.payload.value
|
state.beaconPort = action.payload.value
|
||||||
} else {
|
} else {
|
||||||
state.vcPort = action.payload.value
|
state.vcPort = action.payload.value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setAddress: (state, action) => {
|
setAddress: (state, action) => {
|
||||||
if (action.payload.addressType === 'Beacon') {
|
if (action.payload.addressType === BEACON) {
|
||||||
state.beaconAddress = action.payload.value
|
state.beaconAddress = action.payload.value
|
||||||
} else if (action.payload.addressType === 'Validator Client') {
|
} else if (action.payload.addressType === VALIDATOR_CLIENT) {
|
||||||
state.vcAddress = action.payload.value
|
state.vcAddress = action.payload.value
|
||||||
} else {
|
} else {
|
||||||
state.nodeAddress = action.payload.value
|
state.nodeAddress = action.payload.value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setIsSwitchOn: (state, action) => {
|
setIsSwitchOn: (state, action) => {
|
||||||
if (action.payload.switchType === 'Beacon') {
|
if (action.payload.switchType === BEACON) {
|
||||||
state.isBeaconSwitchOn = action.payload.value
|
state.isBeaconSwitchOn = action.payload.value
|
||||||
} else if (action.payload.switchType === 'Validator Client') {
|
} else if (action.payload.switchType === VALIDATOR_CLIENT) {
|
||||||
state.isVcSwitchOn = action.payload.value
|
state.isVcSwitchOn = action.payload.value
|
||||||
} else {
|
} else {
|
||||||
state.isNodeSwitchOn = action.payload.value
|
state.isNodeSwitchOn = action.payload.value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setIsChecked: (state, action) => {
|
setIsChecked: (state, action) => {
|
||||||
if (action.payload.checkType === 'Beacon') {
|
if (action.payload.checkType === BEACON) {
|
||||||
state.isBeaconChecked = action.payload.value
|
state.isBeaconChecked = action.payload.value
|
||||||
} else if (action.payload.checkType === 'Validator Client') {
|
} else if (action.payload.checkType === VALIDATOR_CLIENT) {
|
||||||
state.isVcChecked = action.payload.value
|
state.isVcChecked = action.payload.value
|
||||||
} else {
|
} else {
|
||||||
state.isNodeChecked = action.payload.value
|
state.isNodeChecked = action.payload.value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user