import React from 'react'; import { isPositiveIntegerOrZero } from 'libs/validators'; import { translateRaw } from 'translations'; import { Result } from 'mycrypto-nano-result'; import { FieldInput } from './FieldInput'; interface OwnProps { address?: string; onChange(decimals: Result): void; } export class DecimalField extends React.Component { public render() { return ( !(req.toVal().res === '0')} address={this.props.address} userInputValidator={this.isValidUserInput} onChange={this.props.onChange} /> ); } private isValidUserInput = (userInput: string) => { const validDecimals = isPositiveIntegerOrZero(Number(userInput)); const decimals: Result = validDecimals ? Result.from({ res: userInput }) : Result.from({ err: 'Invalid decimal' }); return decimals; }; }