From 6754dc67ded3f3a45214348e614842b9f93aa5af Mon Sep 17 00:00:00 2001 From: Nuzhy-Deriv <125249108+Nuzhy-Deriv@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:15:29 +0800 Subject: [PATCH] Nuzhy/trade forms UI fixes (#743) * fix: wrap form component with breakpont provider * fix: duration units sorted --- package-lock.json | 8 +- package.json | 2 +- .../app/pages/form/currency-dropdown.jsx | 20 +- .../app/pages/form/dropdown-component.jsx | 20 +- .../app/pages/form/form-component.jsx | 443 +++++++++--------- .../app/pages/form/numbers-dropdown.jsx | 22 +- .../app/pages/form/time-selection.jsx | 18 +- src/javascript/app/pages/trade/duration.js | 12 +- 8 files changed, 270 insertions(+), 275 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c6364ad8a5..47fe986a8f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@binary-com/binary-document-uploader": "^2.4.4", "@binary-com/binary-style": "^0.2.26", "@binary-com/webtrader-charts": "^0.6.1", - "@deriv-com/quill-ui": "^1.13.25", + "@deriv-com/quill-ui": "^1.13.26", "@deriv/deriv-api": "^1.0.15", "@deriv/quill-icons": "^1.23.1", "@livechat/customer-sdk": "4.0.2", @@ -2502,9 +2502,9 @@ } }, "node_modules/@deriv-com/quill-ui": { - "version": "1.13.25", - "resolved": "https://registry.npmjs.org/@deriv-com/quill-ui/-/quill-ui-1.13.25.tgz", - "integrity": "sha512-P6awW5AvZWZvEw7giu0zpfk7jVA4jq4hMo4qQIySKJHnsZw4Wms1+Klj0jSzZKjDMFlIgj1/rkN0FgKYjo1bpA==", + "version": "1.13.26", + "resolved": "https://registry.npmjs.org/@deriv-com/quill-ui/-/quill-ui-1.13.26.tgz", + "integrity": "sha512-91PDDeNqw6tVYo4pjSpJVUQgMdu9Dm2M4xqWKVKCKzTguS3YHl8sBfpQcbBGM9XrZWbsc/qcUiWc5EyBnti6lg==", "dependencies": { "@deriv-com/quill-tokens": "^2.0.8", "@deriv/quill-icons": "^1.22.10", diff --git a/package.json b/package.json index 1f1f61da572..821a8a1eb24 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "@binary-com/binary-document-uploader": "^2.4.4", "@binary-com/binary-style": "^0.2.26", "@binary-com/webtrader-charts": "^0.6.1", - "@deriv-com/quill-ui": "^1.13.25", + "@deriv-com/quill-ui": "^1.13.26", "@deriv/deriv-api": "^1.0.15", "@deriv/quill-icons": "^1.23.1", "@livechat/customer-sdk": "4.0.2", diff --git a/src/javascript/app/pages/form/currency-dropdown.jsx b/src/javascript/app/pages/form/currency-dropdown.jsx index 5151b503f78..9cba742c7cb 100644 --- a/src/javascript/app/pages/form/currency-dropdown.jsx +++ b/src/javascript/app/pages/form/currency-dropdown.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { BreakpointProvider, CustomDropdown, DropdownItem, DropdownTitle, useDropdown } from '@deriv-com/quill-ui'; +import { CustomDropdown, DropdownItem, DropdownTitle, useDropdown } from '@deriv-com/quill-ui'; const CurrencyContent = ({ currency_list, currency, onUpdate, elementId }) => { const { close } = useDropdown(); @@ -26,14 +26,12 @@ const CurrencyContent = ({ currency_list, currency, onUpdate, elementId }) => { ); }; export const CurrencyDropdown = ({ currency_list, currency, onUpdate, elementId }) => ( - - - - - + + + ); diff --git a/src/javascript/app/pages/form/dropdown-component.jsx b/src/javascript/app/pages/form/dropdown-component.jsx index 3847e49dd77..f03fea6dedf 100644 --- a/src/javascript/app/pages/form/dropdown-component.jsx +++ b/src/javascript/app/pages/form/dropdown-component.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { BreakpointProvider, CustomDropdown, DropdownItem, useDropdown } from '@deriv-com/quill-ui'; +import { CustomDropdown, DropdownItem, useDropdown } from '@deriv-com/quill-ui'; const DropdownContent = ({ options, value, onUpdate, elementId }) => { const { close } = useDropdown(); @@ -29,14 +29,12 @@ const DropdownContent = ({ options, value, onUpdate, elementId }) => { ); }; export const DropdownComponent = ({ label = '', options, value, onUpdate, elementId }) => ( - - - - - + + + ); diff --git a/src/javascript/app/pages/form/form-component.jsx b/src/javascript/app/pages/form/form-component.jsx index b4a4efd1c13..c75a5dc9dd6 100644 --- a/src/javascript/app/pages/form/form-component.jsx +++ b/src/javascript/app/pages/form/form-component.jsx @@ -5,6 +5,7 @@ import { DatePickerDropdown, Checkbox, SectionMessage, + BreakpointProvider, } from '@deriv-com/quill-ui'; import moment from 'moment'; import { CurrencyDropdown } from './currency-dropdown.jsx'; @@ -134,265 +135,267 @@ export const FormComponent = () => { ]; return ( -
- {contractForms.includes(formName) && ( - <> - {formName === 'highlowticks' && ( -
- -
- )} - {formName === 'reset' && reset_message && ( -
- -
- )} - -
- - {['risefall', 'callputequal'].includes(formName) && start_dates && ( -
-
- -
- {date_start !== 'now' && ( -
- -
- )} + +
+ {contractForms.includes(formName) && ( + <> + {formName === 'highlowticks' && ( +
+ +
+ )} + {formName === 'reset' && reset_message && ( +
+
)} + +
- {formName !== 'highlowticks' && ( - <> + {['risefall', 'callputequal'].includes(formName) && start_dates && (
- {expiryType === 'duration' && ( - <> -
- { - updateFormField( - 'duration_amount', - e.target.value, - 'input' - ); - }} - /> -
-
- -
- - )} - {expiryType === 'endtime' && ( - <> - {endtime_data && ( -
- {endtime_data.show_datepicker ? ( - { - onExpiryDateChange(value); - }} - /> - ) : ( - - )} -
- )} - + {date_start !== 'now' && ( +
+ +
)}
+ )} - {expiryType === 'endtime' && expiry_time && ( + {formName !== 'highlowticks' && ( + <>
-
+ {expiryType === 'duration' && ( + <> +
+ { + updateFormField( + 'duration_amount', + e.target.value, + 'input' + ); + }} + /> +
+
+ +
+ + )} + {expiryType === 'endtime' && ( + <> + {endtime_data && ( +
+ {endtime_data.show_datepicker ? ( + { + onExpiryDateChange(value); + }} + /> + ) : ( + + )} +
+ )} + + )}
- )} - - )} - + {expiryType === 'endtime' && expiry_time && ( +
+
+ +
+
+ )} + + )} - {['matchdiff', 'overunder'].includes(formName) && ( -
-
- -
-
- )} + - {['highlowticks'].includes(formName) && ( -
-
- + {['matchdiff', 'overunder'].includes(formName) && ( +
+
+ +
-
- )} + )} - {!['lookbackhigh', 'lookbacklow', 'lookbackhighlow'].includes( - formName - ) && ( -
-
- + {['highlowticks'].includes(formName) && ( +
+
+ +
+ )} - {currency_list ? ( - <> + {!['lookbackhigh', 'lookbacklow', 'lookbackhighlow'].includes( + formName + ) && ( +
+
+ +
+ + {currency_list ? ( + <> +
+ handleAmountChange(e, 'amount')} + /> +
+
+ +
+ + ) : (
- handleAmountChange(e, 'amount')} + value={amount} + addonLabel={currency} + addOnPosition='right' />
-
- -
- - ) : ( -
- handleAmountChange(e, 'amount')} - value={amount} - addonLabel={currency} - addOnPosition='right' - /> -
- )} -
- )} + )} +
+ )} - {['lookbackhigh', 'lookbacklow', 'lookbackhighlow'].includes( - formName - ) && ( -
- {currency_list ? ( - <> + {['lookbackhigh', 'lookbacklow', 'lookbackhighlow'].includes( + formName + ) && ( +
+ {currency_list ? ( + <> +
+ handleAmountChange(e, 'multiplier')} + /> +
+
+ +
+ + ) : (
- handleAmountChange(e, 'multiplier')} />
-
- -
- - ) : ( -
- handleAmountChange(e, 'multiplier')} - /> -
- )} -
- )} - - {show_allow_equals && ( -
- { - updateFormField('callputequal', e, 'change'); - }} - size='md' - checked={+is_equal === 1} - infoIconMessage={localize( - 'Win payout if exit spot is also equal to entry spot.' )} - /> -
- )} -
- - )} -
+
+ )} + + {show_allow_equals && ( +
+ { + updateFormField('callputequal', e, 'change'); + }} + size='md' + checked={+is_equal === 1} + infoIconMessage={localize( + 'Win payout if exit spot is also equal to entry spot.' + )} + /> +
+ )} +
+ + )} +
+
); }; diff --git a/src/javascript/app/pages/form/numbers-dropdown.jsx b/src/javascript/app/pages/form/numbers-dropdown.jsx index b23cb7c9a5a..90a2f352f2f 100644 --- a/src/javascript/app/pages/form/numbers-dropdown.jsx +++ b/src/javascript/app/pages/form/numbers-dropdown.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { BreakpointProvider, CustomDropdown, DropdownItem, useDropdown } from '@deriv-com/quill-ui'; +import { CustomDropdown, DropdownItem, useDropdown } from '@deriv-com/quill-ui'; const Content = ({ value, start, end, elementId, onUpdate }) => { const { close } = useDropdown(); @@ -22,15 +22,13 @@ const Content = ({ value, start, end, elementId, onUpdate }) => { }; export const NumbersDropdown = ({ value, label, start, end, elementId, onUpdate }) => ( - - - - - + + + ); diff --git a/src/javascript/app/pages/form/time-selection.jsx b/src/javascript/app/pages/form/time-selection.jsx index fb7479f02f5..8d6e623ac59 100644 --- a/src/javascript/app/pages/form/time-selection.jsx +++ b/src/javascript/app/pages/form/time-selection.jsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { BreakpointProvider, CustomDropdown, DropdownItem, useDropdown } from '@deriv-com/quill-ui'; +import { CustomDropdown, DropdownItem, useDropdown } from '@deriv-com/quill-ui'; import moment from 'moment/moment'; import { useTimeChange } from '../../hooks/events'; import tradeManager from '../../common/trade_manager.js'; @@ -82,14 +82,12 @@ export const TimePickerDropdown = ({ }; return ( - - handleOpen(elementId)}> - - - + handleOpen(elementId)}> + + ); }; diff --git a/src/javascript/app/pages/trade/duration.js b/src/javascript/app/pages/trade/duration.js index fc0d3a82449..481901a30b5 100644 --- a/src/javascript/app/pages/trade/duration.js +++ b/src/javascript/app/pages/trade/duration.js @@ -145,18 +145,18 @@ const Durations = (() => { } }); + const list = Object.keys(duration_list).sort((a, b) => ( + commonTrading.durationOrder(a) > commonTrading.durationOrder(b) ? 1 : -1 + )); + const duration_options = []; - Object.values(duration_list).forEach(option => { - duration_options.push({ text: option.text, value: option.value }); + Object.values(list).forEach(option => { + duration_options.push({ text: duration_list[option].text, value: option }); }); tradeManager.set({ duration_options, }); - const list = Object.keys(duration_list).sort((a, b) => ( - commonTrading.durationOrder(a) > commonTrading.durationOrder(b) ? 1 : -1 - )); - smallest_duration = { amount: duration_list[list[0]].dataset.minimum, unit : list[0],