Skip to content

Commit

Permalink
Ameerul /Task 89855 Add a checkbox to select/deselect a payment metho…
Browse files Browse the repository at this point in the history
…d when creating or updating a sell ad and making a sell order (deriv-com#7824)

* chore: added checkbox to payment method card

* fix: added logic to disable checkbox and show checkbox in certain tabs only
  • Loading branch information
ameerul-deriv authored Mar 21, 2023
1 parent 8a4f36a commit 3ce03d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import classNames from 'classnames';
import { Dropdown, Icon, Text } from '@deriv/components';
import { Checkbox, Dropdown, Icon, Text } from '@deriv/components';
import { isEmptyObject } from '@deriv/shared';
import { localize } from 'Components/i18next';
import { useStores } from 'Stores';
import PropTypes from 'prop-types';
Expand All @@ -20,7 +21,7 @@ const PaymentMethodCard = ({
small,
style,
}) => {
const { my_profile_store } = useStores();
const { general_store, my_ads_store, my_profile_store } = useStores();
const method = !is_add && payment_method?.display_name.replace(/\s|-/gm, '');
const payment_account = payment_method?.fields?.account?.value;
const payment_account_name = payment_method?.display_name;
Expand Down Expand Up @@ -49,7 +50,6 @@ const PaymentMethodCard = ({
custom_color='var(--brand-red-coral)'
size={32}
/>

<Text align='center' color={disabled ? 'less-prominent' : 'prominent'} size='xs'>
{label || add_payment_method}
</Text>
Expand Down Expand Up @@ -86,6 +86,17 @@ const PaymentMethodCard = ({
is_align_text_left
/>
)}
{(general_store.active_index === 2 || general_store.active_index === 0) && (
<Checkbox
className='payment-method-card__checkbox'
disabled={
my_ads_store.payment_method_ids.length === 3 &&
!my_ads_store.payment_method_ids.includes(payment_method.ID)
}
onChange={onClick}
value={!isEmptyObject(style)}
/>
)}
</div>
<div className='payment-method-card__body'>
<Text color='prominent' size={large ? 'xs' : 'xxs'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
}
}

&__checkbox {
.dc-checkbox__box {
margin: 0;
}
}

&__icon {
border-radius: 2px;
}
Expand Down

0 comments on commit 3ce03d5

Please sign in to comment.