Skip to content

Commit

Permalink
fix: update payload property (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
mubbsharanwar authored Jul 4, 2024
1 parent 5c6b646 commit 75e0195
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/forms/registration-popup/data/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const registerInitialState = {
validationState: DEFAULT_STATE,
registrationError: {},
registrationResult: {},
registrationFields: { marketingEmailOptIn: true },
registrationFields: { marketingEmailsOptIn: true },
userPipelineDataLoaded: false,
validationApiRateLimited: false,
validations: null,
Expand Down
20 changes: 10 additions & 10 deletions src/forms/registration-popup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const RegistrationForm = () => {
const [formStartTime, setFormStartTime] = useState(null);

const [formFields, setFormFields] = useState({
name: '', email: '', password: '', marketingEmailOptIn: true,
name: '', email: '', password: '', marketingEmailsOptIn: true,
});
const [errors, setErrors] = useState({});
const [errorCode, setErrorCode] = useState({ type: '', count: 0 });
Expand Down Expand Up @@ -103,7 +103,7 @@ const RegistrationForm = () => {
if (!userPipelineDataLoaded && thirdPartyAuthApiStatus === COMPLETE_STATE) {
if (thirdPartyAuthErrorMessage) {
setErrorCode(prevState => ({ type: TPA_AUTHENTICATION_FAILURE, count: prevState.count + 1 }));
localStorage.removeItem('marketingEmailOptIn');
localStorage.removeItem('marketingEmailsOptIn');
localStorage.removeItem('ssoPipelineRedirectionDone');
}
if (pipelineUserDetails && Object.keys(pipelineUserDetails).length !== 0) {
Expand Down Expand Up @@ -149,8 +149,8 @@ const RegistrationForm = () => {
if (registrationError[name]) {
dispatch(clearRegistrationBackendError(name));
}
// seting marketingEmailOptIn state for SSO authentication flow for register API call
if (name === 'marketingEmailOptIn') {
// seting marketingEmailsOptIn state for SSO authentication flow for register API call
if (name === 'marketingEmailsOptIn') {
dispatch(setRegistrationFields({ [name]: value }));
}
setErrors(prevErrors => ({ ...prevErrors, [name]: '' }));
Expand All @@ -163,14 +163,14 @@ const RegistrationForm = () => {
&& localStorage.getItem('ssoPipelineRedirectionDone')
) {
localStorage.removeItem('ssoPipelineRedirectionDone');
localStorage.removeItem('marketingEmailOptIn');
localStorage.removeItem('marketingEmailsOptIn');
}
}, [currentProvider, thirdPartyAuthApiStatus]);

useEffect(() => {
if (registrationResult.success) {
// clear local storage
localStorage.removeItem('marketingEmailOptIn');
localStorage.removeItem('marketingEmailsOptIn');
localStorage.removeItem('ssoPipelineRedirectionDone');

// This event is used by GTM
Expand Down Expand Up @@ -220,8 +220,8 @@ const RegistrationForm = () => {
payload.social_auth_provider = currentProvider;

if (!isLoginSSOIntent) {
delete payload.marketingEmailOptIn;
payload.marketingEmailOptIn = localStorage.getItem('marketingEmailOptIn');
delete payload.marketingEmailsOptIn;
payload.marketingEmailsOptIn = localStorage.getItem('marketingEmailsOptIn');
}
}

Expand Down Expand Up @@ -343,8 +343,8 @@ const RegistrationForm = () => {
/>
)}
<MarketingEmailOptInCheckbox
name="marketingEmailOptIn"
value={formFields.marketingEmailOptIn}
name="marketingEmailsOptIn"
value={formFields.marketingEmailsOptIn}
handleChange={handleOnChange}
/>
<div className="d-flex flex-column my-4">
Expand Down
4 changes: 2 additions & 2 deletions src/forms/registration-popup/tests/RegistrationPopup.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('RegistrationForm Test', () => {
email: '[email protected]',
name: 'test',
password: 'test-password12',
marketing_email_opt_in: true,
marketing_emails_opt_in: true,
honor_code: true,
terms_of_service: true,
total_registration_time: 0,
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('RegistrationForm Test', () => {
email: '[email protected]',
name: 'test',
password: 'test-password12',
marketing_email_opt_in: true,
marketing_emails_opt_in: true,
honor_code: true,
terms_of_service: true,
country: 'US',
Expand Down

0 comments on commit 75e0195

Please sign in to comment.