Skip to content

Commit

Permalink
Feat new flow mf account (#24)
Browse files Browse the repository at this point in the history
* fix: resolved issues with index

* ref: refactored trade assessment code

* fix: added unique key

* fix: refactored response pick
  • Loading branch information
likhith-deriv authored Aug 24, 2022
1 parent 76e151c commit fabc9f6
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ import { connect } from 'Stores/connect';
import { useHistory, withRouter } from 'react-router';
import { Formik, Form } from 'formik';

const populateData = form_data => {
return {
risk_tolerance: form_data.risk_tolerance,
source_of_experience: form_data.source_of_experience,
cfd_experience: form_data.cfd_experience,
cfd_frequency: form_data.cfd_frequency,
trading_experience_financial_instruments: form_data.trading_experience_financial_instruments,
trading_frequency_financial_instruments: form_data.trading_frequency_financial_instruments,
cfd_trading_definition: form_data.cfd_trading_definition,
leverage_impact_trading: form_data.leverage_impact_trading,
leverage_trading_high_risk_stop_loss: form_data.leverage_trading_high_risk_stop_loss,
required_initial_margin: form_data.required_initial_margin,
};
};

const TradingAssessment = ({
is_virtual,
setFinancialAndTradingAssessment,
Expand All @@ -28,7 +43,8 @@ const TradingAssessment = ({
history.push(routes.personal_details);
} else {
WS.authorized.storage.getFinancialAssessment().then(data => {
setInitialFormValues(data.get_financial_assessment);
// set initial form data
setInitialFormValues(populateData(data.get_financial_assessment));
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -92,7 +108,7 @@ const TradingAssessment = ({

return (
<Formik
initialValues={initial_form_values ?? form_data}
initialValues={initial_form_values}
onSubmit={values => {
setFormData(values);
handleSubmit(values);
Expand Down

0 comments on commit fabc9f6

Please sign in to comment.