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

Adrienne / Changed layout for PM cards list in Ads page #5284

Merged
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2a88134
PM cards in mobile layout is now horizontal according to design, PM c…
adrienne-deriv Apr 20, 2022
ba9e595
eslint formatted
adrienne-deriv Apr 20, 2022
f35115c
Refactored changes to a new component
adrienne-deriv Apr 21, 2022
6ac5ca2
Merge branch 'binary-com:master' into bug-57367-alignment-issues-PM
adrienne-deriv Apr 21, 2022
1482240
eslint formatted
adrienne-deriv Apr 21, 2022
4e2c62f
Merge branch 'bug-57367-alignment-issues-PM' of github.com:adrienne-d…
adrienne-deriv Apr 21, 2022
c08a1af
Delete icons.js
adrienne-deriv Apr 22, 2022
53ffd88
Revert icons.js deletion
adrienne-deriv Apr 22, 2022
5c7b025
Refactored code
adrienne-deriv Apr 22, 2022
ace4852
Alphabetize new component props
adrienne-deriv Apr 22, 2022
e6fea1f
Alphabetize new component props
adrienne-deriv Apr 22, 2022
c10f4f9
Refactored quick add PM modal to include new PM layout changes
adrienne-deriv May 9, 2022
4ba090e
Refactored quick add PM modal to include new PM layout changes
adrienne-deriv May 9, 2022
944afc8
Renamed component
adrienne-deriv May 10, 2022
a3c1aaa
Removed redundant css class for sell ad PM list
adrienne-deriv May 10, 2022
f584874
Added css class for horizontal scrolling
adrienne-deriv May 10, 2022
398299a
Fixed CircleCI build issue
adrienne-deriv May 10, 2022
a90aa29
Fixed merge conflicts
adrienne-deriv May 20, 2022
bc75184
Sorted payment methods in order
adrienne-deriv Jun 3, 2022
930e08c
Merge branch 'master' of github.com:binary-com/deriv-app into bug-573…
adrienne-deriv Jun 3, 2022
fedad81
Fixed merge conflicts
adrienne-deriv Jun 8, 2022
84db6b0
Adjusted PM categories order in My Profile PM and Add PM card height
adrienne-deriv Jun 8, 2022
f1f6807
Adjusted PM categories order in My Profile PM and Add PM card height
adrienne-deriv Jun 8, 2022
7553421
Adjusted card margin for My Profile page and sorted pm cards in sell …
adrienne-deriv Jun 13, 2022
a8429b2
Adjusted left margin for payment methods list
adrienne-deriv Jun 22, 2022
002a51d
Fixed merge conflits
adrienne-deriv Jun 28, 2022
ed5f91e
Merge branch 'master' into bug-57367-alignment-issues-PM
carolsachdeva Jun 30, 2022
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 @@ -5,17 +5,13 @@ import { Autocomplete, Icon, Input, Text } from '@deriv/components';
import { useStores } from 'Stores';
import PaymentMethodCard from '../my-profile/payment-methods/payment-method-card';
import { localize, Localize } from 'Components/i18next';
import SellAdPaymentMethodsList from './sell-ad-payment-methods-list';

