@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.
Files changed (38) hide show
  1. package/dist/@Types/FormStep.d.ts +7 -3
  2. package/dist/@Types/GenericFormSteps.d.ts +1 -0
  3. package/dist/App/App.css +11 -0
  4. package/dist/App/App.d.ts +2 -0
  5. package/dist/App/App.js +2 -1
  6. package/dist/App/AppFunctions.d.ts +4 -4
  7. package/dist/App/AppHooks.js +1 -17
  8. package/dist/Form/Form.d.ts +2 -0
  9. package/dist/Form/FormFunctions.js +2 -0
  10. package/dist/FormSteps/@Construction/CBRElementStep/CBRElementStep.js +33 -30
  11. package/dist/FormSteps/@Construction/CBRPropertyStep/CBRPropertyStep.js +26 -23
  12. package/dist/FormSteps/AYFStepMapper.js +45 -42
  13. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +57 -54
  14. package/dist/FormSteps/CBRStepMapper.js +80 -65
  15. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +64 -57
  16. package/dist/FormSteps/SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep.js +5 -2
  17. package/dist/FormSteps/SmartSelectStep/SmartSelectStep.d.ts +4 -1
  18. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +30 -9
  19. package/dist/Services/DraftService.d.ts +21 -0
  20. package/dist/Services/DraftService.js +71 -0
  21. package/dist/Shared/SmartDraftRenderer.d.ts +8 -0
  22. package/dist/Shared/SmartDraftRenderer.js +17 -0
  23. package/dist/States/GlobalSlice.d.ts +2 -0
  24. package/dist/Utils/AxiosAPI.d.ts +11 -0
  25. package/dist/Utils/AxiosAPI.js +72 -0
  26. package/dist/Utils/StoreContext.d.ts +2 -0
  27. package/dist/Utils/StoreContext.js +2 -0
  28. package/dist/Utils/TestUtils.d.ts +22 -2
  29. package/dist/Utils/TestUtils.js +11 -4
  30. package/dist/Utils/_api.d.ts +8 -0
  31. package/dist/Utils/_api.js +13 -0
  32. package/dist/Utils/store.d.ts +10 -2
  33. package/dist/Utils/store.js +12 -2
  34. package/dist/constants/FormStepTypes.d.ts +2 -1
  35. package/dist/constants/FormStepTypes.js +1 -0
  36. package/dist/hooks.d.ts +0 -2
  37. package/dist/hooks.js +2 -3
  38. 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: string;
11
- description: string | null;
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;
@@ -2,6 +2,7 @@ import { Condition } from './Condition';
2
2
  export interface GBaseStep {
3
3
  id: string;
4
4
  idSection: string;
5
+ idOriginal: string;
5
6
  type: string;
6
7
  editable?: boolean;
7
8
  partial?: boolean;
package/dist/App/App.css CHANGED
@@ -18,3 +18,14 @@
18
18
  text-align: center;
19
19
  }
20
20
  }
21
+
22
+ .Erk-Forms-Draft {
23
+ text-align: center;
24
+ pointer-events: none;
25
+ }
26
+
27
+ .Erk-Forms-Draft {
28
+ .public-DraftStyleDefault-block {
29
+ margin: 0;
30
+ }
31
+ }
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 { StoreContext, useAppSelector } from '../hooks';
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: string;
10
- countryCode: 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: string;
21
- countryCode: 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'>;
@@ -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
- if (step.type === FormStepTypes.TITLE) {
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
  };
