@legalplace/wizardx-core 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/App.d.ts +5 -5
- package/dist/App.js +22 -35
- package/dist/App.test.js +2 -2
- package/dist/Globals.d.ts +4 -0
- package/dist/Globals.js +9 -6
- package/dist/Loader.d.ts +1 -0
- package/dist/Loader.js +2 -0
- package/dist/PluginLoader.d.ts +3 -3
- package/dist/PluginLoader.js +22 -26
- package/dist/PluginLoader.test.js +6 -6
- package/dist/Shimmer.d.ts +1 -1
- package/dist/Shimmer.js +45 -47
- package/dist/ThemeLoader.d.ts +6 -5
- package/dist/ThemeLoader.js +21 -25
- package/dist/ThemeLoader.test.js +4 -3
- package/dist/components/PluginRoute.d.ts +3 -3
- package/dist/components/PluginRoute.js +8 -7
- package/dist/components/SmartScript.d.ts +7 -8
- package/dist/components/SmartScript.js +22 -21
- package/dist/components/UserLocked/UserLockedComponent.d.ts +1 -1
- package/dist/components/UserLocked/UserLockedComponent.js +5 -6
- package/dist/components/View.d.ts +8 -4
- package/dist/components/View.js +46 -55
- package/dist/components/View.test.js +6 -5
- package/dist/componentsConnectors/connectBox.d.ts +2 -3
- package/dist/componentsConnectors/connectBox.js +4 -4
- package/dist/componentsConnectors/connectBox.test.js +7 -7
- package/dist/componentsConnectors/connectDocument.d.ts +0 -1
- package/dist/componentsConnectors/connectDocument.js +6 -6
- package/dist/componentsConnectors/connectDocument.test.js +5 -5
- package/dist/componentsConnectors/connectHeader.d.ts +0 -1
- package/dist/componentsConnectors/connectHeader.js +2 -2
- package/dist/componentsConnectors/connectMetaTitle.d.ts +0 -1
- package/dist/componentsConnectors/connectMetaTitle.js +2 -2
- package/dist/componentsConnectors/connectMetaTitle.test.js +3 -3
- package/dist/componentsConnectors/connectOption.d.ts +2 -3
- package/dist/componentsConnectors/connectOption.js +9 -9
- package/dist/componentsConnectors/connectPagination.d.ts +0 -1
- package/dist/componentsConnectors/connectPagination.js +3 -3
- package/dist/componentsConnectors/connectPreview.d.ts +0 -1
- package/dist/componentsConnectors/connectPreview.js +2 -2
- package/dist/componentsConnectors/connectProgress.d.ts +0 -1
- package/dist/componentsConnectors/connectProgress.js +3 -3
- package/dist/componentsConnectors/connectRootOption.d.ts +2 -3
- package/dist/componentsConnectors/connectRootOption.js +2 -2
- package/dist/componentsConnectors/connectSection.d.ts +0 -1
- package/dist/componentsConnectors/connectSection.js +4 -4
- package/dist/componentsConnectors/connectSummary.d.ts +0 -1
- package/dist/componentsConnectors/connectSummary.js +2 -2
- package/dist/componentsConnectors/connectSummaryItem.d.ts +0 -1
- package/dist/componentsConnectors/connectSummaryItem.js +6 -6
- package/dist/componentsConnectors/connectTermsheet.d.ts +2 -2
- package/dist/componentsConnectors/connectTermsheet.js +43 -46
- package/dist/componentsConnectors/connectVariable.d.ts +1 -2
- package/dist/componentsConnectors/connectVariable.js +10 -10
- package/dist/componentsConnectors/connectWizardWrapper.d.ts +0 -1
- package/dist/componentsConnectors/connectWizardWrapper.js +4 -4
- package/dist/componentsConnectors/connector/componentConnector.d.ts +8 -8
- package/dist/componentsConnectors/connector/componentConnector.js +16 -19
- package/dist/componentsConnectors/library.d.ts +61 -0
- package/dist/componentsConnectors/library.js +34 -0
- package/dist/config.d.ts +1 -1
- package/dist/constants/phoneValidation.d.ts +3 -0
- package/dist/constants/phoneValidation.js +3 -0
- package/dist/helpers/outputsParsing.d.ts +1 -1
- package/dist/helpers/outputsParsing.js +25 -25
- package/dist/helpers/preloadTheme.js +1 -1
- package/dist/helpers/scriptsLoader.d.ts +1 -0
- package/dist/helpers/scriptsLoader.js +24 -0
- package/dist/helpers/sendinblueHelper.d.ts +3 -3
- package/dist/helpers/sendinblueHelper.js +29 -18
- package/dist/hooks/usePrevious.js +1 -1
- package/dist/libs/ConditionsInitiator.d.ts +1 -1
- package/dist/libs/ConditionsInitiator.js +2 -2
- package/dist/libs/ConditionsRunner/DataPopulator.js +7 -7
- package/dist/libs/ConditionsRunner.d.ts +3 -3
- package/dist/libs/ConditionsRunner.js +43 -43
- package/dist/libs/DocumentsOutputs.d.ts +2 -2
- package/dist/libs/DocumentsOutputs.js +5 -5
- package/dist/libs/Eval/EvalBase.js +17 -17
- package/dist/libs/Eval/EvalFunctions.d.ts +1 -1
- package/dist/libs/Eval/EvalFunctions.js +100 -100
- package/dist/libs/Eval/NumbersToLetters.js +46 -46
- package/dist/libs/EvalVariable.d.ts +2 -2
- package/dist/libs/EvalVariable.js +30 -29
- package/dist/libs/EventsTracking.js +32 -32
- package/dist/libs/Extracts.js +20 -20
- package/dist/libs/InputsInitiator.d.ts +1 -1
- package/dist/libs/InputsInitiator.js +15 -15
- package/dist/libs/NumAuto.js +1 -1
- package/dist/libs/OvcConverter.d.ts +1 -1
- package/dist/libs/OvcConverter.js +23 -23
- package/dist/libs/PathReader.d.ts +1 -1
- package/dist/libs/PathReader.js +22 -22
- package/dist/libs/SectionValidity.js +3 -3
- package/dist/libs/SmartScriptStore.d.ts +6 -6
- package/dist/libs/SmartScriptStore.js +33 -33
- package/dist/misc/test_model.d.ts +2 -2
- package/dist/misc/test_model.js +3807 -3807
- package/dist/polyfills/index.d.ts +5 -0
- package/dist/polyfills/index.js +5 -0
- package/dist/polyfills/prepend.js +2 -2
- package/dist/polyfills/stringRepeat.js +4 -4
- package/dist/redux/actions/app.d.ts +12 -12
- package/dist/redux/actions/app.js +1 -1
- package/dist/redux/actions/conditions.d.ts +2 -2
- package/dist/redux/actions/conditions.js +1 -1
- package/dist/redux/actions/inputs.d.ts +3 -1
- package/dist/redux/actions/inputs.js +6 -1
- package/dist/redux/actions/library.d.ts +74 -0
- package/dist/redux/actions/library.js +11 -0
- package/dist/redux/actions/mandatories.d.ts +1 -1
- package/dist/redux/actions/mandatories.js +1 -1
- package/dist/redux/actions/references.d.ts +4 -4
- package/dist/redux/actions/references.js +1 -1
- package/dist/redux/actions/sagas/data.d.ts +1 -1
- package/dist/redux/actions/sagas/data.js +1 -1
- package/dist/redux/actions/sagas/model.d.ts +3 -3
- package/dist/redux/actions/sagas/model.js +3 -3
- package/dist/redux/actions/sagas/user.d.ts +1 -1
- package/dist/redux/actions/sagas/user.js +1 -1
- package/dist/redux/actions/smartscript.d.ts +3 -3
- package/dist/redux/actions/smartscript.js +1 -1
- package/dist/redux/actions/user.d.ts +4 -4
- package/dist/redux/actions/user.js +1 -1
- package/dist/redux/constants/app.js +22 -22
- package/dist/redux/constants/conditions.js +8 -8
- package/dist/redux/constants/inputs.d.ts +1 -0
- package/dist/redux/constants/inputs.js +7 -6
- package/dist/redux/constants/mandatories.js +6 -6
- package/dist/redux/constants/references.js +3 -3
- package/dist/redux/constants/sagas/data.js +1 -1
- package/dist/redux/constants/sagas/model.js +2 -2
- package/dist/redux/constants/sagas/user.js +2 -2
- package/dist/redux/constants/smartscript.js +4 -4
- package/dist/redux/constants/user.js +3 -3
- package/dist/redux/listeners/subscriber.d.ts +2 -2
- package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/conditionsWatcherMiddleware.js +28 -28
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +4 -2
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.js +10 -10
- package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/mandatoriesWatcherMiddleware.js +13 -13
- package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/multiplesActionsMiddleware.js +2 -2
- package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +3 -3
- package/dist/redux/middlewares/paginationWatcherMiddleware.js +24 -24
- package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/pluginsHookMiddleware.js +1 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/prefillerWatcherMiddleware.js +28 -28
- package/dist/redux/middlewares/smartscriptMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/smartscriptMiddleware.js +33 -15
- package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +5 -0
- package/dist/redux/middlewares/thirdpartyScriptsMiddleware.js +16 -0
- package/dist/redux/reducers/app/customizations/initCustomizationAutoDefault.d.ts +2 -2
- package/dist/redux/reducers/app/customizations/initCustomizationMeta.d.ts +2 -2
- package/dist/redux/reducers/app/instance/initInstance.d.ts +2 -2
- package/dist/redux/reducers/app/instance/setDataStatus.d.ts +2 -2
- package/dist/redux/reducers/app/instance/updateInstance.d.ts +2 -2
- package/dist/redux/reducers/app/instance/updateInstancePaid.d.ts +2 -2
- package/dist/redux/reducers/app/meta/fetchModelFailed.d.ts +1 -1
- package/dist/redux/reducers/app/meta/fetchModelFailed.js +1 -1
- package/dist/redux/reducers/app/meta/fetchModelNonBlocking.d.ts +1 -1
- package/dist/redux/reducers/app/meta/fetchModelNonBlocking.js +1 -1
- package/dist/redux/reducers/app/meta/fetchModelSucceeded.d.ts +1 -1
- package/dist/redux/reducers/app/meta/fetchModelSucceeded.js +1 -1
- package/dist/redux/reducers/app/meta/fetchModelUnhealthy.d.ts +2 -2
- package/dist/redux/reducers/app/meta/fetchModelUnhealthy.js +1 -1
- package/dist/redux/reducers/app/meta/fetchModelUserLocked.d.ts +1 -1
- package/dist/redux/reducers/app/meta/fetchModelUserLocked.js +1 -1
- package/dist/redux/reducers/app/meta/initMeta.d.ts +2 -2
- package/dist/redux/reducers/app/meta/setModelUuid.d.ts +2 -2
- package/dist/redux/reducers/app/pagination/goNextPage.d.ts +1 -1
- package/dist/redux/reducers/app/pagination/goNextPage.js +1 -1
- package/dist/redux/reducers/app/pagination/goPage.d.ts +2 -2
- package/dist/redux/reducers/app/pagination/goPage.js +2 -2
- package/dist/redux/reducers/app/pagination/goPreviousPage.d.ts +1 -1
- package/dist/redux/reducers/app/pagination/goPreviousPage.js +1 -1
- package/dist/redux/reducers/app/pagination/initPagination.d.ts +2 -2
- package/dist/redux/reducers/app/pagination/initPagination.js +1 -1
- package/dist/redux/reducers/app/pagination/updateAvailableAppStates.d.ts +2 -2
- package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +5 -5
- package/dist/redux/reducers/app/wizard/updateAvailableSections.d.ts +2 -2
- package/dist/redux/reducers/app/wizard/updateAvailableSections.js +2 -2
- package/dist/redux/reducers/app.d.ts +2 -2
- package/dist/redux/reducers/app.js +30 -30
- package/dist/redux/reducers/conditions/addMultipleOccurency.d.ts +2 -2
- package/dist/redux/reducers/conditions/addMultipleOccurency.js +3 -3
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.d.ts +2 -2
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.js +2 -2
- package/dist/redux/reducers/conditions/initConditions.d.ts +2 -2
- package/dist/redux/reducers/conditions/updateDocumentConditions.d.ts +2 -2
- package/dist/redux/reducers/conditions/updateOptionConditions.d.ts +2 -2
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.d.ts +2 -2
- package/dist/redux/reducers/conditions/updatePrefillerConditions.d.ts +2 -2
- package/dist/redux/reducers/conditions/updatePrefillerConditions.js +2 -2
- package/dist/redux/reducers/conditions/updateSectionConditions.d.ts +2 -2
- package/dist/redux/reducers/conditions/updateVariableConditions.d.ts +2 -2
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.d.ts +2 -2
- package/dist/redux/reducers/conditions.d.ts +2 -2
- package/dist/redux/reducers/conditions.js +13 -13
- package/dist/redux/reducers/inputs/addMultipleOccurency.d.ts +2 -2
- package/dist/redux/reducers/inputs/addMultipleOccurency.js +4 -4
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.d.ts +2 -2
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.js +2 -2
- package/dist/redux/reducers/inputs/initOption.d.ts +2 -2
- package/dist/redux/reducers/inputs/initVariable.d.ts +2 -2
- package/dist/redux/reducers/inputs/updateOptionInput.d.ts +2 -2
- package/dist/redux/reducers/inputs/updateVariableInput.d.ts +2 -2
- package/dist/redux/reducers/inputs.d.ts +2 -2
- package/dist/redux/reducers/inputs.js +8 -8
- package/dist/redux/reducers/mandatories/addMultipleOccurency.d.ts +2 -2
- package/dist/redux/reducers/mandatories/addMultipleOccurency.js +2 -2
- package/dist/redux/reducers/mandatories/deleteMultipleOccurency.d.ts +2 -2
- package/dist/redux/reducers/mandatories/deleteMultipleOccurency.js +2 -2
- package/dist/redux/reducers/mandatories/initMandatoryOption.d.ts +2 -2
- package/dist/redux/reducers/mandatories/initMandatoryVariable.d.ts +2 -2
- package/dist/redux/reducers/mandatories/setMandatoryIgnore.d.ts +2 -2
- package/dist/redux/reducers/mandatories/setMandatoryOption.d.ts +2 -2
- package/dist/redux/reducers/mandatories/setMandatorySection.d.ts +2 -2
- package/dist/redux/reducers/mandatories/setMandatoryVariable.d.ts +2 -2
- package/dist/redux/reducers/mandatories.d.ts +2 -2
- package/dist/redux/reducers/mandatories.js +11 -11
- package/dist/redux/reducers/references/initReferences.d.ts +2 -2
- package/dist/redux/reducers/references/updateOptionMeta.d.ts +2 -2
- package/dist/redux/reducers/references/updateOptionMeta.js +2 -2
- package/dist/redux/reducers/references/updateVariableMeta.d.ts +2 -2
- package/dist/redux/reducers/references/updateVariableMeta.js +2 -2
- package/dist/redux/reducers/references.d.ts +2 -2
- package/dist/redux/reducers/references.js +5 -5
- package/dist/redux/reducers/smartscript/enableSmartScript.d.ts +1 -1
- package/dist/redux/reducers/smartscript/initSmartScriptTriggers.d.ts +2 -2
- package/dist/redux/reducers/smartscript/updateSmartscriptOptionHidden.d.ts +2 -2
- package/dist/redux/reducers/smartscript/updateSmartscriptVariableHidden.d.ts +2 -2
- package/dist/redux/reducers/smartscript.d.ts +2 -2
- package/dist/redux/reducers/smartscript.js +6 -6
- package/dist/redux/reducers/user/initUser.d.ts +2 -2
- package/dist/redux/reducers/user/setUserStatus.d.ts +2 -2
- package/dist/redux/reducers/user/setUserValidToken.d.ts +2 -2
- package/dist/redux/reducers/user.d.ts +2 -2
- package/dist/redux/reducers/user.js +9 -9
- package/dist/redux/routerHistory.d.ts +2 -2
- package/dist/redux/routerHistory.js +5 -5
- package/dist/redux/sagas/fetchModel.d.ts +4 -4
- package/dist/redux/sagas/fetchModel.js +79 -131
- package/dist/redux/sagas/fetchModel.test.js +2 -3
- package/dist/redux/sagas/homogeneousRadioInputsSaga.js +5 -5
- package/dist/redux/sagas/initInputs.d.ts +5 -0
- package/dist/redux/sagas/initInputs.js +63 -0
- package/dist/redux/sagas/runner.d.ts +1 -1
- package/dist/redux/sagas/runner.js +7 -5
- package/dist/redux/sagas/saveData.js +34 -25
- package/dist/redux/sagas/setDefaults.js +8 -8
- package/dist/redux/sagas/setUserEmail.js +43 -43
- package/dist/redux/selectors/app.d.ts +1 -0
- package/dist/redux/selectors/app.js +26 -25
- package/dist/redux/selectors/conditions.js +34 -34
- package/dist/redux/selectors/inputs.d.ts +1 -1
- package/dist/redux/selectors/inputs.js +8 -8
- package/dist/{componentsConnectors/connector/connectorSelectors.d.ts → redux/selectors/library.d.ts} +17 -16
- package/dist/redux/selectors/library.js +8 -0
- package/dist/redux/selectors/mandatories.js +10 -10
- package/dist/redux/selectors/references.d.ts +1 -0
- package/dist/redux/selectors/references.js +20 -19
- package/dist/redux/selectors/selectors.d.ts +2 -2
- package/dist/redux/selectors/selectors.js +2 -2
- package/dist/redux/selectors/smartscript.js +5 -5
- package/dist/redux/selectors/user.js +5 -5
- package/dist/redux/store.d.ts +6 -2
- package/dist/redux/store.js +31 -31
- package/dist/service/api.manager.d.ts +2 -2
- package/dist/service/api.manager.js +46 -46
- package/dist/service/auth.service.js +2 -2
- package/dist/service/pardot.service.js +2 -2
- package/dist/tests-misc/plugins/jestTestPlugin/after.d.ts +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/after.js +2 -2
- package/dist/tests-misc/plugins/jestTestPlugin/before.d.ts +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/before.js +2 -5
- package/dist/tests-misc/plugins/jestTestPlugin/index.js +4 -4
- package/dist/tests-misc/plugins/jestTestPlugin/title.d.ts +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/title.js +2 -2
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +0 -1
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +2 -2
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +0 -1
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +2 -2
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +0 -1
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +2 -2
- package/dist/tests-misc/themes/jestTestTheme/faltyIndex.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/faltyIndexLoader.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/index.js +4 -4
- package/dist/types/Actions.type.d.ts +42 -37
- package/dist/types/Components.type.d.ts +4 -5
- package/dist/types/State.type.d.ts +9 -9
- package/dist/types/Termsheet.type.d.ts +4 -4
- package/dist/types/api.type.d.ts +4 -4
- package/dist/types/config.type.d.ts +2 -3
- package/dist/types/getActions.type.d.ts +2 -2
- package/dist/types/getConnectors.type.d.ts +2 -3
- package/dist/types/getSelectors.type.d.ts +2 -2
- package/dist/wizard-params.d.ts +1 -1
- package/dist/wizard-params.js +16 -16
- package/jest.config.ts +1 -1
- package/package.json +16 -8
- package/setupJest.ts +8 -0
- package/src/App.tsx +22 -25
- package/src/Globals.ts +12 -8
- package/src/Loader.tsx +8 -0
- package/src/PluginLoader.tsx +20 -37
- package/src/Shimmer.tsx +58 -45
- package/src/ThemeLoader.test.tsx +1 -0
- package/src/ThemeLoader.tsx +27 -42
- package/src/components/PluginRoute.tsx +8 -6
- package/src/components/SmartScript.tsx +29 -28
- package/src/components/UserLocked/UserLockedComponent.tsx +3 -3
- package/src/components/View.test.tsx +3 -0
- package/src/components/View.tsx +52 -54
- package/src/componentsConnectors/connectBox.tsx +6 -6
- package/src/componentsConnectors/connectDocument.tsx +6 -6
- package/src/componentsConnectors/connectHeader.tsx +2 -2
- package/src/componentsConnectors/connectMetaTitle.tsx +2 -2
- package/src/componentsConnectors/connectOption.tsx +11 -11
- package/src/componentsConnectors/connectPagination.tsx +3 -3
- package/src/componentsConnectors/connectPreview.tsx +2 -2
- package/src/componentsConnectors/connectProgress.tsx +3 -3
- package/src/componentsConnectors/connectRootOption.tsx +4 -4
- package/src/componentsConnectors/connectSection.tsx +4 -4
- package/src/componentsConnectors/connectSummary.tsx +2 -2
- package/src/componentsConnectors/connectSummaryItem.tsx +6 -6
- package/src/componentsConnectors/connectTermsheet.tsx +46 -46
- package/src/componentsConnectors/connectVariable.tsx +11 -11
- package/src/componentsConnectors/connectWizardWrapper.tsx +4 -4
- package/src/componentsConnectors/connector/componentConnector.tsx +22 -20
- package/src/componentsConnectors/library.ts +35 -0
- package/src/config.test.ts +2 -1
- package/src/config.ts +1 -1
- package/src/constants/phoneValidation.ts +6 -0
- package/src/definitions/path.join.d.ts +1 -1
- package/src/helpers/outputsParsing.ts +26 -26
- package/src/helpers/preloadTheme.ts +2 -2
- package/src/helpers/scriptsLoader.ts +20 -0
- package/src/helpers/sendinblueHelper.ts +23 -17
- package/src/hooks/usePrevious.ts +1 -1
- package/src/libs/ConditionsInitiator.ts +3 -3
- package/src/libs/ConditionsRunner/DataPopulator.ts +7 -7
- package/src/libs/ConditionsRunner.ts +53 -53
- package/src/libs/DocumentsOutputs.ts +7 -7
- package/src/libs/Eval/EvalBase.ts +17 -17
- package/src/libs/Eval/EvalFunctions.ts +100 -100
- package/src/libs/Eval/NumbersToLetters.ts +48 -48
- package/src/libs/EvalVariable.ts +34 -31
- package/src/libs/EventsTracking.ts +38 -38
- package/src/libs/Extracts.ts +21 -21
- package/src/libs/InputsInitiator.ts +16 -16
- package/src/libs/NumAuto.ts +1 -1
- package/src/libs/OvcConverter.ts +25 -25
- package/src/libs/PathReader.ts +23 -23
- package/src/libs/SectionValidity.ts +3 -3
- package/src/libs/SmartScriptStore.ts +40 -40
- package/src/misc/test_model.ts +3809 -3809
- package/src/polyfills/index.ts +5 -0
- package/src/polyfills/prepend.ts +2 -2
- package/src/polyfills/stringRepeat.ts +4 -4
- package/src/redux/actions/app.ts +13 -13
- package/src/redux/actions/conditions.ts +3 -3
- package/src/redux/actions/inputs.ts +18 -2
- package/src/redux/actions/library.ts +23 -0
- package/src/redux/actions/mandatories.ts +2 -2
- package/src/redux/actions/references.ts +5 -5
- package/src/redux/actions/sagas/data.ts +2 -2
- package/src/redux/actions/sagas/model.ts +6 -6
- package/src/redux/actions/sagas/user.ts +2 -2
- package/src/redux/actions/smartscript.ts +4 -4
- package/src/redux/actions/user.ts +5 -5
- package/src/redux/constants/app.ts +22 -22
- package/src/redux/constants/conditions.ts +8 -8
- package/src/redux/constants/inputs.ts +8 -6
- package/src/redux/constants/mandatories.ts +6 -6
- package/src/redux/constants/references.ts +3 -3
- package/src/redux/constants/sagas/data.ts +1 -1
- package/src/redux/constants/sagas/model.ts +2 -2
- package/src/redux/constants/sagas/user.ts +2 -2
- package/src/redux/constants/smartscript.ts +4 -4
- package/src/redux/constants/user.ts +3 -3
- package/src/redux/listeners/subscriber.ts +2 -2
- package/src/redux/middlewares/conditionsWatcherMiddleware.ts +31 -31
- package/src/redux/middlewares/evaluationsWatcherMiddleware.test.ts +1 -1
- package/src/redux/middlewares/evaluationsWatcherMiddleware.ts +13 -13
- package/src/redux/middlewares/mandatoriesWatcherMiddleware.ts +16 -16
- package/src/redux/middlewares/multiplesActionsMiddleware.ts +6 -6
- package/src/redux/middlewares/paginationWatcherMiddleware.ts +27 -27
- package/src/redux/middlewares/pluginsHookMiddleware.ts +2 -2
- package/src/redux/middlewares/prefillerWatcherMiddleware.ts +31 -31
- package/src/redux/middlewares/smartscriptMiddleware.ts +61 -20
- package/src/redux/middlewares/thirdpartyScriptsMiddleware.ts +41 -0
- package/src/redux/reducers/app/customizations/initCustomizationAutoDefault.ts +2 -2
- package/src/redux/reducers/app/customizations/initCustomizationMeta.ts +2 -2
- package/src/redux/reducers/app/instance/initInstance.ts +2 -2
- package/src/redux/reducers/app/instance/setDataStatus.ts +2 -2
- package/src/redux/reducers/app/instance/updateInstance.ts +2 -2
- package/src/redux/reducers/app/instance/updateInstancePaid.ts +2 -2
- package/src/redux/reducers/app/meta/fetchModelFailed.ts +2 -2
- package/src/redux/reducers/app/meta/fetchModelNonBlocking.ts +2 -2
- package/src/redux/reducers/app/meta/fetchModelSucceeded.ts +2 -2
- package/src/redux/reducers/app/meta/fetchModelUnhealthy.ts +3 -3
- package/src/redux/reducers/app/meta/fetchModelUserLocked.ts +2 -2
- package/src/redux/reducers/app/meta/initMeta.ts +2 -2
- package/src/redux/reducers/app/meta/setModelUuid.ts +2 -2
- package/src/redux/reducers/app/pagination/goNextPage.ts +2 -2
- package/src/redux/reducers/app/pagination/goPage.ts +4 -4
- package/src/redux/reducers/app/pagination/goPreviousPage.ts +2 -2
- package/src/redux/reducers/app/pagination/initPagination.ts +3 -3
- package/src/redux/reducers/app/pagination/updateAvailableAppStates.ts +7 -7
- package/src/redux/reducers/app/wizard/updateAvailableSections.ts +4 -4
- package/src/redux/reducers/app.ts +32 -32
- package/src/redux/reducers/conditions/addMultipleOccurency.ts +5 -5
- package/src/redux/reducers/conditions/deleteMultipleOccurency.ts +4 -4
- package/src/redux/reducers/conditions/initConditions.ts +2 -2
- package/src/redux/reducers/conditions/updateDocumentConditions.ts +2 -2
- package/src/redux/reducers/conditions/updateOptionConditions.ts +2 -2
- package/src/redux/reducers/conditions/updateOptionValidatorCondition.ts +2 -2
- package/src/redux/reducers/conditions/updatePrefillerConditions.ts +4 -4
- package/src/redux/reducers/conditions/updateSectionConditions.ts +2 -2
- package/src/redux/reducers/conditions/updateVariableConditions.ts +2 -2
- package/src/redux/reducers/conditions/updateVariableValidatorCondition.ts +2 -2
- package/src/redux/reducers/conditions.ts +15 -15
- package/src/redux/reducers/inputs/addMultipleOccurency.ts +6 -6
- package/src/redux/reducers/inputs/deleteMultipleOccurency.ts +4 -4
- package/src/redux/reducers/inputs/initOption.ts +2 -2
- package/src/redux/reducers/inputs/initVariable.ts +2 -2
- package/src/redux/reducers/inputs/updateOptionInput.ts +2 -2
- package/src/redux/reducers/inputs/updateVariableInput.ts +2 -2
- package/src/redux/reducers/inputs.ts +10 -10
- package/src/redux/reducers/mandatories/addMultipleOccurency.ts +4 -4
- package/src/redux/reducers/mandatories/deleteMultipleOccurency.ts +4 -4
- package/src/redux/reducers/mandatories/initMandatoryOption.ts +2 -2
- package/src/redux/reducers/mandatories/initMandatoryVariable.ts +2 -2
- package/src/redux/reducers/mandatories/setMandatoryIgnore.ts +2 -2
- package/src/redux/reducers/mandatories/setMandatoryOption.ts +2 -2
- package/src/redux/reducers/mandatories/setMandatorySection.ts +2 -2
- package/src/redux/reducers/mandatories/setMandatoryVariable.ts +2 -2
- package/src/redux/reducers/mandatories.ts +13 -13
- package/src/redux/reducers/references/initReferences.ts +2 -2
- package/src/redux/reducers/references/updateOptionMeta.ts +4 -4
- package/src/redux/reducers/references/updateVariableMeta.ts +4 -4
- package/src/redux/reducers/references.ts +7 -7
- package/src/redux/reducers/smartscript/enableSmartScript.ts +1 -1
- package/src/redux/reducers/smartscript/initSmartScriptTriggers.ts +2 -2
- package/src/redux/reducers/smartscript/updateSmartscriptOptionHidden.ts +2 -2
- package/src/redux/reducers/smartscript/updateSmartscriptVariableHidden.ts +2 -2
- package/src/redux/reducers/smartscript.ts +8 -8
- package/src/redux/reducers/user/initUser.ts +2 -2
- package/src/redux/reducers/user/setUserStatus.ts +2 -2
- package/src/redux/reducers/user/setUserValidToken.ts +2 -2
- package/src/redux/reducers/user.ts +11 -11
- package/src/redux/routerHistory.ts +6 -6
- package/src/redux/sagas/fetchModel.test.ts +2 -5
- package/src/redux/sagas/fetchModel.ts +86 -187
- package/src/redux/sagas/homogeneousRadioInputsSaga.ts +6 -6
- package/src/redux/sagas/initInputs.ts +110 -0
- package/src/redux/sagas/runner.ts +8 -6
- package/src/redux/sagas/saveData.ts +32 -28
- package/src/redux/sagas/setDefaults.ts +8 -8
- package/src/redux/sagas/setUserEmail.ts +46 -45
- package/src/redux/selectors/app.ts +34 -28
- package/src/redux/selectors/conditions.ts +41 -41
- package/src/redux/selectors/inputs.ts +10 -10
- package/src/redux/selectors/library.ts +17 -0
- package/src/redux/selectors/mandatories.ts +10 -10
- package/src/redux/selectors/references.ts +25 -21
- package/src/redux/selectors/selectors.ts +4 -4
- package/src/redux/selectors/smartscript.ts +6 -6
- package/src/redux/selectors/user.ts +8 -8
- package/src/redux/store.ts +42 -32
- package/src/service/api.manager.ts +53 -53
- package/src/service/auth.service.ts +2 -2
- package/src/service/pardot.service.ts +2 -2
- package/src/tests-misc/plugins/jestTestPlugin/after.tsx +1 -1
- package/src/tests-misc/plugins/jestTestPlugin/before.tsx +1 -1
- package/src/tests-misc/plugins/jestTestPlugin/index.ts +4 -4
- package/src/tests-misc/plugins/jestTestPlugin/title.tsx +2 -2
- package/src/tests-misc/themes/jestTestTheme/components/EmailComponent.tsx +1 -1
- package/src/tests-misc/themes/jestTestTheme/components/TermsheetComponent.tsx +1 -1
- package/src/tests-misc/themes/jestTestTheme/components/WizardComponent.tsx +1 -1
- package/src/tests-misc/themes/jestTestTheme/faltyIndex.ts +1 -1
- package/src/tests-misc/themes/jestTestTheme/faltyIndexLoader.ts +1 -1
- package/src/tests-misc/themes/jestTestTheme/index.ts +4 -4
- package/src/types/Actions.type.ts +63 -55
- package/src/types/Components.type.ts +4 -4
- package/src/types/State.type.ts +14 -14
- package/src/types/Termsheet.type.ts +4 -4
- package/src/types/api.type.ts +4 -4
- package/src/types/config.type.ts +3 -3
- package/src/types/getActions.type.ts +2 -2
- package/src/types/getConnectors.type.ts +2 -2
- package/src/types/getSelectors.type.ts +2 -2
- package/src/wizard-params.ts +17 -17
- package/tsconfig.json +1 -1
- package/dist/componentsConnectors/connector/connectorSelectors.js +0 -9
- package/dist/componentsConnectors/index.d.ts +0 -16
- package/dist/componentsConnectors/index.js +0 -16
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.js +0 -1
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/index.js +0 -2
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +0 -1
- package/dist/index.d.ts +0 -23
- package/dist/index.js +0 -23
- package/dist/libs/index.d.ts +0 -12
- package/dist/libs/index.js +0 -12
- package/dist/redux/actions/index.d.ts +0 -8
- package/dist/redux/actions/index.js +0 -8
- package/dist/redux/actions/sagas/index.d.ts +0 -3
- package/dist/redux/actions/sagas/index.js +0 -3
- package/dist/redux/constants/index.d.ts +0 -8
- package/dist/redux/constants/index.js +0 -8
- package/dist/redux/constants/sagas/index.d.ts +0 -3
- package/dist/redux/constants/sagas/index.js +0 -3
- package/dist/redux/index.d.ts +0 -4
- package/dist/redux/index.js +0 -4
- package/dist/redux/selectors/index.d.ts +0 -7
- package/dist/redux/selectors/index.js +0 -7
- package/dist/service/index.d.ts +0 -3
- package/dist/service/index.js +0 -3
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.js +0 -10
- package/src/componentsConnectors/connector/connectorSelectors.ts +0 -19
- package/src/componentsConnectors/index.ts +0 -16
- package/src/constants/index.ts +0 -1
- package/src/helpers/index.ts +0 -2
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -47
- package/src/libs/index.ts +0 -12
- package/src/redux/actions/index.ts +0 -8
- package/src/redux/actions/sagas/index.ts +0 -3
- package/src/redux/constants/index.ts +0 -8
- package/src/redux/constants/sagas/index.ts +0 -3
- package/src/redux/index.ts +0 -4
- package/src/redux/selectors/index.ts +0 -7
- package/src/service/index.ts +0 -3
- package/src/types/index.ts +0 -10
|
@@ -1,38 +1,34 @@
|
|
|
1
|
-
import { call, put, takeLatest, select, fork, join } from
|
|
2
|
-
import Cookies from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { initReferencesAction } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { enableSmartscriptAction } from '../actions/smartscript';
|
|
24
|
-
import { FETCH_MODEL, FETCH_MODEL_PREREQUISITES, } from '../constants/sagas/model';
|
|
25
|
-
import { fetchModelAction } from '../actions/sagas/model';
|
|
1
|
+
import { call, put, takeLatest, select, fork, join } from "redux-saga/effects";
|
|
2
|
+
import Cookies from "universal-cookie";
|
|
3
|
+
import { initInputsAction } from "../actions/inputs";
|
|
4
|
+
import { initMetaAction, initPaginationAction, initInstanceAction, fetchModelSucceededAction, fetchModelFailedAction, initCustomizationMetaAction, fetchModelUnhealthyAction, initCustomizationAutoDefaultAction, fetchModelUserLockedAction, updateAvailableAppStatesAction, goPageAction, fetchModelNonBlockingAction, setModelUuidAction, } from "../actions/app";
|
|
5
|
+
import { initReferencesAction } from "../actions/references";
|
|
6
|
+
import { selectSectionConditionValue } from "../selectors/conditions";
|
|
7
|
+
import { selectAllSectionsReferences } from "../selectors/references";
|
|
8
|
+
import { selectInstanceUniqid, isStepAvailable } from "../selectors/app";
|
|
9
|
+
import { getConfig, updateConfig } from "../../config";
|
|
10
|
+
import { isLevelAccessibleForUser } from "../selectors/user";
|
|
11
|
+
import { PathReader } from "../../libs/PathReader";
|
|
12
|
+
import { IntputsInitiator } from "../../libs/InputsInitiator";
|
|
13
|
+
import { initUserAction, setUserStatusAction } from "../actions/user";
|
|
14
|
+
import { OvcConverter } from "../../libs/OvcConverter";
|
|
15
|
+
import Globals from "../../Globals";
|
|
16
|
+
import { getFetchModelArguments, getCreateInstanceArguments, getClientConfigArguments, getWizardConfigArguments, getModelInformationArguments, } from "../../service/api.manager";
|
|
17
|
+
import { loadTheme, setWizardTheme } from "../../ThemeLoader";
|
|
18
|
+
import { loadPlugins } from "../../PluginLoader";
|
|
19
|
+
import { enableSmartscriptAction } from "../actions/smartscript";
|
|
20
|
+
import { FETCH_MODEL, FETCH_MODEL_PREREQUISITES, } from "../constants/sagas/model";
|
|
21
|
+
import { fetchModelAction } from "../actions/sagas/model";
|
|
22
|
+
import { initInputsDecorator } from "./initInputs";
|
|
26
23
|
const cookies = new Cookies();
|
|
27
|
-
const getValues = (arr1, arr2) => arr1.map((v, index) => arr2[index] || v);
|
|
28
24
|
function* setFetchModelToNonBlocking(firstCurrentAppState) {
|
|
29
25
|
yield put(initPaginationAction({
|
|
30
26
|
currentPage: 1,
|
|
31
27
|
greatestPage: 1,
|
|
32
28
|
currentSectionId: 0,
|
|
33
29
|
availableSections: [],
|
|
34
|
-
currentAppState: firstCurrentAppState ||
|
|
35
|
-
availableAppStates: [
|
|
30
|
+
currentAppState: firstCurrentAppState || "wizard",
|
|
31
|
+
availableAppStates: ["wizard"],
|
|
36
32
|
}));
|
|
37
33
|
const state = yield select((s) => s);
|
|
38
34
|
const pathReader = new PathReader(state);
|
|
@@ -45,7 +41,7 @@ function* getClientConfig(permalink, uniqid) {
|
|
|
45
41
|
if (clientConfigResponse === undefined) {
|
|
46
42
|
throw new Error(`Unable to fetch client config, we did not receive any response`);
|
|
47
43
|
}
|
|
48
|
-
clientConfigResponse = yield call([clientConfigResponse,
|
|
44
|
+
clientConfigResponse = yield call([clientConfigResponse, "json"]);
|
|
49
45
|
if ((_a = clientConfigResponse.clientConfig.metadata) === null || _a === void 0 ? void 0 : _a.apiEndpoint) {
|
|
50
46
|
updateConfig(Object.assign(Object.assign({}, getConfig()), { apiEndpoint: (_b = clientConfigResponse.clientConfig.metadata) === null || _b === void 0 ? void 0 : _b.apiEndpoint }));
|
|
51
47
|
}
|
|
@@ -57,7 +53,7 @@ function* getClientConfig(permalink, uniqid) {
|
|
|
57
53
|
updateConfig(Object.assign(Object.assign({}, getConfig()), { authCookieDomain: ((_e = clientConfigResponse.clientConfig.metadata) === null || _e === void 0 ? void 0 : _e.authCookieDomain) ||
|
|
58
54
|
process.env.REACT_APP_COOKIES_ALL_SUBDOMAIN }));
|
|
59
55
|
if (/compactTheme/.test(window.location.href)) {
|
|
60
|
-
yield call(setWizardTheme, { name:
|
|
56
|
+
yield call(setWizardTheme, { name: "compact" });
|
|
61
57
|
}
|
|
62
58
|
else if ((_g = (_f = clientConfigResponse.clientConfig.metadata) === null || _f === void 0 ? void 0 : _f.theme) === null || _g === void 0 ? void 0 : _g.name) {
|
|
63
59
|
yield call(setWizardTheme, clientConfigResponse.clientConfig.metadata.theme);
|
|
@@ -80,12 +76,12 @@ function* getWizardConfig(permalink, uniqidParam, prefix, queryParams) {
|
|
|
80
76
|
if (response === undefined) {
|
|
81
77
|
throw new Error(`Unable to fetch wizard config, we did not receive any response`);
|
|
82
78
|
}
|
|
83
|
-
response = yield call([response,
|
|
79
|
+
response = yield call([response, "json"]);
|
|
84
80
|
if (response.redirect) {
|
|
85
81
|
window.onbeforeunload = null;
|
|
86
82
|
window.location.href = `${response.redirect}${response.redirectParams
|
|
87
83
|
? `?redirectUrl=${encodeURIComponent(window.location.href)}`
|
|
88
|
-
:
|
|
84
|
+
: ""}`;
|
|
89
85
|
}
|
|
90
86
|
yield put(setModelUuidAction(response.modelUuid));
|
|
91
87
|
return { modelUuid: response.modelUuid };
|
|
@@ -96,9 +92,9 @@ function* fetchModelInformation(modelUuid, permalink, prefix, queryParams) {
|
|
|
96
92
|
if (response === undefined) {
|
|
97
93
|
throw new Error(`Unable to fetch wizard config, we did not receive any response`);
|
|
98
94
|
}
|
|
99
|
-
response = yield call([response,
|
|
100
|
-
if (response.status ===
|
|
101
|
-
if (Globals.
|
|
95
|
+
response = yield call([response, "json"]);
|
|
96
|
+
if (response.status === "unhealthy") {
|
|
97
|
+
if (Globals.appEnv === "production") {
|
|
102
98
|
yield put(fetchModelFailedAction());
|
|
103
99
|
}
|
|
104
100
|
else
|
|
@@ -108,13 +104,13 @@ function* fetchModelInformation(modelUuid, permalink, prefix, queryParams) {
|
|
|
108
104
|
const meta = Object.assign(Object.assign({}, response.meta), { permalink,
|
|
109
105
|
prefix });
|
|
110
106
|
yield put(initMetaAction(meta));
|
|
111
|
-
document.title = `${meta.title} - ${((_a = getConfig().brand) === null || _a === void 0 ? void 0 : _a.name) ||
|
|
107
|
+
document.title = `${meta.title} - ${((_a = getConfig().brand) === null || _a === void 0 ? void 0 : _a.name) || "LegalPlace"}`;
|
|
112
108
|
const { references, customization, smartScript } = response;
|
|
113
109
|
yield put(initReferencesAction(references));
|
|
114
110
|
if (customization.disableAutoDefault !== undefined)
|
|
115
111
|
yield put(initCustomizationAutoDefaultAction(customization.disableAutoDefault));
|
|
116
|
-
if (typeof customization ===
|
|
117
|
-
typeof customization.meta ===
|
|
112
|
+
if (typeof customization === "object" &&
|
|
113
|
+
typeof customization.meta === "object")
|
|
118
114
|
yield put(initCustomizationMetaAction(customization.meta));
|
|
119
115
|
return { ovc: response.ovc, references, meta: response.meta, smartScript };
|
|
120
116
|
}
|
|
@@ -122,23 +118,23 @@ function* fetchInstanceInformation(appStates, permalink, uniqid, uniqidParam, pr
|
|
|
122
118
|
var _a, _b;
|
|
123
119
|
let response = yield call(fetch, ...getFetchModelArguments(permalink, uniqidParam, prefix, queryParams));
|
|
124
120
|
if (response === undefined) {
|
|
125
|
-
throw new Error(`Unable to fetch ${permalink}${uniqid && uniqid.trim().length > 0 ? `/${uniqid}` :
|
|
121
|
+
throw new Error(`Unable to fetch ${permalink}${uniqid && uniqid.trim().length > 0 ? `/${uniqid}` : ""}, we did not recieve any response`);
|
|
126
122
|
}
|
|
127
|
-
response = yield call([response,
|
|
123
|
+
response = yield call([response, "json"]);
|
|
128
124
|
if (response.redirect) {
|
|
129
125
|
window.onbeforeunload = null;
|
|
130
126
|
window.location.href = `${response.redirect}${response.redirectParams
|
|
131
127
|
? `?redirectUrl=${encodeURIComponent(window.location.href)}`
|
|
132
|
-
:
|
|
128
|
+
: ""}`;
|
|
133
129
|
}
|
|
134
|
-
if (response.errors || response.status ===
|
|
135
|
-
throw new Error(`Unable to fetch ${permalink}${uniqid && uniqid.trim().length > 0 ? `/${uniqid}` :
|
|
130
|
+
if (response.errors || response.status === "error") {
|
|
131
|
+
throw new Error(`Unable to fetch ${permalink}${uniqid && uniqid.trim().length > 0 ? `/${uniqid}` : ""}`);
|
|
136
132
|
}
|
|
137
|
-
if (response.instance && response.instance.appType ===
|
|
138
|
-
const abCookie = cookies.get(
|
|
139
|
-
if (abCookie && abCookie.split(
|
|
140
|
-
cookies.set(
|
|
141
|
-
path:
|
|
133
|
+
if (response.instance && response.instance.appType === "react") {
|
|
134
|
+
const abCookie = cookies.get("X-Source");
|
|
135
|
+
if (abCookie && abCookie.split("/").length > 1) {
|
|
136
|
+
cookies.set("X-Source", `${abCookie.split("/")[0]}/wizard`, {
|
|
137
|
+
path: "/",
|
|
142
138
|
encode: (value) => value,
|
|
143
139
|
});
|
|
144
140
|
window.onbeforeunload = () => { };
|
|
@@ -146,51 +142,51 @@ function* fetchInstanceInformation(appStates, permalink, uniqid, uniqidParam, pr
|
|
|
146
142
|
}
|
|
147
143
|
}
|
|
148
144
|
const instance = {
|
|
149
|
-
dataStatus:
|
|
150
|
-
uniqid: uniqid ||
|
|
145
|
+
dataStatus: "saved",
|
|
146
|
+
uniqid: uniqid || "",
|
|
151
147
|
draft: response.instance && response.instance.draft,
|
|
152
148
|
companyId: (_a = response.instance) === null || _a === void 0 ? void 0 : _a.companyId,
|
|
153
149
|
employeeId: (_b = response.instance) === null || _b === void 0 ? void 0 : _b.employeeId,
|
|
154
150
|
isOrderHandled: response.instance && response.instance.isOrderHandled,
|
|
155
151
|
isPaid: response.instance &&
|
|
156
|
-
(response.instance.isPaid.toString() ===
|
|
152
|
+
(response.instance.isPaid.toString() === "1" ||
|
|
157
153
|
response.instance.isPaid === true),
|
|
158
154
|
steps: response.instance &&
|
|
159
|
-
(typeof response.instance.steps ===
|
|
155
|
+
(typeof response.instance.steps === "string" ||
|
|
160
156
|
Array.isArray(response.instance.steps))
|
|
161
157
|
? response.instance.steps
|
|
162
158
|
: [1],
|
|
163
159
|
};
|
|
164
160
|
if (pathReader.modelVersion)
|
|
165
|
-
instance.steps =
|
|
161
|
+
instance.steps = "*";
|
|
166
162
|
yield put(initInstanceAction(instance));
|
|
167
163
|
const availableAppStates = appStates || getConfig().appStates;
|
|
168
|
-
if (typeof response.user ===
|
|
169
|
-
typeof response.user.email ===
|
|
170
|
-
typeof response.user.displayName ===
|
|
171
|
-
typeof response.user.level ===
|
|
164
|
+
if (typeof response.user === "object" &&
|
|
165
|
+
typeof response.user.email === "string" &&
|
|
166
|
+
typeof response.user.displayName === "string" &&
|
|
167
|
+
typeof response.user.level === "string") {
|
|
172
168
|
yield put(initUserAction({
|
|
173
169
|
email: response.user.email,
|
|
174
170
|
displayName: response.user.displayName,
|
|
175
171
|
level: response.user.level,
|
|
176
172
|
}));
|
|
177
|
-
yield put(setUserStatusAction(
|
|
178
|
-
if (availableAppStates.includes(
|
|
179
|
-
availableAppStates.splice(availableAppStates.indexOf(
|
|
173
|
+
yield put(setUserStatusAction("authenticated"));
|
|
174
|
+
if (availableAppStates.includes("email"))
|
|
175
|
+
availableAppStates.splice(availableAppStates.indexOf("email"), 1);
|
|
180
176
|
}
|
|
181
|
-
if (instance.draft === false && !isLevelAccessibleForUser(
|
|
177
|
+
if (instance.draft === false && !isLevelAccessibleForUser("USER")) {
|
|
182
178
|
yield put(fetchModelUserLockedAction());
|
|
183
179
|
}
|
|
184
180
|
return { instance, availableAppStates, ovc: response.ovc };
|
|
185
181
|
}
|
|
186
182
|
function* createInstance(enableShadowInstance, modelInformation, uniqid, permalink, pathReader, urlParams) {
|
|
187
183
|
const { meta } = modelInformation;
|
|
188
|
-
const isShadowInstanceEnabled = typeof enableShadowInstance !==
|
|
184
|
+
const isShadowInstanceEnabled = typeof enableShadowInstance !== "undefined"
|
|
189
185
|
? enableShadowInstance
|
|
190
186
|
: getConfig().enableShadowInstance;
|
|
191
187
|
const instance = {
|
|
192
|
-
dataStatus:
|
|
193
|
-
uniqid: uniqid ||
|
|
188
|
+
dataStatus: "saved",
|
|
189
|
+
uniqid: uniqid || "",
|
|
194
190
|
draft: false,
|
|
195
191
|
companyId: undefined,
|
|
196
192
|
employeeId: undefined,
|
|
@@ -199,23 +195,23 @@ function* createInstance(enableShadowInstance, modelInformation, uniqid, permali
|
|
|
199
195
|
steps: [1],
|
|
200
196
|
};
|
|
201
197
|
if (pathReader.modelVersion)
|
|
202
|
-
instance.steps =
|
|
198
|
+
instance.steps = "*";
|
|
203
199
|
if (isShadowInstanceEnabled === true &&
|
|
204
200
|
(instance.uniqid === undefined ||
|
|
205
|
-
(typeof instance.uniqid ===
|
|
206
|
-
const searchParams = `${urlParams && urlParams.get(
|
|
207
|
-
? `?contractName=${urlParams.get(
|
|
208
|
-
:
|
|
201
|
+
(typeof instance.uniqid === "string" && instance.uniqid.trim() === ""))) {
|
|
202
|
+
const searchParams = `${urlParams && urlParams.get("contractName") && urlParams.get("userId")
|
|
203
|
+
? `?contractName=${urlParams.get("contractName")}&userId=${urlParams.get("userId")}`
|
|
204
|
+
: ""}`;
|
|
209
205
|
const res = yield call(fetch, ...getCreateInstanceArguments(permalink, searchParams, meta.modelVersion));
|
|
210
|
-
const instanceResponse = yield call([res,
|
|
211
|
-
if (instanceResponse.status !==
|
|
212
|
-
throw new Error(
|
|
206
|
+
const instanceResponse = yield call([res, "json"]);
|
|
207
|
+
if (instanceResponse.status !== "SUCCESS") {
|
|
208
|
+
throw new Error("Unable to create instance");
|
|
213
209
|
}
|
|
214
210
|
instance.uniqid = instanceResponse.uniqid;
|
|
215
211
|
instance.isPaid = instanceResponse.isPaid === true;
|
|
216
212
|
instance.isOrderHandled = instanceResponse.isOrderHandled;
|
|
217
213
|
instance.steps =
|
|
218
|
-
typeof instanceResponse.steps ===
|
|
214
|
+
typeof instanceResponse.steps === "string" ||
|
|
219
215
|
Array.isArray(instanceResponse.steps)
|
|
220
216
|
? instanceResponse.steps
|
|
221
217
|
: [1];
|
|
@@ -224,22 +220,18 @@ function* createInstance(enableShadowInstance, modelInformation, uniqid, permali
|
|
|
224
220
|
}
|
|
225
221
|
function* fetchModelPrerequisites(action) {
|
|
226
222
|
const { permalink, prefix } = action;
|
|
227
|
-
if (!permalink && window.location.href.includes(
|
|
223
|
+
if (!permalink && window.location.href.includes("smartscript"))
|
|
228
224
|
return;
|
|
229
225
|
const uniqid = selectInstanceUniqid() || getConfig().uniqid;
|
|
230
|
-
const uniqidParam = uniqid && uniqid.trim().length > 0 ? `/${uniqid}` :
|
|
226
|
+
const uniqidParam = uniqid && uniqid.trim().length > 0 ? `/${uniqid}` : "";
|
|
231
227
|
const urlParams = new URLSearchParams(window.location.search);
|
|
232
228
|
const state = yield select((s) => s);
|
|
233
229
|
const pathReader = new PathReader(state);
|
|
234
230
|
const queryParams = new URLSearchParams(window.location.search);
|
|
235
231
|
if (pathReader.modelVersion)
|
|
236
|
-
queryParams.set(
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
const [clientConfigReturnValue, wizardConfig] = yield join([
|
|
240
|
-
clientConfigTask,
|
|
241
|
-
wizardConfigTask,
|
|
242
|
-
]);
|
|
232
|
+
queryParams.set("version", pathReader.modelVersion);
|
|
233
|
+
const clientConfigReturnValue = yield call(getClientConfig, permalink, uniqid || "");
|
|
234
|
+
const wizardConfig = yield call(getWizardConfig, permalink, uniqidParam, prefix, queryParams);
|
|
243
235
|
yield put(fetchModelAction(permalink, prefix, uniqid, uniqidParam, queryParams, pathReader, urlParams, clientConfigReturnValue, wizardConfig));
|
|
244
236
|
}
|
|
245
237
|
function* fetchModelDecorator(action) {
|
|
@@ -270,68 +262,24 @@ function* fetchModelDecorator(action) {
|
|
|
270
262
|
}
|
|
271
263
|
const { references, smartScript } = modelInformation;
|
|
272
264
|
let ovc = ovcFromApi || null;
|
|
273
|
-
if (typeof ovc ===
|
|
265
|
+
if (typeof ovc === "object" &&
|
|
274
266
|
ovc !== null &&
|
|
275
267
|
Object.keys(ovc).length === 0)
|
|
276
268
|
ovc = null;
|
|
277
269
|
if (OvcConverter.isOvc(ovc))
|
|
278
270
|
ovc = OvcConverter.convertToOptionsVariables(ovc, references);
|
|
279
271
|
const inputs = new IntputsInitiator(references, ovc).getInputs();
|
|
280
|
-
|
|
281
|
-
yield put(initConditionsAction(conditions));
|
|
282
|
-
const optionsIds = Object.keys(inputs.options);
|
|
283
|
-
for (let i = 0; i < optionsIds.length; i += 1) {
|
|
284
|
-
let optionId = parseInt(optionsIds[i], 10);
|
|
285
|
-
let values = inputs.options[optionId];
|
|
286
|
-
yield put(initOptionAction(optionId, values));
|
|
287
|
-
const { meta: meta2 } = references.options[optionId];
|
|
288
|
-
const { type } = meta2;
|
|
289
|
-
let { mandatory } = meta2;
|
|
290
|
-
let sendOptionAction = true;
|
|
291
|
-
if (['checkbox', 'radio'].includes(type)) {
|
|
292
|
-
if (type === 'radio') {
|
|
293
|
-
const { parents } = selectOptionRelations(optionId);
|
|
294
|
-
const parentId = parents[0];
|
|
295
|
-
const isMandatoryOption = selectMandatoryOptionItem(parentId);
|
|
296
|
-
if (typeof isMandatoryOption !== 'undefined') {
|
|
297
|
-
const mandatoryOption = selectMandatoryOption(parentId);
|
|
298
|
-
sendOptionAction = !mandatoryOption.every((v) => v === true);
|
|
299
|
-
if (sendOptionAction === true && mandatoryOption) {
|
|
300
|
-
if (values.length >= mandatoryOption.length) {
|
|
301
|
-
values = getValues(values, [...mandatoryOption]);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
values = getValues([...mandatoryOption], values);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
mandatory = references.options[parentId].meta.mandatory;
|
|
309
|
-
optionId = parentId;
|
|
310
|
-
}
|
|
311
|
-
if (mandatory === true && sendOptionAction === true) {
|
|
312
|
-
yield put(initMandatoryOptionAction(optionId, values));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
const variablesIds = Object.keys(inputs.variables);
|
|
317
|
-
for (let i = 0; i < variablesIds.length; i += 1) {
|
|
318
|
-
const variableId = variablesIds[i];
|
|
319
|
-
const values = inputs.variables[variableId];
|
|
320
|
-
yield put(initVariableAction(parseInt(variableId, 10), values));
|
|
321
|
-
if (references.variables[variableId].mandatory === true)
|
|
322
|
-
yield put(initMandatoryVariableAction(parseInt(variableId, 10), values.map((value) => `${value}`.trim().length > 0)));
|
|
323
|
-
}
|
|
324
|
-
yield put(initConditionsAction(conditions));
|
|
272
|
+
yield call(initInputsDecorator, initInputsAction(inputs, references));
|
|
325
273
|
const sectionsReferences = selectAllSectionsReferences();
|
|
326
274
|
if (sectionsReferences === undefined)
|
|
327
|
-
throw new Error(
|
|
275
|
+
throw new Error("Sections references not found");
|
|
328
276
|
const availableSections = Object.keys(sectionsReferences)
|
|
329
277
|
.filter((sectionId) => {
|
|
330
278
|
const condition = selectSectionConditionValue(parseInt(sectionId, 10)) !== false;
|
|
331
279
|
const sectionReference = sectionsReferences[sectionId];
|
|
332
280
|
const sectionGrantLevel = sectionReference.grantLevel
|
|
333
281
|
? sectionReference.grantLevel
|
|
334
|
-
:
|
|
282
|
+
: "GUEST";
|
|
335
283
|
const grant = isLevelAccessibleForUser(sectionGrantLevel);
|
|
336
284
|
const availableStep = isStepAvailable(sectionReference.step);
|
|
337
285
|
return condition && grant && availableStep;
|
|
@@ -342,7 +290,7 @@ function* fetchModelDecorator(action) {
|
|
|
342
290
|
greatestPage: 1,
|
|
343
291
|
currentSectionId: availableSections[0],
|
|
344
292
|
availableSections,
|
|
345
|
-
currentAppState: firstCurrentAppState ||
|
|
293
|
+
currentAppState: firstCurrentAppState || "wizard",
|
|
346
294
|
availableAppStates,
|
|
347
295
|
}));
|
|
348
296
|
if (smartScript === true) {
|
|
@@ -11,10 +11,9 @@ const meta = {
|
|
|
11
11
|
title: 'Test model',
|
|
12
12
|
permalink,
|
|
13
13
|
};
|
|
14
|
-
require('jest-fetch-mock').enableMocks();
|
|
15
14
|
jest.mock('../../config', () => ({
|
|
16
15
|
getConfig: () => ({
|
|
17
|
-
apiEndpoint:
|
|
16
|
+
apiEndpoint: 'https://api.mock/api/v1/',
|
|
18
17
|
router: {
|
|
19
18
|
wizardPath: '/:permalink/questionnaire/:page([0-9]+|sommaire)',
|
|
20
19
|
wizardInstancePath: '/:permalink/questionnaire/:uniqid([0-9a-zA-Z]+)/:page([0-9]+|sommaire)',
|
|
@@ -50,7 +49,7 @@ describe('Fetch model saga', () => {
|
|
|
50
49
|
it('Sends fetch client config request to API', () => {
|
|
51
50
|
fetchMock.mockResponseOnce(JSON.stringify({ model, meta }));
|
|
52
51
|
store.dispatch(fetchModelPrerequisitesAction(permalink));
|
|
53
|
-
expect(fetchMock.mock.calls.length).toEqual(
|
|
52
|
+
expect(fetchMock.mock.calls.length).toEqual(1);
|
|
54
53
|
expect(fetchMock.mock.calls[0][0]).toEqual(`${mockApiEndpoint}client-config?permalink=${permalink}&disableOnBoarding=true`);
|
|
55
54
|
});
|
|
56
55
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { put, takeLatest } from
|
|
2
|
-
import { UPDATE_OPTION_INPUT } from
|
|
3
|
-
import { selectRadioSiblings } from
|
|
4
|
-
import { updateOptionAction } from
|
|
5
|
-
import { selectOptionInputByIndex } from
|
|
1
|
+
import { put, takeLatest } from "redux-saga/effects";
|
|
2
|
+
import { UPDATE_OPTION_INPUT } from "../constants/inputs";
|
|
3
|
+
import { selectRadioSiblings } from "../selectors/references";
|
|
4
|
+
import { updateOptionAction } from "../actions/inputs";
|
|
5
|
+
import { selectOptionInputByIndex } from "../selectors/inputs";
|
|
6
6
|
function* homogeneousRadioInputsDecorator(action) {
|
|
7
7
|
const { id, index, value } = action;
|
|
8
8
|
if (value === true) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StateType } from "../../types/State.type";
|
|
2
|
+
import { ActionsType } from "../../types/Actions.type";
|
|
3
|
+
export declare function initInputsDecorator(action: ActionsType.Inputs.initInputs): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<ActionsType.Conditions.initConditions> | import("redux-saga/effects").PutEffect<ActionsType.Inputs.initOption> | import("redux-saga/effects").PutEffect<ActionsType.Mandatories.initMandatoryOption> | import("redux-saga/effects").PutEffect<ActionsType.Inputs.initVariable> | import("redux-saga/effects").PutEffect<ActionsType.Mandatories.initMandatoryVariable>, void, StateType>;
|
|
4
|
+
declare function initInputsSaga(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
5
|
+
export default initInputsSaga;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { select, takeLatest, put } from "redux-saga/effects";
|
|
2
|
+
import { INIT_INPUTS } from "../constants/inputs";
|
|
3
|
+
import { selectMandatoryOptionItem, selectMandatoryOption, } from "../selectors/mandatories";
|
|
4
|
+
import { initMandatoryOptionAction, initMandatoryVariableAction, } from "../actions/mandatories";
|
|
5
|
+
import { initOptionAction, initVariableAction } from "../actions/inputs";
|
|
6
|
+
import { initConditionsAction } from "../actions/conditions";
|
|
7
|
+
import { ConditionsInitiator } from "../../libs/ConditionsInitiator";
|
|
8
|
+
import { selectOptionRelations } from "../selectors/references";
|
|
9
|
+
const getValues = (arr1, arr2) => arr1.map((v, index) => arr2[index] || v);
|
|
10
|
+
export function* initInputsDecorator(action) {
|
|
11
|
+
const state = yield select((s) => s);
|
|
12
|
+
const references = action.references ? action.references : state.references;
|
|
13
|
+
const { inputs } = action;
|
|
14
|
+
const conditions = new ConditionsInitiator(references, inputs).getConditions();
|
|
15
|
+
yield put(initConditionsAction(conditions));
|
|
16
|
+
const optionsIds = Object.keys(inputs.options);
|
|
17
|
+
for (let i = 0; i < optionsIds.length; i += 1) {
|
|
18
|
+
let optionId = parseInt(optionsIds[i], 10);
|
|
19
|
+
let values = inputs.options[optionId];
|
|
20
|
+
yield put(initOptionAction(optionId, values));
|
|
21
|
+
const { meta: meta2 } = references.options[optionId];
|
|
22
|
+
const { type } = meta2;
|
|
23
|
+
let { mandatory } = meta2;
|
|
24
|
+
let sendOptionAction = true;
|
|
25
|
+
if (["checkbox", "radio"].includes(type)) {
|
|
26
|
+
if (type === "radio") {
|
|
27
|
+
const { parents } = selectOptionRelations(optionId);
|
|
28
|
+
const parentId = parents[0];
|
|
29
|
+
const isMandatoryOption = selectMandatoryOptionItem(parentId);
|
|
30
|
+
if (typeof isMandatoryOption !== "undefined") {
|
|
31
|
+
const mandatoryOption = selectMandatoryOption(parentId);
|
|
32
|
+
sendOptionAction = !mandatoryOption.every((v) => v === true);
|
|
33
|
+
if (sendOptionAction === true && mandatoryOption) {
|
|
34
|
+
if (values.length >= mandatoryOption.length) {
|
|
35
|
+
values = getValues(values, [...mandatoryOption]);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
values = getValues([...mandatoryOption], values);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
mandatory = references.options[parentId].meta.mandatory;
|
|
43
|
+
optionId = parentId;
|
|
44
|
+
}
|
|
45
|
+
if (mandatory === true && sendOptionAction === true) {
|
|
46
|
+
yield put(initMandatoryOptionAction(optionId, values));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const variablesIds = Object.keys(inputs.variables);
|
|
51
|
+
for (let i = 0; i < variablesIds.length; i += 1) {
|
|
52
|
+
const variableId = variablesIds[i];
|
|
53
|
+
const values = inputs.variables[variableId];
|
|
54
|
+
yield put(initVariableAction(parseInt(variableId, 10), values));
|
|
55
|
+
if (references.variables[variableId].mandatory === true)
|
|
56
|
+
yield put(initMandatoryVariableAction(parseInt(variableId, 10), values.map((value) => `${value}`.trim().length > 0)));
|
|
57
|
+
}
|
|
58
|
+
yield put(initConditionsAction(conditions));
|
|
59
|
+
}
|
|
60
|
+
function* initInputsSaga() {
|
|
61
|
+
yield takeLatest(INIT_INPUTS, initInputsDecorator);
|
|
62
|
+
}
|
|
63
|
+
export default initInputsSaga;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SagaMiddleware } from
|
|
1
|
+
import { SagaMiddleware } from "@redux-saga/core";
|
|
2
2
|
export declare const sagasRunner: (sagaMiddleware: SagaMiddleware<Record<string, unknown>>) => void;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import fetchModelSaga from
|
|
2
|
-
import setDefaultsSaga from
|
|
3
|
-
import saveDataSaga from
|
|
4
|
-
import homogeneousRadioInputsSaga from
|
|
5
|
-
import setUserEmailSaga from
|
|
1
|
+
import fetchModelSaga from "./fetchModel";
|
|
2
|
+
import setDefaultsSaga from "./setDefaults";
|
|
3
|
+
import saveDataSaga from "./saveData";
|
|
4
|
+
import homogeneousRadioInputsSaga from "./homogeneousRadioInputsSaga";
|
|
5
|
+
import setUserEmailSaga from "./setUserEmail";
|
|
6
|
+
import initInputsSaga from "./initInputs";
|
|
6
7
|
const sagas = [
|
|
7
8
|
fetchModelSaga,
|
|
8
9
|
setDefaultsSaga,
|
|
9
10
|
saveDataSaga,
|
|
10
11
|
setUserEmailSaga,
|
|
11
12
|
homogeneousRadioInputsSaga,
|
|
13
|
+
initInputsSaga,
|
|
12
14
|
];
|
|
13
15
|
export const sagasRunner = (sagaMiddleware) => {
|
|
14
16
|
sagas.forEach((saga) => sagaMiddleware.run(saga));
|
|
@@ -1,46 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { call, put, takeLatest } from "redux-saga/effects";
|
|
11
|
+
import { v4 as uuid } from "uuid";
|
|
12
|
+
import { setDataStatus } from "../actions/app";
|
|
13
|
+
import { selectPermalink, selectInstanceUniqid, selectDocumentTitle, selectInstanceIsPaid, } from "../selectors/app";
|
|
14
|
+
import { SAVE_DATA } from "../constants/sagas/data";
|
|
15
|
+
import { selectInputs } from "../selectors/inputs";
|
|
16
|
+
import { OvcConverter } from "../../libs/OvcConverter";
|
|
17
|
+
import { updateInstanceArguments } from "../../service/api.manager";
|
|
18
|
+
import { getSendinblueIdentifyAttributes } from "../../helpers/sendinblueHelper";
|
|
19
|
+
import { getConfig } from "../../config";
|
|
20
|
+
import { selectUserEmail } from "../selectors/user";
|
|
21
|
+
const getSendinblueData = (uniqid, paid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
22
|
const email = selectUserEmail();
|
|
14
|
-
const apiEndpoint = getConfig().apiEndpoint + (/\/$/.test(getConfig().apiEndpoint) ?
|
|
23
|
+
const apiEndpoint = getConfig().apiEndpoint + (/\/$/.test(getConfig().apiEndpoint) ? "" : "/");
|
|
15
24
|
const ovc = OvcConverter.convertToOvc(selectInputs());
|
|
16
25
|
const nbFilledVars = Object.keys(ovc.v).reduce((p, c) => {
|
|
17
26
|
const currentValue = ovc.v[c];
|
|
18
27
|
const o = Array.isArray(currentValue)
|
|
19
|
-
? currentValue.reduce((_p, _c) => _p + (_c !==
|
|
20
|
-
: currentValue !==
|
|
28
|
+
? currentValue.reduce((_p, _c) => _p + (_c !== "" ? 1 : 0), 0)
|
|
29
|
+
: currentValue !== ""
|
|
21
30
|
? 1
|
|
22
31
|
: 0;
|
|
23
32
|
return p + o;
|
|
24
33
|
}, 0);
|
|
25
|
-
const attributes = getSendinblueIdentifyAttributes(uniqid, selectDocumentTitle(), nbFilledVars, paid, window.location.host);
|
|
34
|
+
const attributes = yield getSendinblueIdentifyAttributes(uniqid, selectDocumentTitle(), nbFilledVars, paid, window.location.host);
|
|
26
35
|
return [apiEndpoint, email, attributes];
|
|
27
|
-
};
|
|
36
|
+
});
|
|
28
37
|
function* saveDataDecorator(action) {
|
|
29
38
|
try {
|
|
30
|
-
yield put(setDataStatus(
|
|
39
|
+
yield put(setDataStatus("saving"));
|
|
31
40
|
const permalink = selectPermalink();
|
|
32
41
|
const uniqid = selectInstanceUniqid();
|
|
33
42
|
const response = yield call(fetch, ...updateInstanceArguments(permalink, uniqid, OvcConverter.convertToOvc(selectInputs()), action.confirmAnswer ? 0 : 1, action.additionalProperties));
|
|
34
|
-
const responseData = yield call([response,
|
|
43
|
+
const responseData = yield call([response, "json"]);
|
|
35
44
|
if (action.redirect === true) {
|
|
36
45
|
if (responseData.redirect_to) {
|
|
37
46
|
try {
|
|
38
|
-
const [apiEndpoint, email, attributes] = getSendinblueData
|
|
47
|
+
const [apiEndpoint, email, attributes] = yield call(getSendinblueData, [uniqid, selectInstanceIsPaid()]);
|
|
39
48
|
yield call(fetch, `${apiEndpoint}event/create/${uniqid}/${uuid()}`, {
|
|
40
|
-
method:
|
|
41
|
-
credentials:
|
|
49
|
+
method: "POST",
|
|
50
|
+
credentials: "include",
|
|
42
51
|
headers: {
|
|
43
|
-
|
|
52
|
+
"Content-Type": "application/json",
|
|
44
53
|
},
|
|
45
54
|
body: JSON.stringify({
|
|
46
55
|
email,
|
|
@@ -58,11 +67,11 @@ function* saveDataDecorator(action) {
|
|
|
58
67
|
window.location.href = action.redirectFallback;
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
|
-
yield put(setDataStatus(
|
|
70
|
+
yield put(setDataStatus("saved"));
|
|
62
71
|
}
|
|
63
72
|
catch (e) {
|
|
64
73
|
console.error(e);
|
|
65
|
-
yield put(setDataStatus(
|
|
74
|
+
yield put(setDataStatus("failed"));
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
function* saveDataSaga() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { call, put, takeLatest } from
|
|
2
|
-
import { selectCurrentPage, selectAvailableSections, selectCurrentSectionId, } from
|
|
3
|
-
import { selectSectionDefaults, selectRadioSiblings, } from
|
|
4
|
-
import { selectOptionInput, selectOptionInputByIndex, } from
|
|
5
|
-
import { updateOptionAction } from
|
|
6
|
-
import { goPageAction } from
|
|
7
|
-
import { selectOptionConditionValue } from
|
|
1
|
+
import { call, put, takeLatest } from "redux-saga/effects";
|
|
2
|
+
import { selectCurrentPage, selectAvailableSections, selectCurrentSectionId, } from "../selectors/app";
|
|
3
|
+
import { selectSectionDefaults, selectRadioSiblings, } from "../selectors/references";
|
|
4
|
+
import { selectOptionInput, selectOptionInputByIndex, } from "../selectors/inputs";
|
|
5
|
+
import { updateOptionAction } from "../actions/inputs";
|
|
6
|
+
import { goPageAction } from "../actions/app";
|
|
7
|
+
import { selectOptionConditionValue } from "../selectors/conditions";
|
|
8
8
|
function setOptionsDefaults(id, defaults, parentIndexes) {
|
|
9
9
|
let ActionsToDispatch = [];
|
|
10
10
|
const currentConditions = selectOptionConditionValue(id);
|
|
@@ -97,6 +97,6 @@ function* setDefaultOptions() {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
function* setDefaultsSaga() {
|
|
100
|
-
yield takeLatest(
|
|
100
|
+
yield takeLatest("SET_DEFAULTS", setDefaultOptions);
|
|
101
101
|
}
|
|
102
102
|
export default setDefaultsSaga;
|