From 415f59ca696f605131115efff2c64730310f32a8 Mon Sep 17 00:00:00 2001 From: Melisa Anabella Rossi Date: Tue, 31 Oct 2023 14:40:39 -0300 Subject: [PATCH] fix manage land expiration date (#2045) --- .../components/ManageAssetPage/Sell/Sell.tsx | 6 +++++- .../components/Modals/SellModal/SellModal.tsx | 21 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/webapp/src/components/ManageAssetPage/Sell/Sell.tsx b/webapp/src/components/ManageAssetPage/Sell/Sell.tsx index 4cc447106d..6efe72fac0 100644 --- a/webapp/src/components/ManageAssetPage/Sell/Sell.tsx +++ b/webapp/src/components/ManageAssetPage/Sell/Sell.tsx @@ -86,7 +86,11 @@ const Sell = (props: Props) => { {t('manage_asset_page.sell.expiration_date')}
- {intlFormat(order.expiresAt)} + {intlFormat( + order.expiresAt * + // if the expire date length is 10 then it is assumed that it is in seconds + (order.expiresAt.toString().length === 10 ? 1000 : 1) + )}
diff --git a/webapp/src/components/Modals/SellModal/SellModal.tsx b/webapp/src/components/Modals/SellModal/SellModal.tsx index 3d589bb3eb..ab8adf767b 100644 --- a/webapp/src/components/Modals/SellModal/SellModal.tsx +++ b/webapp/src/components/Modals/SellModal/SellModal.tsx @@ -71,11 +71,22 @@ const SellModal = ({ isUpdate ? ethers.utils.formatEther(order!.price) : '' ) - const [expiresAt, setExpiresAt] = useState( - isUpdate && order!.expiresAt && isValid(order!.expiresAt) - ? formatDate(addDays(order!.expiresAt, 1), INPUT_FORMAT) - : getDefaultExpirationDate() - ) + const [expiresAt, setExpiresAt] = useState(() => { + let exp = order?.expiresAt + + if (isUpdate && exp) { + // If the order's expiration is in seconds, convert it to milliseconds + if (exp.toString().length === 10) { + exp = exp * 1000 + } + + if (isValid(exp)) { + return formatDate(addDays(exp, 1), INPUT_FORMAT) + } + } + + return getDefaultExpirationDate() + }) const parsedValueToConfirm = parseFloat(price).toString()