import { InputWrapper, inputStyles, InputProps, Button } from '@gear-js/ui'; import BigNumber from 'bignumber.js'; import clsx from 'clsx'; import { useFormContext, useWatch } from 'react-hook-form'; import { NumericFormat, NumericFormatProps } from 'react-number-format'; import { formStyles } from '@/shared/ui/form'; import calculatorSVG from '@/shared/assets/images/actions/calculator.svg?react'; import { Result } from '@/hooks/useGasCalculate/types'; import { BalanceUnit } from '@/shared/ui/form/balance-unit'; import { Info } from '../Info'; import styles from './GasField.module.scss'; type Props = Omit & { info: Result | undefined; onGasCalculate: () => void; }; const GasField = (props: Props) => { const { disabled, onGasCalculate, direction = 'x', gap, block, info, ...other } = props; const name = 'gasLimit'; const { setValue, getFieldState, formState } = useFormContext(); const inputValue = useWatch({ name }); const { error } = getFieldState(name, formState); const increaseByTenPercent = () => { const bnValue = BigNumber(inputValue); const bnMultiplier = bnValue.multipliedBy(0.1); const increasedValue = bnValue.plus(bnMultiplier); setValue(name, increasedValue.toFixed(), { shouldValidate: true }); }; const inputClassName = clsx(inputStyles.input, inputStyles.dark, styles.field); return (
setValue(name, value, { shouldValidate: true })} />
{info && }
); }; export { GasField };