Skip to content

Commit

Permalink
Merge pull request #76 from ameerul-deriv/P2PS-1994-wrong-title-for-b…
Browse files Browse the repository at this point in the history
…uy/sell-modal-issue

[P2PS] Ameerul /P2PS-1994 Wrong title for buy/sell modal from advertiser page
  • Loading branch information
farrah-deriv committed Nov 24, 2023
2 parents d26a9c2 + 7a17b09 commit 25b5538
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('<BuySellModal />', () => {
},
table_type: 'buy',
fetchAdvertiserAdverts: jest.fn(),
is_buy: true,
is_buy_advert: true,
setFormErrorCode: jest.fn(),
unsubscribeAdvertInfo: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import BuySellModalError from './buy-sell-modal-error';
const BuySellModal = () => {
const { hideModal, is_modal_open, showModal } = useModalManagerContext();
const { buy_sell_store, general_store, my_profile_store, order_store } = useStores();
const { is_buy, selected_ad_state } = buy_sell_store;
const { is_buy_advert, selected_ad_state } = buy_sell_store;
const { balance } = general_store;
const { should_show_add_payment_method_form } = my_profile_store;

Expand All @@ -28,7 +28,7 @@ const BuySellModal = () => {
const [is_account_balance_low, setIsAccountBalanceLow] = React.useState(false);
const submitForm = React.useRef<(() => void) | null>(null);

const show_low_balance_message = !is_buy && is_account_balance_low;
const show_low_balance_message = !is_buy_advert && is_account_balance_low;

const setSubmitForm = (submitFormFn: () => void) => (submitForm.current = submitFormFn);

Expand Down Expand Up @@ -110,7 +110,7 @@ const BuySellModal = () => {
is_flex
is_modal_open={is_modal_open}
page_header_className='buy-sell-modal__header'
renderPageHeaderElement={<BuySellModalTitle is_buy={is_buy} />}
renderPageHeaderElement={<BuySellModalTitle is_buy={is_buy_advert} />}
pageHeaderReturnFn={onCancel}
>
<BuySellModalError
Expand Down Expand Up @@ -144,15 +144,15 @@ const BuySellModal = () => {
className={classNames('buy-sell-modal', {
'buy-sell-modal__form': should_show_add_payment_method_form,
})}
height={is_buy ? 'auto' : '649px'}
height={is_buy_advert ? 'auto' : '649px'}
is_open={is_modal_open}
portalId='modal_root'
title={<BuySellModalTitle is_buy={is_buy} />}
title={<BuySellModalTitle is_buy={is_buy_advert} />}
toggleModal={onCancel}
width='456px'
>
{/* Parent height - Modal.Header height - Modal.Footer height */}
<ThemedScrollbars height={is_buy ? '100%' : 'calc(100% - 5.8rem - 7.4rem)'}>
<ThemedScrollbars height={is_buy_advert ? '100%' : 'calc(100% - 5.8rem - 7.4rem)'}>
<Modal.Body className='buy-sell-modal__layout'>
<BuySellModalError
error_message={error_message}
Expand Down
8 changes: 4 additions & 4 deletions packages/p2p/src/pages/buy-sell/buy-sell-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BuySellForm = props => {
buy_sell_store.setFormProps(props);
}, [props, buy_sell_store]);

const { advert, setIsSubmitDisabled, setPageFooterParent, setSubmitForm } = props;
const { advert, setPageFooterParent } = props;
const {
advertiser_details,
description,
Expand Down Expand Up @@ -161,7 +161,7 @@ const BuySellForm = props => {
};

React.useEffect(() => {
setIsSubmitDisabled(
buy_sell_store.form_props.setIsSubmitDisabled(
!isValid ||
isSubmitting ||
(buy_sell_store.is_sell_advert && payment_method_names && selected_methods.length < 1)
Expand All @@ -170,13 +170,13 @@ const BuySellForm = props => {
isValid,
isSubmitting,
selected_methods.length,
buy_sell_store.form_props,
buy_sell_store.is_sell_advert,
payment_method_names,
buy_sell_store.form_props,
]);

React.useEffect(() => {
setSubmitForm(submitForm);
buy_sell_store.form_props.setSubmitForm(submitForm);
}, [submitForm, buy_sell_store.form_props]);

return (
Expand Down

0 comments on commit 25b5538

Please sign in to comment.