diff --git a/src/javascript/app/pages/trade/purchase/contract-details.jsx b/src/javascript/app/pages/trade/purchase/contract-details.jsx index 8041f6db164..2207515a2bf 100644 --- a/src/javascript/app/pages/trade/purchase/contract-details.jsx +++ b/src/javascript/app/pages/trade/purchase/contract-details.jsx @@ -1,6 +1,6 @@ /* eslint-disable import/no-unresolved */ import React, { useEffect, useState } from 'react'; -import { Button, Skeleton, Text } from '@deriv-com/quill-ui'; +import { Button, Skeleton, Text } from '@deriv-com/quill-ui'; import { LabelPairedArrowLeftMdRegularIcon } from '@deriv/quill-icons/LabelPaired'; import ContractTable from './contract-table'; import Portal from '../../portal'; @@ -10,6 +10,26 @@ import { localize } from '../../../../_common/localize'; import { Explanation } from '../../bottom/explanation'; import { TimeTooltipWrapper, triggerClick } from '../../../common/helpers'; +const resetPopupData = (isAuditReset = false) => { + const audit_reset_object = { + cd_showAudit: false, + auditDataEnd: [], + cd_infoMsg : null, + }; + + const contract_reset_object = { + ...audit_reset_object, + showContractDetailsPopup: false, + cd_showSell : false, + cd_contractEnded : false, + cd_showAuditBtn : false, + }; + + dataManager.setPurchase({ + ...(isAuditReset ? { ...audit_reset_object } : contract_reset_object), + }); +}; + const AuditSection = ({ data }) => { const auditData = { start: { @@ -35,9 +55,7 @@ const AuditSection = ({ data }) => { icon={} color='black' onClick={() => { - dataManager.setPurchase({ - cd_showAudit: false, - }); + resetPopupData(true); triggerClick('#contract_purchase_button'); }} /> @@ -57,12 +75,12 @@ const AuditSection = ({ data }) => {
{Object.keys(auditData).map(adk =>{ - const { title,content } = auditData[adk]; - - if (content){ + const { title, content } = auditData[adk]; + + if (content?.length) { return ( -
+
{title} @@ -104,7 +122,7 @@ const AuditSection = ({ data }) => { ); } - return false; + return null; })}
@@ -128,9 +146,7 @@ const DetailsSection = ({ data }) => ( icon={} color='black' onClick={() => { - dataManager.setPurchase({ - showContractDetailsPopup: false, - }); + resetPopupData(false); }} />
@@ -175,9 +191,7 @@ const ContractDetails = () => { useEffect(() => { const handleKeyDown = (event) => { if (event.key === 'Escape') { - dataManager.setPurchase({ - showContractDetailsPopup: false, - }); + resetPopupData(false); } }; diff --git a/src/javascript/app/pages/trade/purchase/purchase.jsx b/src/javascript/app/pages/trade/purchase/purchase.jsx index 89215c2cf3f..1199e5fff11 100644 --- a/src/javascript/app/pages/trade/purchase/purchase.jsx +++ b/src/javascript/app/pages/trade/purchase/purchase.jsx @@ -29,6 +29,8 @@ const Purchase = () => { error : null, cd_errorMsg : null, cd_showAuditBtn : false, + cd_contractEnded : false, + auditDataEnd : [], cd_infoMsg : null, });