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

[P2PS] - Nada/2570/fix payment method checkbox issue, condition issue #15980

Merged
Merged
Show file tree
Hide file tree
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
Expand Up @@ -43,7 +43,7 @@ const PaymentMethodCard = ({
small = false,
style,
}: TPaymentMethodCardProps) => {
const { general_store, my_ads_store, my_profile_store } = useStores();
const { buy_sell_store, general_store, my_ads_store, my_profile_store } = useStores();
const { active_index } = general_store;
const { payment_method_ids } = my_ads_store;

Expand Down Expand Up @@ -133,7 +133,11 @@ const PaymentMethodCard = ({
suffix_icon='IcCashierVerticalEllipsis'
/>
)}
{(active_index === 2 || active_index === 0) && (
{/* Display the checkbox selection only when payment method card is shown from
buy/sell tab(active_index === 0) or from my-ads tab(active_index === 2) or when its advertiser page */}
{(active_index === 2 ||
active_index === 0 ||
(active_index === 3 && buy_sell_store.show_advertiser_page)) && (
Copy link
Contributor

Choose a reason for hiding this comment

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

since we are not calling this component in orders page, can you please check if we can remove this condition instead?

<Checkbox
className='payment-method-card__checkbox'
disabled={payment_method_ids.length === 3 && !payment_method_ids.includes(id)}
Expand Down
1 change: 1 addition & 0 deletions packages/p2p/src/pages/buy-sell/buy-sell-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const BuySellForm = props => {

if (!my_profile_store.advertiser_has_payment_methods) {
my_profile_store.getPaymentMethodsList();
my_profile_store.getAdvertiserPaymentMethods();
}

advertiser_page_store.setFormErrorMessage('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jest.mock('../payment-methods-empty', () => jest.fn(() => <div>PaymentMethodsEmp
describe('<PaymentMethods />', () => {
beforeEach(() => {
mock_store = {
buy_sell_store: {
show_advertiser_page: jest.fn(() => true),
},
general_store: {
active_index: 3,
setFormikRef: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { my_profile_tabs } from 'Constants/my-profile-tabs';
import PaymentMethodsList from '../payment-methods-list';

const mock_store: DeepPartial<ReturnType<typeof useStores>> = {
buy_sell_store: {
show_advertiser_page: jest.fn(() => true),
},
general_store: {
active_index: 3,
},
Expand Down
Loading