diff --git a/package-lock.json b/package-lock.json index d99f2a111074..1b9d4d4f7bd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -195,6 +195,7 @@ "svg-sprite-loader": "^6.0.11", "svgo": "^2.8.0", "svgo-loader": "^3.0.0", + "tailwind-merge": "^1.14.0", "tailwindcss": "^3.3.6", "terser-webpack-plugin": "^5.1.1", "typescript": "^4.6.3", @@ -46582,7 +46583,6 @@ "version": "1.14.0", "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-1.14.0.tgz", "integrity": "sha512-3mFKyCo/MBcgyOTlrY8T7odzZFx+w+qKSMAmdFzRvqBfLlSigU6TZnlFHK0lkMwj9Bj8OYU+9yW9lmGuS0QEnQ==", - "peer": true, "funding": { "type": "github", "url": "https://github.com/sponsors/dcastil" @@ -83548,8 +83548,7 @@ "tailwind-merge": { "version": "1.14.0", "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-1.14.0.tgz", - "integrity": "sha512-3mFKyCo/MBcgyOTlrY8T7odzZFx+w+qKSMAmdFzRvqBfLlSigU6TZnlFHK0lkMwj9Bj8OYU+9yW9lmGuS0QEnQ==", - "peer": true + "integrity": "sha512-3mFKyCo/MBcgyOTlrY8T7odzZFx+w+qKSMAmdFzRvqBfLlSigU6TZnlFHK0lkMwj9Bj8OYU+9yW9lmGuS0QEnQ==" }, "tailwindcss": { "version": "3.4.1", diff --git a/packages/tradershub/package.json b/packages/tradershub/package.json index 57d76071f473..d065207315a1 100644 --- a/packages/tradershub/package.json +++ b/packages/tradershub/package.json @@ -14,30 +14,20 @@ }, "dependencies": { "@deriv/api": "^1.0.0", - "@deriv/integration": "^1.0.0", "@deriv/library": "^1.0.0", "@deriv/quill-icons": "^1.18.3", "@deriv-com/ui": "1.8.2", "@deriv/react-joyride": "^2.6.2", - "@deriv/utils": "^1.0.0", - "@tanstack/react-table": "^8.10.3", - "@zxcvbn-ts/core": "^3.0.4", - "@zxcvbn-ts/language-common": "^3.0.4", "class-variance-authority": "^0.7.0", - "classnames": "^2.2.6", - "downshift": "^8.2.2", "embla-carousel-react": "8.0.0-rc12", "formik": "^2.1.4", "i18next": "^22.4.6", - "moment": "^2.29.2", "qrcode.react": "^3.1.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-modal": "^3.16.1", - "react-dropzone": "11.0.1", "react-i18next": "^11.11.0", "react-router-dom": "^5.2.0", - "react-transition-group": "4.4.2", "tailwind-merge": "^1.14.0", "usehooks-ts": "^2.7.0", "yup": "^0.32.11" @@ -45,7 +35,6 @@ "devDependencies": { "@testing-library/react": "^12.0.0", "@testing-library/user-event": "^13.5.0", - "@types/css-modules": "^1.0.2", "@types/react-dom": "^18.0.0", "@typescript-eslint/eslint-plugin": "5.45.0", "@typescript-eslint/parser": "5.45.0", diff --git a/packages/tradershub/src/App.tsx b/packages/tradershub/src/App.tsx index 94b634bdee26..0b046023a126 100644 --- a/packages/tradershub/src/App.tsx +++ b/packages/tradershub/src/App.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { UIProvider } from '@/components'; +import { RealAccountCreationProvider } from '@/providers'; import { APIProvider } from '@deriv/api'; import { Provider } from '@deriv/library'; -import { SignupWizardProvider } from './providers/SignupWizardProvider'; import AppContent from './AppContent'; import './index.scss'; @@ -11,9 +11,9 @@ const App = () => ( - + - + diff --git a/packages/tradershub/src/AppContent.tsx b/packages/tradershub/src/AppContent.tsx index 79c7bdaff172..e58bdb7f020a 100644 --- a/packages/tradershub/src/AppContent.tsx +++ b/packages/tradershub/src/AppContent.tsx @@ -1,8 +1,8 @@ import React, { Fragment } from 'react'; import { AppContainer, EUDisclaimerMessage } from '@/components'; +import { RealAccountCreation } from '@/flows'; import { useRegulationFlags } from '@/hooks'; import { Router } from '@/routes'; -import SignupWizard from './flows/RealAccountSIgnup/SignupWizard'; const AppContent = () => { const { isEU } = useRegulationFlags(); @@ -14,7 +14,7 @@ const AppContent = () => { {isEU && } - + ); }; diff --git a/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountBanner.tsx b/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountBanner.tsx index 8b4179c008fd..a2405bbb19a4 100644 --- a/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountBanner.tsx +++ b/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountBanner.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Button, Text } from '@deriv-com/ui'; -import { useSignupWizardContext } from '../../providers/SignupWizardProvider'; +import { useRealAccountCreationContext } from '../../providers/RealAccountCreationProvider'; /** * `GetADerivAccountBanner` is a functional component that displays a banner message @@ -10,7 +10,7 @@ import { useSignupWizardContext } from '../../providers/SignupWizardProvider'; * @returns {React.ReactElement} A `div` element containing the banner message and the button. */ const GetADerivAccountBanner = () => { - const { setIsWizardOpen } = useSignupWizardContext(); + const { setIsWizardOpen } = useRealAccountCreationContext(); return (
You need a Deriv account to create a CFD account. diff --git a/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountDialog.tsx b/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountDialog.tsx index 13b0eeef79b8..14402f3ab913 100644 --- a/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountDialog.tsx +++ b/packages/tradershub/src/components/GetADerivAccountBanner/GetADerivAccountDialog.tsx @@ -3,7 +3,7 @@ import ReactModal from 'react-modal'; import { ButtonGroup } from '@/components'; import { CUSTOM_STYLES } from '@/helpers'; import { Button, Text } from '@deriv-com/ui'; -import { useSignupWizardContext } from '../../providers/SignupWizardProvider'; +import { useRealAccountCreationContext } from '../../providers/RealAccountCreationProvider'; type TGetADerivAccountDialog = { isOpen: boolean; @@ -17,7 +17,7 @@ type TGetADerivAccountDialog = { * @returns {React.ReactElement} A `` component containing the dialog message and action button. */ const GetADerivAccountDialog = ({ isOpen, onClose }: TGetADerivAccountDialog) => { - const { setIsWizardOpen } = useSignupWizardContext(); + const { setIsWizardOpen } = useRealAccountCreationContext(); return ( diff --git a/packages/tradershub/src/components/GetDerivAccount/GetDerivAccount.tsx b/packages/tradershub/src/components/GetDerivAccount/GetDerivAccount.tsx index 7afd5686da1f..aced8aa25c74 100644 --- a/packages/tradershub/src/components/GetDerivAccount/GetDerivAccount.tsx +++ b/packages/tradershub/src/components/GetDerivAccount/GetDerivAccount.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { useSignupWizardContext } from '../../providers/SignupWizardProvider'; +import { useRealAccountCreationContext } from '../../providers/RealAccountCreationProvider'; import { IconComponent } from '../IconComponent'; import { TradingAccountCard, TradingAccountCardContent, TradingAccountCardLightButton } from '../TradingAccountCard'; const TrailingButton = () => { - const { setIsWizardOpen } = useSignupWizardContext(); + const { setIsWizardOpen } = useRealAccountCreationContext(); return setIsWizardOpen(true)} />; }; diff --git a/packages/tradershub/src/components/ProgressBar/index.tsx b/packages/tradershub/src/components/ProgressBar/index.tsx index f748ba96e5d8..fb5fd25274f0 100644 --- a/packages/tradershub/src/components/ProgressBar/index.tsx +++ b/packages/tradershub/src/components/ProgressBar/index.tsx @@ -1,4 +1,5 @@ -import DesktopProgressBar from './DesktopProgressBar'; -import MobileProgressBar from './MobileProgressBar'; +import type { TSteps } from './Stepper'; -export { DesktopProgressBar, MobileProgressBar }; +export { default as DesktopProgressBar } from './DesktopProgressBar'; +export { default as MobileProgressBar } from './MobileProgressBar'; +export { TSteps }; diff --git a/packages/tradershub/src/components/index.ts b/packages/tradershub/src/components/index.ts index 13e3b39a60a7..e36730ff0148 100644 --- a/packages/tradershub/src/components/index.ts +++ b/packages/tradershub/src/components/index.ts @@ -13,6 +13,7 @@ export * from './IconComponent'; export * from './Loaders'; export * from './Modal'; export * from './OptionsAndMultipliersSection'; +export * from './ProgressBar'; export * from './RegulationSwitcher'; export * from './SentEmailContent'; export * from './StaticLink'; diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/index.tsx b/packages/tradershub/src/flows/RealAccountCreation/RealAccountCreation.tsx similarity index 74% rename from packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/index.tsx rename to packages/tradershub/src/flows/RealAccountCreation/RealAccountCreation.tsx index 94ee920b397f..f8c6b19642f9 100644 --- a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/index.tsx +++ b/packages/tradershub/src/flows/RealAccountCreation/RealAccountCreation.tsx @@ -1,29 +1,26 @@ import React, { Fragment, useState } from 'react'; import ReactModal from 'react-modal'; +import { DesktopProgressBar, MobileProgressBar, TSteps } from '@/components'; +import { CUSTOM_STYLES } from '@/helpers'; +import { AccountOpeningSuccessModal, ExitConfirmationDialog } from '@/modals'; +import { useRealAccountCreationContext } from '@/providers'; import { StandaloneXmarkBoldIcon } from '@deriv/quill-icons'; import { Text } from '@deriv-com/ui'; -import { DesktopProgressBar, MobileProgressBar } from '../../../components/ProgressBar'; -import { TSteps } from '../../../components/ProgressBar/Stepper'; -import { CUSTOM_STYLES } from '../../../helpers/signupModalHelpers'; -import { useSignupWizardContext } from '../../../providers/SignupWizardProvider'; -import AccountOpeningSuccessModal from '../AccountOpeningSuccessModal/AccountOpeningSuccessModal'; -import ExitConfirmationDialog from '../ExitConfirmationDialog'; -import WizardScreens from './WizardScreens'; -import './index.scss'; +import WizardScreens from './WizardScreens/WizardScreens'; const FORM_PROGRESS_STEPS: TSteps = ['Account currency', 'Personal details', 'Address', 'Terms of use']; /** - * @name SignupWizard - * @description The SignupWizard component is used to render the signup wizard modal. + * @name RealAccountCreation + * @description The RealAccountCreation component is used to render the signup wizard modal. * @example * return ( - * + * * ); */ -const SignupWizard = () => { +const RealAccountCreation = () => { const [isConfirmationDialogOpen, setIsConfirmationDialogOpen] = useState(false); - const { currentStep, isWizardOpen } = useSignupWizardContext(); + const { currentStep, isWizardOpen } = useRealAccountCreationContext(); return ( @@ -66,4 +63,4 @@ const SignupWizard = () => { ); }; -export default SignupWizard; +export default RealAccountCreation; diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/Actions/index.tsx b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenActions/WizardScreenActions.tsx similarity index 79% rename from packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/Actions/index.tsx rename to packages/tradershub/src/flows/RealAccountCreation/WizardScreenActions/WizardScreenActions.tsx index d38ce76daf4e..ec55aa3002e5 100644 --- a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/Actions/index.tsx +++ b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenActions/WizardScreenActions.tsx @@ -1,31 +1,31 @@ import React from 'react'; import { useFormikContext } from 'formik'; import { ButtonGroup } from '@/components'; +import { useRealAccountCreationContext } from '@/providers'; import { Button, Divider, useDevice } from '@deriv-com/ui'; -import { useSignupWizardContext } from '../../../../providers/SignupWizardProvider'; -type TActions = { +type TWizardScreenActions = { isSubmitBtnLoading?: boolean; submitDisabled?: boolean; }; /** - * @name Actions - * @description The Actions component is used to navigate between steps in the SignupWizard component. + * @name WizardScreenActions + * @description The WizardScreenActions component is used to navigate between steps in the RealAccountCreation component. * Intended to be used as a child component of the Formik component. * @param {Object} props - React props object * @param {boolean} [props.submitDisabled] - A boolean that determines whether the Next button is disabled * @param {boolean} [props.isSubmitBtnLoading] - A boolean that determines whether the Next button is in a loading state * @example * return ( - * + * * ); */ -const Actions = ({ submitDisabled = false, isSubmitBtnLoading = false }: TActions) => { +const WizardScreenActions = ({ submitDisabled = false, isSubmitBtnLoading = false }: TWizardScreenActions) => { const { helpers: { canGoToNextStep, canGoToPrevStep, goToPrevStep }, - } = useSignupWizardContext(); + } = useRealAccountCreationContext(); const { isSubmitting } = useFormikContext(); const { isDesktop } = useDevice(); @@ -59,4 +59,4 @@ const Actions = ({ submitDisabled = false, isSubmitBtnLoading = false }: TAction ); }; -export default Actions; +export default WizardScreenActions; diff --git a/packages/tradershub/src/flows/RealAccountCreation/WizardScreenActions/index.ts b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenActions/index.ts new file mode 100644 index 000000000000..ad5d2e2f7586 --- /dev/null +++ b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenActions/index.ts @@ -0,0 +1 @@ +export { default as WizardScreenActions } from './WizardScreenActions'; diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper/WizardScreenWrapper.tsx b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenWrapper/WizardScreenWrapper.tsx similarity index 95% rename from packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper/WizardScreenWrapper.tsx rename to packages/tradershub/src/flows/RealAccountCreation/WizardScreenWrapper/WizardScreenWrapper.tsx index 269a8f03dd10..d661600c9560 100644 --- a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper/WizardScreenWrapper.tsx +++ b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenWrapper/WizardScreenWrapper.tsx @@ -5,7 +5,7 @@ type TWizardScreenWrapper = { children: React.ReactNode; heading: ReactNode }; /** * @name WizardScreenWrapper - * @description The WizardScreenWrapper component is used to wrap the screens in the SignupWizard component. + * @description The WizardScreenWrapper component is used to wrap the screens in the RealAccountCreation component. * @param {Object} props - React props object * @param {React.ReactNode} props.children - The content to be wrapped. * @param {React.ReactNode} props.heading - The heading of the screen. diff --git a/packages/tradershub/src/flows/RealAccountCreation/WizardScreenWrapper/index.ts b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenWrapper/index.ts new file mode 100644 index 000000000000..681e4e5e2800 --- /dev/null +++ b/packages/tradershub/src/flows/RealAccountCreation/WizardScreenWrapper/index.ts @@ -0,0 +1 @@ +export { default as WizardScreenWrapper } from './WizardScreenWrapper'; diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreens/index.tsx b/packages/tradershub/src/flows/RealAccountCreation/WizardScreens/WizardScreens.tsx similarity index 69% rename from packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreens/index.tsx rename to packages/tradershub/src/flows/RealAccountCreation/WizardScreens/WizardScreens.tsx index a64336393eb4..d9148363d17d 100644 --- a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreens/index.tsx +++ b/packages/tradershub/src/flows/RealAccountCreation/WizardScreens/WizardScreens.tsx @@ -1,17 +1,17 @@ import React from 'react'; -import { useSignupWizardContext } from '../../../../providers/SignupWizardProvider'; -import { Address, CurrencySelector, PersonalDetails, TermsOfUse } from '../../../../screens'; +import { useRealAccountCreationContext } from '@/providers'; +import { Address, CurrencySelector, PersonalDetails, TermsOfUse } from '@/screens'; /** * @name WizardScreens - * @description The WizardScreens component is used to render the screens in the SignupWizard component based on the active step from `SignupWizardContext`. + * @description The WizardScreens component is used to render the screens in the RealAccountCreation component based on the active step from `RealAccountCreationContext`. * @example * return ( * * ); */ const WizardScreens = () => { - const { currentStep } = useSignupWizardContext(); + const { currentStep } = useRealAccountCreationContext(); switch (currentStep) { case 1: diff --git a/packages/tradershub/src/flows/RealAccountCreation/WizardScreens/index.ts b/packages/tradershub/src/flows/RealAccountCreation/WizardScreens/index.ts new file mode 100644 index 000000000000..2faff6138312 --- /dev/null +++ b/packages/tradershub/src/flows/RealAccountCreation/WizardScreens/index.ts @@ -0,0 +1 @@ +export { default as WizardScreens } from './WizardScreens'; diff --git a/packages/tradershub/src/flows/RealAccountCreation/index.ts b/packages/tradershub/src/flows/RealAccountCreation/index.ts new file mode 100644 index 000000000000..ef1850b43001 --- /dev/null +++ b/packages/tradershub/src/flows/RealAccountCreation/index.ts @@ -0,0 +1,4 @@ +export { default as RealAccountCreation } from './RealAccountCreation'; +export * from './WizardScreenActions'; +export * from './WizardScreens'; +export * from './WizardScreenWrapper'; diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper/index.ts b/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper/index.ts deleted file mode 100644 index 5258a343a353..000000000000 --- a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import WizardScreenWrapper from './WizardScreenWrapper'; - -export default WizardScreenWrapper; diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/index.scss b/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/index.scss deleted file mode 100644 index 3b23f00fb957..000000000000 --- a/packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/index.scss +++ /dev/null @@ -1,27 +0,0 @@ -.ReactModal__Overlay { - background-color: rgba(0, 0, 0, 0.72); - z-index: 9999; -} - -.ReactModal__Content { - opacity: 0; - transition: all 350ms ease-in-out; - - &--after-open { - opacity: 1; - bottom: auto; - left: 50%; - right: auto; - top: 50%; - transform: translate(-50%, -50%); - border-radius: 0; - border: none; - padding: 0; - margin: 0; - background: none; - } - - &--before-close { - opacity: 0; - } -} diff --git a/packages/tradershub/src/flows/index.ts b/packages/tradershub/src/flows/index.ts new file mode 100644 index 000000000000..32a1e660323e --- /dev/null +++ b/packages/tradershub/src/flows/index.ts @@ -0,0 +1 @@ +export * from './RealAccountCreation'; diff --git a/packages/tradershub/src/hooks/useNewCRRealAccount.ts b/packages/tradershub/src/hooks/useNewCRRealAccount.ts index c7ff96b71ae8..bb65f25c716f 100644 --- a/packages/tradershub/src/hooks/useNewCRRealAccount.ts +++ b/packages/tradershub/src/hooks/useNewCRRealAccount.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect } from 'react'; -import { useSignupWizardContext } from '@/providers/SignupWizardProvider'; +import { useRealAccountCreationContext } from '@/providers/RealAccountCreationProvider'; import { useAuthorize, useCreateNewRealAccount, useSettings } from '@deriv/api'; import useSyncLocalStorageClientAccounts from './useSyncLocalStorageClientAccounts'; @@ -9,7 +9,7 @@ import useSyncLocalStorageClientAccounts from './useSyncLocalStorageClientAccoun * @returns {Object} Submit handler function, the new real CR account data and the status of the request. */ const useNewCRRealAccount = () => { - const { setIsWizardOpen, state, setIsSuccessModalOpen } = useSignupWizardContext(); + const { setIsWizardOpen, state, setIsSuccessModalOpen } = useRealAccountCreationContext(); const { data: newTradingAccountData, mutate: createAccount, status, ...rest } = useCreateNewRealAccount(); const { data: settingsData } = useSettings(); diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/AccountOpeningSuccessModal/AccountOpeningSuccessModal.tsx b/packages/tradershub/src/modals/AccountOpeningSuccessModal/AccountOpeningSuccessModal.tsx similarity index 91% rename from packages/tradershub/src/flows/RealAccountSIgnup/AccountOpeningSuccessModal/AccountOpeningSuccessModal.tsx rename to packages/tradershub/src/modals/AccountOpeningSuccessModal/AccountOpeningSuccessModal.tsx index e9562533c76a..559880905f8b 100644 --- a/packages/tradershub/src/flows/RealAccountSIgnup/AccountOpeningSuccessModal/AccountOpeningSuccessModal.tsx +++ b/packages/tradershub/src/modals/AccountOpeningSuccessModal/AccountOpeningSuccessModal.tsx @@ -4,11 +4,11 @@ import { useHistory } from 'react-router-dom'; import Checkmark from '@/assets/svgs/checkmark.svg'; import { ActionScreen, ButtonGroup, IconComponent } from '@/components'; import { CUSTOM_STYLES } from '@/helpers'; -import { useSignupWizardContext } from '@/providers/SignupWizardProvider'; +import { useRealAccountCreationContext } from '@/providers'; import { Button, Text, useDevice } from '@deriv-com/ui'; const SelectedCurrencyIcon = () => { - const { state } = useSignupWizardContext(); + const { state } = useRealAccountCreationContext(); return (
{ }; const AccountOpeningSuccessModal = () => { - const { isSuccessModalOpen, reset } = useSignupWizardContext(); + const { isSuccessModalOpen, reset } = useRealAccountCreationContext(); const { isDesktop } = useDevice(); - const { state } = useSignupWizardContext(); + const { state } = useRealAccountCreationContext(); const history = useHistory(); const handleNavigateToDeposit = () => { diff --git a/packages/tradershub/src/modals/AccountOpeningSuccessModal/index.ts b/packages/tradershub/src/modals/AccountOpeningSuccessModal/index.ts new file mode 100644 index 000000000000..43f6fa58415e --- /dev/null +++ b/packages/tradershub/src/modals/AccountOpeningSuccessModal/index.ts @@ -0,0 +1 @@ +export { default as AccountOpeningSuccessModal } from './AccountOpeningSuccessModal'; diff --git a/packages/tradershub/src/flows/RealAccountSIgnup/ExitConfirmationDialog/index.tsx b/packages/tradershub/src/modals/ExitConfirmationDialog/ExitConfirmationDialog.tsx similarity index 85% rename from packages/tradershub/src/flows/RealAccountSIgnup/ExitConfirmationDialog/index.tsx rename to packages/tradershub/src/modals/ExitConfirmationDialog/ExitConfirmationDialog.tsx index d356c8129d22..1d66dd3df80d 100644 --- a/packages/tradershub/src/flows/RealAccountSIgnup/ExitConfirmationDialog/index.tsx +++ b/packages/tradershub/src/modals/ExitConfirmationDialog/ExitConfirmationDialog.tsx @@ -1,11 +1,11 @@ import React from 'react'; import ReactModal from 'react-modal'; +import { CUSTOM_STYLES } from '@/helpers'; +import { useRealAccountCreationContext } from '@/providers'; import { Button, Text } from '@deriv-com/ui'; -import { CUSTOM_STYLES } from '../../../helpers/signupModalHelpers'; -import { useSignupWizardContext } from '../../../providers/SignupWizardProvider'; const ExitConfirmationDialog = ({ isOpen, onClose }: { isOpen: boolean; onClose: () => void }) => { - const { reset } = useSignupWizardContext(); + const { reset } = useRealAccountCreationContext(); const handleClose = () => { onClose(); diff --git a/packages/tradershub/src/modals/ExitConfirmationDialog/index.ts b/packages/tradershub/src/modals/ExitConfirmationDialog/index.ts new file mode 100644 index 000000000000..92da84656c18 --- /dev/null +++ b/packages/tradershub/src/modals/ExitConfirmationDialog/index.ts @@ -0,0 +1 @@ +export { default as ExitConfirmationDialog } from './ExitConfirmationDialog'; diff --git a/packages/tradershub/src/modals/index.ts b/packages/tradershub/src/modals/index.ts index 498310f7221d..756d5c240622 100644 --- a/packages/tradershub/src/modals/index.ts +++ b/packages/tradershub/src/modals/index.ts @@ -1 +1,3 @@ +export * from './AccountOpeningSuccessModal'; +export * from './ExitConfirmationDialog'; export * from './RegulationModal'; diff --git a/packages/tradershub/src/providers/SignupWizardProvider/SignupWizardContext.tsx b/packages/tradershub/src/providers/RealAccountCreationProvider/RealAccountCreationContext.tsx similarity index 69% rename from packages/tradershub/src/providers/SignupWizardProvider/SignupWizardContext.tsx rename to packages/tradershub/src/providers/RealAccountCreationProvider/RealAccountCreationContext.tsx index a9f118f0ef59..666c2c4a7e8c 100644 --- a/packages/tradershub/src/providers/SignupWizardProvider/SignupWizardContext.tsx +++ b/packages/tradershub/src/providers/RealAccountCreationProvider/RealAccountCreationContext.tsx @@ -1,6 +1,6 @@ import React, { createContext, useCallback, useContext, useMemo, useReducer, useState } from 'react'; import { useStep } from 'usehooks-ts'; -import { Helpers, TSignupWizardContext, TSignupWizardProvider } from './types'; +import { Helpers, TRealAccountCreationContext, TRealAccountCreationProvider } from './types'; import { valuesReducer } from './ValuesReducer'; export const ACTION_TYPES = { @@ -27,7 +27,7 @@ const initialHelpers: Helpers = { }) as React.Dispatch>, }; -export const SignupWizardContext = createContext({ +export const RealAccountCreationContext = createContext({ currentStep: 0, dispatch: /* noop */ () => { /* noop */ @@ -49,20 +49,22 @@ export const SignupWizardContext = createContext({ }, }); -export const useSignupWizardContext = () => { - const context = useContext(SignupWizardContext); +export const useRealAccountCreationContext = () => { + const context = useContext(RealAccountCreationContext); if (!context) - throw new Error('useSignupWizardContext() must be called within a component wrapped in SignupWizardProvider.'); + throw new Error( + 'useRealAccountCreationContext() must be called within a component wrapped in RealAccountCreationProvider.' + ); return context; }; /** - * @name SignupWizardProvider - * @description The SignupWizardProvider component is used to wrap the components that need access to the SignupWizardContext. + * @name RealAccountCreationProvider + * @description The RealAccountCreationProvider component is used to wrap the components that need access to the RealAccountCreationContext. * @param {React.ReactNode} children - The content to be wrapped. */ -export const SignupWizardProvider = ({ children }: TSignupWizardProvider) => { +export const RealAccountCreationProvider = ({ children }: TRealAccountCreationProvider) => { const [isWizardOpen, setIsWizardOpen] = useState(false); const [isSuccessModalOpen, setIsSuccessModalOpen] = useState(false); const [currentStep, helpers] = useStep(4); @@ -79,7 +81,7 @@ export const SignupWizardProvider = ({ children }: TSignupWizardProvider) => { helpers.setStep(1); }, [helpers]); - const contextState: TSignupWizardContext = useMemo( + const contextState: TRealAccountCreationContext = useMemo( () => ({ currentStep, dispatch, @@ -94,5 +96,5 @@ export const SignupWizardProvider = ({ children }: TSignupWizardProvider) => { [currentStep, helpers, isSuccessModalOpen, isWizardOpen, reset, state] ); - return {children}; + return {children}; }; diff --git a/packages/tradershub/src/providers/SignupWizardProvider/ValuesReducer.ts b/packages/tradershub/src/providers/RealAccountCreationProvider/ValuesReducer.ts similarity index 92% rename from packages/tradershub/src/providers/SignupWizardProvider/ValuesReducer.ts rename to packages/tradershub/src/providers/RealAccountCreationProvider/ValuesReducer.ts index 86c075f9a4bc..4da80af3e158 100644 --- a/packages/tradershub/src/providers/SignupWizardProvider/ValuesReducer.ts +++ b/packages/tradershub/src/providers/RealAccountCreationProvider/ValuesReducer.ts @@ -1,4 +1,4 @@ -import { ACTION_TYPES } from './SignupWizardContext'; +import { ACTION_TYPES } from './RealAccountCreationContext'; import { TActions, TState } from './types'; export function valuesReducer(state: TState, action: TActions) { diff --git a/packages/tradershub/src/providers/RealAccountCreationProvider/index.ts b/packages/tradershub/src/providers/RealAccountCreationProvider/index.ts new file mode 100644 index 000000000000..ab18f8c41767 --- /dev/null +++ b/packages/tradershub/src/providers/RealAccountCreationProvider/index.ts @@ -0,0 +1,2 @@ +export * from './RealAccountCreationContext'; +export * from './types'; diff --git a/packages/tradershub/src/providers/SignupWizardProvider/types.ts b/packages/tradershub/src/providers/RealAccountCreationProvider/types.ts similarity index 82% rename from packages/tradershub/src/providers/SignupWizardProvider/types.ts rename to packages/tradershub/src/providers/RealAccountCreationProvider/types.ts index 4ec6c3d14136..23e919d927b7 100644 --- a/packages/tradershub/src/providers/SignupWizardProvider/types.ts +++ b/packages/tradershub/src/providers/RealAccountCreationProvider/types.ts @@ -1,9 +1,9 @@ import { useStep } from 'usehooks-ts'; -import { ACTION_TYPES } from './SignupWizardContext'; +import { ACTION_TYPES } from './RealAccountCreationContext'; export type Helpers = ReturnType[1]; -export type TSignupWizardContext = { +export type TRealAccountCreationContext = { currentStep: number; dispatch: React.Dispatch; helpers: Helpers; @@ -19,6 +19,7 @@ export type TState = { accountOpeningReason?: string; currency?: string; dateOfBirth?: string; + detailsConfirmation?: boolean; firstLineAddress?: string; firstName?: string; lastName?: string; @@ -27,12 +28,13 @@ export type TState = { secondLineAddress?: string; stateProvince?: string; taxIdentificationNumber?: string; + taxInfoConfirmation?: boolean; taxResidence?: string; townCity?: string; zipCode?: string; }; -export type TSignupWizardProvider = { +export type TRealAccountCreationProvider = { children: React.ReactNode; }; diff --git a/packages/tradershub/src/providers/SignupWizardProvider/index.ts b/packages/tradershub/src/providers/SignupWizardProvider/index.ts deleted file mode 100644 index 042f41e79bca..000000000000 --- a/packages/tradershub/src/providers/SignupWizardProvider/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './SignupWizardContext'; -export * from './types'; diff --git a/packages/tradershub/src/providers/index.ts b/packages/tradershub/src/providers/index.ts new file mode 100644 index 000000000000..47f4bebc895a --- /dev/null +++ b/packages/tradershub/src/providers/index.ts @@ -0,0 +1 @@ +export * from './RealAccountCreationProvider'; diff --git a/packages/tradershub/src/screens/Address/Address.tsx b/packages/tradershub/src/screens/Address/Address.tsx index 5d821295ceea..d5c375ef3f24 100644 --- a/packages/tradershub/src/screens/Address/Address.tsx +++ b/packages/tradershub/src/screens/Address/Address.tsx @@ -1,13 +1,15 @@ import React from 'react'; import { Form, Formik, FormikValues } from 'formik'; +import { WizardScreenActions, WizardScreenWrapper } from '@/flows'; import { ScrollToFieldError } from '@/helpers'; import { address } from '@/utils'; import { useSettings, useStatesList } from '@deriv/api'; import { LabelPairedChevronDownMdRegularIcon } from '@deriv/quill-icons'; -import { Dropdown, Input, Text } from '@deriv-com/ui'; -import Actions from '../../flows/RealAccountSIgnup/SignupWizard/Actions'; -import WizardScreenWrapper from '../../flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper'; -import { ACTION_TYPES, useSignupWizardContext } from '../../providers/SignupWizardProvider/SignupWizardContext'; +import { Dropdown, Input, Text, useDevice } from '@deriv-com/ui'; +import { + ACTION_TYPES, + useRealAccountCreationContext, +} from '../../providers/RealAccountCreationProvider/RealAccountCreationContext'; /** * @name Address @@ -19,7 +21,8 @@ const Address = () => { const { data: getSettings } = useSettings(); const country = getSettings?.country_code ?? ''; const { data: statesList } = useStatesList(country); - const { dispatch, helpers, state } = useSignupWizardContext(); + const { dispatch, helpers, state } = useRealAccountCreationContext(); + const { isDesktop } = useDevice(); const handleSubmit = (values: FormikValues) => { dispatch({ @@ -70,6 +73,7 @@ const Address = () => { { /> { {
{ />
- + )} diff --git a/packages/tradershub/src/screens/CurrencySelector/CurrencySelector.tsx b/packages/tradershub/src/screens/CurrencySelector/CurrencySelector.tsx index aadbf700d9a7..d41e19d7cccc 100644 --- a/packages/tradershub/src/screens/CurrencySelector/CurrencySelector.tsx +++ b/packages/tradershub/src/screens/CurrencySelector/CurrencySelector.tsx @@ -1,10 +1,9 @@ import React from 'react'; import { Form, Formik, FormikValues } from 'formik'; +import { WizardScreenActions, WizardScreenWrapper } from '@/flows'; +import { CURRENCY_TYPES } from '@/helpers'; +import { ACTION_TYPES, useRealAccountCreationContext } from '@/providers'; import { Divider } from '@deriv-com/ui'; -import Actions from '../../flows/RealAccountSIgnup/SignupWizard/Actions'; -import WizardScreenWrapper from '../../flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper'; -import { CURRENCY_TYPES } from '../../helpers/currencyConfig'; -import { ACTION_TYPES, useSignupWizardContext } from '../../providers/SignupWizardProvider/SignupWizardContext'; import Currencies from './Currencies'; /** @@ -13,7 +12,7 @@ import Currencies from './Currencies'; * @returns {React.ReactNode} */ const CurrencySelector = () => { - const { dispatch, helpers, state } = useSignupWizardContext(); + const { dispatch, helpers, state } = useRealAccountCreationContext(); const handleSubmit = (values: FormikValues) => { dispatch({ payload: { currency: values.currency }, type: ACTION_TYPES.SET_CURRENCY }); @@ -34,7 +33,7 @@ const CurrencySelector = () => { - + )} diff --git a/packages/tradershub/src/screens/PersonalDetails/PersonalDetails.tsx b/packages/tradershub/src/screens/PersonalDetails/PersonalDetails.tsx index af16f175b172..c389b83a5be0 100644 --- a/packages/tradershub/src/screens/PersonalDetails/PersonalDetails.tsx +++ b/packages/tradershub/src/screens/PersonalDetails/PersonalDetails.tsx @@ -1,11 +1,10 @@ import React from 'react'; import { Form, Formik, FormikValues } from 'formik'; +import { WizardScreenActions, WizardScreenWrapper } from '@/flows'; import { ScrollToFieldError } from '@/helpers'; +import { ACTION_TYPES, useRealAccountCreationContext } from '@/providers'; import { personalDetails } from '@/utils'; import { Text } from '@deriv-com/ui'; -import Actions from '../../flows/RealAccountSIgnup/SignupWizard/Actions'; -import WizardScreenWrapper from '../../flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper'; -import { ACTION_TYPES, useSignupWizardContext } from '../../providers/SignupWizardProvider/SignupWizardContext'; import AdditionalInformation from './Sections/AdditionalInformation'; import Details from './Sections/Details'; @@ -16,7 +15,7 @@ import Details from './Sections/Details'; * @returns {React.ReactNode} */ const PersonalDetails = () => { - const { dispatch, helpers, state } = useSignupWizardContext(); + const { dispatch, helpers, state } = useRealAccountCreationContext(); const handleSubmit = (values: FormikValues) => { dispatch({ payload: { ...values }, type: ACTION_TYPES.SET_PERSONAL_DETAILS }); @@ -27,13 +26,13 @@ const PersonalDetails = () => { firstName: state.firstName ?? '', lastName: state.lastName ?? '', dateOfBirth: state.dateOfBirth ?? '', - confirmation: false, + detailsConfirmation: state.detailsConfirmation ?? false, phoneNumber: state.phoneNumber ?? '', placeOfBirth: state.placeOfBirth ?? '', taxResidence: state.taxResidence ?? '', taxIdentificationNumber: state.taxIdentificationNumber ?? '', accountOpeningReason: state.accountOpeningReason ?? '', - taxInfoConfirmation: false, + taxInfoConfirmation: state.taxInfoConfirmation ?? false, }; return ( @@ -56,7 +55,7 @@ const PersonalDetails = () => {
- + )} diff --git a/packages/tradershub/src/screens/PersonalDetails/Sections/AdditionalInformation.tsx b/packages/tradershub/src/screens/PersonalDetails/Sections/AdditionalInformation.tsx index 128767bbe15e..a99cb5c9e6de 100644 --- a/packages/tradershub/src/screens/PersonalDetails/Sections/AdditionalInformation.tsx +++ b/packages/tradershub/src/screens/PersonalDetails/Sections/AdditionalInformation.tsx @@ -88,7 +88,7 @@ const AdditionalInformation = () => { setFieldValue('taxResidence', selectedItem); }} value={values.taxResidence} - variant='comboBox' + variant='prompt' />
diff --git a/packages/tradershub/src/screens/PersonalDetails/Sections/Details.tsx b/packages/tradershub/src/screens/PersonalDetails/Sections/Details.tsx index 018bfdc8ea5d..9b522801208d 100644 --- a/packages/tradershub/src/screens/PersonalDetails/Sections/Details.tsx +++ b/packages/tradershub/src/screens/PersonalDetails/Sections/Details.tsx @@ -7,8 +7,8 @@ const ExampleImage = lazy(() => import('@/assets/svgs/personal-details-example.s const Details = () => { const { errors, handleBlur, handleChange, touched, values } = useFormikContext<{ - confirmation: boolean; dateOfBirth: string; + detailsConfirmation: boolean; firstName: string; lastName: string; }>(); @@ -21,7 +21,7 @@ const Details = () => {
-
+
To avoid delays, enter your name and{' '} @@ -33,7 +33,7 @@ const Details = () => {
{ /> { {/** Add date picker when available from deriv/ui */} { const { errors, values } = useFormikContext<{ - confirmation: boolean; dateOfBirth: string; + detailsConfirmation: boolean; firstName: string; lastName: string; }>(); @@ -20,12 +20,12 @@ const DetailsConfirmation = () => { ); return ( - + {({ field, meta }: FieldProps) => ( diff --git a/packages/tradershub/src/screens/TermsOfUse/TermsOfUse.tsx b/packages/tradershub/src/screens/TermsOfUse/TermsOfUse.tsx index 1bccef875a5d..91a03d4e78cf 100644 --- a/packages/tradershub/src/screens/TermsOfUse/TermsOfUse.tsx +++ b/packages/tradershub/src/screens/TermsOfUse/TermsOfUse.tsx @@ -1,17 +1,13 @@ import React from 'react'; import { Form, Formik, FormikHelpers, FormikValues } from 'formik'; +import { WizardScreenActions, WizardScreenWrapper } from '@/flows'; import { ScrollToFieldError } from '@/helpers'; import { useNewCRRealAccount } from '@/hooks'; import { termsOfUse } from '@/utils'; -import { Text } from '@deriv-com/ui'; -import Actions from '../../flows/RealAccountSIgnup/SignupWizard/Actions'; -import WizardScreenWrapper from '../../flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper'; +import { Divider, Text } from '@deriv-com/ui'; import FatcaDeclaration from './TermsOfUseSections/FatcaDeclaration'; import PEPs from './TermsOfUseSections/PEPs'; -// Replace divider from deriv-com/ui once it is implemented -const Divider = () =>
; - /** * @name TermsOfUse * @description The TermsOfUse component is used to display the terms and conditions before creating an account. @@ -66,7 +62,7 @@ const TermsOfUse = () => {
-