fix(#2553): show rejection reason & orderbook fixed dp (#2563)

* fix: orderbook fixed dp - and show rejection reason

* fix: show rejection reason in order list

* fix: fix parked rejection reason test

* fix: remove not covered part
This commit is contained in:
m.ray 2023-01-10 08:41:37 -05:00 committed by GitHub
parent cf43566bde
commit 0fd1739ce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 13 deletions

View File

@ -216,12 +216,14 @@ describe('subscribe orders', { tags: '@smoke' }, () => {
it('must see a parked order', () => {
// 7002-SORD-048
// NOT COVERED: must see an explanation of why parked orders happen
updateOrder({
id: orderId,
status: Schema.OrderStatus.STATUS_PARKED,
});
cy.getByTestId(`order-status-${orderId}`).should('have.text', 'Parked');
cy.getByTestId(`order-status-${orderId}`).should(
'have.text',
'Parked: Internal error'
);
});
it('must see the size of the order and direction/side -', () => {

View File

@ -13,7 +13,7 @@ import {
import classNames from 'classnames';
import {
addDecimalsFormatNumber,
addDecimalsFixedFormatNumber,
t,
useResizeObserver,
formatNumberFixed,
@ -227,25 +227,25 @@ const OrderbookDebugInfo = ({
viewportHeight,
lockOnMidPrice,
priceInCenter: priceInCenter
? addDecimalsFormatNumber(priceInCenter, decimalPlaces)
? addDecimalsFixedFormatNumber(priceInCenter, decimalPlaces)
: '-',
maxPriceLevel: addDecimalsFormatNumber(
maxPriceLevel: addDecimalsFixedFormatNumber(
maxPriceLevel ?? '0',
decimalPlaces
),
bestStaticBidPrice: addDecimalsFormatNumber(
bestStaticBidPrice: addDecimalsFixedFormatNumber(
bestStaticBidPrice ?? '0',
decimalPlaces
),
bestStaticOfferPrice: addDecimalsFormatNumber(
bestStaticOfferPrice: addDecimalsFixedFormatNumber(
bestStaticOfferPrice ?? '0',
decimalPlaces
),
minPriceLevel: addDecimalsFormatNumber(
minPriceLevel: addDecimalsFixedFormatNumber(
minPriceLevel ?? '0',
decimalPlaces
),
midPrice: addDecimalsFormatNumber(
midPrice: addDecimalsFixedFormatNumber(
(bestStaticOfferPrice &&
bestStaticBidPrice &&
getPriceLevel(

View File

@ -84,11 +84,9 @@ const getRejectionReason = (order: OrderEventFieldsFragment): string | null => {
Schema.OrderTimeInForceMapping[order.timeInForce]
} order was not filled and it has been stopped`
);
case Schema.OrderStatus.STATUS_REJECTED:
default:
return order.rejectionReason
? t(Schema.OrderRejectionReasonMapping[order.rejectionReason])
: null;
default:
return null;
}
};

View File

@ -249,7 +249,7 @@ export const OrderListTable = forwardRef<AgGridReact, OrderListTableProps>(
value,
data,
}: VegaValueFormatterParams<Order, 'status'>) => {
if (value === Schema.OrderStatus.STATUS_REJECTED) {
if (data?.rejectionReason && value) {
return `${Schema.OrderStatusMapping[value]}: ${
data?.rejectionReason &&
Schema.OrderRejectionReasonMapping[data.rejectionReason]

View File

@ -100,6 +100,16 @@ export const addDecimalsFormatNumber = (
return formatNumber(x, formatDecimals);
};
export const addDecimalsFixedFormatNumber = (
rawValue: string | number,
decimalPlaces: number,
formatDecimals: number = decimalPlaces
) => {
const x = addDecimal(rawValue, decimalPlaces);
return formatNumberFixed(x, formatDecimals);
};
export const formatNumberPercentage = (value: BigNumber, decimals?: number) => {
const decimalPlaces =
typeof decimals === 'undefined' ? Math.max(value.dp() || 0, 2) : decimals;