From d8512afb2b03762c4a24e28870d6a5006886545b Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Mon, 12 Sep 2022 14:28:07 +0100 Subject: [PATCH] fix: #1297 Order submission expiresAt is only available when the time in force is of type GTT (#1308) * fix: #1297 Order submission expires at is only available when the time in force is of type GTT * fix: add expires at visible in edit dialog * fix:#1297 add GTC and GTT tests for expires at --- .../components/deal-ticket/deal-ticket.tsx | 4 ++ .../order-list/order-edit-dialog.tsx | 9 ++++ .../lib/order-hooks/use-order-submit.spec.tsx | 42 ++++++++++++++++++- .../src/lib/order-hooks/use-order-submit.tsx | 11 +++-- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx index e0cb6ab4c..c1ed43607 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -60,6 +60,10 @@ export const DealTicket = ({ price: order.price && removeDecimal(order.price, market.decimalPlaces), size: removeDecimal(order.size, market.positionDecimalPlaces), + expiresAt: + order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT + ? order.expiresAt + : undefined, }); } }, diff --git a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx index 16eb1f998..0fb03e705 100644 --- a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx +++ b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx @@ -3,6 +3,7 @@ import { addDecimalsFormatNumber, toDecimal, Size, + getDateTimeFormat, } from '@vegaprotocol/react-helpers'; import { OrderType } from '@vegaprotocol/types'; import { @@ -13,6 +14,7 @@ import { Dialog, Icon, } from '@vegaprotocol/ui-toolkit'; +import { OrderTimeInForce } from '@vegaprotocol/types'; import { useForm } from 'react-hook-form'; import type { OrderFields } from '../order-data-provider'; @@ -77,6 +79,13 @@ export const OrderEditDialog = ({
+ {order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT && + order.expiresAt && ( +{t(`Expires at`)}
+{getDateTimeFormat().format(new Date(order.expiresAt))}
+