fix: edit order dialog
This commit is contained in:
parent
8f334f42ad
commit
c7e79aa196
@ -4,6 +4,8 @@ import {
|
|||||||
addDecimal,
|
addDecimal,
|
||||||
addDecimalsFormatNumber,
|
addDecimalsFormatNumber,
|
||||||
useValidateAmount,
|
useValidateAmount,
|
||||||
|
determinePriceStep,
|
||||||
|
determineSizeStep,
|
||||||
} from '@vegaprotocol/utils';
|
} from '@vegaprotocol/utils';
|
||||||
import { Size } from '@vegaprotocol/datagrid';
|
import { Size } from '@vegaprotocol/datagrid';
|
||||||
import * as Schema from '@vegaprotocol/types';
|
import * as Schema from '@vegaprotocol/types';
|
||||||
@ -52,8 +54,10 @@ export const OrderEditDialog = ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const step = toDecimal(order.market?.decimalPlaces ?? 0);
|
const step = order.market ? determinePriceStep(order.market) : toDecimal(0);
|
||||||
const stepSize = toDecimal(order.market?.positionDecimalPlaces ?? 0);
|
const stepSize = order.market
|
||||||
|
? determineSizeStep(order.market)
|
||||||
|
: toDecimal(0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@ -117,9 +121,11 @@ export const OrderEditDialog = ({
|
|||||||
required: t('You need to provide a price'),
|
required: t('You need to provide a price'),
|
||||||
validate: {
|
validate: {
|
||||||
min: (value) =>
|
min: (value) =>
|
||||||
Number(value) > 0
|
Number(value) >= Number(step)
|
||||||
? true
|
? true
|
||||||
: t('The price cannot be negative'),
|
: t('Price cannot be lower than {{priceStep}}', {
|
||||||
|
step,
|
||||||
|
}),
|
||||||
validate: validateAmount(step, t('Price')),
|
validate: validateAmount(step, t('Price')),
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
@ -139,7 +145,11 @@ export const OrderEditDialog = ({
|
|||||||
required: t('You need to provide a size'),
|
required: t('You need to provide a size'),
|
||||||
validate: {
|
validate: {
|
||||||
min: (value) =>
|
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')),
|
validate: validateAmount(stepSize, t('Size')),
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
|
Loading…
Reference in New Issue
Block a user