@arquimedes.co/eureka-forms 2.0.101 → 2.0.103

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.
@@ -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;
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 */
@@ -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,7 @@ 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
- }
177
160
  });
178
161
  }
179
162
  };
@@ -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);
@@ -59,76 +59,91 @@ import InputIcon from '../Shared/InputIcon/InputIcon';
59
59
  var baseUrl = "https://integrations.".concat(process.env.REACT_APP_DOMAIN, "/sinco/cbr/");
60
60
  function CBRStepMapper(props) {
61
61
  var _this = this;
62
- var getTipoDocOptions = function (idOrganization) { return __awaiter(_this, void 0, void 0, function () {
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0:
66
- if (!idOrganization)
67
- return [2 /*return*/, null];
68
- return [4 /*yield*/, axios.get(baseUrl + 'TiposDoc?idOrganization=' + idOrganization)];
69
- case 1: return [2 /*return*/, (_a.sent()).data];
70
- }
62
+ var getTipoDocOptions = function (_step, _dependencies, _a) {
63
+ var idOrganization = _a.idOrganization;
64
+ return __awaiter(_this, void 0, void 0, function () {
65
+ return __generator(this, function (_b) {
66
+ switch (_b.label) {
67
+ case 0:
68
+ if (!idOrganization)
69
+ return [2 /*return*/, null];
70
+ return [4 /*yield*/, axios.get(baseUrl + 'TiposDoc?idOrganization=' + idOrganization)];
71
+ case 1: return [2 /*return*/, (_b.sent()).data];
72
+ }
73
+ });
71
74
  });
72
- }); };
73
- var getProyectoOptions = function (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
74
- var idMacroProyecto, proyectos;
75
- var _a, _b, _c, _d;
76
- return __generator(this, function (_e) {
77
- switch (_e.label) {
78
- case 0:
79
- if (!idOrganization)
80
- return [2 /*return*/, null];
81
- idMacroProyecto = (_d = (_c = dependencyStore[(_b = (_a = step.dependencies) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '']) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.id;
82
- return [4 /*yield*/, axios.get(baseUrl + 'Proyectos?idOrganization=' + idOrganization)];
83
- case 1:
84
- proyectos = (_e.sent()).data;
85
- if (idMacroProyecto) {
86
- proyectos = proyectos.filter(function (proyecto) { return proyecto.idMacroProyecto === idMacroProyecto; });
87
- }
88
- return [2 /*return*/, proyectos];
89
- }
75
+ };
76
+ var getProyectoOptions = function (step, dependencyStore, _a) {
77
+ var idOrganization = _a.idOrganization;
78
+ return __awaiter(_this, void 0, void 0, function () {
79
+ var idMacroProyecto, proyectos;
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
+ idMacroProyecto = (_e = (_d = dependencyStore[(_c = (_b = step.dependencies) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : '']) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.id;
87
+ return [4 /*yield*/, axios.get(baseUrl + 'Proyectos?idOrganization=' + idOrganization)];
88
+ case 1:
89
+ proyectos = (_f.sent()).data;
90
+ if (idMacroProyecto) {
91
+ proyectos = proyectos.filter(function (proyecto) { return proyecto.idMacroProyecto === idMacroProyecto; });
92
+ }
93
+ return [2 /*return*/, proyectos];
94
+ }
95
+ });
90
96
  });
91
- }); };
92
- var getMacroProyectoOptions = function (idOrganization) { return __awaiter(_this, void 0, void 0, function () {
93
- return __generator(this, function (_a) {
94
- switch (_a.label) {
95
- case 0:
96
- if (!idOrganization)
97
- return [2 /*return*/, null];
98
- return [4 /*yield*/, axios.get(baseUrl + 'MacroProyectos?idOrganization=' + idOrganization)];
99
- case 1: return [2 /*return*/, (_a.sent()).data];
100
- }
97
+ };
98
+ var getMacroProyectoOptions = function (_step, _dependencies, _a) {
99
+ var idOrganization = _a.idOrganization;
100
+ return __awaiter(_this, void 0, void 0, function () {
101
+ return __generator(this, function (_b) {
102
+ switch (_b.label) {
103
+ case 0:
104
+ if (!idOrganization)
105
+ return [2 /*return*/, null];
106
+ return [4 /*yield*/, axios.get(baseUrl + 'MacroProyectos?idOrganization=' + idOrganization)];
107
+ case 1: return [2 /*return*/, (_b.sent()).data];
108
+ }
109
+ });
101
110
  });
102
- }); };
103
- var getTipoSolicitanteOptions = function (idOrganization) { return __awaiter(_this, void 0, void 0, function () {
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
106
- case 0:
107
- if (!idOrganization)
108
- return [2 /*return*/, null];
109
- return [4 /*yield*/, axios.get(baseUrl + 'TiposSolicitante?idOrganization=' + idOrganization)];
110
- case 1: return [2 /*return*/, (_a.sent()).data];
111
- }
111
+ };
112
+ var getTipoSolicitanteOptions = function (_step, _dependencies, _a) {
113
+ var idOrganization = _a.idOrganization;
114
+ return __awaiter(_this, void 0, void 0, function () {
115
+ return __generator(this, function (_b) {
116
+ switch (_b.label) {
117
+ case 0:
118
+ if (!idOrganization)
119
+ return [2 /*return*/, null];
120
+ return [4 /*yield*/, axios.get(baseUrl + 'TiposSolicitante?idOrganization=' + idOrganization)];
121
+ case 1: return [2 /*return*/, (_b.sent()).data];
122
+ }
123
+ });
112
124
  });
113
- }); };
114
- var getTipoEspaciosOptions = function (idOrganization, step, dependencyStore) { return __awaiter(_this, void 0, void 0, function () {
115
- var idProyecto, params;
116
- var _a, _b;
117
- return __generator(this, function (_c) {
118
- switch (_c.label) {
119
- case 0:
120
- if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
121
- idProyecto = (_b = (_a = dependencyStore[step.dependencies[0]]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.id;
122
- if (!idProyecto) {
123
- return [2 /*return*/, null]; //null para indicar que falta la depedency
124
- }
125
- params = new URLSearchParams({ idProyecto: idProyecto, idOrganization: idOrganization });
126
- return [4 /*yield*/, axios.get(baseUrl + 'TiposEspacio?' + params.toString())];
127
- case 1: return [2 /*return*/, (_c.sent()).data];
128
- case 2: return [2 /*return*/, null];
129
- }
125
+ };
126
+ var getTipoEspaciosOptions = function (step, dependencyStore, _a) {
127
+ var idOrganization = _a.idOrganization;
128
+ return __awaiter(_this, void 0, void 0, function () {
129
+ var idProyecto, params;
130
+ var _b, _c;
131
+ return __generator(this, function (_d) {
132
+ switch (_d.label) {
133
+ case 0:
134
+ if (!(step.dependencies && idOrganization)) return [3 /*break*/, 2];
135
+ idProyecto = (_c = (_b = dependencyStore[step.dependencies[0]]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
136
+ if (!idProyecto) {
137
+ return [2 /*return*/, null]; //null para indicar que falta la depedency
138
+ }
139
+ params = new URLSearchParams({ idProyecto: idProyecto, idOrganization: idOrganization });
140
+ return [4 /*yield*/, axios.get(baseUrl + 'TiposEspacio?' + params.toString())];
141
+ case 1: return [2 /*return*/, (_d.sent()).data];
142
+ case 2: return [2 /*return*/, null];
143
+ }
144
+ });
130
145
  });
131
- }); };
146
+ };
132
147
  switch (props.step.type) {
133
148
  case CBRFormStepTypes.CBR_EMAIL:
134
149
  return (_jsx(TextInputStep, __assign({}, props, { step: props.step, validation: {
@@ -171,70 +171,77 @@ function EntityValuePickerStep(_a) {
171
171
  } }) }))] }));
172
172
  }
173
173
  export default EntityValuePickerStep;
174
- var getEntityValueOptions = function (idOrganization, step, dependencyStore) { return __awaiter(void 0, void 0, void 0, function () {
175
- var urlPath, _i, _a, path, idEntityValue, currentValue, params, _b, _c, filter, currentValue, url, response;
176
- var _d, _e, _f, _g, _h;
177
- return __generator(this, function (_j) {
178
- switch (_j.label) {
179
- case 0:
180
- if (!idOrganization)
181
- return [2 /*return*/, null];
182
- urlPath = '';
183
- for (_i = 0, _a = step.path; _i < _a.length; _i++) {
184
- path = _a[_i];
185
- idEntityValue = 'null';
186
- switch (path.type) {
187
- case EntityValueDataTypes.STEP: {
188
- currentValue = (_d = dependencyStore[path.idStep]) === null || _d === void 0 ? void 0 : _d.value;
189
- if (!currentValue)
190
- return [2 /*return*/, null];
191
- if (typeof currentValue === 'string')
192
- idEntityValue = currentValue;
193
- else
194
- idEntityValue = (_e = currentValue._id) !== null && _e !== void 0 ? _e : currentValue.id;
195
- break;
196
- }
197
- case EntityValueDataTypes.VALUE:
198
- default:
199
- idEntityValue = (_f = path.idEntityValue) !== null && _f !== void 0 ? _f : 'null';
200
- break;
201
- }
202
- urlPath +=
203
- '/' + path.idEntity + (idEntityValue ? '/' + idEntityValue : '');
204
- }
205
- params = new URLSearchParams({});
206
- for (_b = 0, _c = step.filters; _b < _c.length; _b++) {
207
- filter = _c[_b];
208
- switch (filter.type) {
209
- case EntityValueDataTypes.STEP: {
210
- currentValue = (_g = dependencyStore[filter.idStep]) === null || _g === void 0 ? void 0 : _g.value;
211
- if (currentValue) {
174
+ var getEntityValueOptions = function (step, dependencyStore, _a) {
175
+ var idOrganization = _a.idOrganization, idCurrentAgent = _a.idCurrentAgent;
176
+ return __awaiter(void 0, void 0, void 0, function () {
177
+ var urlPath, _i, _b, path, idEntityValue, currentValue, params, _c, _d, filter, currentValue, url, response;
178
+ var _e, _f, _g, _h, _j;
179
+ return __generator(this, function (_k) {
180
+ switch (_k.label) {
181
+ case 0:
182
+ if (!idOrganization)
183
+ return [2 /*return*/, null];
184
+ urlPath = '';
185
+ for (_i = 0, _b = step.path; _i < _b.length; _i++) {
186
+ path = _b[_i];
187
+ idEntityValue = 'null';
188
+ switch (path.type) {
189
+ case EntityValueDataTypes.STEP: {
190
+ currentValue = (_e = dependencyStore[path.idStep]) === null || _e === void 0 ? void 0 : _e.value;
191
+ if (!currentValue)
192
+ return [2 /*return*/, null];
212
193
  if (typeof currentValue === 'string')
213
- params.set(filter.idProperty, currentValue);
194
+ idEntityValue = currentValue;
214
195
  else
215
- params.set(filter.idProperty, (_h = currentValue._id) !== null && _h !== void 0 ? _h : currentValue.id);
196
+ idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
197
+ break;
216
198
  }
217
- else if (filter.required) {
218
- return [2 /*return*/, null];
199
+ case EntityValueDataTypes.VALUE:
200
+ default:
201
+ idEntityValue = (_g = path.idEntityValue) !== null && _g !== void 0 ? _g : 'null';
202
+ break;
203
+ }
204
+ urlPath +=
205
+ '/' + path.idEntity + (idEntityValue ? '/' + idEntityValue : '');
206
+ }
207
+ params = new URLSearchParams({});
208
+ for (_c = 0, _d = step.filters; _c < _d.length; _c++) {
209
+ filter = _d[_c];
210
+ switch (filter.type) {
211
+ case EntityValueDataTypes.STEP: {
212
+ currentValue = (_h = dependencyStore[filter.idStep]) === null || _h === void 0 ? void 0 : _h.value;
213
+ if (currentValue) {
214
+ if (typeof currentValue === 'string')
215
+ params.set(filter.idProperty, currentValue);
216
+ else
217
+ params.set(filter.idProperty, (_j = currentValue._id) !== null && _j !== void 0 ? _j : currentValue.id);
218
+ }
219
+ else if (filter.required) {
220
+ return [2 /*return*/, null];
221
+ }
222
+ break;
219
223
  }
220
- break;
224
+ case EntityValueDataTypes.CURRENT_AGENT:
225
+ if (idCurrentAgent)
226
+ params.set(filter.idProperty, idCurrentAgent);
227
+ break;
228
+ case EntityValueDataTypes.VALUE:
229
+ default:
230
+ params.set(filter.idProperty, filter.value);
231
+ break;
221
232
  }
222
- case EntityValueDataTypes.VALUE:
223
- default:
224
- params.set(filter.idProperty, filter.value);
225
- break;
226
233
  }
227
- }
228
- url = "".concat(idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
229
- return [4 /*yield*/, widgetInstance.get(url, {
230
- timeout: 120000,
231
- })];
232
- case 1:
233
- response = _j.sent();
234
- return [2 /*return*/, response.data.filter(function (option) { var _a; return ((_a = step.options[option._id]) === null || _a === void 0 ? void 0 : _a.type) !== EntityValueOptionTypes.HIDE; })];
235
- }
234
+ url = "".concat(idOrganization, "/entities/").concat(step.idEntity).concat(urlPath, "?").concat(params.toString());
235
+ return [4 /*yield*/, widgetInstance.get(url, {
236
+ timeout: 120000,
237
+ })];
238
+ case 1:
239
+ response = _k.sent();
240
+ return [2 /*return*/, response.data.filter(function (option) { var _a; return ((_a = step.options[option._id]) === null || _a === void 0 ? void 0 : _a.type) !== EntityValueOptionTypes.HIDE; })];
241
+ }
242
+ });
236
243
  });
237
- }); };
244
+ };
238
245
  var getOptionalDependencies = function (step) {
239
246
  var _a;
240
247
  var optional = [];
@@ -78,7 +78,7 @@ function SmartSelectStep(_a) {
78
78
  var onChange = useCallback(function (value) {
79
79
  return handleChange(valueOverwrite ? valueOverwrite(value) : value);
80
80
  }, [handleChange, valueOverwrite]);
81
- var _l = useAppSelector(function (state) { return state.global; }), postview = _l.postview, formStyle = _l.formStyle, idOrganization = _l.idOrganization;
81
+ var _l = useAppSelector(function (state) { return state.global; }), postview = _l.postview, formStyle = _l.formStyle, idOrganization = _l.idOrganization, idCurrentAgent = _l.idCurrentAgent;
82
82
  var form = useContext(FormContext);
83
83
  var _m = useState(), options = _m[0], setOptions = _m[1];
84
84
  var _o = useState(false), loading = _o[0], setLoading = _o[1];
@@ -122,7 +122,10 @@ function SmartSelectStep(_a) {
122
122
  _a.label = 1;
123
123
  case 1:
124
124
  _a.trys.push([1, 3, , 4]);
125
- return [4 /*yield*/, (getOptions === null || getOptions === void 0 ? void 0 : getOptions(idOrganization, step, dependencies))];
125
+ return [4 /*yield*/, (getOptions === null || getOptions === void 0 ? void 0 : getOptions(step, dependencies, {
126
+ idOrganization: idOrganization,
127
+ idCurrentAgent: postview ? undefined : idCurrentAgent,
128
+ }))];
126
129
  case 2:
127
130
  resp = _a.sent();
128
131
  if (value) {
@@ -9,7 +9,10 @@ export interface SmartSelectStepProps<StepType extends GSmartSelect = GSmartSele
9
9
  /** The icon to display */
10
10
  icon?: React.ReactNode;
11
11
  /** Function to call to get the options of the selector, return null if dependency is not met */
12
- getOptions: (idOrganization: string | undefined, step: StepType, dependencyStore: DependencyStore) => Promise<any[] | null>;
12
+ getOptions: (step: StepType, dependencyStore: DependencyStore, options: {
13
+ idOrganization?: string;
14
+ idCurrentAgent?: string;
15
+ }) => Promise<any[] | null>;
13
16
  /** Function to call to filter the options of the selector */
14
17
  filterOptions?: (options: any[], dependencyStore: DependencyStore) => any[];
15
18
  /** Function to determine the currently selected option */
@@ -16,30 +16,37 @@ import { useAppSelector } from '../../../hooks';
16
16
  import FormContext from '../../../Contexts/FormContext';
17
17
  import { useContext } from 'react';
18
18
  import { useFormStep } from '../../StepHooks';
19
+ import { convertFromRaw, EditorState } from 'draft-js';
20
+ import { stringToDraft } from '../../../Utils/DraftFunctions';
21
+ import { Editor } from 'react-draft-wysiwyg';
19
22
  function TitleStep(_a) {
20
23
  var _b, _c, _d;
21
24
  var step = _a.step;
22
25
  var value = useFormStep(step, {
23
26
  defaultValue: undefined,
24
27
  }).value;
25
- var title = (_b = value === null || value === void 0 ? void 0 : value.title) !== null && _b !== void 0 ? _b : step.title;
26
- var description = (_c = value === null || value === void 0 ? void 0 : value.description) !== null && _c !== void 0 ? _c : step.description;
27
28
  var formStyle = useAppSelector(function (state) { return state.global; }).formStyle;
28
29
  var form = useContext(FormContext);
29
30
  var widthStats = useAppSelector(function (state) { return state.widthStats; });
30
- var size = (_d = step.size) !== null && _d !== void 0 ? _d : form.size.blockNum;
31
+ var size = (_b = step.size) !== null && _b !== void 0 ? _b : form.size.blockNum;
32
+ var title = convertFromRaw((value === null || value === void 0 ? void 0 : value.title)
33
+ ? stringToDraft(value.title)
34
+ : (_c = step.title) !== null && _c !== void 0 ? _c : stringToDraft(''));
35
+ var description = convertFromRaw((value === null || value === void 0 ? void 0 : value.description)
36
+ ? stringToDraft(value.description)
37
+ : (_d = step.description) !== null && _d !== void 0 ? _d : stringToDraft(''));
31
38
  return (_jsxs("div", __assign({ className: styles.container, style: {
32
39
  color: formStyle.textColor,
33
40
  width: widthStats.currentBreakPoint <= size
34
41
  ? '100%'
35
42
  : calcStepWidth(size, form.size),
36
- } }, { children: [title && (_jsx("div", __assign({ className: styles.titleLbl, style: {
43
+ } }, { children: [title.getPlainText().length > 0 && (_jsx("div", __assign({ className: styles.titleLbl, style: {
37
44
  textAlign: widthStats.isMobile &&
38
45
  widthStats.currentBreakPoint <= size
39
46
  ? 'center'
40
47
  : 'start',
41
- } }, { children: title }))), description && (_jsx("p", __assign({ className: styles.descriptionPar, style: {
48
+ } }, { children: _jsx(Editor, { editorClassName: 'Erk-Forms-Draft', editorState: EditorState.createWithContent(title), readOnly: true, toolbarHidden: true }) }))), description.getPlainText().length > 0 && (_jsx("div", __assign({ className: styles.descriptionPar, style: {
42
49
  margin: title ? '10px 0px' : '0px 0px 5px 0px',
43
- } }, { children: description })))] })));
50
+ } }, { children: _jsx(Editor, { editorClassName: 'Erk-Forms-Draft', editorState: EditorState.createWithContent(description), readOnly: true, toolbarHidden: true }) })))] })));
44
51
  }
45
52
  export default TitleStep;
@@ -5,6 +5,7 @@ import { EurekaDraft } from '../@Types/Draft/Draft';
5
5
  import { CountryCode } from 'libphonenumber-js';
6
6
  export interface GlobalState {
7
7
  idOrganization: string;
8
+ idCurrentAgent?: string;
8
9
  countryCode: CountryCode;
9
10
  formStyle: FormStyle;
10
11
  confirmation: {
@@ -28,6 +29,7 @@ export declare const GlobalSlice: import("@reduxjs/toolkit").Slice<GlobalState,
28
29
  formStyle: FormStyle;
29
30
  preview: boolean;
30
31
  idOrganization: string;
32
+ idCurrentAgent?: string | undefined;
31
33
  countryCode: CountryCode;
32
34
  confirmation: {
33
35
  confirmationMessage: EurekaDraft;
@@ -56,7 +56,8 @@ export declare enum MapperStyleTypes {
56
56
  }
57
57
  export declare enum EntityValueDataTypes {
58
58
  STEP = "STEP",
59
- VALUE = "VALUE"
59
+ VALUE = "VALUE",
60
+ CURRENT_AGENT = "CURRENT_AGENT"
60
61
  }
61
62
  export declare enum ApiSelectorParamTypes {
62
63
  STEP = "STEP",
@@ -67,6 +67,7 @@ export var EntityValueDataTypes;
67
67
  (function (EntityValueDataTypes) {
68
68
  EntityValueDataTypes["STEP"] = "STEP";
69
69
  EntityValueDataTypes["VALUE"] = "VALUE";
70
+ EntityValueDataTypes["CURRENT_AGENT"] = "CURRENT_AGENT";
70
71
  })(EntityValueDataTypes || (EntityValueDataTypes = {}));
71
72
  export var ApiSelectorParamTypes;
72
73
  (function (ApiSelectorParamTypes) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version": "2.0.101",
4
+ "version": "2.0.103",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",