diff --git a/components/forms/newsletter/component.jsx b/components/forms/newsletter/component.jsx
index 6820bb5000..ee25b906e2 100644
--- a/components/forms/newsletter/component.jsx
+++ b/components/forms/newsletter/component.jsx
@@ -11,6 +11,7 @@ import Select from 'components/forms/components/select';
import Submit from 'components/forms/components/submit';
import SuccessMessage from 'components/success-message';
import Error from 'components/forms/components/error';
+import { preferredLanguages } from 'components/forms/profile/config';
import { email as validateEmail } from 'components/forms/validations';
import Checkbox from '../components/checkbox/component';
@@ -29,14 +30,6 @@ const sectors = [
'Other',
];
-const preferredLanguages = [
- { label: 'English', value: 'en' },
- { label: 'Français', value: 'fr' },
- { label: 'Español', value: 'es' },
- { label: 'Português', value: 'pt' },
- { label: 'Bahasa Indonesia', value: 'id' },
-];
-
const interests = [
'Innovations in Monitoring',
'Fires',
diff --git a/components/forms/profile/actions.js b/components/forms/profile/actions.js
index 34893a5fb1..02da3ef394 100644
--- a/components/forms/profile/actions.js
+++ b/components/forms/profile/actions.js
@@ -1,9 +1,19 @@
import { createThunkAction } from 'redux/actions';
+import axios from 'axios';
import { FORM_ERROR } from 'final-form';
import { updateProfile, createProfile } from 'services/user';
import { setMyGFW } from 'providers/mygfw-provider/actions';
+const saveOrttoProfile = async (payload) => {
+ try {
+ await axios.post('/api/ortto', payload);
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.error(error);
+ }
+};
+
export const saveProfile = createThunkAction(
'saveProfile',
(fields) => (dispatch) => {
@@ -17,6 +27,7 @@ export const saveProfile = createThunkAction(
firstName,
lastName,
email,
+ old_email,
country,
city,
state,
@@ -29,6 +40,8 @@ export const saveProfile = createThunkAction(
jobTitle,
signUpForTesting,
isUserProfileFilled,
+ receive_updates = false,
+ preferred_language = 'en',
} = fields;
const postData = {
@@ -47,6 +60,8 @@ export const saveProfile = createThunkAction(
aoiCountry,
jobTitle,
areaOrRegionOfInterest,
+ receive_updates,
+ preferred_language,
subsector:
subsector && subsector.includes('Other')
? `Other: ${subsector_otherInput || ''}`
@@ -72,8 +87,27 @@ export const saveProfile = createThunkAction(
const updateOrCreate = isUserProfileFilled ? updateProfile : createProfile;
return updateOrCreate(id, postData)
- .then((response) => {
+ .then(async (response) => {
if (response.data && response.data.data) {
+ saveOrttoProfile({
+ email,
+ first_name: firstName,
+ last_name: lastName,
+ organization: company,
+ job_title: jobTitle,
+ job_function:
+ subsector && subsector.includes('Other')
+ ? `Other: ${subsector_otherInput || ''}`
+ : subsector,
+ sector,
+ city,
+ country,
+ preferred_language,
+ interests: interests.toString(),
+ receive_updates,
+ old_email,
+ });
+
const { attributes } = response.data.data;
dispatch(
setMyGFW({
diff --git a/components/forms/profile/component.jsx b/components/forms/profile/component.jsx
index df45b72073..d3f8659e5b 100644
--- a/components/forms/profile/component.jsx
+++ b/components/forms/profile/component.jsx
@@ -14,6 +14,7 @@ import Submit from 'components/forms/components/submit';
import ConfirmationMessage from 'components/confirmation-message';
import Button from 'components/ui/button';
import Error from 'components/forms/components/error';
+import { preferredLanguages } from 'components/forms/profile/config';
import {
email as validateEmail,
@@ -95,6 +96,11 @@ class ProfileForm extends PureComponent {
validate={[validateEmail]}
required
/>
+