@legalplace/wizardx-core 2.6.3 → 2.7.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 +43 -0
- package/dist/App.js +13 -4
- package/dist/PluginLoader.d.ts +3 -1
- package/dist/PluginLoader.js +12 -0
- package/dist/ThemeLoader.d.ts +2 -2
- package/dist/componentsConnectors/connectBox.d.ts +3 -1
- package/dist/componentsConnectors/connectDocument.d.ts +3 -1
- package/dist/componentsConnectors/connectHeader.d.ts +3 -1
- package/dist/componentsConnectors/connectMetaTitle.d.ts +3 -1
- package/dist/componentsConnectors/connectOption.d.ts +6 -2
- package/dist/componentsConnectors/connectOption.js +1 -1
- package/dist/componentsConnectors/connectPagination.d.ts +3 -1
- package/dist/componentsConnectors/connectPreview.d.ts +3 -1
- package/dist/componentsConnectors/connectProgress.d.ts +3 -1
- package/dist/componentsConnectors/connectRootOption.d.ts +3 -1
- package/dist/componentsConnectors/connectSection.d.ts +3 -1
- package/dist/componentsConnectors/connectSection.js +7 -10
- package/dist/componentsConnectors/connectSummary.d.ts +3 -1
- package/dist/componentsConnectors/connectSummaryItem.d.ts +3 -1
- package/dist/componentsConnectors/connectVariable.d.ts +6 -2
- package/dist/componentsConnectors/connectVariable.js +1 -1
- package/dist/componentsConnectors/connectWizardWrapper.d.ts +3 -1
- package/dist/componentsConnectors/connector/componentConnector.d.ts +5 -1
- package/dist/componentsConnectors/connector/componentConnector.js +44 -4
- package/dist/componentsConnectors/connector/index.d.ts +1 -0
- package/dist/componentsConnectors/connector/index.js +1 -0
- package/dist/componentsConnectors/index.d.ts +17 -0
- package/dist/componentsConnectors/index.js +17 -0
- package/dist/componentsConnectors/library.d.ts +43 -15
- package/dist/constants/phoneValidation.d.ts +0 -1
- package/dist/constants/phoneValidation.js +0 -1
- package/dist/helpers/apiEndpoint.d.ts +1 -0
- package/dist/helpers/apiEndpoint.js +4 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +4 -0
- package/dist/helpers/propsEqualityCheck.d.ts +1 -0
- package/dist/helpers/propsEqualityCheck.js +9 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/useActions.d.ts +2 -0
- package/dist/hooks/useActions.js +4 -0
- package/dist/hooks/useDispatch.d.ts +1 -0
- package/dist/hooks/useDispatch.js +4 -0
- package/dist/hooks/useSelectors.d.ts +2 -0
- package/dist/hooks/useSelectors.js +4 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/libs/EventsTracking.d.ts +0 -1
- package/dist/libs/EventsTracking.js +0 -18
- package/dist/libs/PathReader.d.ts +10 -6
- package/dist/libs/PathReader.js +47 -28
- package/dist/libs/index.d.ts +5 -0
- package/dist/libs/index.js +5 -0
- package/dist/redux/actions/index.d.ts +9 -0
- package/dist/redux/actions/index.js +9 -0
- package/dist/redux/actions/library.d.ts +59 -63
- package/dist/redux/actions/sagas/index.d.ts +3 -0
- package/dist/redux/actions/sagas/index.js +3 -0
- package/dist/redux/actions/sagas/model.d.ts +1 -5
- package/dist/redux/constants/app.d.ts +2 -0
- package/dist/redux/constants/app.js +2 -0
- package/dist/redux/constants/index.d.ts +8 -0
- package/dist/redux/constants/index.js +8 -0
- package/dist/redux/constants/sagas/index.d.ts +3 -0
- package/dist/redux/constants/sagas/index.js +3 -0
- package/dist/redux/index.d.ts +5 -0
- package/dist/redux/index.js +5 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.js +11 -5
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +120 -113
- package/dist/redux/middlewares/paginationWatcherMiddleware.js +2 -2
- package/dist/redux/middlewares/smartscriptMiddleware.js +8 -0
- package/dist/redux/reducers/pluginsStore.d.ts +3 -0
- package/dist/redux/reducers/pluginsStore.js +12 -0
- package/dist/redux/routerHistory.js +2 -2
- package/dist/redux/sagas/fetchModel.js +22 -6
- package/dist/redux/sagas/initInputs.js +6 -7
- package/dist/redux/sagas/saveData.js +3 -46
- package/dist/redux/sagas/setUserEmail.js +1 -28
- package/dist/redux/selectors/app.js +13 -18
- package/dist/redux/selectors/cache.d.ts +17 -0
- package/dist/redux/selectors/cache.js +35 -0
- package/dist/redux/selectors/conditions.js +7 -7
- package/dist/redux/selectors/index.d.ts +8 -0
- package/dist/redux/selectors/index.js +8 -0
- package/dist/redux/selectors/inputs.js +3 -3
- package/dist/redux/selectors/library.d.ts +2 -2
- package/dist/redux/selectors/references.js +26 -26
- package/dist/redux/selectors/selectors.d.ts +2 -2
- package/dist/redux/selectors/selectors.js +19 -8
- package/dist/redux/selectors/selectors.test.js +6 -6
- package/dist/redux/selectors/user.js +5 -5
- package/dist/redux/store.d.ts +1 -1
- package/dist/redux/store.js +12 -4
- package/dist/service/api.manager.d.ts +1 -6
- package/dist/service/index.d.ts +3 -0
- package/dist/service/index.js +3 -0
- package/dist/types/PluginConfig.type.d.ts +57 -0
- package/dist/types/PluginConfig.type.js +1 -0
- package/dist/types/State.type.d.ts +6 -0
- package/dist/types/config.type.d.ts +3 -1
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.js +11 -0
- package/package.json +11 -12
- package/.depcheckrc +0 -1
- package/.eslintignore +0 -2
- package/.eslintrc +0 -5
- package/__mocks__/fileMock.js +0 -1
- package/babel.config.json +0 -3
- package/dist/helpers/sendinblueHelper.d.ts +0 -4
- package/dist/helpers/sendinblueHelper.js +0 -46
- package/dist/libs/Extracts.d.ts +0 -20
- package/dist/libs/Extracts.js +0 -110
- package/jest.config.ts +0 -193
- package/setupJest.ts +0 -8
- package/src/App.test.tsx +0 -41
- package/src/App.tsx +0 -152
- package/src/Globals.ts +0 -69
- package/src/Loader.tsx +0 -8
- package/src/PluginLoader.test.tsx +0 -70
- package/src/PluginLoader.tsx +0 -407
- package/src/Shimmer.tsx +0 -108
- package/src/ThemeLoader.test.tsx +0 -82
- package/src/ThemeLoader.tsx +0 -95
- package/src/components/PluginRoute.tsx +0 -48
- package/src/components/SmartScript.tsx +0 -166
- package/src/components/UserLocked/UserLockedComponent.tsx +0 -33
- package/src/components/View.test.tsx +0 -110
- package/src/components/View.tsx +0 -114
- package/src/componentsConnectors/connectBox.test.tsx +0 -226
- package/src/componentsConnectors/connectBox.tsx +0 -70
- package/src/componentsConnectors/connectDocument.test.tsx +0 -108
- package/src/componentsConnectors/connectDocument.tsx +0 -64
- package/src/componentsConnectors/connectHeader.tsx +0 -21
- package/src/componentsConnectors/connectMetaTitle.test.tsx +0 -40
- package/src/componentsConnectors/connectMetaTitle.tsx +0 -8
- package/src/componentsConnectors/connectOption.tsx +0 -222
- package/src/componentsConnectors/connectPagination.tsx +0 -102
- package/src/componentsConnectors/connectPreview.tsx +0 -5
- package/src/componentsConnectors/connectProgress.tsx +0 -59
- package/src/componentsConnectors/connectRootOption.tsx +0 -95
- package/src/componentsConnectors/connectSection.tsx +0 -79
- package/src/componentsConnectors/connectSummary.tsx +0 -21
- package/src/componentsConnectors/connectSummaryItem.tsx +0 -102
- package/src/componentsConnectors/connectTermsheet.tsx +0 -359
- package/src/componentsConnectors/connectVariable.tsx +0 -191
- package/src/componentsConnectors/connectWizardWrapper.tsx +0 -30
- package/src/componentsConnectors/connector/componentConnector.tsx +0 -219
- package/src/componentsConnectors/library.ts +0 -35
- package/src/config.test.ts +0 -63
- package/src/config.ts +0 -11
- package/src/constants/emailValidation.ts +0 -2
- package/src/constants/phoneValidation.ts +0 -6
- package/src/definitions/path.join.d.ts +0 -4
- package/src/helpers/outputsParsing.ts +0 -412
- package/src/helpers/preloadTheme.ts +0 -17
- package/src/helpers/scriptsLoader.ts +0 -20
- package/src/helpers/sendinblueHelper.ts +0 -65
- package/src/hooks/usePrevious.ts +0 -9
- package/src/libs/ConditionsInitiator.ts +0 -164
- package/src/libs/ConditionsRunner/DataPopulator.ts +0 -266
- package/src/libs/ConditionsRunner.ts +0 -454
- package/src/libs/DocumentsOutputs.ts +0 -171
- package/src/libs/Eval/EvalBase.ts +0 -116
- package/src/libs/Eval/EvalFunctions.ts +0 -724
- package/src/libs/Eval/NumbersToLetters.ts +0 -185
- package/src/libs/EvalVariable.ts +0 -265
- package/src/libs/EventsTracking.ts +0 -276
- package/src/libs/Extracts.ts +0 -159
- package/src/libs/InputsInitiator.ts +0 -136
- package/src/libs/NumAuto.test.ts +0 -55
- package/src/libs/NumAuto.ts +0 -56
- package/src/libs/OvcConverter.ts +0 -285
- package/src/libs/PathReader.ts +0 -272
- package/src/libs/SectionValidity.test.ts +0 -146
- package/src/libs/SectionValidity.ts +0 -110
- package/src/libs/SmartScriptStore.ts +0 -492
- package/src/misc/test_model.ts +0 -14603
- package/src/misc/test_models/connectDocumen.testmodel.json +0 -178
- package/src/misc/test_models/setDefaults.testmodel.json +0 -279
- package/src/misc/test_models/testmodel.json +0 -1
- package/src/polyfills/index.ts +0 -5
- package/src/polyfills/objectValues.ts +0 -4
- package/src/polyfills/prepend.ts +0 -31
- package/src/polyfills/stringRepeat.ts +0 -44
- package/src/redux/actions/app.test.ts +0 -123
- package/src/redux/actions/app.ts +0 -249
- package/src/redux/actions/conditions.test.ts +0 -84
- package/src/redux/actions/conditions.ts +0 -135
- package/src/redux/actions/inputs.test.ts +0 -85
- package/src/redux/actions/inputs.ts +0 -111
- package/src/redux/actions/library.ts +0 -23
- package/src/redux/actions/mandatories.ts +0 -98
- package/src/redux/actions/references.test.ts +0 -48
- package/src/redux/actions/references.ts +0 -37
- package/src/redux/actions/sagas/data.test.ts +0 -11
- package/src/redux/actions/sagas/data.ts +0 -18
- package/src/redux/actions/sagas/model.test.ts +0 -14
- package/src/redux/actions/sagas/model.ts +0 -48
- package/src/redux/actions/sagas/user.ts +0 -25
- package/src/redux/actions/smartscript.ts +0 -55
- package/src/redux/actions/user.test.ts +0 -18
- package/src/redux/actions/user.ts +0 -41
- package/src/redux/constants/app.ts +0 -36
- package/src/redux/constants/conditions.ts +0 -25
- package/src/redux/constants/inputs.ts +0 -15
- package/src/redux/constants/mandatories.ts +0 -11
- package/src/redux/constants/references.ts +0 -7
- package/src/redux/constants/sagas/data.ts +0 -1
- package/src/redux/constants/sagas/model.ts +0 -2
- package/src/redux/constants/sagas/user.ts +0 -2
- package/src/redux/constants/smartscript.ts +0 -9
- package/src/redux/constants/user.ts +0 -6
- package/src/redux/listeners/subscriber.test.ts +0 -45
- package/src/redux/listeners/subscriber.ts +0 -29
- package/src/redux/middlewares/conditionsWatcherMiddleware.test.ts +0 -370
- package/src/redux/middlewares/conditionsWatcherMiddleware.ts +0 -321
- package/src/redux/middlewares/evaluationsWatcherMiddleware.test.ts +0 -323
- package/src/redux/middlewares/evaluationsWatcherMiddleware.ts +0 -250
- package/src/redux/middlewares/mandatoriesWatcherMiddleware.ts +0 -473
- package/src/redux/middlewares/multiplesActionsMiddleware.test.ts +0 -230
- package/src/redux/middlewares/multiplesActionsMiddleware.ts +0 -121
- package/src/redux/middlewares/paginationWatcherMiddleware.ts +0 -251
- package/src/redux/middlewares/pluginsHookMiddleware.ts +0 -24
- package/src/redux/middlewares/prefillerWatcherMiddleware.test.ts +0 -118
- package/src/redux/middlewares/prefillerWatcherMiddleware.ts +0 -462
- package/src/redux/middlewares/smartscriptMiddleware.ts +0 -228
- package/src/redux/middlewares/thirdpartyScriptsMiddleware.ts +0 -41
- package/src/redux/reducers/app/customizations/initCustomizationAutoDefault.ts +0 -16
- package/src/redux/reducers/app/customizations/initCustomizationMeta.ts +0 -16
- package/src/redux/reducers/app/instance/initInstance.ts +0 -29
- package/src/redux/reducers/app/instance/setDataStatus.ts +0 -16
- package/src/redux/reducers/app/instance/updateInstance.ts +0 -30
- package/src/redux/reducers/app/instance/updateInstancePaid.ts +0 -20
- package/src/redux/reducers/app/instance.test.ts +0 -106
- package/src/redux/reducers/app/meta/fetchModelFailed.ts +0 -11
- package/src/redux/reducers/app/meta/fetchModelNonBlocking.ts +0 -11
- package/src/redux/reducers/app/meta/fetchModelSucceeded.ts +0 -11
- package/src/redux/reducers/app/meta/fetchModelUnhealthy.ts +0 -18
- package/src/redux/reducers/app/meta/fetchModelUserLocked.ts +0 -11
- package/src/redux/reducers/app/meta/initMeta.ts +0 -22
- package/src/redux/reducers/app/meta/setModelUuid.ts +0 -17
- package/src/redux/reducers/app/meta.test.ts +0 -90
- package/src/redux/reducers/app/pagination/goNextPage.ts +0 -69
- package/src/redux/reducers/app/pagination/goPage.ts +0 -81
- package/src/redux/reducers/app/pagination/goPreviousPage.ts +0 -60
- package/src/redux/reducers/app/pagination/initPagination.ts +0 -46
- package/src/redux/reducers/app/pagination/updateAvailableAppStates.ts +0 -77
- package/src/redux/reducers/app/pagination.test.ts +0 -363
- package/src/redux/reducers/app/wizard/updateAvailableSections.ts +0 -40
- package/src/redux/reducers/app/wizard.test.ts +0 -84
- package/src/redux/reducers/app.test.ts +0 -336
- package/src/redux/reducers/app.ts +0 -150
- package/src/redux/reducers/conditions/addMultipleOccurency.test.ts +0 -131
- package/src/redux/reducers/conditions/addMultipleOccurency.ts +0 -155
- package/src/redux/reducers/conditions/deleteMultipleOccurency.test.ts +0 -95
- package/src/redux/reducers/conditions/deleteMultipleOccurency.ts +0 -141
- package/src/redux/reducers/conditions/initConditions.ts +0 -18
- package/src/redux/reducers/conditions/updateDocumentConditions.test.ts +0 -47
- package/src/redux/reducers/conditions/updateDocumentConditions.ts +0 -21
- package/src/redux/reducers/conditions/updateOptionConditions.ts +0 -24
- package/src/redux/reducers/conditions/updateOptionValidatorCondition.test.ts +0 -50
- package/src/redux/reducers/conditions/updateOptionValidatorCondition.ts +0 -28
- package/src/redux/reducers/conditions/updatePrefillerConditions.ts +0 -29
- package/src/redux/reducers/conditions/updateSectionConditions.ts +0 -28
- package/src/redux/reducers/conditions/updateVariableConditions.ts +0 -25
- package/src/redux/reducers/conditions/updateVariableValidatorCondition.test.ts +0 -50
- package/src/redux/reducers/conditions/updateVariableValidatorCondition.ts +0 -28
- package/src/redux/reducers/conditions.test.ts +0 -241
- package/src/redux/reducers/conditions.ts +0 -68
- package/src/redux/reducers/inputs/addMultipleOccurency.test.ts +0 -117
- package/src/redux/reducers/inputs/addMultipleOccurency.ts +0 -50
- package/src/redux/reducers/inputs/deleteMultipleOccurency.test.ts +0 -70
- package/src/redux/reducers/inputs/deleteMultipleOccurency.ts +0 -50
- package/src/redux/reducers/inputs/initOption.ts +0 -16
- package/src/redux/reducers/inputs/initVariable.ts +0 -16
- package/src/redux/reducers/inputs/updateOptionInput.ts +0 -24
- package/src/redux/reducers/inputs/updateVariableInput.ts +0 -24
- package/src/redux/reducers/inputs.test.ts +0 -221
- package/src/redux/reducers/inputs.ts +0 -51
- package/src/redux/reducers/mandatories/addMultipleOccurency.ts +0 -52
- package/src/redux/reducers/mandatories/deleteMultipleOccurency.ts +0 -55
- package/src/redux/reducers/mandatories/initMandatoryOption.ts +0 -17
- package/src/redux/reducers/mandatories/initMandatoryVariable.ts +0 -17
- package/src/redux/reducers/mandatories/setMandatoryIgnore.ts +0 -17
- package/src/redux/reducers/mandatories/setMandatoryOption.ts +0 -25
- package/src/redux/reducers/mandatories/setMandatorySection.ts +0 -20
- package/src/redux/reducers/mandatories/setMandatoryVariable.ts +0 -24
- package/src/redux/reducers/mandatories.ts +0 -56
- package/src/redux/reducers/references/initReferences.ts +0 -37
- package/src/redux/reducers/references/updateOptionMeta.ts +0 -73
- package/src/redux/reducers/references/updateVariableMeta.ts +0 -72
- package/src/redux/reducers/references.ts +0 -59
- package/src/redux/reducers/smartscript/enableSmartScript.ts +0 -13
- package/src/redux/reducers/smartscript/initSmartScriptTriggers.ts +0 -14
- package/src/redux/reducers/smartscript/updateSmartscriptOptionHidden.ts +0 -30
- package/src/redux/reducers/smartscript/updateSmartscriptVariableHidden.ts +0 -30
- package/src/redux/reducers/smartscript.ts +0 -47
- package/src/redux/reducers/user/initUser.ts +0 -15
- package/src/redux/reducers/user/setUserStatus.ts +0 -13
- package/src/redux/reducers/user/setUserValidToken.ts +0 -13
- package/src/redux/reducers/user.test.ts +0 -51
- package/src/redux/reducers/user.ts +0 -40
- package/src/redux/routerHistore.test.ts +0 -19
- package/src/redux/routerHistory.ts +0 -26
- package/src/redux/sagas/fetchModel.test.ts +0 -76
- package/src/redux/sagas/fetchModel.ts +0 -683
- package/src/redux/sagas/homogeneousRadioInputsSaga.ts +0 -42
- package/src/redux/sagas/initInputs.ts +0 -110
- package/src/redux/sagas/runner.test.ts +0 -12
- package/src/redux/sagas/runner.ts +0 -26
- package/src/redux/sagas/saveData.test.ts +0 -125
- package/src/redux/sagas/saveData.ts +0 -116
- package/src/redux/sagas/setDefaults.test.ts +0 -100
- package/src/redux/sagas/setDefaults.ts +0 -167
- package/src/redux/sagas/setUserEmail.ts +0 -221
- package/src/redux/selectors/app.test.ts +0 -162
- package/src/redux/selectors/app.ts +0 -331
- package/src/redux/selectors/conditions.test.ts +0 -92
- package/src/redux/selectors/conditions.ts +0 -293
- package/src/redux/selectors/inputs.test.ts +0 -72
- package/src/redux/selectors/inputs.ts +0 -76
- package/src/redux/selectors/library.ts +0 -17
- package/src/redux/selectors/mandatories.ts +0 -83
- package/src/redux/selectors/references.test.ts +0 -660
- package/src/redux/selectors/references.ts +0 -413
- package/src/redux/selectors/selectors.test.ts +0 -21
- package/src/redux/selectors/selectors.ts +0 -87
- package/src/redux/selectors/smartscript.ts +0 -30
- package/src/redux/selectors/user.test.ts +0 -39
- package/src/redux/selectors/user.ts +0 -45
- package/src/redux/store.test.ts +0 -22
- package/src/redux/store.ts +0 -100
- package/src/service/api.manager.ts +0 -261
- package/src/service/auth.service.ts +0 -5
- package/src/service/pardot.service.ts +0 -10
- package/src/tests-misc/plugins/jestTestPlugin/after.tsx +0 -5
- package/src/tests-misc/plugins/jestTestPlugin/before.tsx +0 -11
- package/src/tests-misc/plugins/jestTestPlugin/index.ts +0 -11
- package/src/tests-misc/plugins/jestTestPlugin/title.tsx +0 -8
- package/src/tests-misc/themes/jestTestTheme/components/EmailComponent.tsx +0 -5
- package/src/tests-misc/themes/jestTestTheme/components/TermsheetComponent.tsx +0 -5
- package/src/tests-misc/themes/jestTestTheme/components/WizardComponent.tsx +0 -5
- package/src/tests-misc/themes/jestTestTheme/faltyIndex.ts +0 -3
- package/src/tests-misc/themes/jestTestTheme/faltyIndexLoader.ts +0 -1
- package/src/tests-misc/themes/jestTestTheme/index.ts +0 -13
- package/src/types/Actions.type.ts +0 -612
- package/src/types/Components.type.ts +0 -181
- package/src/types/State.type.ts +0 -323
- package/src/types/Termsheet.type.ts +0 -28
- package/src/types/api.type.ts +0 -37
- package/src/types/config.type.ts +0 -55
- package/src/types/env.type.ts +0 -5
- package/src/types/getActions.type.ts +0 -3
- package/src/types/getConnectors.type.ts +0 -5
- package/src/types/getSelectors.type.ts +0 -3
- package/src/wizard-params.ts +0 -56
- package/tsconfig.json +0 -43
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { call, fork, put, takeLatest } from "redux-saga/effects";
|
|
2
|
-
import { getContractFunnelGAEvent } from "@legalplace/lp-events";
|
|
3
|
-
import { v4 as uuid } from "uuid";
|
|
4
|
-
import { getConfig } from "../../config";
|
|
5
|
-
import {
|
|
6
|
-
selectPermalink,
|
|
7
|
-
selectInstanceUniqid,
|
|
8
|
-
selectDocumentTitle,
|
|
9
|
-
selectAvailableAppStates,
|
|
10
|
-
selectDocumentModelVersion,
|
|
11
|
-
} from "../selectors/app";
|
|
12
|
-
import { selectInputs } from "../selectors/inputs";
|
|
13
|
-
import { SET_USER_EMAIL } from "../constants/sagas/user";
|
|
14
|
-
import { setUserStatusAction, initUserAction } from "../actions/user";
|
|
15
|
-
import { ActionsType } from "../../types/Actions.type";
|
|
16
|
-
import { IInstanceCreationResponse } from "../../types/api.type";
|
|
17
|
-
import {
|
|
18
|
-
updateAvailableAppStatesAction,
|
|
19
|
-
initInstanceAction,
|
|
20
|
-
goNextPageAction,
|
|
21
|
-
} from "../actions/app";
|
|
22
|
-
|
|
23
|
-
import { OvcConverter } from "../../libs/OvcConverter";
|
|
24
|
-
import { getSendinblueIdentifyAttributes } from "../../helpers/sendinblueHelper";
|
|
25
|
-
import { setUserEmailSucceeded } from "../actions/sagas/user";
|
|
26
|
-
import { EMAIL_REGEX } from "../../constants/emailValidation";
|
|
27
|
-
|
|
28
|
-
const canalHeaders = {
|
|
29
|
-
"lp-referrer": window.document.referrer,
|
|
30
|
-
"lp-origin": window.location.href,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function* setUserEmailDecorator(action: ActionsType.User.setUserEmail): any {
|
|
34
|
-
try {
|
|
35
|
-
/**
|
|
36
|
-
* Validating email
|
|
37
|
-
*/
|
|
38
|
-
const { email, tags, inBackground } = action;
|
|
39
|
-
if (!EMAIL_REGEX.test(email)) {
|
|
40
|
-
if (!inBackground) yield put(setUserStatusAction("failed"));
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
yield put(setUserStatusAction("inprogress"));
|
|
45
|
-
|
|
46
|
-
// Getting Permalink & uniqid
|
|
47
|
-
const permalink = selectPermalink();
|
|
48
|
-
const instanceUniqid = selectInstanceUniqid();
|
|
49
|
-
|
|
50
|
-
// Getting OVC
|
|
51
|
-
const ovc = OvcConverter.convertToOvc(selectInputs());
|
|
52
|
-
|
|
53
|
-
// Counting filled variables
|
|
54
|
-
const nbFilledVars = Object.keys(ovc.v).reduce((p, c) => {
|
|
55
|
-
const currentValue = ovc.v[c];
|
|
56
|
-
// eslint-disable-next-line no-nested-ternary
|
|
57
|
-
const o: number = Array.isArray(currentValue)
|
|
58
|
-
? currentValue.reduce((_p: number, _c) => _p + (_c !== "" ? 1 : 0), 0)
|
|
59
|
-
: currentValue !== ""
|
|
60
|
-
? 1
|
|
61
|
-
: 0;
|
|
62
|
-
return p + o;
|
|
63
|
-
}, 0);
|
|
64
|
-
|
|
65
|
-
// Request Body
|
|
66
|
-
let body: Record<string, any> = {
|
|
67
|
-
ovc,
|
|
68
|
-
nb_filled_vars: nbFilledVars,
|
|
69
|
-
nb_chosen_options: 0,
|
|
70
|
-
email,
|
|
71
|
-
tags,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// Creating a new instance if we don't have a uniqid
|
|
75
|
-
if (instanceUniqid === undefined || instanceUniqid.length === 0) {
|
|
76
|
-
body = {
|
|
77
|
-
...body,
|
|
78
|
-
app_type: "wizardx",
|
|
79
|
-
draft: 1,
|
|
80
|
-
contract_version: selectDocumentModelVersion(),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const apiEndpoint =
|
|
85
|
-
getConfig().apiEndpoint +
|
|
86
|
-
(/\/$/.test(getConfig().apiEndpoint) ? "" : "/");
|
|
87
|
-
|
|
88
|
-
const instanceResponse = yield call(
|
|
89
|
-
fetch,
|
|
90
|
-
`${apiEndpoint}wizard/instance/${permalink}/${instanceUniqid || ""}`,
|
|
91
|
-
{
|
|
92
|
-
method:
|
|
93
|
-
instanceUniqid === undefined || instanceUniqid.length === 0
|
|
94
|
-
? "POST"
|
|
95
|
-
: "PUT",
|
|
96
|
-
credentials: "include",
|
|
97
|
-
headers: {
|
|
98
|
-
"Content-Type": "application/json",
|
|
99
|
-
...canalHeaders,
|
|
100
|
-
},
|
|
101
|
-
body: JSON.stringify(body),
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
const response: IInstanceCreationResponse = yield call([
|
|
105
|
-
instanceResponse,
|
|
106
|
-
"json",
|
|
107
|
-
]);
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Redirecting user in case we recieved a redirect order
|
|
111
|
-
*/
|
|
112
|
-
const { redirect_to: redirectTo, user, uniqid, isPaid } = response;
|
|
113
|
-
if (typeof redirectTo !== "string" || action.disableRedirect) {
|
|
114
|
-
if (!instanceUniqid?.length) {
|
|
115
|
-
yield put(
|
|
116
|
-
initInstanceAction({
|
|
117
|
-
dataStatus: "saved",
|
|
118
|
-
uniqid,
|
|
119
|
-
isPaid: isPaid || false,
|
|
120
|
-
steps: [1],
|
|
121
|
-
})
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
yield put(setUserStatusAction("authenticated"));
|
|
125
|
-
if (user) {
|
|
126
|
-
yield put(
|
|
127
|
-
initUserAction({
|
|
128
|
-
...user,
|
|
129
|
-
level: user.role || user.level,
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Identifying user
|
|
136
|
-
if (typeof window.sendinblue !== "undefined" && response.user) {
|
|
137
|
-
const attributes = yield getSendinblueIdentifyAttributes(
|
|
138
|
-
uniqid,
|
|
139
|
-
selectDocumentTitle(),
|
|
140
|
-
nbFilledVars,
|
|
141
|
-
false,
|
|
142
|
-
window.location.host
|
|
143
|
-
);
|
|
144
|
-
window.sendinblue.identify(email, attributes);
|
|
145
|
-
const fetchParams = {
|
|
146
|
-
method: "POST",
|
|
147
|
-
credentials: "include",
|
|
148
|
-
headers: {
|
|
149
|
-
"Content-Type": "application/json",
|
|
150
|
-
},
|
|
151
|
-
body: JSON.stringify({
|
|
152
|
-
email,
|
|
153
|
-
attributes,
|
|
154
|
-
}),
|
|
155
|
-
};
|
|
156
|
-
try {
|
|
157
|
-
// if we redirect afterwards we wait for the call to finish otherwise we do it in background
|
|
158
|
-
if (typeof redirectTo === "string" && !action.disableRedirect) {
|
|
159
|
-
yield call(
|
|
160
|
-
// @ts-ignore for some reason saga doesn't like fetchParams being in a seperate variable
|
|
161
|
-
fetch,
|
|
162
|
-
`${apiEndpoint}event/create/${uniqid}/${uuid()}`,
|
|
163
|
-
fetchParams
|
|
164
|
-
);
|
|
165
|
-
} else {
|
|
166
|
-
yield fork(
|
|
167
|
-
// @ts-ignore for some reason saga doesn't like fetchParams being in a seperate variable
|
|
168
|
-
fetch,
|
|
169
|
-
`${apiEndpoint}event/create/${uniqid}/${uuid()}`,
|
|
170
|
-
fetchParams
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
} catch (error) {
|
|
174
|
-
// keep going in case the request fail for now
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
try {
|
|
179
|
-
if (redirectTo && redirectTo.includes("generation"))
|
|
180
|
-
window.dataLayer.push(
|
|
181
|
-
getContractFunnelGAEvent({
|
|
182
|
-
currentStep: 1,
|
|
183
|
-
contractName: selectDocumentTitle(),
|
|
184
|
-
sectionTitle: "Choississez votre pack",
|
|
185
|
-
pageAction: "Confirmation avant paiement 1 | 2",
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
} catch (error) {
|
|
189
|
-
// eslint-disable-next-line
|
|
190
|
-
console.error(error);
|
|
191
|
-
}
|
|
192
|
-
// Redirecting user
|
|
193
|
-
if (typeof redirectTo === "string" && !action.disableRedirect) {
|
|
194
|
-
// Disabling onbeforeunload
|
|
195
|
-
window.onbeforeunload = () => {};
|
|
196
|
-
|
|
197
|
-
// Add 1 second before redirection to wait for all HTTP requests to finish
|
|
198
|
-
setTimeout(() => {
|
|
199
|
-
window.location.href = redirectTo;
|
|
200
|
-
}, 1000);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const availableAppStates = [...selectAvailableAppStates()];
|
|
204
|
-
availableAppStates.splice(availableAppStates.indexOf("email"), 1);
|
|
205
|
-
|
|
206
|
-
// Updating appstates
|
|
207
|
-
yield put(updateAvailableAppStatesAction(availableAppStates));
|
|
208
|
-
if (!inBackground) yield put(goNextPageAction());
|
|
209
|
-
yield put(setUserEmailSucceeded());
|
|
210
|
-
} catch (e) {
|
|
211
|
-
// eslint-disable-next-line no-console
|
|
212
|
-
console.error(e);
|
|
213
|
-
yield put(setUserStatusAction("inprogress"));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function* setUserEmailSaga() {
|
|
218
|
-
yield takeLatest(SET_USER_EMAIL, setUserEmailDecorator);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export default setUserEmailSaga;
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { createAppStore, getStore } from '../store';
|
|
2
|
-
import {
|
|
3
|
-
initPaginationAction,
|
|
4
|
-
initMetaAction,
|
|
5
|
-
initInstanceAction,
|
|
6
|
-
} from '../actions/app';
|
|
7
|
-
import {
|
|
8
|
-
selectCurrentPage,
|
|
9
|
-
selectCurrentSectionId,
|
|
10
|
-
selectAvailableSections,
|
|
11
|
-
selectPermalink,
|
|
12
|
-
selectDocumentId,
|
|
13
|
-
selectDocumentTitle,
|
|
14
|
-
selectInstanceUniqid,
|
|
15
|
-
selectInstanceIsPaid,
|
|
16
|
-
} from './app';
|
|
17
|
-
|
|
18
|
-
// Initiating state
|
|
19
|
-
createAppStore('memory');
|
|
20
|
-
const store = getStore();
|
|
21
|
-
|
|
22
|
-
describe('App selectors test suit', () => {
|
|
23
|
-
it('Returns current page correctly', () => {
|
|
24
|
-
// Initiating pagination
|
|
25
|
-
store.dispatch(
|
|
26
|
-
initPaginationAction({
|
|
27
|
-
currentSectionId: 1,
|
|
28
|
-
currentPage: 13,
|
|
29
|
-
greatestPage: 1,
|
|
30
|
-
availableSections: [1, 2, 3],
|
|
31
|
-
availableAppStates: ['wizard'],
|
|
32
|
-
currentAppState: 'wizard',
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const selector = selectCurrentPage();
|
|
37
|
-
|
|
38
|
-
expect(selector).toBe(13);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('Returns current section id correctly', () => {
|
|
42
|
-
// Initiating pagination
|
|
43
|
-
store.dispatch(
|
|
44
|
-
initPaginationAction({
|
|
45
|
-
currentSectionId: 32,
|
|
46
|
-
currentPage: 13,
|
|
47
|
-
greatestPage: 13,
|
|
48
|
-
availableSections: [1, 2, 3],
|
|
49
|
-
availableAppStates: ['wizard'],
|
|
50
|
-
currentAppState: 'wizard',
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const selector = selectCurrentSectionId();
|
|
55
|
-
|
|
56
|
-
expect(selector).toBe(32);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('Returns available sections correctly', () => {
|
|
60
|
-
// Initiating pagination
|
|
61
|
-
store.dispatch(
|
|
62
|
-
initPaginationAction({
|
|
63
|
-
currentSectionId: 32,
|
|
64
|
-
currentPage: 13,
|
|
65
|
-
greatestPage: 13,
|
|
66
|
-
availableSections: [1, 2, 3],
|
|
67
|
-
availableAppStates: ['wizard'],
|
|
68
|
-
currentAppState: 'wizard',
|
|
69
|
-
})
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const selector = selectAvailableSections();
|
|
73
|
-
|
|
74
|
-
expect(selector).toEqual([1, 2, 3]);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('Returns permalink correctly', () => {
|
|
78
|
-
// Initiating pagination
|
|
79
|
-
store.dispatch(
|
|
80
|
-
initMetaAction({
|
|
81
|
-
permalink: 'some-permalink',
|
|
82
|
-
title: 'Some title',
|
|
83
|
-
prefix: '',
|
|
84
|
-
id: 123,
|
|
85
|
-
modelVersion: 1,
|
|
86
|
-
productType: 'demarche',
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const selector = selectPermalink();
|
|
91
|
-
|
|
92
|
-
expect(selector).toBe('some-permalink');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('Returns document id correctly', () => {
|
|
96
|
-
// Initiating pagination
|
|
97
|
-
store.dispatch(
|
|
98
|
-
initMetaAction({
|
|
99
|
-
permalink: 'some-permalink',
|
|
100
|
-
title: 'Some title',
|
|
101
|
-
prefix: '',
|
|
102
|
-
id: 123,
|
|
103
|
-
modelVersion: 1,
|
|
104
|
-
productType: 'demarche',
|
|
105
|
-
})
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const selector = selectDocumentId();
|
|
109
|
-
|
|
110
|
-
expect(selector).toBe(123);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('Returns document title correctly', () => {
|
|
114
|
-
// Initiating pagination
|
|
115
|
-
store.dispatch(
|
|
116
|
-
initMetaAction({
|
|
117
|
-
permalink: 'some-permalink',
|
|
118
|
-
title: 'Some title',
|
|
119
|
-
prefix: '',
|
|
120
|
-
id: 123,
|
|
121
|
-
modelVersion: 1,
|
|
122
|
-
productType: 'demarche',
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
const selector = selectDocumentTitle();
|
|
127
|
-
|
|
128
|
-
expect(selector).toBe('Some title');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('Returns instance uniqid correctly', () => {
|
|
132
|
-
// Initiating pagination
|
|
133
|
-
store.dispatch(
|
|
134
|
-
initInstanceAction({
|
|
135
|
-
dataStatus: 'saved',
|
|
136
|
-
uniqid: 'SomeUNiqID',
|
|
137
|
-
isPaid: false,
|
|
138
|
-
steps: '*',
|
|
139
|
-
})
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
const selector = selectInstanceUniqid();
|
|
143
|
-
|
|
144
|
-
expect(selector).toBe('SomeUNiqID');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('Returns instance isPaid correctly', () => {
|
|
148
|
-
// Initiating pagination
|
|
149
|
-
store.dispatch(
|
|
150
|
-
initInstanceAction({
|
|
151
|
-
dataStatus: 'saved',
|
|
152
|
-
uniqid: 'SomeUNiqID',
|
|
153
|
-
isPaid: true,
|
|
154
|
-
steps: '*',
|
|
155
|
-
})
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
const selector = selectInstanceIsPaid();
|
|
159
|
-
|
|
160
|
-
expect(selector).toBeTruthy();
|
|
161
|
-
});
|
|
162
|
-
});
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
import { createSelector } from "./selectors";
|
|
2
|
-
import { selectOptionInput } from "./inputs";
|
|
3
|
-
import { StateType } from "../../types/State.type";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns current page number
|
|
7
|
-
*/
|
|
8
|
-
export const selectCurrentPage = createSelector(
|
|
9
|
-
(state: StateType) => state.app.pagination.currentPage,
|
|
10
|
-
(state: StateType) => state.app.pagination.currentPage.toString()
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Returns availableAppStates
|
|
15
|
-
*/
|
|
16
|
-
export const selectAvailableAppStates = createSelector(
|
|
17
|
-
(state: StateType) => state.app.pagination.availableAppStates,
|
|
18
|
-
(state: StateType) => state.app.pagination.availableAppStates.join("-")
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Returns currentAppState
|
|
23
|
-
*/
|
|
24
|
-
export const selectCurrentAppState = createSelector(
|
|
25
|
-
(state: StateType) => state.app.pagination.currentAppState,
|
|
26
|
-
(state: StateType) => state.app.pagination.currentAppState
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns isFirstPage
|
|
31
|
-
*/
|
|
32
|
-
export const selectIsFirstPage = createSelector(
|
|
33
|
-
(state: StateType) => state.app.pagination.isFirstPage,
|
|
34
|
-
(state: StateType) => state.app.pagination.isFirstPage.toString()
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Returns isLastPage
|
|
39
|
-
*/
|
|
40
|
-
export const selectIsLastPage = createSelector(
|
|
41
|
-
(state: StateType) => state.app.pagination.isLastPage,
|
|
42
|
-
(state: StateType) => state.app.pagination.isLastPage.toString()
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
export const selectIsLastWizardPage = createSelector(
|
|
46
|
-
(state: StateType) =>
|
|
47
|
-
state.app.pagination.currentPage ===
|
|
48
|
-
state.app.wizard.availableSections.length,
|
|
49
|
-
(state: StateType) => state.app.pagination.currentPage.toString()
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Returns greatest page user went to
|
|
54
|
-
*/
|
|
55
|
-
export const selectGreatestPage = createSelector(
|
|
56
|
-
(state: StateType) => state.app.pagination.greatestPage,
|
|
57
|
-
(state: StateType) => state.app.pagination.greatestPage
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Returns current section id
|
|
62
|
-
*/
|
|
63
|
-
export const selectCurrentSectionId = createSelector(
|
|
64
|
-
(state: StateType) => state.app.wizard.currentSectionId,
|
|
65
|
-
(state: StateType) => state.app.wizard.currentSectionId
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Returns current available sections
|
|
70
|
-
*/
|
|
71
|
-
export const selectAvailableSections = createSelector(
|
|
72
|
-
(state: StateType) => [...state.app.wizard.availableSections],
|
|
73
|
-
(state: StateType) =>
|
|
74
|
-
state.app.wizard.availableSections.reduce((p, c) => p + c, 0)
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Returns all available options
|
|
79
|
-
*/
|
|
80
|
-
export const selectAvailableOptions = createSelector(
|
|
81
|
-
(state: StateType, document = "main") => {
|
|
82
|
-
let availableOptions: number[] = [];
|
|
83
|
-
|
|
84
|
-
const { availableSections } = state.app.wizard;
|
|
85
|
-
const documentSections = Object.keys(
|
|
86
|
-
state.references.sections[document]
|
|
87
|
-
).map((id) => parseInt(id, 10));
|
|
88
|
-
const sections = document === "main" ? availableSections : documentSections;
|
|
89
|
-
|
|
90
|
-
sections.forEach((sectionId) => {
|
|
91
|
-
const { options } = state.references.sections[document][sectionId];
|
|
92
|
-
availableOptions = [...availableOptions, ...options];
|
|
93
|
-
});
|
|
94
|
-
return availableOptions;
|
|
95
|
-
},
|
|
96
|
-
(state: StateType, document = "main") => {
|
|
97
|
-
if (document === "main")
|
|
98
|
-
return state.app.wizard.availableSections.reduce(
|
|
99
|
-
(a, b) => `${a}${b}`,
|
|
100
|
-
""
|
|
101
|
-
);
|
|
102
|
-
return document;
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Returns all multiples occurencies
|
|
108
|
-
*/
|
|
109
|
-
export const selectMultipleOccurencies = createSelector(
|
|
110
|
-
(state: StateType) => {
|
|
111
|
-
const multipleOptionsOccurencies: Record<string, number> = {};
|
|
112
|
-
const availableOptions = selectAvailableOptions("main");
|
|
113
|
-
if (availableOptions === undefined) return {};
|
|
114
|
-
availableOptions.forEach((optionId) => {
|
|
115
|
-
const ref = state.references.options[optionId];
|
|
116
|
-
if (ref.meta.multiple?.enabled === true) {
|
|
117
|
-
multipleOptionsOccurencies[optionId] =
|
|
118
|
-
selectOptionInput(optionId).length;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
return multipleOptionsOccurencies;
|
|
122
|
-
},
|
|
123
|
-
() => Math.random()
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
export const selectOutputsIds = createSelector(
|
|
127
|
-
(state: StateType, document: string): [number, string][] => {
|
|
128
|
-
const availableOptions = selectAvailableOptions(document);
|
|
129
|
-
if (availableOptions === undefined) return [];
|
|
130
|
-
const outputs = availableOptions.map((optionId): [number, string] => {
|
|
131
|
-
const ref = state.references.options[optionId];
|
|
132
|
-
return [optionId, ref.meta.type];
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
return outputs;
|
|
136
|
-
},
|
|
137
|
-
(state: StateType, document: string) => {
|
|
138
|
-
if (document !== "main") return document;
|
|
139
|
-
return state.app.wizard.availableSections.reduce((a, b) => `${a}${b}`, "");
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Returns permalink
|
|
145
|
-
*/
|
|
146
|
-
export const selectPermalink = createSelector(
|
|
147
|
-
(state: StateType) => state.app.meta.permalink,
|
|
148
|
-
(state: StateType) => state.app.meta.permalink
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Returns title
|
|
153
|
-
*/
|
|
154
|
-
export const selectDocumentTitle = createSelector(
|
|
155
|
-
(state: StateType) => state.app.meta.title,
|
|
156
|
-
(state: StateType) => state.app.meta.title
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Returns title
|
|
161
|
-
*/
|
|
162
|
-
export const selectDocumentId = createSelector(
|
|
163
|
-
(state: StateType) => state.app.meta.id,
|
|
164
|
-
(state: StateType) => state.app.meta.id
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Returns modelVersion
|
|
169
|
-
*/
|
|
170
|
-
export const selectDocumentModelVersion = createSelector(
|
|
171
|
-
(state: StateType) => state.app.meta.modelVersion,
|
|
172
|
-
(state: StateType) => state.app.meta.modelVersion
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Returns productType
|
|
177
|
-
*/
|
|
178
|
-
export const selectDocumentProductType = createSelector(
|
|
179
|
-
(state: StateType) => state.app.meta.productType,
|
|
180
|
-
(state: StateType) => state.app.meta.productType
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Returns product title
|
|
185
|
-
*/
|
|
186
|
-
export const selectMeta = createSelector(
|
|
187
|
-
(state: StateType) => state.app.meta,
|
|
188
|
-
(state: StateType) => state.app.meta.title
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Returns meta Fetch status
|
|
193
|
-
*/
|
|
194
|
-
export const selectMetaFetchStatus = createSelector(
|
|
195
|
-
(state: StateType) => state.app.meta.fetchStatus,
|
|
196
|
-
(state: StateType) => state.app.meta.fetchStatus
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Returns organization prefix
|
|
201
|
-
*/
|
|
202
|
-
export const selectPrefix = createSelector(
|
|
203
|
-
(state: StateType) => (!state.app.meta ? undefined : state.app.meta.prefix),
|
|
204
|
-
(state: StateType) => (!state.app.meta ? "0" : state.app.meta.permalink)
|
|
205
|
-
);
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Returns instance's uniqid
|
|
209
|
-
*/
|
|
210
|
-
export const selectInstanceUniqid = createSelector(
|
|
211
|
-
(state: StateType) =>
|
|
212
|
-
!state.app.instance ? undefined : state.app.instance.uniqid,
|
|
213
|
-
(state: StateType) => (!state.app.instance ? "0" : state.app.instance.uniqid)
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Returns instance's companyId
|
|
218
|
-
*/
|
|
219
|
-
export const selectInstanceCompanyId = createSelector(
|
|
220
|
-
(state: StateType) =>
|
|
221
|
-
!state.app.instance ? undefined : state.app.instance.companyId,
|
|
222
|
-
(state: StateType) =>
|
|
223
|
-
!state.app.instance || !state.app.instance.companyId
|
|
224
|
-
? "0"
|
|
225
|
-
: state.app.instance.companyId
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Returns instance's employeeId
|
|
230
|
-
*/
|
|
231
|
-
export const selectInstanceEmployeeId = createSelector(
|
|
232
|
-
(state: StateType) =>
|
|
233
|
-
!state.app.instance ? undefined : state.app.instance.employeeId,
|
|
234
|
-
(state: StateType) =>
|
|
235
|
-
!state.app.instance || !state.app.instance.employeeId
|
|
236
|
-
? "0"
|
|
237
|
-
: state.app.instance.employeeId
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Returns instance's data status
|
|
242
|
-
*/
|
|
243
|
-
export const selectDataStatus = createSelector(
|
|
244
|
-
(state: StateType) =>
|
|
245
|
-
!state.app.instance ? "unsaved" : state.app.instance.dataStatus,
|
|
246
|
-
(state: StateType) =>
|
|
247
|
-
!state.app.instance ? "0" : state.app.instance.dataStatus
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Returns instance's uniqid
|
|
252
|
-
*/
|
|
253
|
-
export const selectInstanceIsPaid = createSelector(
|
|
254
|
-
(state: StateType) => !!(state.app.instance && state.app.instance.isPaid),
|
|
255
|
-
(state: StateType) =>
|
|
256
|
-
state.app.instance && state.app.instance.isPaid
|
|
257
|
-
? state.app.instance.isPaid.toString()
|
|
258
|
-
: "0"
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Returns instance's steps
|
|
263
|
-
*/
|
|
264
|
-
export const selectInstanceSteps = createSelector(
|
|
265
|
-
(state: StateType) => !!(state.app.instance && state.app.instance.steps),
|
|
266
|
-
(state: StateType) =>
|
|
267
|
-
state.app.instance && state.app.instance.steps
|
|
268
|
-
? state.app.instance.steps.toString()
|
|
269
|
-
: "0"
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Verifies whether step is available for insatnce
|
|
274
|
-
*/
|
|
275
|
-
export const isStepAvailable = createSelector(
|
|
276
|
-
(state: StateType, steps: "*" | number[] | undefined) => {
|
|
277
|
-
if (steps === undefined) return true;
|
|
278
|
-
|
|
279
|
-
// If instance isn't defined
|
|
280
|
-
if (state.app.instance === undefined)
|
|
281
|
-
return steps === "*" ? true : steps.includes(1);
|
|
282
|
-
|
|
283
|
-
// If step is accessible by all
|
|
284
|
-
if (steps === "*") return true;
|
|
285
|
-
|
|
286
|
-
// If instance gives access to all steps
|
|
287
|
-
if (state.app.instance.steps === "*") return true;
|
|
288
|
-
return state.app.instance.steps
|
|
289
|
-
.map((c) => steps.includes(c))
|
|
290
|
-
.reduce((a, b) => a || b, false);
|
|
291
|
-
},
|
|
292
|
-
(state: StateType, steps) =>
|
|
293
|
-
state.app.instance && state.app.instance.steps && steps
|
|
294
|
-
? `${state.app.instance.steps.toString()}-${steps.toString()}`
|
|
295
|
-
: "0"
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Returns customization extracts
|
|
300
|
-
*/
|
|
301
|
-
export const selectCustomizationMeta = createSelector(
|
|
302
|
-
(state: StateType) => state.app.customization.meta,
|
|
303
|
-
(state: StateType) =>
|
|
304
|
-
state.app.customization.meta !== undefined ? "1" : Math.random()
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Returns customization disableAutoDefault
|
|
309
|
-
*/
|
|
310
|
-
export const selectCustomizationAutoDefaultType = createSelector(
|
|
311
|
-
(state: StateType) => state.app.customization.disableAutoDefault,
|
|
312
|
-
(state: StateType) =>
|
|
313
|
-
state.app.customization.disableAutoDefault !== undefined
|
|
314
|
-
? "1"
|
|
315
|
-
: Math.random()
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Returns Model's UUID
|
|
320
|
-
*/
|
|
321
|
-
export const selectModelUuid = createSelector(
|
|
322
|
-
(state: StateType) => state.app.meta.modelUuid,
|
|
323
|
-
(state: StateType) =>
|
|
324
|
-
state.app.meta.modelUuid !== undefined ? "1" : Math.random()
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
export const CompletelyUnusedSelector = createSelector(
|
|
328
|
-
(state: StateType) => state.app.meta.modelUuid,
|
|
329
|
-
(state: StateType) =>
|
|
330
|
-
state.app.meta.modelUuid !== undefined ? "1" : Math.random()
|
|
331
|
-
);
|