From 9c6ca8c0ab2274a803cbd6f6f787210c08100d81 Mon Sep 17 00:00:00 2001 From: lubega-deriv <142860499+lubega-deriv@users.noreply.github.com> Date: Tue, 7 Nov 2023 19:10:26 +0800 Subject: [PATCH] feat: fiat on ramp disclaimer screen (#11246) --- .../cashier/modules/FiatOnRamp/FiatOnRamp.tsx | 58 +++++++++++-------- .../FiatOnRampDisclaimer.scss | 19 ++++++ .../FiatOnRampDisclaimer.tsx | 43 ++++++++++++++ .../components/FiatOnRampDisclaimer/index.ts | 1 + .../FiatOnRampProviderCard.scss | 0 .../FiatOnRampProviderCard.tsx | 18 +++--- .../FiatOnRampProviderCard/index.ts | 0 .../modules/FiatOnRamp/components/index.ts | 2 + 8 files changed, 110 insertions(+), 31 deletions(-) create mode 100644 packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.scss create mode 100644 packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.tsx create mode 100644 packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/index.ts rename packages/wallets/src/features/cashier/modules/FiatOnRamp/{ => components}/FiatOnRampProviderCard/FiatOnRampProviderCard.scss (100%) rename packages/wallets/src/features/cashier/modules/FiatOnRamp/{ => components}/FiatOnRampProviderCard/FiatOnRampProviderCard.tsx (75%) rename packages/wallets/src/features/cashier/modules/FiatOnRamp/{ => components}/FiatOnRampProviderCard/index.ts (100%) create mode 100644 packages/wallets/src/features/cashier/modules/FiatOnRamp/components/index.ts diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRamp.tsx b/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRamp.tsx index 4bddf0da85fd..88e62ea3f3c4 100644 --- a/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRamp.tsx +++ b/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRamp.tsx @@ -1,38 +1,48 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useHistory } from 'react-router-dom'; import { WalletButton, WalletText } from '../../../../components'; import BackArrow from '../../../../public/images/ic-back-arrow.svg'; +import { FiatOnRampDisclaimer, FiatOnRampProviderCard } from './components'; import { fiatOnRampProvider } from './constants'; -import OnRampProviderCard from './FiatOnRampProviderCard/FiatOnRampProviderCard'; import './FiatOnRamp.scss'; const FiatOnRamp = () => { const history = useHistory(); + const [disclaimer, setDisclaimer] = useState(false); + + const handleDisclaimer = () => setDisclaimer(disclaimer => !disclaimer); return ( -
- } - onClick={() => history.push('/wallets/cashier/deposit')} - text='Back' - /> -
-
- - Fiat onramp is a cashier service that allows you to convert fiat currencies to crypto to top up - your Deriv crypto accounts. Listed here are third-party crypto exchanges. You’ll need to create - an account with them to use their services. - + + {disclaimer ? ( + + ) : ( +
+ } + onClick={() => history.push('/wallets/cashier/deposit')} + text='Back' + /> +
+
+ + Fiat onramp is a cashier service that allows you to convert fiat currencies to crypto to + top up your Deriv crypto accounts. Listed here are third-party crypto exchanges. You’ll + need to create an account with them to use their services. + +
+ +
- -
-
+ )} + ); }; diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.scss b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.scss new file mode 100644 index 000000000000..2cb603b72ffd --- /dev/null +++ b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.scss @@ -0,0 +1,19 @@ +.wallets-fiat-onramp-disclaimer { + align-items: flex-start; + display: flex; + flex-direction: column; + gap: 1.6rem; + justify-content: center; + max-width: 79.2rem; + + @include mobile { + justify-content: flex-start; + } + + &__buttons { + display: flex; + gap: 0.8rem; + justify-content: flex-end; + width: 100%; + } +} diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.tsx b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.tsx new file mode 100644 index 000000000000..19fe18330c1b --- /dev/null +++ b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/FiatOnRampDisclaimer.tsx @@ -0,0 +1,43 @@ +import React, { MouseEventHandler, useCallback } from 'react'; +import { useQuery } from '@deriv/api'; +import { WalletButton, WalletText } from '../../../../../../components'; +import './FiatOnRampDisclaimer.scss'; + +type TFiatOnRampDisclaimer = { + handleDisclaimer: MouseEventHandler; +}; + +const FiatOnRampDisclaimer: React.FC = ({ handleDisclaimer }) => { + const { data: provider } = useQuery('service_token', { + payload: { referrer: window.location.href, service: 'banxa' }, + }); + + const redirectToBanxa = useCallback(() => { + const banxaUrl = provider?.service_token?.banxa?.url ?? ''; + if (banxaUrl) { + const link = document.createElement('a'); + link.href = banxaUrl; + link.target = '_blank'; + link.click(); + } + }, [provider?.service_token?.banxa?.url]); + + return ( +
+ + Disclaimer + + + By clicking Continue, you'll be redirected to Banxa, a third-party payment service + provider. Please note that Deriv is not responsible for the content or services provided by Banxa. If + you encounter any issues related to Banxa services, you should contact Banxa directly. + +
+ + redirectToBanxa()} size='md' text={'Continue'} /> +
+
+ ); +}; + +export default FiatOnRampDisclaimer; diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/index.ts b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/index.ts new file mode 100644 index 000000000000..8f1699125782 --- /dev/null +++ b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampDisclaimer/index.ts @@ -0,0 +1 @@ +export { default as FiatOnRampDisclaimer } from './FiatOnRampDisclaimer'; diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRampProviderCard/FiatOnRampProviderCard.scss b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampProviderCard/FiatOnRampProviderCard.scss similarity index 100% rename from packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRampProviderCard/FiatOnRampProviderCard.scss rename to packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampProviderCard/FiatOnRampProviderCard.scss diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRampProviderCard/FiatOnRampProviderCard.tsx b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampProviderCard/FiatOnRampProviderCard.tsx similarity index 75% rename from packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRampProviderCard/FiatOnRampProviderCard.tsx rename to packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampProviderCard/FiatOnRampProviderCard.tsx index 73742d5b94f3..8122c0653b94 100644 --- a/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRampProviderCard/FiatOnRampProviderCard.tsx +++ b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampProviderCard/FiatOnRampProviderCard.tsx @@ -1,17 +1,22 @@ -import React from 'react'; -import { useHistory } from 'react-router-dom'; -import { WalletButton, WalletText } from '../../../../../components'; +import React, { MouseEventHandler } from 'react'; +import { WalletButton, WalletText } from '../../../../../../components'; import './FiatOnRampProviderCard.scss'; type TFiatOnRampProvider = { description: string; getPaymentIcons: () => React.ReactNode[]; + handleDisclaimer: MouseEventHandler; icon: React.ReactNode; name: string; }; -const FiatOnRampProviderCard: React.FC = ({ description, getPaymentIcons, icon, name }) => { - const history = useHistory(); +const FiatOnRampProviderCard: React.FC = ({ + description, + getPaymentIcons, + handleDisclaimer, + icon, + name, +}) => { const paymentIcons = getPaymentIcons(); return ( @@ -33,8 +38,7 @@ const FiatOnRampProviderCard: React.FC = ({ description, ge
{paymentIcon}
))}
- {/* TODO: Add OnClick event to redirect user to disclaimer screen */} - history.push('/wallets/cashier/on-ramp')} size='md' text={'Select'} /> + ); }; diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRampProviderCard/index.ts b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampProviderCard/index.ts similarity index 100% rename from packages/wallets/src/features/cashier/modules/FiatOnRamp/FiatOnRampProviderCard/index.ts rename to packages/wallets/src/features/cashier/modules/FiatOnRamp/components/FiatOnRampProviderCard/index.ts diff --git a/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/index.ts b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/index.ts new file mode 100644 index 000000000000..bfe756770ab1 --- /dev/null +++ b/packages/wallets/src/features/cashier/modules/FiatOnRamp/components/index.ts @@ -0,0 +1,2 @@ +export * from './FiatOnRampDisclaimer'; +export * from './FiatOnRampProviderCard';