Resolve "Users "Setup for company" field is overridden to true for existing users during subscription purchase"
What does this MR do?
When in the subscription flow (http://localhost:3000/-/subscriptions/new
), the value for setup_for_company
would automatically be updated to TRUE
for existing users, while it should not do so if the original value was FALSE
.
The idea behind the original code, was that we wanted to show the setup_for_company
experience to existing users if they had not answered that question (a value of NULL
) when signing up.
When showing the subscription page, the value for setup_for_company
used to be set as follows:
- When set to
TRUE
in the database, we used to set thesetupForCompany
data attribute totrue
on the element that sets the state for the Vue component, otherwise we setsetupForCompany
tofalse
- When initializing the state of the Vue component, we used to have the logic:
isSetupForCompany = parseBoolean(setupForCompany) || !isNewUser
The above means that when the setup_for_company
value in the DB is set to NULL
or FALSE
, we look to the value of isNewUser
to set it in the Vue component which then, without user interaction, erroneously updates the value of setup_for_company
in the database to TRUE
if it is viewed by an existing user when submitting the form in the component.
This MR fixes this problem by passing the original value and set it to the value of !isNewUser
only if it has not been set.
Issue: #336975 (closed)