Skip to content

Commit

Permalink
Merge pull request #11 from ameerul-deriv/P2PS-1305-access-the-share-…
Browse files Browse the repository at this point in the history
…ad-link

Ameerul /P2PS-1305 access the share ad link
  • Loading branch information
ameerul-deriv committed Sep 1, 2023
2 parents 5282366 + 1953d9f commit fd08ecd
Show file tree
Hide file tree
Showing 27 changed files with 490 additions and 124 deletions.
161 changes: 133 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"mobx-react": "^7.5.1",
"onfido-sdk-ui": "^11.0.0",
"prop-types": "^15.7.2",
"qrcode.react": "^1.0.0",
"qrcode.react": "^3.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cashier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"mobx": "^6.6.1",
"moment": "^2.29.2",
"prop-types": "^15.7.2",
"qrcode.react": "^1.0.0",
"qrcode.react": "^3.1.0",
"react": "^17.0.2",
"react-content-loader": "^6.2.0",
"react-dom": "^17.0.2",
Expand Down
11 changes: 9 additions & 2 deletions packages/cashier/src/components/error-dialog/error-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ type TErrorDialogProps = {

type TSetDetails = {
title: string;
cancel_button_text: undefined | string;
cancel_button_text?: string;
confirm_button_text: undefined | string;
onConfirm: undefined | (() => void);
onConfirm?: () => void;
message: undefined | string | TReactElement;
has_close_icon?: boolean;
};
Expand Down Expand Up @@ -107,6 +107,13 @@ const ErrorDialog = observer(({ className, error = {} }: TErrorDialogProps) => {
onConfirm: undefined,
message: error_message,
});
} else if (error_code === 'ShareMyAdsError') {
setDetails({
title: localize('Deriv P2P unavailable'),
confirm_button_text: localize('OK'),
message: error_message,
has_close_icon: true,
});
} else {
setDetails({
title: localize('Cashier Error'),
Expand Down
25 changes: 22 additions & 3 deletions packages/cashier/src/containers/cashier/cashier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type TCashierOptions = {
};

const Cashier = observer(({ history, location, routes: routes_config }: TCashierProps) => {
const { common, ui, client } = useStore();
const { common, ui, client, traders_hub } = useStore();
const { withdraw, general_store, payment_agent } = useCashierStore();
const { error } = withdraw;
const {
Expand All @@ -68,8 +68,9 @@ const Cashier = observer(({ history, location, routes: routes_config }: TCashier
} = usePaymentAgentTransferVisible();
const { is_payment_agent_visible } = payment_agent;
const { is_from_derivgo } = common;
const { is_cashier_visible: is_visible, toggleCashier } = ui;
const { is_account_setting_loaded, is_logged_in, is_logging_in } = client;
const { is_demo } = traders_hub;
const { is_cashier_visible: is_visible, toggleCashier, toggleReadyToDepositModal } = ui;
const { currency, is_account_setting_loaded, is_logged_in, is_logging_in, is_svg } = client;
const is_account_transfer_visible = useAccountTransferVisible();
const is_onramp_visible = useOnrampVisible();
const p2p_notification_count = useP2PNotificationCount();
Expand Down Expand Up @@ -200,8 +201,26 @@ const Cashier = observer(({ history, location, routes: routes_config }: TCashier

useEffect(() => {
if (is_p2p_enabled_success && !is_p2p_enabled && history.location.pathname.startsWith(routes.cashier_p2p)) {
const url_params = new URLSearchParams(history.location.search);
const advert_id = url_params.get('advert_id');

history.push(routes.cashier_deposit);

if (advert_id) {
if (is_demo) {
toggleReadyToDepositModal();
} else {
error.setErrorMessage({
code: 'ShareMyAdsError',
message:
currency !== 'USD' && is_svg
? localize('Deriv P2P is currently unavailable in this currency.')
: localize('Deriv P2P is currently unavailable in your country.'),
});
}
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [history, is_p2p_enabled, is_p2p_enabled_success]);

if (
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/components/dialog/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
margin-top: 1.4rem;
&--end {
justify-content: flex-end;
}
Expand Down
Loading

0 comments on commit fd08ecd

Please sign in to comment.