mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-27 10:30:31 +00:00
feat: add live checking on the addresses and ports
This commit is contained in:
parent
5c2c065c00
commit
b832ee70b0
@ -26,9 +26,7 @@ const InputsRow = ({
|
|||||||
port,
|
port,
|
||||||
isSwitchOn,
|
isSwitchOn,
|
||||||
}: InputsRowProps) => {
|
}: InputsRowProps) => {
|
||||||
const { beaconPort, vcPort, isNodeSwitchOn } = useSelector(
|
const { beaconPort, vcPort, isNodeSwitchOn } = useSelector((state: RootState) => state.pairDevice)
|
||||||
(state: RootState) => state.pairDevice,
|
|
||||||
)
|
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const isSwitchOnResult = isAdvanced ? isSwitchOn : isNodeSwitchOn
|
const isSwitchOnResult = isAdvanced ? isSwitchOn : isNodeSwitchOn
|
||||||
const switchStyle = isSwitchOnResult
|
const switchStyle = isSwitchOnResult
|
||||||
@ -43,6 +41,26 @@ const InputsRow = ({
|
|||||||
dispatch({ type: 'pairDevice/setAddress', payload: { value, addressType } })
|
dispatch({ type: 'pairDevice/setAddress', payload: { value, addressType } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isAddressValid = (address: string) => {
|
||||||
|
return address.length > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const isPortValid = (port: string) => {
|
||||||
|
if (port.length === 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return !isNaN(Number(port))
|
||||||
|
}
|
||||||
|
|
||||||
|
const isValidRow = () => {
|
||||||
|
if (isAdvanced) {
|
||||||
|
return isAddressValid(address) && isPortValid(port)
|
||||||
|
} else {
|
||||||
|
return isAddressValid(address) && isPortValid(vcPort) && isPortValid(beaconPort)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles['row-container']}>
|
<div className={styles['row-container']}>
|
||||||
<YStack space={'$2'} flexBasis={0} flexGrow={2}>
|
<YStack space={'$2'} flexBasis={0} flexGrow={2}>
|
||||||
@ -86,7 +104,7 @@ const InputsRow = ({
|
|||||||
size={16}
|
size={16}
|
||||||
style={{
|
style={{
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
backgroundColor: isChecked ? '#1B273D1A' : '#2A4AF5',
|
backgroundColor: isValidRow() ? '#2A4AF5' : '#1B273D1A',
|
||||||
padding: '1px',
|
padding: '1px',
|
||||||
}}
|
}}
|
||||||
color={'white'}
|
color={'white'}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user