Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meenu/fix: fixed audit page #779

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 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,19 @@ import { localize } from '../../../../_common/localize';
import { Explanation } from '../../bottom/explanation';
import { TimeTooltipWrapper, triggerClick } from '../../../common/helpers';

const getDefaultPurchaseObject = () => ({
cd_showAudit: false,
auditDataEnd: [],
cd_infoMsg : null,
});

const setPurchaseWithDefaults = (additionalProps = {}) => {
dataManager.setPurchase({
...getDefaultPurchaseObject(),
...additionalProps,
});
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const getDefaultPurchaseObject = () => ({
cd_showAudit: false,
auditDataEnd: [],
cd_infoMsg : null,
});
const setPurchaseWithDefaults = (additionalProps = {}) => {
dataManager.setPurchase({
...getDefaultPurchaseObject(),
...additionalProps,
});
};
const setPurchaseWithDefaults = (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 +48,7 @@ const AuditSection = ({ data }) => {
icon={<LabelPairedArrowLeftMdRegularIcon />}
color='black'
onClick={() => {
dataManager.setPurchase({
cd_showAudit: false,
});
setPurchaseWithDefaults();
triggerClick('#contract_purchase_button');
}}
/>
Expand All @@ -57,12 +68,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 +115,7 @@ const AuditSection = ({ data }) => {
);
}

return false;
return null;
})}
<div className='table-box lg'>
<Explanation explanationOnly />
Expand All @@ -128,8 +139,13 @@ const DetailsSection = ({ data }) => (
icon={<LabelPairedArrowLeftMdRegularIcon />}
color='black'
onClick={() => {
dataManager.setPurchase({
setPurchaseWithDefaults({

showContractDetailsPopup: false,
cd_showSell : false,
cd_contractEnded : false,
cd_showAuditBtn : false,

});
}}
/>
Expand Down Expand Up @@ -175,8 +191,12 @@ const ContractDetails = () => {
useEffect(() => {
const handleKeyDown = (event) => {
if (event.key === 'Escape') {
dataManager.setPurchase({
setPurchaseWithDefaults({
showContractDetailsPopup: false,
cd_showSell : false,
cd_contractEnded : false,
cd_showAuditBtn : 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
Loading