@arquimedes.co/eureka-forms 2.0.101 → 2.0.104
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/dist/@Types/FormStep.d.ts +7 -3
- package/dist/@Types/GenericFormSteps.d.ts +1 -0
- package/dist/App/App.css +11 -0
- package/dist/App/App.d.ts +2 -0
- package/dist/App/App.js +2 -1
- package/dist/App/AppFunctions.d.ts +4 -4
- package/dist/App/AppHooks.js +1 -17
- package/dist/Form/Form.d.ts +2 -0
- package/dist/Form/FormFunctions.js +2 -0
- package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +33 -30
- package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +26 -23
- package/dist/FormSteps/AYFStepMapper.js +45 -42
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +57 -54
- package/dist/FormSteps/CBRStepMapper.js +80 -65
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +64 -57
- package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +5 -2
- package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +4 -1
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +30 -9
- package/dist/Services/DraftService.d.ts +21 -0
- package/dist/Services/DraftService.js +71 -0
- package/dist/Shared/SmartDraftRenderer.d.ts +8 -0
- package/dist/Shared/SmartDraftRenderer.js +17 -0
- package/dist/States/GlobalSlice.d.ts +2 -0
- package/dist/Utils/AxiosAPI.d.ts +11 -0
- package/dist/Utils/AxiosAPI.js +72 -0
- package/dist/Utils/StoreContext.d.ts +2 -0
- package/dist/Utils/StoreContext.js +2 -0
- package/dist/Utils/TestUtils.d.ts +22 -2
- package/dist/Utils/TestUtils.js +11 -4
- package/dist/Utils/_api.d.ts +8 -0
- package/dist/Utils/_api.js +13 -0
- package/dist/Utils/store.d.ts +10 -2
- package/dist/Utils/store.js +12 -2
- package/dist/constants/FormStepTypes.d.ts +2 -1
- package/dist/constants/FormStepTypes.js +1 -0
- package/dist/hooks.d.ts +0 -2
- package/dist/hooks.js +2 -3
- package/package.json +1 -1
|
@@ -7,8 +7,8 @@ import { Time } from './Time';
|
|
|
7
7
|
export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper;
|
|
8
8
|
export interface Title extends GSteps.GBaseStep {
|
|
9
9
|
type: FormStepTypes.TITLE;
|
|
10
|
-
title
|
|
11
|
-
description
|
|
10
|
+
title?: EurekaDraft;
|
|
11
|
+
description?: EurekaDraft;
|
|
12
12
|
size?: 1 | 2 | 3 | 4;
|
|
13
13
|
}
|
|
14
14
|
export interface TimePicker extends GSteps.GTimePicker {
|
|
@@ -146,7 +146,7 @@ export interface ValueEntityValuePickerPath {
|
|
|
146
146
|
type: EntityValueDataTypes.VALUE;
|
|
147
147
|
idEntityValue: string | null;
|
|
148
148
|
}
|
|
149
|
-
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter;
|
|
149
|
+
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | CurrentAgentEntityValuePickerFilter;
|
|
150
150
|
export interface StepEntityValuePickerFilter {
|
|
151
151
|
idProperty: string;
|
|
152
152
|
type: EntityValueDataTypes.STEP;
|
|
@@ -159,6 +159,10 @@ export interface ValueEntityValuePickerFilter {
|
|
|
159
159
|
type: EntityValueDataTypes.VALUE;
|
|
160
160
|
value: any;
|
|
161
161
|
}
|
|
162
|
+
export interface CurrentAgentEntityValuePickerFilter {
|
|
163
|
+
idProperty: string;
|
|
164
|
+
type: EntityValueDataTypes.CURRENT_AGENT;
|
|
165
|
+
}
|
|
162
166
|
export interface ApiSelector extends GSteps.GSmartSelect {
|
|
163
167
|
type: FormStepTypes.API_SELECTOR;
|
|
164
168
|
icon?: IconTypes;
|
package/dist/App/App.css
CHANGED
package/dist/App/App.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { CountryCode } from 'libphonenumber-js';
|
|
|
7
7
|
export interface AppProps {
|
|
8
8
|
/** If the app is currently a widget */
|
|
9
9
|
isWidget?: boolean;
|
|
10
|
+
/** The id of the current agent using the form (Internal)*/
|
|
11
|
+
idCurrentAgent?: string;
|
|
10
12
|
/** The apikey of the Form */
|
|
11
13
|
apiKey?: string;
|
|
12
14
|
/** The id of the form's organization */
|
package/dist/App/App.js
CHANGED
|
@@ -29,9 +29,10 @@ import FormComponent from '../Form/Form';
|
|
|
29
29
|
import { Provider } from 'react-redux';
|
|
30
30
|
import { store } from '../Utils/store';
|
|
31
31
|
import { useSetupApp } from './AppHooks';
|
|
32
|
-
import {
|
|
32
|
+
import { useAppSelector } from '../hooks';
|
|
33
33
|
import CustomContext from '../Contexts/CustomContext';
|
|
34
34
|
import { nanoid } from '@reduxjs/toolkit';
|
|
35
|
+
import { StoreContext } from '../Utils/StoreContext';
|
|
35
36
|
export var IdFormContext = createContext('');
|
|
36
37
|
function AppComponent(_a) {
|
|
37
38
|
var formData = _a.formData, valuesData = _a.valuesData, props = __rest(_a, ["formData", "valuesData"]);
|
|
@@ -6,8 +6,8 @@ import { MapperElement } from '../@Types/MapperElement';
|
|
|
6
6
|
import { MapperValue } from '../FormSteps/MapperStep/MaterialMapperStep/MaterialMapperStep';
|
|
7
7
|
import { CountryCode } from 'libphonenumber-js/max';
|
|
8
8
|
export declare const calcValuesStore: (orgInfo: {
|
|
9
|
-
idOrganization
|
|
10
|
-
countryCode
|
|
9
|
+
idOrganization?: string;
|
|
10
|
+
countryCode?: CountryCode;
|
|
11
11
|
}, form: Readonly<Form>, originalValues?: Record<string, any>, postview?: boolean, customSteps?: Record<string, CustomStep>) => Promise<ValuesStore>;
|
|
12
12
|
export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<string, CustomStep>, path?: string) => {
|
|
13
13
|
element: MapperElement<Type>;
|
|
@@ -17,7 +17,7 @@ export declare const addMapperStep: <Type>(step: Mapper, customSteps: Record<str
|
|
|
17
17
|
steps: Record<string, FormStep>;
|
|
18
18
|
};
|
|
19
19
|
export declare const mapOriginalValue: (orgInfo: {
|
|
20
|
-
idOrganization
|
|
21
|
-
countryCode
|
|
20
|
+
idOrganization?: string;
|
|
21
|
+
countryCode?: CountryCode;
|
|
22
22
|
}, step: FormStep, value: any, values: ValuesStore, form?: Readonly<Form>, path?: string) => Promise<any>;
|
|
23
23
|
export declare const calcInitialSections: (form: Form) => Pick<SiteState, 'previousSections' | 'idCurrentSection' | 'nextSections'>;
|
package/dist/App/AppHooks.js
CHANGED
|
@@ -68,8 +68,6 @@ import { calcDependencies } from '../Form/FormFunctions';
|
|
|
68
68
|
import { iterateNestedSteps } from '../FormSteps/StepFunctions';
|
|
69
69
|
import { createNextState } from '@reduxjs/toolkit';
|
|
70
70
|
import { BaseConfirmationMessage } from '../Contexts/FormContext';
|
|
71
|
-
import FormStepTypes from '../constants/FormStepTypes';
|
|
72
|
-
import { draftToString } from '../Utils/DraftFunctions';
|
|
73
71
|
export var useSetupApp = function (isEmbedded, _a) {
|
|
74
72
|
var _b;
|
|
75
73
|
var preview = _a.preview, internal = _a.internal, postview = _a.postview, partial = _a.partial, editable = _a.editable, handleConfirmed = _a.handleConfirmed, customSteps = _a.customSteps, valuesData = _a.valuesData, apiKey = _a.apiKey, formData = _a.formData, classifiers = _a.classifiers, others = __rest(_a, ["preview", "internal", "postview", "partial", "editable", "handleConfirmed", "customSteps", "valuesData", "apiKey", "formData", "classifiers"]);
|
|
@@ -158,22 +156,8 @@ export var useSetupApp = function (isEmbedded, _a) {
|
|
|
158
156
|
for (var _b = 0, _c = section.steps; _b < _c.length; _b++) {
|
|
159
157
|
var idStep = _c[_b];
|
|
160
158
|
iterateNestedSteps(idStep, form.steps, function (step) {
|
|
161
|
-
var _a, _b, _c;
|
|
162
159
|
step.idSection = section.id;
|
|
163
|
-
|
|
164
|
-
if ((_a = step.title) === null || _a === void 0 ? void 0 : _a.blocks) {
|
|
165
|
-
if ((_b = step.title) === null || _b === void 0 ? void 0 : _b.blocks)
|
|
166
|
-
step.title = draftToString({
|
|
167
|
-
form: form,
|
|
168
|
-
dependencies: {},
|
|
169
|
-
}, step.title);
|
|
170
|
-
if ((_c = step.description) === null || _c === void 0 ? void 0 : _c.blocks)
|
|
171
|
-
step.description = draftToString({
|
|
172
|
-
form: form,
|
|
173
|
-
dependencies: {},
|
|
174
|
-
}, step.description);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
160
|
+
step.idOriginal = step.id;
|
|
177
161
|
});
|
|
178
162
|
}
|
|
179
163
|
};
|
package/dist/Form/Form.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { FormStep } from '../@Types/FormStep';
|
|
|
9
9
|
import { CBRFormStep } from '../@Types/CBRFormStep';
|
|
10
10
|
export declare const getLocale: () => any;
|
|
11
11
|
export interface StepDependency {
|
|
12
|
+
/** The id of the step before it was mapped */
|
|
13
|
+
idOriginal: string;
|
|
12
14
|
dependents: (FormStep | CBRFormStep)[];
|
|
13
15
|
value: any | undefined;
|
|
14
16
|
type: FormStepTypes | CBRFormStepTypes | 'ORIGINAL';
|
|
@@ -215,6 +215,7 @@ function calcStepDependency(idStep, steps, values, customSteps) {
|
|
|
215
215
|
if (!originalValue_1)
|
|
216
216
|
console.error('Missing Step Dependency:', idStep);
|
|
217
217
|
return {
|
|
218
|
+
idOriginal: idStep,
|
|
218
219
|
type: originalValue_1 ? 'ORIGINAL' : 'MISSING',
|
|
219
220
|
value: originalValue_1 !== null && originalValue_1 !== void 0 ? originalValue_1 : null,
|
|
220
221
|
dependents: [],
|
|
@@ -223,6 +224,7 @@ function calcStepDependency(idStep, steps, values, customSteps) {
|
|
|
223
224
|
var originalValue = (_b = (_a = values.sections[depStep.idSection]) === null || _a === void 0 ? void 0 : _a[depStep.id]) !== null && _b !== void 0 ? _b : values.global[depStep.id];
|
|
224
225
|
return {
|
|
225
226
|
type: depStep.type,
|
|
227
|
+
idOriginal: depStep.idOriginal,
|
|
226
228
|
value: calcStepDependencyValue(depStep, originalValue, customSteps),
|
|
227
229
|
dependents: [],
|
|
228
230
|
};
|
|
@@ -91,37 +91,40 @@ function ElementSubStepRenderer(_a) {
|
|
|
91
91
|
return option.id === value.id;
|
|
92
92
|
}, getValueString: function (value) { return value === null || value === void 0 ? void 0 : value.id; }, renderNestedSteps: function (value) { return (_jsx(ElementSubStepRenderer, __assign({ value: value }, stepProps, { step: subStep }))); } })));
|
|
93
93
|
}
|
|
94
|
-
var getElementOptions = function (
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
94
|
+
var getElementOptions = function (step, dependencyStore, _a) {
|
|
95
|
+
var idOrganization = _a.idOrganization;
|
|
96
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
+
var idProyecto, response, father_1;
|
|
98
|
+
var _b, _c, _d;
|
|
99
|
+
return __generator(this, function (_e) {
|
|
100
|
+
switch (_e.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
|
|
103
|
+
idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
|
|
104
|
+
if (!idProyecto) {
|
|
105
|
+
return [2 /*return*/, null]; //null para indicar que falta la depedency
|
|
106
|
+
}
|
|
107
|
+
return [4 /*yield*/, axios.get("https://integrations.".concat(process.env.REACT_APP_DOMAIN, "/sinco/cbr/Locativas?idOrganization=").concat(idOrganization))];
|
|
108
|
+
case 1:
|
|
109
|
+
response = (_e.sent()).data;
|
|
110
|
+
father_1 = (_d = dependencyStore[step.dependencies[1]]) === null || _d === void 0 ? void 0 : _d.value;
|
|
111
|
+
if (father_1 && father_1.id === undefined) {
|
|
112
|
+
return [2 /*return*/, null];
|
|
113
|
+
}
|
|
114
|
+
return [2 /*return*/, response.filter(function (locativa) {
|
|
115
|
+
if (father_1 === null || father_1 === void 0 ? void 0 : father_1.id) {
|
|
116
|
+
return (locativa.id.startsWith(father_1.id) &&
|
|
117
|
+
locativa.id !== father_1.id);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return locativa.id.length === 2;
|
|
121
|
+
}
|
|
122
|
+
})];
|
|
123
|
+
case 2: return [2 /*return*/, null];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
123
126
|
});
|
|
124
|
-
}
|
|
127
|
+
};
|
|
125
128
|
var calcDepError = function (steps) {
|
|
126
129
|
for (var _i = 0, steps_1 = steps; _i < steps_1.length; _i++) {
|
|
127
130
|
var step = steps_1[_i];
|
|
@@ -62,30 +62,33 @@ function CBRPropertyStepComponent(props) {
|
|
|
62
62
|
var _this = this;
|
|
63
63
|
var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
|
|
64
64
|
var _a = useState(undefined), showWarning = _a[0], setShowWarning = _a[1];
|
|
65
|
-
var getInmueblesOptions = function (
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
65
|
+
var getInmueblesOptions = function (step, dependencyStore, _a) {
|
|
66
|
+
var idOrganization = _a.idOrganization;
|
|
67
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
68
|
+
var idProyecto, idMacroProyecto;
|
|
69
|
+
var _b, _c, _d, _e;
|
|
70
|
+
return __generator(this, function (_f) {
|
|
71
|
+
switch (_f.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
|
|
74
|
+
idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
|
|
75
|
+
idMacroProyecto = (_e = (_d = dependencyStore[step.dependencies[0]]) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.idMacroProyecto;
|
|
76
|
+
if (!idProyecto) {
|
|
77
|
+
return [2 /*return*/, null]; //null para indicar que falta la depedency
|
|
78
|
+
}
|
|
79
|
+
return [4 /*yield*/, axios.get(baseUrl +
|
|
80
|
+
'Inmuebles?idMacro=' +
|
|
81
|
+
idMacroProyecto +
|
|
82
|
+
'&idProyecto=' +
|
|
83
|
+
idProyecto +
|
|
84
|
+
'&idOrganization=' +
|
|
85
|
+
idOrganization)];
|
|
86
|
+
case 1: return [2 /*return*/, (_f.sent()).data];
|
|
87
|
+
case 2: return [2 /*return*/, null];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
87
90
|
});
|
|
88
|
-
}
|
|
91
|
+
};
|
|
89
92
|
return (_jsxs(React.Fragment, { children: [_jsx(SmartSelectStep, __assign({}, props, { icon: _jsx(InputIcon, { icon: 'PROPERTY' }), getOptionSelected: function (option, value) {
|
|
90
93
|
return option.id === value.id;
|
|
91
94
|
}, calcDepError: function (steps) {
|
|
@@ -75,51 +75,54 @@ function AYFStepMapper(props) {
|
|
|
75
75
|
]];
|
|
76
76
|
});
|
|
77
77
|
}); };
|
|
78
|
-
var getCiudadesOptions = function (
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
78
|
+
var getCiudadesOptions = function (step, dependencyStore, _a) {
|
|
79
|
+
var idOrganization = _a.idOrganization;
|
|
80
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
81
|
+
var nit, params, _i, _b, dep, value, error_1;
|
|
82
|
+
var _c, _d, _e, _f;
|
|
83
|
+
return __generator(this, function (_g) {
|
|
84
|
+
switch (_g.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
if (!idOrganization)
|
|
87
|
+
return [2 /*return*/, null];
|
|
88
|
+
nit = (_c = dependencyStore[step.idNitStep]) === null || _c === void 0 ? void 0 : _c.value;
|
|
89
|
+
params = new URLSearchParams({
|
|
90
|
+
idOrganization: idOrganization,
|
|
91
|
+
idCompany: nit,
|
|
92
|
+
nit: 'true',
|
|
93
|
+
});
|
|
94
|
+
for (_i = 0, _b = (_d = step.dependencies) !== null && _d !== void 0 ? _d : []; _i < _b.length; _i++) {
|
|
95
|
+
dep = _b[_i];
|
|
96
|
+
value = (_e = dependencyStore[dep]) === null || _e === void 0 ? void 0 : _e.value;
|
|
97
|
+
if (value && dep.startsWith('AYF')) {
|
|
98
|
+
switch ((_f = dep.split('-')) === null || _f === void 0 ? void 0 : _f[0]) {
|
|
99
|
+
case AYFFormStepTypes.AYF_START_MONTH:
|
|
100
|
+
params.set('startMonth', value.id);
|
|
101
|
+
break;
|
|
102
|
+
case AYFFormStepTypes.AYF_END_MONTH:
|
|
103
|
+
params.set('endMonth', value.id);
|
|
104
|
+
break;
|
|
105
|
+
case AYFFormStepTypes.AYF_YEAR:
|
|
106
|
+
params.set('year', value);
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return [
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return [2 /*return
|
|
119
|
-
|
|
120
|
-
}
|
|
113
|
+
_g.label = 1;
|
|
114
|
+
case 1:
|
|
115
|
+
_g.trys.push([1, 3, , 4]);
|
|
116
|
+
return [4 /*yield*/, axios.get(baseUrl + 'CiudadesICA?' + params.toString())];
|
|
117
|
+
case 2: return [2 /*return*/, (_g.sent()).data];
|
|
118
|
+
case 3:
|
|
119
|
+
error_1 = _g.sent();
|
|
120
|
+
return [2 /*return*/, null];
|
|
121
|
+
case 4: return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
121
124
|
});
|
|
122
|
-
}
|
|
125
|
+
};
|
|
123
126
|
switch (props.step.type) {
|
|
124
127
|
case AYFFormStepTypes.AYF_START_MONTH:
|
|
125
128
|
case AYFFormStepTypes.AYF_END_MONTH:
|
|
@@ -90,65 +90,68 @@ function ApiSelectorComponent(_a) {
|
|
|
90
90
|
return (_a = option === null || option === void 0 ? void 0 : option[step.labelAttribute]) !== null && _a !== void 0 ? _a : '';
|
|
91
91
|
}
|
|
92
92
|
var getApiOptions = useMemo(function () {
|
|
93
|
-
return function (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
return function (step, dependencyStore, _a) {
|
|
94
|
+
var idOrganization = _a.idOrganization;
|
|
95
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
+
function calcOptionId(option) {
|
|
97
|
+
var _a;
|
|
98
|
+
return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
|
|
99
|
+
}
|
|
100
|
+
var params, _i, _b, filter, currentValue, filterStep, url, response;
|
|
101
|
+
var _c, _d;
|
|
102
|
+
return __generator(this, function (_e) {
|
|
103
|
+
switch (_e.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
params = new URLSearchParams({});
|
|
106
|
+
for (_i = 0, _b = step.queryParams; _i < _b.length; _i++) {
|
|
107
|
+
filter = _b[_i];
|
|
108
|
+
switch (filter.type) {
|
|
109
|
+
case ApiSelectorParamTypes.STEP: {
|
|
110
|
+
currentValue = (_c = dependencyStore[filter.idStep]) === null || _c === void 0 ? void 0 : _c.value;
|
|
111
|
+
filterStep = form.steps[filter.idStep];
|
|
112
|
+
if (currentValue) {
|
|
113
|
+
if (filterStep.type ===
|
|
114
|
+
FormStepTypes.API_SELECTOR) {
|
|
115
|
+
params.set(filter.key, currentValue[step.idAttribute]);
|
|
116
|
+
}
|
|
117
|
+
else if (typeof currentValue === 'string')
|
|
118
|
+
params.set(filter.key, currentValue);
|
|
119
|
+
else
|
|
120
|
+
params.set(filter.key, (_d = currentValue.label) !== null && _d !== void 0 ? _d : currentValue.id);
|
|
114
121
|
}
|
|
115
|
-
else if (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
else if (filter.required) {
|
|
121
|
-
return [2 /*return*/, null];
|
|
122
|
+
else if (filter.required) {
|
|
123
|
+
return [2 /*return*/, null];
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
122
126
|
}
|
|
123
|
-
|
|
127
|
+
case ApiSelectorParamTypes.VALUE:
|
|
128
|
+
default:
|
|
129
|
+
params.set(filter.key, filter.value);
|
|
130
|
+
break;
|
|
124
131
|
}
|
|
125
|
-
case ApiSelectorParamTypes.VALUE:
|
|
126
|
-
default:
|
|
127
|
-
params.set(filter.key, filter.value);
|
|
128
|
-
break;
|
|
129
132
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
url +=
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
133
|
+
url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
|
|
134
|
+
if (idOrganization &&
|
|
135
|
+
url.includes(process.env.REACT_APP_DOMAIN))
|
|
136
|
+
params.set('idOrganization', idOrganization);
|
|
137
|
+
if (!step.url.includes('?'))
|
|
138
|
+
url += '?';
|
|
139
|
+
url += params.toString();
|
|
140
|
+
return [4 /*yield*/, (idOrganization
|
|
141
|
+
? widgetInstance.get(url)
|
|
142
|
+
: axiosInstance.get(url))];
|
|
143
|
+
case 1:
|
|
144
|
+
response = _e.sent();
|
|
145
|
+
return [2 /*return*/, response.data.filter(function (option) {
|
|
146
|
+
var _a;
|
|
147
|
+
return calcOptionId(option) &&
|
|
148
|
+
((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
|
|
149
|
+
ApiSelectorOptionTypes.HIDE;
|
|
150
|
+
})];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
150
153
|
});
|
|
151
|
-
}
|
|
154
|
+
};
|
|
152
155
|
}, [form]);
|
|
153
156
|
return (_jsx(StepFillerContainer, __assign({ step: step }, { children: _jsx(SmartSelect, __assign({}, others, { editable: editable, step: step, icon: step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined, getOptions: getApiOptions, getOptionSelected: function (option, value) {
|
|
154
157
|
return calcOptionId(option) === calcOptionId(value);
|