diff --git a/components/FormikFields/PaperInputPicker/Looper/index.js b/components/FormikFields/PaperInputPicker/Looper/index.js index 0d6e55bc2..6b5d2d92b 100644 --- a/components/FormikFields/PaperInputPicker/Looper/index.js +++ b/components/FormikFields/PaperInputPicker/Looper/index.js @@ -67,6 +67,9 @@ const Looper = ({ } else { updatedQuestion.formikKey = `${updatedQuestion.formikKey}__sameForm${individualLoopsAdded}`; } + if (updatedQuestion.options) { + updatedQuestion.options = updateTextKeys(updatedQuestion.options) + } updatedQuestions = updatedQuestions.concat(updatedQuestion); }); @@ -77,6 +80,17 @@ const Looper = ({ setIndividualLoopsAdded(individualLoopsAdded + 1); }; + const updateTextKeys = (options) => { + let updatedOptions = [] + options.forEach((option) => { + const updatedOption = _.cloneDeep(option); + const textKeys = updatedOption.textKey.split("__") + updatedOption.textKey = sameForm ? `__${textKeys[1]}__sameForm${individualLoopsAdded}__${textKeys[2]}` : `__${textKeys[1]}__loop${individualLoopsAdded}__${textKeys[2]}`; + updatedOptions = updatedOptions.concat(updatedOption) + }) + return updatedOptions + } + const removeLoop = () => { if (sameForm !== true) { setLoopsAdded(loopsAdded - 1); diff --git a/domains/DataCollection/Forms/SupplementaryForm/utils/index.js b/domains/DataCollection/Forms/SupplementaryForm/utils/index.js index 12297e419..9e95dcf75 100644 --- a/domains/DataCollection/Forms/SupplementaryForm/utils/index.js +++ b/domains/DataCollection/Forms/SupplementaryForm/utils/index.js @@ -3,8 +3,8 @@ function addSelectTextInputs(values, formObject) { Object.entries(values).forEach(([key, val]) => { if (key.slice(0, 2) === '__') { const keys = key.split('__'); - const formikKey = keys[1]; - const formikOrigVal = keys[2]; + const formikKey = keys[2].includes('sameForm') || keys[2].includes('loop') ? `${keys[1]}__${keys[2]}` : keys[1]; + const formikOrigVal = keys[2].includes('sameForm') || keys[2].includes('loop') ? keys[3] : keys[2]; if (typeof (formObject[formikKey]) === 'object') { const index = newFormObject[formikKey].indexOf(formikOrigVal); newFormObject[formikKey][index] = `${formikOrigVal}__${val}`; diff --git a/environment.js b/environment.js index fd8cc5241..cbe7d7ff0 100644 --- a/environment.js +++ b/environment.js @@ -35,18 +35,19 @@ const ENV = { } }; -const getEnvVars = (env = Constants.manifest.releaseChannel) => +const getEnvVars = (env = Constants.manifest.releaseChannel) => { // What is __DEV__ ? // This variable is set to true when react-native is running in Dev mode. // __DEV__ is true when run locally, but false when published. - // if (env === null || env === undefined || env === '' || env.indexOf('dev') !== -1) { - // return ENV.dev; - // } if (env.indexOf('staging') !== -1) { - // return ENV.staging; - // } if (env.indexOf('prod') !== -1) { - // return ENV.prod; - // } - ENV.prod; + if (env === null || env === undefined || env === '' || env.indexOf('dev') !== -1) { + return ENV.dev; + } if (env.indexOf('staging') !== -1) { + return ENV.staging; + } if (env.indexOf('prod') !== -1) { + return ENV.prod; + } + // ENV.prod; +} const selectedENV = getEnvVars(); export default selectedENV;