From bc3903b5b00a7a52776cc8b8bb78878dfd1cfc98 Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Wed, 24 Jan 2024 09:46:40 +0200 Subject: [PATCH] feat: move is valid funcs to utilities --- src/pages/PairDevice/ConnectViaIP/InputsRow.tsx | 13 +------------ src/utilities.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/pages/PairDevice/ConnectViaIP/InputsRow.tsx b/src/pages/PairDevice/ConnectViaIP/InputsRow.tsx index dc3bdb82..f613c9f1 100644 --- a/src/pages/PairDevice/ConnectViaIP/InputsRow.tsx +++ b/src/pages/PairDevice/ConnectViaIP/InputsRow.tsx @@ -6,6 +6,7 @@ import { CheckIcon } from '@status-im/icons' import { RootState } from '../../../redux/store' import PortInput from './PortInput' import { BEACON, VC } from '../../../constants' +import { isAddressValid, isPortValid } from '../../../utilities' import styles from './index.module.css' type InputsRowProps = { @@ -35,18 +36,6 @@ const InputsRow = ({ addressType, portType, address, port, isSwitchOn }: InputsR 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) diff --git a/src/utilities.ts b/src/utilities.ts index 2db499a0..66edbf43 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -68,3 +68,15 @@ export const getHeightPercentages = (amountOfElements: number) => { return `${percentages}%` } + +export const isAddressValid = (address: string) => { + return address.length > 0 +} + +export const isPortValid = (port: string) => { + if (port.length === 0) { + return false + } + + return !isNaN(Number(port)) +}