fix: edit order dialog

This commit is contained in:
asiaznik 2024-03-08 14:27:31 +01:00
parent 8f334f42ad
commit c7e79aa196
No known key found for this signature in database
GPG Key ID: 4D5C8972A02C52C2

View File

@ -4,6 +4,8 @@ import {
addDecimal,
addDecimalsFormatNumber,
useValidateAmount,
determinePriceStep,
determineSizeStep,
} from '@vegaprotocol/utils';
import { Size } from '@vegaprotocol/datagrid';
import * as Schema from '@vegaprotocol/types';
@ -52,8 +54,10 @@ export const OrderEditDialog = ({
},
});
const step = toDecimal(order.market?.decimalPlaces ?? 0);
const stepSize = toDecimal(order.market?.positionDecimalPlaces ?? 0);
const step = order.market ? determinePriceStep(order.market) : toDecimal(0);
const stepSize = order.market
? determineSizeStep(order.market)
: toDecimal(0);
return (
<Dialog
@ -117,9 +121,11 @@ export const OrderEditDialog = ({
required: t('You need to provide a price'),
validate: {
min: (value) =>
Number(value) > 0
Number(value) >= Number(step)
? true
: t('The price cannot be negative'),
: t('Price cannot be lower than {{priceStep}}', {
step,
}),
validate: validateAmount(step, t('Price')),
},
})}
@ -139,7 +145,11 @@ export const OrderEditDialog = ({
required: t('You need to provide a size'),
validate: {
min: (value) =>
Number(value) > 0 ? true : t('The size cannot be negative'),
Number(value) >= Number(stepSize)
? true
: t('Size cannot be lower than {{sizeStep}}', {
stepSize,
}),
validate: validateAmount(stepSize, t('Size')),
},
})}