@@ -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 (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
95
- var idProyecto, response, father_1;
96
- var _a, _b, _c;
97
- return __generator(this, function (_d) {
98
- switch (_d.label) {
99
- case 0:
100
- if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
101
- idProyecto = (_b = (_a = dependencyStore[step.dependencies[0]]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.id;
102
- if (!idProyecto) {
103
- return [2 /*return*/, null]; //null para indicar que falta la depedency
104
- }
105
- return [4 /*yield*/, axios.get("https://integrations.".concat(process.env.REACT_APP_DOMAIN, "/sinco/cbr/Locativas?idOrganization=").concat(idOrganization))];
106
- case 1:
107
- response = (_d.sent()).data;
108
- father_1 = (_c = dependencyStore[step.dependencies[1]]) === null || _c === void 0 ? void 0 : _c.value;
109
- if (father_1 && father_1.id === undefined) {
110
- return [2 /*return*/, null];
111
- }
112
- return [2 /*return*/, response.filter(function (locativa) {
113
- if (father_1 === null || father_1 === void 0 ? void 0 : father_1.id) {
114
- return (locativa.id.startsWith(father_1.id) &&
115
- locativa.id !== father_1.id);
116
- }
117
- else {
118
- return locativa.id.length === 2;
119
- }
120
- })];
121
- case 2: return [2 /*return*/, null];
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 (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
66
- var idProyecto, idMacroProyecto;
67
- var _a, _b, _c, _d;
68
- return __generator(this, function (_e) {
69
- switch (_e.label) {
70
- case 0:
71
- if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
72
- idProyecto = (_b = (_a = dependencyStore[step.dependencies[0]]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.id;
73
- idMacroProyecto = (_d = (_c = dependencyStore[step.dependencies[0]]) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.idMacroProyecto;
74
- if (!idProyecto) {
75
- return [2 /*return*/, null]; //null para indicar que falta la depedency
76
- }
77
- return [4 /*yield*/, axios.get(baseUrl +
78
- 'Inmuebles?idMacro=' +
79
- idMacroProyecto +
80
- '&idProyecto=' +
81
- idProyecto +
82
- '&idOrganization=' +
83
- idOrganization)];
84
- case 1: return [2 /*return*/, (_e.sent()).data];
85
- case 2: return [2 /*return*/, null];
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 (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
79
- var nit, params, _i, _a, dep, value, error_1;
80
- var _b, _c, _d, _e;
81
- return __generator(this, function (_f) {
82
- switch (_f.label) {
83
- case 0:
84
- if (!idOrganization)
85
- return [2 /*return*/, null];
86
- nit = (_b = dependencyStore[step.idNitStep]) === null || _b === void 0 ? void 0 : _b.value;
87
- params = new URLSearchParams({
88
- idOrganization: idOrganization,
89
- idCompany: nit,
90
- nit: 'true',
91
- });
92
- for (_i = 0, _a = (_c = step.dependencies) !== null && _c !== void 0 ? _c : []; _i < _a.length; _i++) {
93
- dep = _a[_i];
94
- value = (_d = dependencyStore[dep]) === null || _d === void 0 ? void 0 : _d.value;
95
- if (value && dep.startsWith('AYF')) {
96
- switch ((_e = dep.split('-')) === null || _e === void 0 ? void 0 : _e[0]) {
97
- case AYFFormStepTypes.AYF_START_MONTH:
98
- params.set('startMonth', value.id);
99
- break;
100
- case AYFFormStepTypes.AYF_END_MONTH:
101
- params.set('endMonth', value.id);
102
- break;
103
- case AYFFormStepTypes.AYF_YEAR:
104
- params.set('year', value);
105
- break;
106
- default:
107
- break;
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
- _f.label = 1;
112
- case 1:
113
- _f.trys.push([1, 3, , 4]);
114
- return [4 /*yield*/, axios.get(baseUrl + 'CiudadesICA?' + params.toString())];
115
- case 2: return [2 /*return*/, (_f.sent()).data];
116
- case 3:
117
- error_1 = _f.sent();
118
- return [2 /*return*/, null];
119
- case 4: return [2 /*return*/];
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 (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
94
- function calcOptionId(option) {
95
- var _a;
96
- return (_a = option === null || option === void 0 ? void 0 : option[step.idAttribute]) !== null && _a !== void 0 ? _a : '';
97
- }
98
- var params, _i, _a, filter, currentValue, filterStep, url, response;
99
- var _b, _c;
100
- return __generator(this, function (_d) {
101
- switch (_d.label) {
102
- case 0:
103
- params = new URLSearchParams({});
104
- for (_i = 0, _a = step.queryParams; _i < _a.length; _i++) {
105
- filter = _a[_i];
106
- switch (filter.type) {
107
- case ApiSelectorParamTypes.STEP: {
108
- currentValue = (_b = dependencyStore[filter.idStep]) === null || _b === void 0 ? void 0 : _b.value;
109
- filterStep = form.steps[filter.idStep];
110
- if (currentValue) {
111
- if (filterStep.type ===
112
- FormStepTypes.API_SELECTOR) {
113
- params.set(filter.key, currentValue[step.idAttribute]);
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 (typeof currentValue === 'string')
116
- params.set(filter.key, currentValue);
117
- else
118
- params.set(filter.key, (_c = currentValue.label) !== null && _c !== void 0 ? _c : currentValue.id);
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
- break;
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
- url = step.url.replace('capta.co', process.env.REACT_APP_DOMAIN);
132
- if (idOrganization &&
133
- url.includes(process.env.REACT_APP_DOMAIN))
134
- params.set('idOrganization', idOrganization);
135
- if (!step.url.includes('?'))
136
- url += '?';
137
- url += params.toString();
138
- return [4 /*yield*/, (idOrganization
139
- ? widgetInstance.get(url)
140
- : axiosInstance.get(url))];
141
- case 1:
142
- response = _d.sent();
143
- return [2 /*return*/, response.data.filter(function (option) {
144
- var _a;
145
- return calcOptionId(option) &&
146
- ((_a = step.options[calcOptionId(option)]) === null || _a === void 0 ? void 0 : _a.type) !==
147
- ApiSelectorOptionTypes.HIDE;
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);