Skip to content

Commit

Permalink
Fix: derived and forex account limits structure (binary-com#6856)
Browse files Browse the repository at this point in the history
  • Loading branch information
akmal-deriv authored and adrienne-deriv committed Nov 17, 2022
1 parent c4c066f commit 72a3b6f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import classNames from 'classnames';
import { Text } from '@deriv/components';

const AccountLimitsTableCell = ({ align, children, is_hint, renderExtraInfo }) => {
const AccountLimitsTableCell = ({ align, children, is_hint, level, renderExtraInfo }) => {
const text_size = is_hint ? 'xxxs' : 'xxs';

return (
Expand All @@ -12,6 +12,7 @@ const AccountLimitsTableCell = ({ align, children, is_hint, renderExtraInfo }) =
className={classNames('da-account-limits__table-cell', {
'da-account-limits__table-cell--left': align !== 'right',
'da-account-limits__table-cell--right': align === 'right',
'da-account-limits__table-cell--submarket': level === 'submarket',
})}
data-testid='account_limit_table_cell'
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const AccountLimitsTurnoverLimitRow = ({ collection, title }) => {

return collection.map(item => (
<tr key={item.name} data-testid='account-limits-turnover-limit-row'>
<AccountLimitsTableCell>
<AccountLimitsTableCell level={item.level}>
{title && `${title} - `}
{item.name}
</AccountLimitsTableCell>
Expand Down
14 changes: 4 additions & 10 deletions packages/account/src/Components/account-limits/account-limits.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ const AccountLimits = ({
}

const { commodities, forex, indices, synthetic_index } = { ...market_specific };
const forex_ordered = forex?.slice().sort((a, b) => (a.name < b.name ? 1 : -1));

if (forex_ordered && forex_ordered.push) {
forex_ordered.push(forex_ordered.shift());
}
const forex_ordered = forex?.slice().sort((a, b) => (a.name > b.name ? 1 : b.name > a.name ? -1 : 0));
const derived_ordered = synthetic_index?.slice().sort((b, a) => (a.level < b.level ? 1 : -1));

const context_value = {
currency,
Expand Down Expand Up @@ -207,12 +204,9 @@ const AccountLimits = ({
</thead>
<tbody>
<AccountLimitsTurnoverLimitRow collection={commodities} />
<AccountLimitsTurnoverLimitRow
collection={forex_ordered}
title={localize('Forex')}
/>
<AccountLimitsTurnoverLimitRow collection={forex_ordered} />
<AccountLimitsTurnoverLimitRow collection={indices} />
<AccountLimitsTurnoverLimitRow collection={synthetic_index} />
<AccountLimitsTurnoverLimitRow collection={derived_ordered} />
</tbody>
</table>
{/* We only show "Withdrawal Limits" on account-wide settings pages. */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
&--right {
text-align: right;
}
&--submarket {
padding-left: 1rem;
}
}

&-wrapper {
Expand Down

0 comments on commit 72a3b6f

Please sign in to comment.