Skip to content

Commit

Permalink
feat: save in datastore format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharmyn28 committed Oct 6, 2023
1 parent ae4edab commit cfe29b5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
19 changes: 17 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2023-10-03T11:54:31.751Z\n"
"PO-Revision-Date: 2023-10-03T11:54:31.751Z\n"
"POT-Creation-Date: 2023-10-06T16:23:08.006Z\n"
"PO-Revision-Date: 2023-10-06T16:23:08.006Z\n"

msgid ""
"The initial configuration of the app has been completed and it is now ready "
Expand Down Expand Up @@ -862,6 +862,15 @@ msgstr ""
"apply to all programs a mobile user has access to. Settings specific to "
"individual programs can also be applied."

msgid "TEI Header"
msgstr "TEI Header"

msgid "Advanced options"
msgstr "Advanced options"

msgid "Filter"
msgstr "Filter"

msgid "Enrollment Date"
msgstr "Enrollment Date"

Expand All @@ -877,6 +886,12 @@ msgstr "Event status"
msgid "Follow up"
msgstr "Follow up"

msgid "There are no Program Indicators with valid expressions for Android"
msgstr "There are no Program Indicators with valid expressions for Android"

msgid "Disable elements do not meet Android criteria"
msgstr "Disable elements do not meet Android criteria"

msgid "Enrollment Status"
msgstr "Enrollment Status"

Expand Down
3 changes: 2 additions & 1 deletion src/pages/Appearance/Programs/ProgramsAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
createSpecificValues,
prepareSettingsSaveDataStore,
prepareSpinnerPreviousSpinner,
prepareSpinnerSettingsDataStore,
removeAttributes,
} from './helper'
import ProgramGlobalSettings from './ProgramGlobalSettings'
Expand Down Expand Up @@ -86,7 +87,7 @@ const ProgramsAppearance = () => {
...spinnerGlobal,
},
specificSettings: {
...prepareSettingsSaveDataStore(spinnerSpecific),
...prepareSpinnerSettingsDataStore(spinnerSpecific),
},
},
completionSpinner: {
Expand Down
31 changes: 30 additions & 1 deletion src/pages/Appearance/Programs/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const createInitialSpinnerValue = (prevDetails) => {
optionalSearch: prevDetails.optionalSearch,
disableReferrals: prevDetails.disableReferrals,
disableCollapsibleSections: prevDetails.disableCollapsibleSections,
programIndicator: prevDetails.programIndicator,
programIndicator:
prevDetails.programIndicator ||
prevDetails?.itemHeader?.programIndicator,
}
}

Expand Down Expand Up @@ -86,6 +88,7 @@ export const prepareSpinnerPreviousSpinner = (settings) => {
'completionSpinner',
'disableReferrals',
'disableCollapsibleSections',
'programIndicator',
]
)
}
Expand Down Expand Up @@ -203,3 +206,29 @@ export const isProgramConfiguration = (configurationType) =>

export const removeAttributes = (itemList) =>
removePropertiesFromObject(itemList, ['summarySettings', 'id', 'name'])

export const prepareSpinnerSettingsDataStore = (settings) => {
const settingsToSave = mapValues(settings, (setting) =>
createItemHeader(setting)
)

return removePropertiesFromObject(settingsToSave, [
'summarySettings',
'id',
'name',
'programIndicator',
])
}

const createItemHeader = (settings) => {
const programIndicator = !isNil(settings.programIndicator) && {
itemHeader: {
programIndicator: settings.programIndicator,
},
}

return {
...settings,
...programIndicator,
}
}

0 comments on commit cfe29b5

Please sign in to comment.