const CreateAdFormPaymentMethods = ({ is_sell_advert, onSelectPaymentMethods }) => {
const { my_ads_store, my_profile_store } = useStores();
const [selected_buy_methods, setSelectedBuyMethods] = React.useState([]);
const [selected_sell_methods, setSelectedSellMethods] = React.useState([]);

const style = {
borderColor: 'var(--brand-secondary)',
borderWidth: '2px',
};

const onClickDeletePaymentMethodItem = value => {
if (value) {
my_ads_store.payment_method_names = my_ads_store.payment_method_names.filter(
Expand Down Expand Up @@ -77,30 +73,17 @@ const CreateAdFormPaymentMethods = ({ is_sell_advert, onSelectPaymentMethods })
if (is_sell_advert) {
if (my_profile_store.advertiser_has_payment_methods) {
return (
<>
{my_profile_store.advertiser_payment_methods_list.map((payment_method, key) => (
<PaymentMethodCard
is_vertical_ellipsis_visible={false}
key={key}
medium
onClick={() => onClickPaymentMethodCard(payment_method)}
payment_method={payment_method}
style={selected_sell_methods.includes(payment_method.ID) ? style : {}}
/>
))}
<PaymentMethodCard
is_add={true}
label={localize('Payment method')}
medium
onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethodModal(true)}
/>
</>
<SellAdPaymentMethodsList
selected_methods={selected_sell_methods}
onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethodModal(true)}
onClickPaymentMethodCard={onClickPaymentMethodCard}
/>
);
}

return (
<PaymentMethodCard
is_add={true}
is_add
label={localize('Payment method')}
medium
onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethodModal(true)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ import { Autocomplete, Icon, Input, Text } from '@deriv/components';
import { useStores } from 'Stores';
import PaymentMethodCard from '../my-profile/payment-methods/payment-method-card';
import { localize, Localize } from 'Components/i18next';
import SellAdPaymentMethodsList from './sell-ad-payment-methods-list';

const EditAdFormPaymentMethods = ({ is_sell_advert, selected_methods, setSelectedMethods }) => {
const { my_ads_store, my_profile_store } = useStores();

const style = {
borderColor: 'var(--brand-secondary)',
borderWidth: '2px',
};

const onClickDeletePaymentMethodItem = value => {
if (value) {
my_ads_store.payment_method_names = my_ads_store.payment_method_names.filter(
Expand Down Expand Up @@ -65,24 +61,11 @@ const EditAdFormPaymentMethods = ({ is_sell_advert, selected_methods, setSelecte
if (is_sell_advert) {
if (my_profile_store.advertiser_has_payment_methods) {
return (
<>
{my_profile_store.advertiser_payment_methods_list.map((payment_method, key) => (
<PaymentMethodCard
is_vertical_ellipsis_visible={false}
key={key}
medium
onClick={() => onClickPaymentMethodCard(payment_method)}
payment_method={payment_method}
style={selected_methods.includes(payment_method.ID) ? style : {}}
/>
))}
<PaymentMethodCard
is_add={true}
label={localize('Payment method')}
medium
onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethodModal(true)}
/>
</>
<SellAdPaymentMethodsList
selected_methods={selected_methods}
onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethodModal(true)}
onClickPaymentMethodCard={onClickPaymentMethodCard}
/>
);
}

Expand Down
13 changes: 8 additions & 5 deletions packages/p2p/src/components/my-ads/my-ads.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@
flex-direction: column;
padding: 1rem 1.6rem 0;
width: 100vw;

&--scroll {
overflow: auto;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed margin-bottom: 7.5rem as it is a bug added in previous PR which will be fixed in card Task #64742


&--horizontal {
padding-right: 0rem;
}
}

&__table {
Expand Down Expand Up @@ -628,11 +636,6 @@
}
}

&__modal-body--scroll {
overflow: auto;
margin-bottom: 7.5rem;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

&__modal-body is already declared in line 197, refactored &__modal-body--scroll to &--scroll within the &__modal-body block

.toggle-ads {
align-items: center;
display: flex;
Expand Down
77 changes: 20 additions & 57 deletions packages/p2p/src/components/my-ads/quick-add-modal.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import classNames from 'classnames';
import * as React from 'react';
import { Formik, Field } from 'formik';
import {
Autocomplete,
Button,
Icon,
Input,
MobileFullPageModal,
Modal,
Text,
ThemedScrollbars,
} from '@deriv/components';
import { Autocomplete, Button, Icon, Input, MobileFullPageModal, Modal, Text } from '@deriv/components';
import { isMobile } from '@deriv/shared';
import { observer } from 'mobx-react-lite';
import { localize, Localize } from 'Components/i18next';
import { buy_sell } from 'Constants/buy-sell';
import { useStores } from 'Stores';
import PaymentMethodCard from '../my-profile/payment-methods/payment-method-card';
import AddPaymentMethod from '../my-profile/payment-methods/add-payment-method/add-payment-method.jsx';
import SellAdPaymentMethodsList from './sell-ad-payment-methods-list';
import './quick-add-modal.scss';

const QuickAddModal = ({ advert }) => {
Expand All @@ -29,11 +20,6 @@ const QuickAddModal = ({ advert }) => {

const is_buy_advert = type === buy_sell.BUY;

const style = {
borderColor: 'var(--brand-secondary)',
borderWidth: '2px',
};

const onClickDeletePaymentMethodItem = value => {
if (value) {
my_ads_store.payment_method_names = my_ads_store.payment_method_names.filter(
Expand Down Expand Up @@ -283,22 +269,9 @@ const QuickAddModal = ({ advert }) => {
<Text color='prominent' size='xxs'>
<Localize i18n_default_text='You may choose up to 3 payment methods for this ad.' />
</Text>
{my_profile_store.advertiser_payment_methods_list.map((payment_method, key) => (
<div key={key}>
<PaymentMethodCard
is_vertical_ellipsis_visible={false}
key={key}
small
onClick={() => onClickPaymentMethodCard(payment_method)}
payment_method={payment_method}
style={selected_methods.includes(payment_method.ID) ? style : {}}
/>
</div>
))}
<PaymentMethodCard
is_add={true}
label={localize('Payment method')}
small
<SellAdPaymentMethodsList
onClickPaymentMethodCard={onClickPaymentMethodCard}
selected_methods={selected_methods}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2022-05-10 at 2 05 27 PM

onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethod(true)}
/>
</>
Expand Down Expand Up @@ -457,9 +430,10 @@ const QuickAddModal = ({ advert }) => {
<Modal
className='p2p-my-ads__modal-error'
has_close_icon={false}
height='660px'
height={my_ads_store.should_show_add_payment_method ? '660px' : 'auto'}
Copy link
Contributor Author

@adrienne-deriv adrienne-deriv May 10, 2022

Choose a reason for hiding this comment

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

Height changed according to design:
Screenshot 2022-05-10 at 3 49 54 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2022-05-10 at 12 36 35 PM

is_open={my_ads_store.is_quick_add_modal_open}
title={localize('Add payment method')}
title={localize('Add payment methods')}
width='440px'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be using px here? why not use rem instead

>
{my_ads_store.should_show_add_payment_method ? (
<Modal.Body
Expand All @@ -470,29 +444,18 @@ const QuickAddModal = ({ advert }) => {
<AddPaymentMethod should_show_page_return={false} should_show_separated_footer={true} />
</Modal.Body>
) : (
<ThemedScrollbars height='calc(100% - 5.8rem - 7.4rem)'>
<Modal.Body>
<Text color='prominent' size='xxs'>
<Localize i18n_default_text='You may choose up to 3 payment methods for this ad.' />
</Text>
{my_profile_store.advertiser_payment_methods_list.map((payment_method, key) => (
<PaymentMethodCard
is_vertical_ellipsis_visible={false}
key={key}
medium
onClick={() => onClickPaymentMethodCard(payment_method)}
payment_method={payment_method}
style={selected_methods.includes(payment_method.ID) ? style : {}}
/>
))}
<PaymentMethodCard
is_add={true}
label={localize('Payment method')}
medium
onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethod(true)}
/>
</Modal.Body>
</ThemedScrollbars>
<Modal.Body className='p2p-my-ads__modal-body--horizontal'>
<Text color='prominent' size='xs'>
<Localize i18n_default_text='You may choose up to 3 payment methods for this ad.' />
</Text>
<SellAdPaymentMethodsList
is_only_horizontal
is_scrollable
onClickPaymentMethodCard={onClickPaymentMethodCard}
selected_methods={selected_methods}
onClickAdd={() => my_ads_store.setShouldShowAddPaymentMethod(true)}
/>
</Modal.Body>
)}
{!my_ads_store.should_show_add_payment_method && (
<Modal.Footer has_separator>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react';
import { useStores } from 'Stores';
import { ThemedScrollbars } from '@deriv/components';
import { isMobile } from '@deriv/shared';
import { observer } from 'mobx-react-lite';
import { localize } from 'Components/i18next';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import PaymentMethodCard from '../my-profile/payment-methods/payment-method-card';
import './sell-ad-payment-methods-list.scss';

const SellAdPaymentMethodsList = ({
is_only_horizontal = isMobile(),
is_scrollable = isMobile(),
onClickAdd,
onClickPaymentMethodCard,
selected_methods,
}) => {
const { my_profile_store } = useStores();

const style = {
borderColor: 'var(--brand-secondary)',
borderWidth: '2px',
};

// payment method order: Bank Transfer -> EWallets -> Others
const payment_method_order = { bank_transfer: 0, other: 2 };
const getPaymentMethodOrder = method => (!(method in payment_method_order) ? 1 : payment_method_order[method]);
const sortPaymentMethods = payment_methods_list => {
return payment_methods_list.sort((i, j) => getPaymentMethodOrder(i.method) - getPaymentMethodOrder(j.method));
};

return (
<ThemedScrollbars
className={classNames('sell-ad-payment-methods__container', {
'sell-ad-payment-methods__container--horizontal': is_only_horizontal,
})}
is_scrollbar_hidden
is_scrollable={is_scrollable}
is_only_horizontal={is_only_horizontal}
>
{sortPaymentMethods([...my_profile_store.advertiser_payment_methods_list]).map((payment_method, key) => (
<PaymentMethodCard
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorted payment methods list in order as per QA requirements
Screenshot 2022-06-03 at 5 04 39 PM
:

is_vertical_ellipsis_visible={false}
key={key}
medium
onClick={() => onClickPaymentMethodCard(payment_method)}
payment_method={payment_method}
style={selected_methods.includes(payment_method.ID) ? style : {}}
/>
))}
<PaymentMethodCard is_add label={localize('Payment method')} medium onClickAdd={onClickAdd} />
</ThemedScrollbars>
);
};

SellAdPaymentMethodsList.propTypes = {
is_only_horizontal: PropTypes.bool,
is_scrollable: PropTypes.bool,
onClickAdd: PropTypes.func,
onClickPaymentMethodCard: PropTypes.func,
selected_methods: PropTypes.array,
};

export default observer(SellAdPaymentMethodsList);
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.sell-ad-payment-methods {
&__container {
display: grid;
grid-template-columns: repeat(4, 0.19fr);

&--horizontal {
grid-auto-flow: column;
& .payment-method-card {
margin: 1rem 1.5rem 1rem auto;
}

& .payment-method-card--add {
margin: 1rem 1.5rem 1rem 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
margin: 1.6rem 0;
padding: 0.8rem;

@include mobile {
margin: 1rem 0;
}

&-icon {
margin-bottom: 0.8rem;
width: auto;
Expand Down
Loading