@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
package/src/Shimmer.tsx
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties, useState } from "react";
|
|
2
|
-
import { connect } from "react-redux";
|
|
3
|
-
import { StateType } from "./types/State.type";
|
|
4
|
-
import { addOnThemeLoadCallback, getThemeShimmer } from "./ThemeLoader";
|
|
5
|
-
import { PluginLoader } from "./PluginLoader";
|
|
6
|
-
import UserLockedComponent from "./components/UserLocked/UserLockedComponent";
|
|
7
|
-
|
|
8
|
-
const Shimmer: React.FC<{
|
|
9
|
-
fetchStatus: StateType.App.Meta["fetchStatus"];
|
|
10
|
-
report: StateType.App.Meta["report"];
|
|
11
|
-
}> = (props) => {
|
|
12
|
-
const [themeLoaded, setThemeloaded] = useState(false);
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
props.fetchStatus === "succeeded" ||
|
|
16
|
-
props.fetchStatus === "nonBlocking"
|
|
17
|
-
) {
|
|
18
|
-
return <>{props.children}</>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
addOnThemeLoadCallback(() => {
|
|
22
|
-
if (!themeLoaded) setThemeloaded(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (!themeLoaded) return null;
|
|
26
|
-
|
|
27
|
-
const ThemeShimmer = getThemeShimmer();
|
|
28
|
-
|
|
29
|
-
const style: CSSProperties = {
|
|
30
|
-
position: "absolute",
|
|
31
|
-
left: "50%",
|
|
32
|
-
top: "50%",
|
|
33
|
-
transform: "translate(-50%, -50%)",
|
|
34
|
-
color: "#AAA",
|
|
35
|
-
fontWeight: "bold",
|
|
36
|
-
textTransform: "uppercase",
|
|
37
|
-
fontSize: "12px",
|
|
38
|
-
userSelect: "none",
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const unhealthyStyle: CSSProperties = {
|
|
42
|
-
color: "#AAA",
|
|
43
|
-
fontWeight: "bold",
|
|
44
|
-
textTransform: "uppercase",
|
|
45
|
-
fontSize: "24px",
|
|
46
|
-
width: "700px",
|
|
47
|
-
margin: "auto",
|
|
48
|
-
textAlign: "center",
|
|
49
|
-
padding: "20px",
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const unhealthyStylePre: CSSProperties = {
|
|
53
|
-
background: "#FDDCD0",
|
|
54
|
-
textAlign: "left",
|
|
55
|
-
fontSize: "12px",
|
|
56
|
-
color: "#6B0435",
|
|
57
|
-
padding: "10px",
|
|
58
|
-
borderRadius: "4px",
|
|
59
|
-
};
|
|
60
|
-
if (ThemeShimmer !== null && props.fetchStatus === "waiting") {
|
|
61
|
-
return <ThemeShimmer />;
|
|
62
|
-
}
|
|
63
|
-
return (
|
|
64
|
-
<>
|
|
65
|
-
{["waiting", "failed"].includes(props.fetchStatus) && (
|
|
66
|
-
<div style={style}>
|
|
67
|
-
{props.fetchStatus === "waiting" && (
|
|
68
|
-
<div className="lds-ripple">
|
|
69
|
-
<div />
|
|
70
|
-
<div />
|
|
71
|
-
</div>
|
|
72
|
-
)}
|
|
73
|
-
{props.fetchStatus === "failed" &&
|
|
74
|
-
"Une erreur a eu lieu pendant le chargement du questionnaire"}
|
|
75
|
-
</div>
|
|
76
|
-
)}
|
|
77
|
-
|
|
78
|
-
{props.fetchStatus === "userLocked" && (
|
|
79
|
-
<>
|
|
80
|
-
<PluginLoader anchor={[`userLockedScreen`]} props={props} />
|
|
81
|
-
<UserLockedComponent unhealthyStyle={unhealthyStyle} />
|
|
82
|
-
</>
|
|
83
|
-
)}
|
|
84
|
-
|
|
85
|
-
{props.fetchStatus === "unhealthy" && (
|
|
86
|
-
<div style={unhealthyStyle}>
|
|
87
|
-
Le modèle semble contenir des erreurs
|
|
88
|
-
<pre style={unhealthyStylePre}>{props.report?.raw}</pre>
|
|
89
|
-
</div>
|
|
90
|
-
)}
|
|
91
|
-
</>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const mapStateToProps = (
|
|
96
|
-
state: StateType
|
|
97
|
-
): {
|
|
98
|
-
fetchStatus: StateType.App.Meta["fetchStatus"];
|
|
99
|
-
report: StateType.App.Meta["report"];
|
|
100
|
-
} => ({
|
|
101
|
-
fetchStatus:
|
|
102
|
-
state.app.meta.fetchStatus === "succeeded"
|
|
103
|
-
? "nonBlocking"
|
|
104
|
-
: state.app.meta.fetchStatus,
|
|
105
|
-
report: state.app.meta.report,
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
export default connect(mapStateToProps)(Shimmer);
|
package/src/ThemeLoader.test.tsx
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import 'regenerator-runtime/runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
-
import { render, cleanup, waitFor } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
afterEach(cleanup);
|
|
7
|
-
|
|
8
|
-
// Mocking config
|
|
9
|
-
jest.mock('./config', () => ({
|
|
10
|
-
__esModule: true,
|
|
11
|
-
getConfig: () => ({
|
|
12
|
-
theme: { name: 'jestTestTheme' },
|
|
13
|
-
plugins: {},
|
|
14
|
-
}),
|
|
15
|
-
loadConfig: async (): Promise<Record<string, any>> => ({
|
|
16
|
-
theme: { name: 'jestTestTheme' },
|
|
17
|
-
plugins: {},
|
|
18
|
-
}),
|
|
19
|
-
isConfigReady: () => true,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
jest.mock('./Globals', () => ({
|
|
23
|
-
loadTheme: (theme: string) => import(`./tests-misc/themes/${theme}`),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
let loadThemeComponent: any;
|
|
27
|
-
let loadTheme: any;
|
|
28
|
-
describe('<ThemeLoader />', () => {
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
31
|
-
loadThemeComponent = require('./ThemeLoader').loadThemeComponent;
|
|
32
|
-
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
33
|
-
loadTheme = require('./ThemeLoader').loadTheme;
|
|
34
|
-
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('Loads WizardComponent properly', async () => {
|
|
38
|
-
await loadTheme();
|
|
39
|
-
const WizardComponent = loadThemeComponent('WizardComponent');
|
|
40
|
-
const { container } = render(<WizardComponent />);
|
|
41
|
-
await waitFor(() =>
|
|
42
|
-
expect(container).toContainHTML(
|
|
43
|
-
'<div><h1>Wizard test theme, WizardComponent</h1></div>'
|
|
44
|
-
)
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('Loads TermsheetComponent properly', async () => {
|
|
49
|
-
const TermsheetComponent = loadThemeComponent('TermsheetComponent');
|
|
50
|
-
const { container } = render(<TermsheetComponent />);
|
|
51
|
-
await waitFor(() =>
|
|
52
|
-
expect(container).toContainHTML(
|
|
53
|
-
'<div><h1>Wizard test theme, TermsheetComponent</h1></div>'
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('loadTheme', () => {
|
|
60
|
-
it("loadTheme reloads theme properly if it's not yet loaded", async () => {
|
|
61
|
-
expect(loadTheme(undefined, true)).resolves.toEqual(undefined);
|
|
62
|
-
});
|
|
63
|
-
it('loadTheme throws an error if theme param is invalid', async () => {
|
|
64
|
-
expect(loadTheme('madeUpTheme')).rejects.toEqual(
|
|
65
|
-
new Error(
|
|
66
|
-
'We are unable to load the theme, please make sure the theme param is valid'
|
|
67
|
-
)
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
it('loadTheme throws an error if theme param is invalid', async () => {
|
|
71
|
-
expect(loadTheme('jestTestTheme/faltyIndexLoader')).rejects.toEqual(
|
|
72
|
-
new Error(
|
|
73
|
-
'We are unable to load the theme, please make sure the theme param is valid'
|
|
74
|
-
)
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
it('loadTheme throws an error if loader result is invalid', async () => {
|
|
78
|
-
expect(loadTheme('jestTestTheme/faltyIndex')).rejects.toEqual(
|
|
79
|
-
new Error('Theme loader function did not return components object')
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
});
|
package/src/ThemeLoader.tsx
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { getConfig, updateConfig } from "./config";
|
|
3
|
-
import { IWizardParamsTheme } from "./types/config.type";
|
|
4
|
-
import Globals from "./Globals";
|
|
5
|
-
|
|
6
|
-
// Getting current theme from config
|
|
7
|
-
let wizardTheme: string;
|
|
8
|
-
let themeParams: IWizardParamsTheme["params"];
|
|
9
|
-
const themeLoadCallbacks: (() => void)[] = [];
|
|
10
|
-
|
|
11
|
-
// This variable will store our theme's index
|
|
12
|
-
let themeIndex: Record<string, React.LazyExoticComponent<React.FC<{}>>>;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Theme loading function
|
|
16
|
-
*/
|
|
17
|
-
export const loadTheme = async (theme?: string, force?: boolean) => {
|
|
18
|
-
let currentTheme;
|
|
19
|
-
|
|
20
|
-
if (theme === undefined) {
|
|
21
|
-
currentTheme = force ? theme : wizardTheme;
|
|
22
|
-
} else {
|
|
23
|
-
currentTheme = theme;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Double checking theme from config
|
|
27
|
-
if (currentTheme === undefined) {
|
|
28
|
-
const config = getConfig();
|
|
29
|
-
wizardTheme = config.theme.name;
|
|
30
|
-
themeParams = config.theme.params;
|
|
31
|
-
currentTheme = wizardTheme;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Importing theme's loader function
|
|
35
|
-
let themeLoader: {
|
|
36
|
-
default?: Record<string, React.LazyExoticComponent<React.FC<{}>>>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
themeLoader = await Globals.loadTheme(currentTheme);
|
|
41
|
-
} catch (e) {
|
|
42
|
-
throw new Error(
|
|
43
|
-
"We are unable to load the theme, please make sure the theme param is valid"
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Extracting loader & default
|
|
48
|
-
const { default: themeDefault } = themeLoader;
|
|
49
|
-
|
|
50
|
-
if (typeof themeDefault !== "undefined") themeIndex = themeDefault;
|
|
51
|
-
else throw new Error("Unable to retrieve theme index");
|
|
52
|
-
|
|
53
|
-
// In case the theme still didn't load we throw an error
|
|
54
|
-
if (typeof themeIndex !== "object")
|
|
55
|
-
throw new Error("Theme loader function did not return components object");
|
|
56
|
-
|
|
57
|
-
themeLoadCallbacks.forEach((cb) => {
|
|
58
|
-
cb();
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Theme component's loader
|
|
64
|
-
*/
|
|
65
|
-
const importThemeComponent = (
|
|
66
|
-
name: string
|
|
67
|
-
): React.LazyExoticComponent<React.FC<{}>> => themeIndex[name];
|
|
68
|
-
/**
|
|
69
|
-
* Theme component's loader
|
|
70
|
-
*/
|
|
71
|
-
export const getThemeShimmer = () =>
|
|
72
|
-
getConfig().theme?.shimmer === true
|
|
73
|
-
? importThemeComponent("ShimmerComponent")
|
|
74
|
-
: null;
|
|
75
|
-
|
|
76
|
-
export const setWizardTheme = async (theme: IWizardParamsTheme) => {
|
|
77
|
-
const { name, params } = theme;
|
|
78
|
-
wizardTheme = name;
|
|
79
|
-
if (params) themeParams = params;
|
|
80
|
-
await loadTheme();
|
|
81
|
-
const previousConfig = getConfig();
|
|
82
|
-
updateConfig({
|
|
83
|
-
...previousConfig,
|
|
84
|
-
theme,
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export const getThemeParams = () => themeParams;
|
|
89
|
-
|
|
90
|
-
export const loadThemeComponent = (name: string) => importThemeComponent(name);
|
|
91
|
-
|
|
92
|
-
export const addOnThemeLoadCallback = (cb: () => void) => {
|
|
93
|
-
if (themeIndex !== undefined) cb();
|
|
94
|
-
themeLoadCallbacks.push(cb);
|
|
95
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { Suspense, useCallback, useEffect, useState } from "react";
|
|
2
|
-
import { RouteComponentProps } from "react-router-dom";
|
|
3
|
-
import { getPluginsAdditionalRoutes, loadPlugins } from "../PluginLoader";
|
|
4
|
-
import Shimmer from "../Shimmer";
|
|
5
|
-
|
|
6
|
-
export interface IRouteProps {
|
|
7
|
-
path: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type IProps = RouteComponentProps<IRouteProps>;
|
|
11
|
-
|
|
12
|
-
const PluginRoute = ({
|
|
13
|
-
match: {
|
|
14
|
-
params: { path },
|
|
15
|
-
},
|
|
16
|
-
}: IProps) => {
|
|
17
|
-
const [RenderComponent, setRenderComponent] =
|
|
18
|
-
useState<React.ElementType | null>(null);
|
|
19
|
-
|
|
20
|
-
const loadRouteComponent = useCallback(async (routePath: string) => {
|
|
21
|
-
try {
|
|
22
|
-
let routes = getPluginsAdditionalRoutes();
|
|
23
|
-
|
|
24
|
-
if (!routes.length) {
|
|
25
|
-
/** @TODO load plugin from backend instead of defaulting to authentication plugin */
|
|
26
|
-
await loadPlugins({ authentication: "1.0.0" });
|
|
27
|
-
routes = getPluginsAdditionalRoutes();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (routes[routePath]) setRenderComponent(routes[routePath]);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
// eslint-disable-next-line no-console
|
|
33
|
-
console.error(error);
|
|
34
|
-
}
|
|
35
|
-
}, []);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
loadRouteComponent(path);
|
|
39
|
-
}, [path, loadRouteComponent]);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Suspense fallback={() => Shimmer}>
|
|
43
|
-
<>{RenderComponent && <RenderComponent />}</>
|
|
44
|
-
</Suspense>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default PluginRoute;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { useParams } from "react-router-dom";
|
|
3
|
-
import queryString from "query-string";
|
|
4
|
-
import { Action } from "redux";
|
|
5
|
-
import type { Moment } from "moment-business-days";
|
|
6
|
-
import { getConfig } from "../config";
|
|
7
|
-
import { SmartScriptStore } from "../libs/SmartScriptStore";
|
|
8
|
-
import { StateType } from "../types/State.type";
|
|
9
|
-
|
|
10
|
-
export type TInitTriggersCallback = (
|
|
11
|
-
triggers: StateType.SmartScript["triggers"],
|
|
12
|
-
actions: Action[]
|
|
13
|
-
) => void;
|
|
14
|
-
|
|
15
|
-
declare global {
|
|
16
|
-
interface Window {
|
|
17
|
-
onInit: typeof SmartScriptStore.onInit;
|
|
18
|
-
onLoad: typeof SmartScriptStore.onLoad;
|
|
19
|
-
onOptionChange: typeof SmartScriptStore.onOptionChange;
|
|
20
|
-
onVariableChange: typeof SmartScriptStore.onVariableChange;
|
|
21
|
-
updateOptionInput: typeof SmartScriptStore.updateOptionInput;
|
|
22
|
-
updateVariableInput: typeof SmartScriptStore.updateVariableInput;
|
|
23
|
-
updateOptionMeta: typeof SmartScriptStore.updateOptionMeta;
|
|
24
|
-
updateVariableMeta: typeof SmartScriptStore.updateVariableMeta;
|
|
25
|
-
option: (id: number, index: number) => boolean;
|
|
26
|
-
variable: (id: number, index: number) => string | number;
|
|
27
|
-
optionAll: (id: number) => boolean[];
|
|
28
|
-
variableAll: (id: number) => (string | number)[];
|
|
29
|
-
hideOption: typeof SmartScriptStore.hideOption;
|
|
30
|
-
displayOption: typeof SmartScriptStore.displayOption;
|
|
31
|
-
hideVariable: typeof SmartScriptStore.hideVariable;
|
|
32
|
-
displayVariable: typeof SmartScriptStore.displayVariable;
|
|
33
|
-
moment: Moment;
|
|
34
|
-
triggerListeners: (
|
|
35
|
-
type: "option" | "variable",
|
|
36
|
-
id: number,
|
|
37
|
-
inputs: StateType.Inputs
|
|
38
|
-
) => Action[];
|
|
39
|
-
initTriggers: (
|
|
40
|
-
callback: TInitTriggersCallback,
|
|
41
|
-
inputs: StateType.Inputs,
|
|
42
|
-
newInstance: boolean
|
|
43
|
-
) => void;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* SmartScriptComponent
|
|
49
|
-
* --------------------
|
|
50
|
-
* This component loads smartscript code to be executed
|
|
51
|
-
* inside an iframe and assures communication with wizardx
|
|
52
|
-
* store
|
|
53
|
-
*/
|
|
54
|
-
const SmartScriptComponent = () => {
|
|
55
|
-
const [smartScriptLoaded, setSmartScriptLoaded] = useState(false);
|
|
56
|
-
const [isNewInstance, setIsNewInstance] = useState(true);
|
|
57
|
-
const [initTriggersCallback, setInitTriggersCallback] =
|
|
58
|
-
useState<TInitTriggersCallback | null>(null);
|
|
59
|
-
|
|
60
|
-
// Defining store
|
|
61
|
-
window.onInit = SmartScriptStore.onInit;
|
|
62
|
-
window.onLoad = SmartScriptStore.onLoad;
|
|
63
|
-
window.onOptionChange = SmartScriptStore.onOptionChange;
|
|
64
|
-
window.onVariableChange = SmartScriptStore.onVariableChange;
|
|
65
|
-
window.updateOptionInput = SmartScriptStore.updateOptionInput;
|
|
66
|
-
window.updateVariableInput = SmartScriptStore.updateVariableInput;
|
|
67
|
-
window.updateOptionMeta = SmartScriptStore.updateOptionMeta;
|
|
68
|
-
window.updateVariableMeta = SmartScriptStore.updateVariableMeta;
|
|
69
|
-
window.option = SmartScriptStore.getOptionInput;
|
|
70
|
-
window.variable = SmartScriptStore.getVariableInput;
|
|
71
|
-
window.optionAll = SmartScriptStore.getOptionAllInput;
|
|
72
|
-
window.variableAll = SmartScriptStore.getVariableAllInput;
|
|
73
|
-
window.hideVariable = SmartScriptStore.hideVariable;
|
|
74
|
-
window.displayVariable = SmartScriptStore.displayVariable;
|
|
75
|
-
window.hideOption = SmartScriptStore.hideOption;
|
|
76
|
-
window.displayOption = SmartScriptStore.displayOption;
|
|
77
|
-
|
|
78
|
-
// Loading SmartScript
|
|
79
|
-
|
|
80
|
-
// API Endpoint
|
|
81
|
-
const apiEndpoint =
|
|
82
|
-
getConfig().apiEndpoint + (/\/$/.test(getConfig().apiEndpoint) ? "" : "/");
|
|
83
|
-
|
|
84
|
-
// Permalink
|
|
85
|
-
const { permalink, uniqid } = useParams<{
|
|
86
|
-
permalink: string;
|
|
87
|
-
uniqid?: string;
|
|
88
|
-
}>();
|
|
89
|
-
|
|
90
|
-
// Model version
|
|
91
|
-
const modelVersion = queryString.parse(window.location.search).version;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Loads smartscript
|
|
95
|
-
*/
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
if (!smartScriptLoaded) {
|
|
98
|
-
const src = `${apiEndpoint}wizard/contractv1/smartscript/${permalink}${
|
|
99
|
-
uniqid ? `/${uniqid}` : ""
|
|
100
|
-
}${modelVersion ? `?version=${modelVersion}` : ""}`;
|
|
101
|
-
const scriptElement = document.createElement("script");
|
|
102
|
-
scriptElement.setAttribute("src", src);
|
|
103
|
-
scriptElement.onload = () => {
|
|
104
|
-
import("moment-business-days").then(() => {
|
|
105
|
-
if (typeof initTriggersCallback === "function") {
|
|
106
|
-
if (isNewInstance) SmartScriptStore.execOnInit();
|
|
107
|
-
SmartScriptStore.execOnLoad();
|
|
108
|
-
initTriggersCallback(
|
|
109
|
-
SmartScriptStore.triggers,
|
|
110
|
-
SmartScriptStore.grabActions()
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
setSmartScriptLoaded(true);
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
document.body.append(scriptElement);
|
|
117
|
-
}
|
|
118
|
-
}, [
|
|
119
|
-
smartScriptLoaded,
|
|
120
|
-
apiEndpoint,
|
|
121
|
-
initTriggersCallback,
|
|
122
|
-
modelVersion,
|
|
123
|
-
permalink,
|
|
124
|
-
uniqid,
|
|
125
|
-
isNewInstance,
|
|
126
|
-
]);
|
|
127
|
-
|
|
128
|
-
// Init triggers
|
|
129
|
-
window.initTriggers = (callback, inputs, newInstance = true) => {
|
|
130
|
-
// Updating Inputs
|
|
131
|
-
SmartScriptStore.inputs = inputs;
|
|
132
|
-
|
|
133
|
-
if (smartScriptLoaded) {
|
|
134
|
-
if (newInstance) SmartScriptStore.execOnInit();
|
|
135
|
-
SmartScriptStore.execOnLoad();
|
|
136
|
-
callback(SmartScriptStore.triggers, SmartScriptStore.grabActions());
|
|
137
|
-
} else {
|
|
138
|
-
setInitTriggersCallback(callback);
|
|
139
|
-
setIsNewInstance(newInstance);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// Triggering listeners
|
|
144
|
-
window.triggerListeners = (type, id, inputs) => {
|
|
145
|
-
const hooks =
|
|
146
|
-
SmartScriptStore.hooks[type === "option" ? "options" : "variables"];
|
|
147
|
-
const listeners = hooks[id];
|
|
148
|
-
|
|
149
|
-
if (Array.isArray(listeners)) {
|
|
150
|
-
// Updating Inputs
|
|
151
|
-
SmartScriptStore.inputs = inputs;
|
|
152
|
-
try {
|
|
153
|
-
listeners.forEach((_cb) => _cb());
|
|
154
|
-
} catch (e) {
|
|
155
|
-
// eslint-disable-next-line no-console
|
|
156
|
-
console.error("SmartScript (onInit) error: ", e.message);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return SmartScriptStore.grabActions();
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
return <>SmartScript</>;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export default SmartScriptComponent;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties } from "react";
|
|
2
|
-
import { ReplaceComponent } from "../../PluginLoader";
|
|
3
|
-
|
|
4
|
-
export interface IProps {
|
|
5
|
-
unhealthyStyle: CSSProperties;
|
|
6
|
-
}
|
|
7
|
-
const UserLockedComponent = ({ unhealthyStyle }: IProps) => (
|
|
8
|
-
<div style={unhealthyStyle}>
|
|
9
|
-
Merci d‘avoir complété votre questionnaire ! Votre Expert-Comptable a
|
|
10
|
-
été notifié de vos réponses et vous contactera pour la suite de la procédure
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* UserLock Higher-Order-Component
|
|
16
|
-
* @param Component UI Component
|
|
17
|
-
*/
|
|
18
|
-
const UserLockHooc =
|
|
19
|
-
(Component: React.ComponentType<IProps>): React.FC<IProps> =>
|
|
20
|
-
// eslint-disable-next-line react/display-name
|
|
21
|
-
(props) => {
|
|
22
|
-
// Component replace
|
|
23
|
-
const replaceAnchors = ["UserLockedComponent"];
|
|
24
|
-
const FinalComponent = ReplaceComponent(replaceAnchors, Component);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<>
|
|
28
|
-
<FinalComponent {...props} />
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default UserLockHooc(UserLockedComponent);
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import 'regenerator-runtime/runtime';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
-
import { render, cleanup, waitFor } from '@testing-library/react';
|
|
5
|
-
import { Provider } from 'react-redux';
|
|
6
|
-
import loadable from '@loadable/component';
|
|
7
|
-
import { createAppStore, getStore } from '../redux/store';
|
|
8
|
-
import {
|
|
9
|
-
initPaginationAction,
|
|
10
|
-
initMetaAction,
|
|
11
|
-
fetchModelSucceededAction,
|
|
12
|
-
goPageAction,
|
|
13
|
-
} from '../redux/actions/app';
|
|
14
|
-
import View from './View';
|
|
15
|
-
import { loadTheme } from '../ThemeLoader';
|
|
16
|
-
|
|
17
|
-
afterEach(cleanup);
|
|
18
|
-
|
|
19
|
-
// Mocking config
|
|
20
|
-
jest.mock('../config', () => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
getConfig: () => ({
|
|
23
|
-
theme: { name: 'jestTestTheme' },
|
|
24
|
-
plugins: {},
|
|
25
|
-
apiEndpoint: 'https://api.legalplace.fr/api/v1/',
|
|
26
|
-
router: {
|
|
27
|
-
wizardPath:
|
|
28
|
-
'/:permalink/:modelId([0-9]+)?/questionnaire/:page([0-9]+|sommaire)',
|
|
29
|
-
wizardInstancePath:
|
|
30
|
-
'/:permalink/:modelId([0-9]+)?/questionnaire/:uniqid([0-9a-zA-Z]+)/:page([0-9]+|sommaire)',
|
|
31
|
-
},
|
|
32
|
-
appStates: ['wizard', 'termsheet'],
|
|
33
|
-
}),
|
|
34
|
-
isConfigReady: () => true,
|
|
35
|
-
loadConfig: async (): Promise<Record<string, any>> => ({
|
|
36
|
-
theme: { name: 'jestTestTheme' },
|
|
37
|
-
plugins: {},
|
|
38
|
-
apiEndpoint: 'https://api.legalplace.fr/api/v1/',
|
|
39
|
-
router: {
|
|
40
|
-
wizardPath:
|
|
41
|
-
'/:permalink/:modelId([0-9]+)?/questionnaire/:page([0-9]+|sommaire)',
|
|
42
|
-
wizardInstancePath:
|
|
43
|
-
'/:permalink/:modelId([0-9]+)?/questionnaire/:uniqid([0-9a-zA-Z]+)/:page([0-9]+|sommaire)',
|
|
44
|
-
},
|
|
45
|
-
appStates: ['wizard', 'termsheet'],
|
|
46
|
-
}),
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
jest.mock('../Globals', () => ({
|
|
50
|
-
loadTheme: (plugin: string) => import(`../tests-misc/themes/${plugin}`),
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
describe('<View />', () => {
|
|
54
|
-
let store: any;
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
createAppStore('memory');
|
|
57
|
-
store = getStore();
|
|
58
|
-
store.dispatch(
|
|
59
|
-
initPaginationAction({
|
|
60
|
-
currentPage: 1,
|
|
61
|
-
greatestPage: 1,
|
|
62
|
-
currentSectionId: 1,
|
|
63
|
-
availableSections: [1, 2],
|
|
64
|
-
currentAppState: 'wizard',
|
|
65
|
-
availableAppStates: ['wizard', 'termsheet'],
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
store.dispatch(
|
|
69
|
-
initMetaAction({
|
|
70
|
-
title: 'My Test Document',
|
|
71
|
-
id: 132,
|
|
72
|
-
prefix: '',
|
|
73
|
-
permalink: 'my-test-document',
|
|
74
|
-
modelVersion: 1,
|
|
75
|
-
productType: 'demarche',
|
|
76
|
-
})
|
|
77
|
-
);
|
|
78
|
-
store.dispatch(fetchModelSucceededAction());
|
|
79
|
-
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('Loads WizardComponent properly', async () => {
|
|
83
|
-
await loadTheme();
|
|
84
|
-
const { container } = render(
|
|
85
|
-
<Provider store={store}>
|
|
86
|
-
<View />
|
|
87
|
-
</Provider>
|
|
88
|
-
);
|
|
89
|
-
await waitFor(() =>
|
|
90
|
-
expect(container).toContainHTML(
|
|
91
|
-
'<div><h1>Wizard test theme, WizardComponent</h1></div>'
|
|
92
|
-
)
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('Loads TermsheetComponent properly', async () => {
|
|
97
|
-
store.dispatch(goPageAction(3));
|
|
98
|
-
await loadTheme();
|
|
99
|
-
const { container } = render(
|
|
100
|
-
<Provider store={store}>
|
|
101
|
-
<View />
|
|
102
|
-
</Provider>
|
|
103
|
-
);
|
|
104
|
-
await waitFor(() =>
|
|
105
|
-
expect(container).toContainHTML(
|
|
106
|
-
'<div><h1>Wizard test theme, TermsheetComponent</h1></div>'
|
|
107
|
-
)
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
});
|