@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
|
@@ -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 (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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 (
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
proyectos =
|
|
87
|
-
|
|
88
|
-
|
|
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 (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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 (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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 (
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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 (
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
194
|
+
idEntityValue = currentValue;
|
|
214
195
|
else
|
|
215
|
-
|
|
196
|
+
idEntityValue = (_f = currentValue._id) !== null && _f !== void 0 ? _f : currentValue.id;
|
|
197
|
+
break;
|
|
216
198
|
}
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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(
|
|
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: (
|
|
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 */
|
|
@@ -14,32 +14,53 @@ import { calcStepWidth } from '../../StepFunctions';
|
|
|
14
14
|
import styles from './MaterialTitleStep.module.css';
|
|
15
15
|
import { useAppSelector } from '../../../hooks';
|
|
16
16
|
import FormContext from '../../../Contexts/FormContext';
|
|
17
|
-
import { useContext } from 'react';
|
|
18
|
-
import { useFormStep } from '../../StepHooks';
|
|
17
|
+
import { useContext, useMemo } from 'react';
|
|
18
|
+
import { selectDependencies, useFormStep } from '../../StepHooks';
|
|
19
|
+
import { convertFromRaw } from 'draft-js';
|
|
20
|
+
import { stringToDraft } from '../../../Utils/DraftFunctions';
|
|
21
|
+
import SmartDraftRenderer from '../../../Shared/SmartDraftRenderer';
|
|
19
22
|
function TitleStep(_a) {
|
|
20
|
-
var _b
|
|
23
|
+
var _b;
|
|
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 = (
|
|
31
|
+
var size = (_b = step.size) !== null && _b !== void 0 ? _b : form.size.blockNum;
|
|
32
|
+
var title = useMemo(function () { return calcBaseDraft(value === null || value === void 0 ? void 0 : value.title, step.title); }, [value === null || value === void 0 ? void 0 : value.title, step.title]);
|
|
33
|
+
var hasTitle = useMemo(function () { return convertFromRaw(title).getPlainText().length > 0; }, [title]);
|
|
34
|
+
var description = useMemo(function () { return calcBaseDraft(value === null || value === void 0 ? void 0 : value.description, step.description); }, [value === null || value === void 0 ? void 0 : value.description, step.description]);
|
|
35
|
+
var hasDescription = useMemo(function () { return convertFromRaw(description).getPlainText().length > 0; }, [description]);
|
|
36
|
+
var dependencies = useAppSelector(function (state) {
|
|
37
|
+
return selectDependencies(state, step.dependencies);
|
|
38
|
+
});
|
|
39
|
+
var values = useMemo(function () {
|
|
40
|
+
var values = {};
|
|
41
|
+
for (var _i = 0, _a = Object.values(dependencies); _i < _a.length; _i++) {
|
|
42
|
+
var _b = _a[_i], idOriginal = _b.idOriginal, value_1 = _b.value;
|
|
43
|
+
values[idOriginal] = value_1;
|
|
44
|
+
}
|
|
45
|
+
return values;
|
|
46
|
+
}, [dependencies]);
|
|
31
47
|
return (_jsxs("div", __assign({ className: styles.container, style: {
|
|
32
48
|
color: formStyle.textColor,
|
|
33
49
|
width: widthStats.currentBreakPoint <= size
|
|
34
50
|
? '100%'
|
|
35
51
|
: calcStepWidth(size, form.size),
|
|
36
|
-
} }, { children: [
|
|
52
|
+
} }, { children: [hasTitle && (_jsx("div", __assign({ className: styles.titleLbl, style: {
|
|
37
53
|
textAlign: widthStats.isMobile &&
|
|
38
54
|
widthStats.currentBreakPoint <= size
|
|
39
55
|
? 'center'
|
|
40
56
|
: 'start',
|
|
41
|
-
} }, { children: title }))),
|
|
57
|
+
} }, { children: _jsx(SmartDraftRenderer, { draft: title, dependencies: values }) }))), hasDescription && (_jsx("div", __assign({ className: styles.descriptionPar, style: {
|
|
42
58
|
margin: title ? '10px 0px' : '0px 0px 5px 0px',
|
|
43
|
-
} }, { children: description })))] })));
|
|
59
|
+
} }, { children: _jsx(SmartDraftRenderer, { draft: description, dependencies: values }) })))] })));
|
|
44
60
|
}
|
|
45
61
|
export default TitleStep;
|
|
62
|
+
function calcBaseDraft(value, draft) {
|
|
63
|
+
return value
|
|
64
|
+
? stringToDraft(value)
|
|
65
|
+
: draft !== null && draft !== void 0 ? draft : stringToDraft('');
|
|
66
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EurekaDraft } from '../@Types/Draft/Draft';
|
|
2
|
+
export declare const DraftApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<{
|
|
3
|
+
url: string;
|
|
4
|
+
timeout?: number | undefined;
|
|
5
|
+
method?: string | undefined;
|
|
6
|
+
body?: any;
|
|
7
|
+
params?: any;
|
|
8
|
+
headers?: Record<string, any> | undefined;
|
|
9
|
+
}, unknown, unknown, {}, {}>, {
|
|
10
|
+
mapDraft: import("@reduxjs/toolkit/query").QueryDefinition<{
|
|
11
|
+
idForm: string;
|
|
12
|
+
dependencies: Record<string, any>;
|
|
13
|
+
}, import("@reduxjs/toolkit/query").BaseQueryFn<{
|
|
14
|
+
url: string;
|
|
15
|
+
timeout?: number | undefined;
|
|
16
|
+
method?: string | undefined;
|
|
17
|
+
body?: any;
|
|
18
|
+
params?: any;
|
|
19
|
+
headers?: Record<string, any> | undefined;
|
|
20
|
+
}, unknown, unknown, {}, {}>, never, EurekaDraft | undefined, "api">;
|
|
21
|
+
}, "api", never, typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/dist/query/react").reactHooksModuleName>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { RootApi } from '../Utils/_api';
|
|
38
|
+
import axiosInstance from '../Utils/AxiosAPI';
|
|
39
|
+
import widgetInstance from '../Utils/AxiosWidget';
|
|
40
|
+
export var DraftApi = RootApi.injectEndpoints({
|
|
41
|
+
endpoints: function (build) { return ({
|
|
42
|
+
mapDraft: build.query({
|
|
43
|
+
queryFn: function (_a, _b) {
|
|
44
|
+
var idForm = _a.idForm, dependencies = _a.dependencies;
|
|
45
|
+
var getState = _b.getState;
|
|
46
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
var idOrganization, response;
|
|
48
|
+
return __generator(this, function (_c) {
|
|
49
|
+
switch (_c.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
idOrganization = getState().forms[idForm]
|
|
52
|
+
.global.idOrganization;
|
|
53
|
+
if (idOrganization != 'AAA')
|
|
54
|
+
return [2 /*return*/, { data: undefined }];
|
|
55
|
+
if (!idOrganization) return [3 /*break*/, 2];
|
|
56
|
+
return [4 /*yield*/, widgetInstance.post("/form/draft?idOrganization=".concat(idOrganization), dependencies)];
|
|
57
|
+
case 1:
|
|
58
|
+
response = _c.sent();
|
|
59
|
+
return [3 /*break*/, 4];
|
|
60
|
+
case 2: return [4 /*yield*/, axiosInstance.post('/form/draft', dependencies)];
|
|
61
|
+
case 3:
|
|
62
|
+
response = _c.sent();
|
|
63
|
+
_c.label = 4;
|
|
64
|
+
case 4: return [2 /*return*/, { data: response.data }];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
}); },
|
|
71
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { EurekaDraft } from '../@Types/Draft/Draft';
|
|
3
|
+
interface SmartDraftRendererProps {
|
|
4
|
+
draft: EurekaDraft;
|
|
5
|
+
dependencies: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
declare function SmartDraftRenderer({ draft, dependencies, }: SmartDraftRendererProps): JSX.Element;
|
|
8
|
+
export default SmartDraftRenderer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
|
+
import { IdFormContext } from '../App/App';
|
|
4
|
+
import { DraftApi } from '../Services/DraftService';
|
|
5
|
+
import { convertFromRaw, EditorState } from 'draft-js';
|
|
6
|
+
import { Editor } from 'react-draft-wysiwyg';
|
|
7
|
+
function SmartDraftRenderer(_a) {
|
|
8
|
+
var draft = _a.draft, dependencies = _a.dependencies;
|
|
9
|
+
var idForm = useContext(IdFormContext);
|
|
10
|
+
var mapped = DraftApi.useMapDraftQuery({
|
|
11
|
+
idForm: idForm,
|
|
12
|
+
dependencies: dependencies,
|
|
13
|
+
}).data;
|
|
14
|
+
var editorState = useMemo(function () { return EditorState.createWithContent(convertFromRaw(mapped !== null && mapped !== void 0 ? mapped : draft)); }, [mapped, draft]);
|
|
15
|
+
return (_jsx(Editor, { editorClassName: 'Erk-Forms-Draft', editorState: editorState, readOnly: true, toolbarHidden: true }));
|
|
16
|
+
}
|
|
17
|
+
export default SmartDraftRenderer;
|
|
@@ -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;
|
package/dist/Utils/AxiosAPI.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
import { BaseQueryFn } from '@reduxjs/toolkit/query';
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
3
|
+
declare const headers: {};
|
|
1
4
|
declare const axiosInstance: import("axios").AxiosInstance;
|
|
2
5
|
export default axiosInstance;
|
|
6
|
+
export declare const axiosBaseQuery: () => BaseQueryFn<{
|
|
7
|
+
url: string;
|
|
8
|
+
timeout?: AxiosRequestConfig['timeout'];
|
|
9
|
+
method?: AxiosRequestConfig['method'];
|
|
10
|
+
body?: AxiosRequestConfig['data'];
|
|
11
|
+
params?: AxiosRequestConfig['params'];
|
|
12
|
+
headers?: Record<string, any>;
|
|
13
|
+
}, unknown, unknown>;
|
package/dist/Utils/AxiosAPI.js
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
import axios from 'axios';
|
|
2
38
|
var headers = {};
|
|
3
39
|
var axiosInstance = axios.create({
|
|
@@ -6,3 +42,39 @@ var axiosInstance = axios.create({
|
|
|
6
42
|
headers: headers,
|
|
7
43
|
});
|
|
8
44
|
export default axiosInstance;
|
|
45
|
+
export var axiosBaseQuery = function () {
|
|
46
|
+
return function (_a) {
|
|
47
|
+
var url = _a.url, method = _a.method, body = _a.body, params = _a.params, timeout = _a.timeout, headers = _a.headers;
|
|
48
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
+
var result, axiosError_1, err;
|
|
50
|
+
var _b, _c;
|
|
51
|
+
return __generator(this, function (_d) {
|
|
52
|
+
switch (_d.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
_d.trys.push([0, 2, , 3]);
|
|
55
|
+
return [4 /*yield*/, axiosInstance({
|
|
56
|
+
url: url,
|
|
57
|
+
method: method,
|
|
58
|
+
data: body,
|
|
59
|
+
params: params,
|
|
60
|
+
headers: headers,
|
|
61
|
+
timeout: timeout,
|
|
62
|
+
})];
|
|
63
|
+
case 1:
|
|
64
|
+
result = _d.sent();
|
|
65
|
+
return [2 /*return*/, { data: result.data }];
|
|
66
|
+
case 2:
|
|
67
|
+
axiosError_1 = _d.sent();
|
|
68
|
+
err = axiosError_1;
|
|
69
|
+
return [2 /*return*/, {
|
|
70
|
+
error: {
|
|
71
|
+
status: (_b = err.response) === null || _b === void 0 ? void 0 : _b.status,
|
|
72
|
+
data: ((_c = err.response) === null || _c === void 0 ? void 0 : _c.data) || err.message,
|
|
73
|
+
},
|
|
74
|
+
}];
|
|
75
|
+
case 3: return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
};
|