Skip to content

Commit

Permalink
Meenu/fix: fixed audit page (#779)
Browse files Browse the repository at this point in the history
* fix: fixed audit page

* fix: refactor

* fix: refcactor purchase function

* fix: refactor function

* fix: refactor purchase function

* fix: rename func
  • Loading branch information
meenakshi-deriv authored Aug 8, 2024
1 parent d6758db commit 44fd237
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
44 changes: 29 additions & 15 deletions src/javascript/app/pages/trade/purchase/contract-details.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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: {
Expand All @@ -35,9 +55,7 @@ const AuditSection = ({ data }) => {
icon={<LabelPairedArrowLeftMdRegularIcon />}
color='black'
onClick={() => {
dataManager.setPurchase({
cd_showAudit: false,
});
resetPopupData(true);
triggerClick('#contract_purchase_button');
}}
/>
Expand All @@ -57,12 +75,12 @@ const AuditSection = ({ data }) => {
<div className='details-column'>
<div className='contract-info-wrapper full'>
{Object.keys(auditData).map(adk =>{
const { title,content } = auditData[adk];

if (content){
const { title, content } = auditData[adk];
if (content?.length) {
return (
<React.Fragment key={`audit-table-${title}-${adk}`}>
<div className='table-box'>
<div className='table-box' >
<Text size='md' bold centered>
{title}
</Text>
Expand Down Expand Up @@ -104,7 +122,7 @@ const AuditSection = ({ data }) => {
);
}

return false;
return null;
})}
<div className='table-box lg'>
<Explanation explanationOnly />
Expand All @@ -128,9 +146,7 @@ const DetailsSection = ({ data }) => (
icon={<LabelPairedArrowLeftMdRegularIcon />}
color='black'
onClick={() => {
dataManager.setPurchase({
showContractDetailsPopup: false,
});
resetPopupData(false);
}}
/>
<div className='title-box'>
Expand Down Expand Up @@ -175,9 +191,7 @@ const ContractDetails = () => {
useEffect(() => {
const handleKeyDown = (event) => {
if (event.key === 'Escape') {
dataManager.setPurchase({
showContractDetailsPopup: false,
});
resetPopupData(false);
}
};

Expand Down
2 changes: 2 additions & 0 deletions src/javascript/app/pages/trade/purchase/purchase.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const Purchase = () => {
error : null,
cd_errorMsg : null,
cd_showAuditBtn : false,
cd_contractEnded : false,
auditDataEnd : [],
cd_infoMsg : null,
});

Expand Down

0 comments on commit 44fd237

Please sign in to comment.