Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: foreign language in export #660

Merged
merged 4 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions shared-helpers/src/views/multiselectQuestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,26 +433,27 @@ export const mapApiToMultiselectForm = (
if (appQuestion.inputType === "checkbox") {
options = question.options.reduce((acc, curr) => {
const claimed = curr.checked
const cleanKey = curr.key.replace(/\.|,|'/g, "")
if (appQuestion.inputType === "checkbox") {
acc[curr.key] = claimed
acc[cleanKey] = claimed
if (curr.extraData?.length) {
acc[`${curr.key}-address`] = curr.extraData[0].value
acc[`${cleanKey}-address`] = curr.extraData[0].value

const addressHolderName = curr.extraData?.find(
(field) => field.key === AddressHolder.Name
)
if (addressHolderName) {
acc[`${curr.key}-${AddressHolder.Name}`] = addressHolderName.value
acc[`${cleanKey}-${AddressHolder.Name}`] = addressHolderName.value
}

const addressHolderRelationship = curr.extraData?.find(
(field) => field.key === AddressHolder.Relationship
)
if (addressHolderRelationship) {
acc[`${curr.key}-${AddressHolder.Relationship}`] = addressHolderRelationship.value
acc[`${cleanKey}-${AddressHolder.Relationship}`] = addressHolderRelationship.value
}
if (curr?.mapPinPosition) {
acc[`${curr.key}-mapPinPosition`] = curr.mapPinPosition
acc[`${cleanKey}-mapPinPosition`] = curr.mapPinPosition
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions sites/public/src/lib/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,22 @@ export const untranslateMultiselectQuestion = (

data.forEach((datum) => {
const question = multiselectQuestions.find(
(elem) => elem.multiselectQuestion.text === datum.key
(elem) =>
elem.multiselectQuestion.text === datum.key ||
elem.multiselectQuestion.untranslatedText === datum.key
)?.multiselectQuestion

if (question) {
datum.key = question.untranslatedText ?? question.text

if (datum.options) {
datum.options.forEach((option) => {
const selectedOption = question.options.find((elem) => elem.text === option.key)

const selectedOption = question.options.find((elem) => {
return elem.text.replace(/\.|,|'/g, "") === option.key
})
if (selectedOption) {
option.key = selectedOption.untranslatedText ?? selectedOption.text
} else if (question.optOutText === option.key) {
} else if (question?.optOutText?.replace(/\.|,|'/g, "") === option.key) {
option.key = question.untranslatedOptOutText ?? question.optOutText
}

Expand Down
Loading