Hi, I'm new to GitHub so not even sure if my query should be going here. I had a question with regards to radio buttons. I currently have two radio buttons in my application, one of which contains a dropdown and the other contains three input fields (a form). switching between these two radio buttons will update values in the store. However when switching to the second radio button after already switching back and fro from the first radio button, the store does not update with whatever the user has input in to the fields. How do I go about changing this? If I want to see the store update with the input field data, what do I need to add?
Below is the code for when the details are changed in the input fields:
detailsChanged = (event, value) => {
const { dispatch, paymentDetail, sortCode } = this.props;
const account = paymentDetail.getIn(['repayment', 'repayment']);
const accountClone = Object.assign({}, account);
accountClone[event.target.name] = value;
const bankNameDetailsObj = sortCode.get('repayment');
let bankNameDetails;
if (bankNameDetailsObj !== undefined) {
bankNameDetails = bankNameDetailsObj.value;
bankNameDetails = bankNameDetails.data;
}
if (event.target.name === 'sortCode') {
if (bankNameDetails.data !== undefined && bankNameDetails.data.bankTitle !== undefined) {
accountClone.bankName = bankNameDetails.data.bankTitle;
}
}
dispatch(setPaymentDetail(
'repayment',
{
value: accountClone,
name: 'repayment',
}),
);
};
this code is for when the user updates which radio button they want to select:
selectRepaymentType = (event) => {
const { dispatch, accountSelection } = this.props;
if (event === 'sameAccount') {
dispatch(deleteSortCode('repayment', null));
const business = accountSelection.getIn(['selectedAccount']);
const accountNumber = business.value.existingCurrentAccount ? business.value.accounts[0].accountNumber : '';
const account = this.getAccountByAccountNumber(accountNumber);
dispatch(setPaymentDetail(
'repayment',
{
value: account,
name: 'repayment',
}),
);
}
dispatch(setPaymentDetail(
'repayment',
{
value: event,
name: 'repaymentMethod',
}),
);
};
Please let me know if you need more information.