Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect user to POI when user accepts risk #6

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const shouldShowPersonalAndAddressDetailsAndCurrency = ({ real_account_signup_ta

export const getItems = props => {
return [
// ...(shouldShowPersonalAndAddressDetailsAndCurrency(props)
// ? [currencySelectorConfig(props, CurrencySelector)]
// : []),
// ...(shouldShowPersonalAndAddressDetailsAndCurrency(props)
// ? [personalDetailsConfig(props, PersonalDetails)]
// : []),
// ...(shouldShowPersonalAndAddressDetailsAndCurrency(props) ? [addressDetailsConfig(props, AddressDetails)] : []),
...(shouldShowPersonalAndAddressDetailsAndCurrency(props)
? [currencySelectorConfig(props, CurrencySelector)]
: []),
...(shouldShowPersonalAndAddressDetailsAndCurrency(props)
? [personalDetailsConfig(props, PersonalDetails)]
: []),
...(shouldShowPersonalAndAddressDetailsAndCurrency(props) ? [addressDetailsConfig(props, AddressDetails)] : []),
...(shouldShowTradingAssessment(props) ? [tradingAssessmentConfig(props, TradingAssessmentNewUser)] : []),
termsOfUseConfig(props, TermsOfUse),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const AccountWizard = props => {
const [form_error, setFormError] = React.useState('');
const [previous_data, setPreviousData] = React.useState([]);
const [state_items, setStateItems] = React.useState([]);
const [should_accept_financial_risk, setShouldAccesptFinancialRisk] = React.useState(false); // eslint-disable-line no-unused-vars
const [should_accept_financial_risk, setShouldAcceptFinancialRisk] = React.useState(false); // eslint-disable-line no-unused-vars

React.useEffect(() => {
props.fetchStatesList();
Expand Down Expand Up @@ -196,7 +196,6 @@ const AccountWizard = props => {
...payload,
};
}
console.log('Get clone: ', clone);

return props.realAccountSignup(clone);
};
Expand Down Expand Up @@ -238,37 +237,36 @@ const AccountWizard = props => {

const createRealAccount = (payload = undefined) => {
props.setLoading(true);
let form_data = { ...form_values() };
const form_data = { ...form_values() };
submitForm(payload)
.then(response => {
// TODO: Code for Success response
console.log('Response: ', response); // eslint-disable-line no-console
props.setIsRiskWarningVisible(false);
props.setShouldShowVerifiedAccount(true);
// props.setIsRiskWarningVisible(false);
// if (props.real_account_signup_target === 'maltainvest') {
// props.onFinishSuccess(response.new_account_maltainvest.currency.toLowerCase());
// } else if (props.real_account_signup_target === 'samoa') {
// props.onOpenWelcomeModal(response.new_account_samoa.currency.toLowerCase());
// } else {
// props.onFinishSuccess(response.new_account_real.currency.toLowerCase());
// }
if (props.real_account_signup_target === 'maltainvest') {
props.onFinishSuccess(response.new_account_maltainvest.currency.toLowerCase());
} else if (props.real_account_signup_target === 'samoa') {
props.onOpenWelcomeModal(response.new_account_samoa.currency.toLowerCase());
} else {
props.onFinishSuccess(response.new_account_real.currency.toLowerCase());
}
})
.catch(error => {
// TODO: Code for Error response
console.log('Check data: ', form_data);
console.log('Error: ', error); // eslint-disable-line no-console
// if (error.code === 'show risk disclaimer') {
// props.setIsRiskWarningVisible(true);
// setShouldAcceptFinancialRisk(true);
// } else {
// props.onError(error, state_items);
// }
if (error.code === 'AppropriatenessTestFailed') {
if (error.code === 'show risk disclaimer') {
props.setIsRiskWarningVisible(true);
setShouldAcceptFinancialRisk(true);
} else if (error.code === 'AppropriatenessTestFailed') {
if (form_data?.risk_tolerance === 'No') {
props.setShouldShowRiskToleranceWarningModal(true);
} else {
props.setShouldShowAppropriatenessTestWarningModal(true);
}
} else {
props.onError(error, state_items);
}
})
.finally(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const RealAccountSignup = ({
setShouldShowRiskToleranceWarningModal,
should_show_appropriateness_test_warning_modal,
setShouldShowAppropriatenessTestWarningModal,
setRealAccountSignupData,
should_show_cooldown_warning_modal,
setShouldShowCooldownWarningModal,
set_should_show_verified_account,
Expand Down Expand Up @@ -348,13 +347,6 @@ const RealAccountSignup = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [is_from_restricted_country, is_real_acc_signup_on]);

//Reset Form data
React.useEffect(() => {
console.log('Comp re-rendered');
setRiskWarningTitle(localize('Risk Tolerance Warning'));
return () => setRealAccountSignupData(null);
}, []);

const closeModal = e => {
replaceCashierMenuOnclick();
// Do not close modal on external link and popover click event
Expand Down Expand Up @@ -429,19 +421,19 @@ const RealAccountSignup = ({

const handleOnAccept = async () => {
try {
console.log('handleOnAccept: ', { ...real_account_form_data });
const response = await realAccountSignup({ ...real_account_form_data, accept_risk: 1 });
setShouldShowVerifiedAccount(true);
setShouldShowAppropriatenessTestWarningModal(false);
// TODO: Show Welcome Modal
} catch (sign_up_error) {
// TODO: Handle Error case
setShouldShowVerifiedAccount(true);
setShouldShowAppropriatenessTestWarningModal(false);
}
};

const handleOnDecline = async () => {
try {
console.log('HandleOnDecline: ', { ...real_account_form_data });
const response = await realAccountSignup({ ...real_account_form_data, accept_risk: 0 });
// TODO: Show CoolDown Modal
} catch (sign_up_error) {
Expand Down Expand Up @@ -483,7 +475,7 @@ const RealAccountSignup = ({
return (
<VerifiedAccountModal
onSubmit={() => {
/*TODO: Redirect to POI */
history.push(routes.proof_of_identity);
}}
onCancel={setShouldShowVerifiedAccount}
fetchFinancialAssessment={fetchFinancialAssessment}
Expand Down Expand Up @@ -612,7 +604,6 @@ export default connect(({ ui, client, common, modules }) => ({
setShouldShowRiskToleranceWarningModal: ui.setShouldShowRiskToleranceWarningModal,
should_show_appropriateness_test_warning_modal: ui.should_show_appropriateness_test_warning_modal,
setShouldShowAppropriatenessTestWarningModal: ui.setShouldShowAppropriatenessTestWarningModal,
setRealAccountSignupData: ui.setRealAccountSignupData,
should_show_cooldown_warning_modal: ui.should_show_cooldown_warning_modal,
setShouldShowCooldownWarningModal: ui.setShouldShowCooldownWarningModal,
set_should_show_verified_account: ui.set_should_show_verified_account,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ export default class ClientStore extends BaseStore {
// : {}),
// });
// }

const response = {
error: {
code: 'AppropriatenessTestFailed',
Expand All @@ -1091,6 +1092,7 @@ export default class ClientStore extends BaseStore {
},
};
return Promise.reject(response.error);

// return Promise.resolve('Pass');
}

Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/Stores/ui-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export default class UIStore extends BaseStore {
@observable should_show_appropriateness_test_warning_modal = false;
@observable should_show_cooldown_warning_modal = false;
@observable set_should_show_verified_account = false;
@observable real_account_signup_data = {};

getDurationFromUnit = unit => this[`duration_${unit}`];

Expand Down Expand Up @@ -423,11 +422,6 @@ export default class UIStore extends BaseStore {
this.set_should_show_verified_account = value;
}

@action.bound
setRealAccountSignupData(form_data) {
this.real_account_signup_data = form_data;
}

@action.bound
resetRealAccountSignupTarget() {
this.deposit_real_account_signup_target = this.real_account_signup_target;
Expand Down