Skip to content

Commit

Permalink
refactor: folder structure (binary-com#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
heorhi-deriv committed Nov 30, 2022
1 parent 3cdd1e6 commit 52dfdd7
Show file tree
Hide file tree
Showing 22 changed files with 34 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import PaymentAgentReceipt from '../payment-agent-receipt';
import PaymentAgentSearchBox from '../payment-agent-search-box';
import PaymentAgentUnlistedWithdrawForm from '../payment-agent-unlisted-withdraw-form';
import PaymentAgentWithdrawConfirm from '../payment-agent-withdraw-confirm';
import { SignupSideNote as PaymentAgentSignupSideNote } from '../payment-agent-signup';
import { PaymentAgentSignupSideNote } from '../payment-agent-signup/components/signup-side-note';

const PaymentAgentSearchWarning = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import VerificationEmail from 'Components/verification-email';
import PaymentAgentContainer from '../payment-agent-container';
import PaymentAgentWithdrawalLocked from '../payment-agent-withdrawal-locked';
import PaymentAgentDisclaimer from '../payment-agent-disclaimer';
import { SignupSideNote as PaymentAgentSignupSideNote } from '../payment-agent-signup';
import { PaymentAgentSignupSideNote } from '../payment-agent-signup/components/signup-side-note';
import SideNote from 'Components/side-note';
import './payment-agent-list.scss';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import SignupSideNote from './signup-side-note';

export { SignupSideNote as PaymentAgentSignupSideNote };
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { observer } from 'mobx-react-lite';
import { Button, Icon, Text } from '@deriv/components';
import getNote from './signup-side-note-provider';
import { useHistory } from 'react-router';
import { useStore } from '../../../../hooks';
import SignupWizard from '../signup-wizard';
import { useStore } from '../../../../../hooks';
import SignupWizard from '../../signup-wizard';
import './signup-side-note.scss';

export type TNote = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import SignupSideNote from './signup-side-note';
import SignupWizard from './signup-wizard';

export { SignupSideNote };
export { SignupWizard };

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { createPortal } from 'react-dom';
import { Text } from '@deriv/components';
import { Localize, localize } from '@deriv/translations';
import { Wizard } from '@deriv/ui';
import CancelWizardDialog from '../cancel-wizard-dialog';
import SelectCountryStep from '../signup-wizard-steps/select-country-step';
import SelfieStep from '../signup-wizard-steps/selfie-step/selfie-step';
import { usePaymentAgentSignupReducer } from './steps-reducer';
import CancelWizardDialog from './components/cancel-wizard-dialog';
import CountryOfIssue from './steps/country-of-issue';
import Selfie from './steps/selfie';
import { usePaymentAgentSignupReducer } from './steps/steps-reducer';
import './signup-wizard.scss';

type TSignupWizardProps = {
Expand All @@ -33,10 +33,6 @@ const SignupWizard = ({ closeWizard }: TSignupWizardProps) => {
closeWizard();
};

const onSelfieSelect: React.ComponentProps<typeof SelfieStep>['onSelect'] = selfie => {
setSelfie({ selfie_with_id: selfie });
};

const onChangeStep = (_current_step: number, _current_step_key?: string) => {
setCurrentStepKey(_current_step_key);
};
Expand Down Expand Up @@ -69,7 +65,7 @@ const SignupWizard = ({ closeWizard }: TSignupWizardProps) => {
is_submit_disabled={!steps_state.selected_country?.value}
is_fullwidth
>
<SelectCountryStep
<CountryOfIssue
selected_country={steps_state.selected_country}
onSelect={setSelectedCountry}
/>
Expand All @@ -79,7 +75,7 @@ const SignupWizard = ({ closeWizard }: TSignupWizardProps) => {
is_submit_disabled={!steps_state.selfie?.selfie_with_id}
is_fullwidth
>
<SelfieStep selfie={steps_state.selfie} onSelect={onSelfieSelect} />
<Selfie selfie={steps_state.selfie} onSelect={setSelfie} />
</Wizard.Step>
<Wizard.Step step_key='complete_step' title='Step 3' is_fullwidth>
<>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from 'react';
import { Text, DesktopWrapper } from '@deriv/components';
import { ResidenceList } from '@deriv/api-types';
import { Localize } from '@deriv/translations';
import CountrySelector from '../../country-selector';
import CountrySelector from './country-selector';

type TCountrySelectorProps = {
onSelect: React.ComponentProps<typeof CountrySelector>['onSelect'];
selected_country?: ResidenceList[number];
};

const SelectCountryStep = ({ onSelect, selected_country }: TCountrySelectorProps) => {
const CountryOfIssue = ({ onSelect, selected_country }: TCountrySelectorProps) => {
return (
<>
<DesktopWrapper>
Expand All @@ -32,4 +32,4 @@ const SelectCountryStep = ({ onSelect, selected_country }: TCountrySelectorProps
);
};

export default React.memo(SelectCountryStep);
export default React.memo(CountryOfIssue);
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ResidenceList } from '@deriv/api-types';
import { Formik, Field, FieldProps } from 'formik';
import { Autocomplete, DesktopWrapper, MobileWrapper, SelectNative } from '@deriv/components';
import { localize } from '@deriv/translations';
import { useStore } from '../../../../hooks';
import { useStore } from '../../../../../../hooks';
import { TReactChangeEvent } from 'Types';
import { observer } from 'mobx-react';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import CountryOfIssue from './country-of-issue';

export default CountryOfIssue;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Selfie from './selfie';

export default Selfie;
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ type TSelfieStep = {
onSelect: (value: TSelfie) => void;
};

const SelfieStep = ({ selfie, onSelect }: TSelfieStep) => {
const Selfie = ({ selfie, onSelect }: TSelfieStep) => {
//TODO: change the description for the selfie depending on the step number
return <SelfieUpload initial_values={selfie} is_pa_signup onFileDrop={onSelect} />;
};

export default React.memo(SelfieStep);
export default React.memo(Selfie);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useReducer } from 'react';
import { ResidenceList } from '@deriv/api-types';
import { TSelfie } from '../signup-wizard-steps/selfie-step/selfie-step';
import { TSelfie } from './selfie/selfie';

type TStepsState = {
selfie: {
Expand All @@ -15,7 +15,7 @@ const ACTION_TYPES = {
} as const;

// Action creators
const setSelfieAC = (value: { selfie_with_id: TSelfie }) => {
const setSelfieAC = (value: TSelfie) => {
return {
type: ACTION_TYPES.SET_SELFIE,
value,
Expand All @@ -30,13 +30,13 @@ const setSelectedCountryAC = (value?: ResidenceList[number]) => {
};

// Initial state
const initial_state = { selfie: null, is_selfie_step_enabled: false, selected_country: {} };
const initial_state = { selected_country: {}, selfie: null };

// Reducer
const stepReducer = (state: TStepsState, action: TActionsTypes): TStepsState => {
const stepsReducer = (state: TStepsState, action: TActionsTypes): TStepsState => {
switch (action.type) {
case ACTION_TYPES.SET_SELFIE:
return { ...state, selfie: action.value };
return { ...state, selfie: { selfie_with_id: action.value } };
case ACTION_TYPES.SET_SELECTED_COUNTRY:
return { ...state, selected_country: action.value };
default:
Expand All @@ -45,9 +45,9 @@ const stepReducer = (state: TStepsState, action: TActionsTypes): TStepsState =>
};

export const usePaymentAgentSignupReducer = () => {
const [steps_state, dispatch] = useReducer(stepReducer, initial_state);
const [steps_state, dispatch] = useReducer(stepsReducer, initial_state);

const setSelfie = useCallback((value: { selfie_with_id: TSelfie }) => dispatch(setSelfieAC(value)), []);
const setSelfie = useCallback((value: TSelfie) => dispatch(setSelfieAC(value)), []);
const setSelectedCountry = useCallback(
(value?: ResidenceList[number]) => dispatch(setSelectedCountryAC(value)),
[]
Expand Down

0 comments on commit 52dfdd7

Please sign in to comment.