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

likhith/OrderConfirmCompleted error status displayed on slow n/w #4832

Merged
merged 16 commits into from
Mar 14, 2022
Merged
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Button, Checkbox, Modal, Text } from '@deriv/components';
import { Button, Checkbox, Loading, Modal, Text } from '@deriv/components';
import { useIsMounted } from '@deriv/shared';
import { Localize } from 'Components/i18next';
import { requestWS } from 'Utils/websocket';
Expand All @@ -27,20 +27,42 @@ const OrderDetailsConfirmModal = ({
const isMounted = useIsMounted();
const [error_message, setErrorMessage] = React.useState('');
const [is_checkbox_checked, setIsCheckboxChecked] = React.useState(false);
const [is_process_request, setIsProcessRequest] = React.useState(false); // This state disables the Release amount button during a request

const confirmOrderRequest = () => {
setIsProcessRequest(true);
requestWS({
p2p_order_confirm: 1,
id,
}).then(response => {
if (isMounted()) {
if (response.error) {
setErrorMessage(response.error.message);
})
.then(response => {
Comment on lines +37 to +38
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the code formatted?
Please use prettier to format the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using prettier. For some reason, thats how the code is refactored

Copy link
Contributor

Choose a reason for hiding this comment

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

@likhith-deriv have you run npm run prettify?😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I have. But in this file, line 38, still seems to be kept in that way. If I remove the spaces and move it up, on save it reverts back :(

Copy link
Contributor

Choose a reason for hiding this comment

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

@likhith-deriv as long as you run npm run prettify, it should be fine ) it's alright then

if (isMounted()) {
if (response.error) {
setErrorMessage(response.error.message);
}
}
}
});
})
.finally(() => setIsProcessRequest(false));
};

let confirm_button_text = null;

if (is_buy_order_for_user) {
confirm_button_text = <Localize i18n_default_text="I've paid" />;
} else if (is_process_request) {
confirm_button_text = <Loading is_fullscreen={false} />;
} else {
confirm_button_text = (
<Localize
i18n_default_text='Release {{amount}} {{currency}}'
values={{
amount: amount_display,
currency: account_currency,
}}
/>
);
}

return (
<Modal
className='order-details-confirm-modal'
Expand Down Expand Up @@ -109,18 +131,13 @@ const OrderDetailsConfirmModal = ({
<Localize i18n_default_text='Cancel' />
)}
</Button>
<Button is_disabled={!is_checkbox_checked} primary large onClick={confirmOrderRequest}>
{is_buy_order_for_user ? (
<Localize i18n_default_text="I've paid" />
) : (
<Localize
i18n_default_text='Release {{amount}} {{currency}}'
values={{
amount: amount_display,
currency: account_currency,
}}
/>
)}
<Button
is_disabled={!is_checkbox_checked || is_process_request}
primary
large
onClick={confirmOrderRequest}
>
{confirm_button_text}
likhith-deriv marked this conversation as resolved.
Show resolved Hide resolved
</Button>
</Button.Group>
</Modal.Footer>
Expand Down