@arquimedes.co/eureka-forms 0.2.2 → 0.2.8
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/App.d.ts +4 -2
- package/dist/App.js +20 -17
- package/dist/AxiosAPI.d.ts +2 -0
- package/dist/AxiosAPI.js +8 -0
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/FormComponents/Form/ColumnForm/ColumnForm.js +30 -61
- package/dist/FormComponents/Form/Form.d.ts +1 -0
- package/dist/FormComponents/Form/Form.js +1 -0
- package/dist/FormComponents/Section/Section.d.ts +1 -0
- package/dist/FormComponents/Step/Step.d.ts +1 -1
- package/dist/FormComponents/Step/Step.js +19 -10
- package/dist/FormComponents/Step/StepFunctions.d.ts +1 -1
- package/dist/FormComponents/Step/StepFunctions.js +6 -7
- package/dist/controllers/FileService.js +12 -7
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Form } from './@Types/Form';
|
|
3
3
|
interface AppProps {
|
|
4
4
|
/** If the app is currently a widget */
|
|
5
|
-
isWidget
|
|
5
|
+
isWidget?: boolean;
|
|
6
6
|
/** The apikey of the Form */
|
|
7
7
|
apiKey?: string;
|
|
8
8
|
/** The domain of the form's organization */
|
|
@@ -17,8 +17,10 @@ interface AppProps {
|
|
|
17
17
|
preview?: boolean;
|
|
18
18
|
/** The data to fill the form with */
|
|
19
19
|
valuesData?: Record<string, unknown>;
|
|
20
|
+
/** Custom steps to display */
|
|
21
|
+
customSteps?: Record<string, JSX.Element>;
|
|
20
22
|
}
|
|
21
|
-
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, ...others }: AppProps): JSX.Element;
|
|
23
|
+
declare function App({ apiKey, domain, preview, formData, postview, isWidget, internal, valuesData, customSteps, ...others }: AppProps): JSX.Element;
|
|
22
24
|
export default App;
|
|
23
25
|
export declare enum SIZES {
|
|
24
26
|
SMALL = "SMALL",
|
package/dist/App.js
CHANGED
|
@@ -64,25 +64,31 @@ import Loader from './shared/Loader/Loader';
|
|
|
64
64
|
import styles from './App.module.css';
|
|
65
65
|
import FormComponent from './FormComponents/Form/Form';
|
|
66
66
|
import StepTypes from './constants/FormStepTypes';
|
|
67
|
+
import axiosInstance from './AxiosAPI';
|
|
67
68
|
function App(_a) {
|
|
68
69
|
var _this = this;
|
|
69
|
-
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData"]);
|
|
70
|
+
var apiKey = _a.apiKey, domain = _a.domain, preview = _a.preview, formData = _a.formData, postview = _a.postview, isWidget = _a.isWidget, internal = _a.internal, valuesData = _a.valuesData, customSteps = _a.customSteps, others = __rest(_a, ["apiKey", "domain", "preview", "formData", "postview", "isWidget", "internal", "valuesData", "customSteps"]);
|
|
70
71
|
var _b = useState(undefined), form = _b[0], setForm = _b[1];
|
|
71
72
|
var _c = useState({}), originalValues = _c[0], setOriginalValues = _c[1];
|
|
72
73
|
var _d = useState(undefined), organizationInfo = _d[0], setOrganizationInfo = _d[1];
|
|
74
|
+
//
|
|
73
75
|
function fetchOrgData(domain) {
|
|
74
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
var
|
|
76
|
-
return __generator(this, function (
|
|
77
|
-
switch (
|
|
77
|
+
var response, _a, currentOrg, favicon;
|
|
78
|
+
return __generator(this, function (_b) {
|
|
79
|
+
switch (_b.label) {
|
|
78
80
|
case 0:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
url += "?domain=" + domain;
|
|
82
|
-
}
|
|
83
|
-
return [4 /*yield*/, axios.get(url)];
|
|
81
|
+
if (!domain) return [3 /*break*/, 2];
|
|
82
|
+
return [4 /*yield*/, axios.get("https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/organization?domain=" + domain)];
|
|
84
83
|
case 1:
|
|
85
|
-
|
|
84
|
+
_a = _b.sent();
|
|
85
|
+
return [3 /*break*/, 4];
|
|
86
|
+
case 2: return [4 /*yield*/, axiosInstance.get('/organization')];
|
|
87
|
+
case 3:
|
|
88
|
+
_a = _b.sent();
|
|
89
|
+
_b.label = 4;
|
|
90
|
+
case 4:
|
|
91
|
+
response = _a;
|
|
86
92
|
if (response === null || response === void 0 ? void 0 : response.data) {
|
|
87
93
|
currentOrg = response.data;
|
|
88
94
|
favicon = document.getElementById('favicon');
|
|
@@ -99,7 +105,7 @@ function App(_a) {
|
|
|
99
105
|
var response;
|
|
100
106
|
return __generator(this, function (_a) {
|
|
101
107
|
switch (_a.label) {
|
|
102
|
-
case 0: return [4 /*yield*/, axios.get(
|
|
108
|
+
case 0: return [4 /*yield*/, axios.get("https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/organization")];
|
|
103
109
|
case 1:
|
|
104
110
|
response = _a.sent();
|
|
105
111
|
if (response.data) {
|
|
@@ -146,12 +152,9 @@ function App(_a) {
|
|
|
146
152
|
switch (_b.label) {
|
|
147
153
|
case 0:
|
|
148
154
|
_b.trys.push([0, 2, , 3]);
|
|
149
|
-
url = "https://
|
|
150
|
-
if (domain) {
|
|
151
|
-
url += "?domain=" + domain;
|
|
152
|
-
}
|
|
155
|
+
url = "https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/form/" + apiKey + "?domain=" + domain;
|
|
153
156
|
return [4 /*yield*/, Promise.all([
|
|
154
|
-
axios.get(url),
|
|
157
|
+
domain ? axios.get(url) : axiosInstance.get("/form/" + apiKey),
|
|
155
158
|
fetchOrgData(domain),
|
|
156
159
|
])];
|
|
157
160
|
case 1:
|
|
@@ -206,7 +209,7 @@ function App(_a) {
|
|
|
206
209
|
setTimeout(function () {
|
|
207
210
|
setForm(tempForm);
|
|
208
211
|
}, 100);
|
|
209
|
-
}, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo }), void 0) }), void 0));
|
|
212
|
+
}, postview: postview === true, internal: internal === true, apiKey: apiKey, domain: domain, originalValues: originalValues, containerRef: containerRef, organization: organizationInfo, customSteps: customSteps !== null && customSteps !== void 0 ? customSteps : {} }), void 0) }), void 0));
|
|
210
213
|
}
|
|
211
214
|
}
|
|
212
215
|
export default App;
|
package/dist/AxiosAPI.js
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FormComponentProps } from '../Form';
|
|
3
|
-
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, originalValues, }: FormComponentProps): JSX.Element;
|
|
3
|
+
declare function ColumnForm({ form, apiKey, reload, domain, postview, internal, formStyle, widthStats, customSteps, originalValues, }: FormComponentProps): JSX.Element;
|
|
4
4
|
export default ColumnForm;
|
|
@@ -56,12 +56,13 @@ import TermComponent from '../../Term/Term';
|
|
|
56
56
|
import ConfirmationDialog from '../ConfirmationDialog/ConfirmationDialog';
|
|
57
57
|
import Loader from '../../../shared/Loader/Loader';
|
|
58
58
|
import axios from 'axios';
|
|
59
|
+
import axiosInstance from '../../../AxiosAPI';
|
|
59
60
|
function ColumnForm(_a) {
|
|
60
61
|
var _this = this;
|
|
61
|
-
var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, originalValues = _a.originalValues;
|
|
62
|
+
var form = _a.form, apiKey = _a.apiKey, reload = _a.reload, domain = _a.domain, postview = _a.postview, internal = _a.internal, formStyle = _a.formStyle, widthStats = _a.widthStats, customSteps = _a.customSteps, originalValues = _a.originalValues;
|
|
62
63
|
var _b = useState(false), tempError = _b[0], setTempError = _b[1];
|
|
63
64
|
var _c = useForm({
|
|
64
|
-
defaultValues:
|
|
65
|
+
defaultValues: originalValues,
|
|
65
66
|
mode: 'onTouched',
|
|
66
67
|
shouldFocusError: true,
|
|
67
68
|
}), getValues = _c.getValues, setValue = _c.setValue, clearErrors = _c.clearErrors, control = _c.control, errors = _c.formState.errors, trigger = _c.trigger;
|
|
@@ -77,14 +78,14 @@ function ColumnForm(_a) {
|
|
|
77
78
|
return _jsx("div", {}, void 0);
|
|
78
79
|
}
|
|
79
80
|
var onSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
80
|
-
var valid, values, _i, _a, idStep, url, resp, error_1;
|
|
81
|
-
return __generator(this, function (
|
|
82
|
-
switch (
|
|
81
|
+
var valid, values, _i, _a, idStep, url, payload, resp, _b, error_1;
|
|
82
|
+
return __generator(this, function (_c) {
|
|
83
|
+
switch (_c.label) {
|
|
83
84
|
case 0:
|
|
84
|
-
if (!(apiKey || internal)) return [3 /*break*/,
|
|
85
|
+
if (!(apiKey || internal)) return [3 /*break*/, 8];
|
|
85
86
|
return [4 /*yield*/, trigger()];
|
|
86
87
|
case 1:
|
|
87
|
-
valid =
|
|
88
|
+
valid = _c.sent();
|
|
88
89
|
values = getValues();
|
|
89
90
|
if (!!valid) return [3 /*break*/, 2];
|
|
90
91
|
console.log('ERRORS:', errors);
|
|
@@ -92,41 +93,47 @@ function ColumnForm(_a) {
|
|
|
92
93
|
setTimeout(function () {
|
|
93
94
|
setTempError(false);
|
|
94
95
|
}, 500);
|
|
95
|
-
return [3 /*break*/,
|
|
96
|
+
return [3 /*break*/, 8];
|
|
96
97
|
case 2:
|
|
97
|
-
|
|
98
|
+
_c.trys.push([2, 7, , 8]);
|
|
98
99
|
setLoading(true);
|
|
99
100
|
for (_i = 0, _a = Object.keys(values); _i < _a.length; _i++) {
|
|
100
101
|
idStep = _a[_i];
|
|
101
102
|
updateValue(idStep, values, form);
|
|
102
103
|
}
|
|
103
|
-
url = "https://
|
|
104
|
-
if (domain) {
|
|
105
|
-
url += "&domain=" + domain;
|
|
106
|
-
}
|
|
104
|
+
url = "https://xkmqdd6tr6.execute-api.us-east-1.amazonaws.com/Prod/ticket?apiKey=" + (internal ? form.apiKey : apiKey) + "&domain=" + domain;
|
|
107
105
|
console.log(values);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
payload = {
|
|
107
|
+
formValues: { steps: values },
|
|
108
|
+
};
|
|
109
|
+
if (!domain) return [3 /*break*/, 4];
|
|
110
|
+
return [4 /*yield*/, axios.post(url, payload)];
|
|
111
111
|
case 3:
|
|
112
|
-
|
|
112
|
+
_b = _c.sent();
|
|
113
|
+
return [3 /*break*/, 6];
|
|
114
|
+
case 4: return [4 /*yield*/, axiosInstance.post("ticket?apiKey=" + (internal ? form.apiKey : apiKey), payload)];
|
|
115
|
+
case 5:
|
|
116
|
+
_b = _c.sent();
|
|
117
|
+
_c.label = 6;
|
|
118
|
+
case 6:
|
|
119
|
+
resp = _b;
|
|
113
120
|
console.log(resp);
|
|
114
121
|
setShowConfirmation(resp === null || resp === void 0 ? void 0 : resp.data);
|
|
115
122
|
setLoading(false);
|
|
116
|
-
return [3 /*break*/,
|
|
117
|
-
case
|
|
118
|
-
error_1 =
|
|
123
|
+
return [3 /*break*/, 8];
|
|
124
|
+
case 7:
|
|
125
|
+
error_1 = _c.sent();
|
|
119
126
|
console.error(error_1);
|
|
120
127
|
setLoading(false);
|
|
121
|
-
return [3 /*break*/,
|
|
122
|
-
case
|
|
128
|
+
return [3 /*break*/, 8];
|
|
129
|
+
case 8: return [2 /*return*/];
|
|
123
130
|
}
|
|
124
131
|
});
|
|
125
132
|
}); };
|
|
126
133
|
return (_jsxs("div", __assign({ className: styles.container, style: { color: formStyle.textColor } }, { children: [loading && _jsx("div", { className: styles.curtain }, void 0), showConfirmation !== undefined && (_jsx(ConfirmationDialog, { formStyle: formStyle, confirmation: showConfirmation, onClose: function () {
|
|
127
134
|
reload();
|
|
128
135
|
setShowConfirmation(undefined);
|
|
129
|
-
} }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, { form: form, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle }, index)); }), form.terms &&
|
|
136
|
+
} }, void 0)), sections.map(function (idSection, index) { return (_jsx(SectionComponent, { form: form, postview: postview, clearErrors: clearErrors, widthStats: widthStats, control: control, getValues: getValues, originalValues: originalValues, errors: errors, index: index, setSections: setSections, section: form.sections[idSection], formStyle: formStyle, customSteps: customSteps }, index)); }), form.terms &&
|
|
130
137
|
!internal &&
|
|
131
138
|
form.terms.map(function (term, index) { return (_jsx(TermComponent, { setValue: setValue, postview: postview, tempError: tempError, term: term, control: control, errors: errors, form: form, formStyle: formStyle }, index)); }), !postview && (_jsx("div", __assign({ className: styles.submitBtnContainer }, { children: _jsxs("button", __assign({ "data-testid": "login__submit", className: styles.submitBtn, onClick: function () {
|
|
132
139
|
onSubmit();
|
|
@@ -170,17 +177,6 @@ var updateValue = function (idStep, values, form) {
|
|
|
170
177
|
}
|
|
171
178
|
break;
|
|
172
179
|
}
|
|
173
|
-
case Types.CLASSIFIER_SELECTOR: {
|
|
174
|
-
var value = values[step.id];
|
|
175
|
-
if (value !== undefined) {
|
|
176
|
-
values[step.id] = {
|
|
177
|
-
value: value,
|
|
178
|
-
path: form.classifiers[value],
|
|
179
|
-
idClassifier: step.idClassifier,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
180
|
default:
|
|
185
181
|
break;
|
|
186
182
|
}
|
|
@@ -203,30 +199,3 @@ function stringToDraft(text) {
|
|
|
203
199
|
});
|
|
204
200
|
return draftStructure;
|
|
205
201
|
}
|
|
206
|
-
function mapValues(pValues, form) {
|
|
207
|
-
var _a, _b, _c;
|
|
208
|
-
var values = __assign({}, (pValues !== null && pValues !== void 0 ? pValues : {}));
|
|
209
|
-
for (var _i = 0, _d = Object.keys(values); _i < _d.length; _i++) {
|
|
210
|
-
var idStep = _d[_i];
|
|
211
|
-
var step = form.steps[idStep];
|
|
212
|
-
switch (step === null || step === void 0 ? void 0 : step.type) {
|
|
213
|
-
case Types.TEXTAREA: {
|
|
214
|
-
var value = __assign({}, values[step.id]);
|
|
215
|
-
if (step.hasTextEditor) {
|
|
216
|
-
delete values[step.id];
|
|
217
|
-
}
|
|
218
|
-
else if (value.value != undefined) {
|
|
219
|
-
values[step.id] = (_a = value.value) !== null && _a !== void 0 ? _a : '';
|
|
220
|
-
}
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
case Types.CLASSIFIER_SELECTOR: {
|
|
224
|
-
values[step.id] = (_c = (_b = values[step.id]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : '';
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
default:
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return values;
|
|
232
|
-
}
|
|
@@ -79,6 +79,7 @@ function FormComponent(_a) {
|
|
|
79
79
|
: styles.standAloneFormCard, style: { backgroundColor: form.style.backgroundColor } }, { children: _jsx(FormTypeComponent, __assign({}, others, { internal: internal, postview: postview, widthStats: widthStats, form: form, formStyle: form.style }), void 0) }), void 0) }), void 0)] }, void 0));
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
|
+
console.log(__assign(__assign({ form: form, internal: internal, postview: postview, organization: organization }, others), { widthStats: widthStats }));
|
|
82
83
|
return _jsx("div", {}, void 0);
|
|
83
84
|
}
|
|
84
85
|
}
|
|
@@ -13,6 +13,7 @@ export interface RecursiveData {
|
|
|
13
13
|
clearErrors: Function;
|
|
14
14
|
getValues: UseFormGetValues<FieldValues>;
|
|
15
15
|
originalValues: Record<string, any>;
|
|
16
|
+
customSteps: Record<string, JSX.Element>;
|
|
16
17
|
}
|
|
17
18
|
export interface SectionComponentProps extends RecursiveData {
|
|
18
19
|
section: Section;
|
|
@@ -6,5 +6,5 @@ export interface StepProps extends RecursiveData {
|
|
|
6
6
|
handleSizeChange: Function;
|
|
7
7
|
level: number;
|
|
8
8
|
}
|
|
9
|
-
declare function StepComponent({ step, ...
|
|
9
|
+
declare function StepComponent({ step, ...props }: StepProps): JSX.Element;
|
|
10
10
|
export default StepComponent;
|
|
@@ -30,35 +30,44 @@ import ClassifierSelectorStep from './ClassifierSelectorStep/ClassifierSelectorS
|
|
|
30
30
|
import TextAreaStep from './TextAreaStep/TextAreaStep';
|
|
31
31
|
import DatePickerStep from './DatePickerStep/DatePickerStep';
|
|
32
32
|
import FileUploadStep from './FileUploadStep/FileUploadStep';
|
|
33
|
+
import React from 'react';
|
|
33
34
|
function StepComponent(_a) {
|
|
34
|
-
var step = _a.step,
|
|
35
|
+
var step = _a.step, props = __rest(_a, ["step"]);
|
|
35
36
|
switch (step.type) {
|
|
36
37
|
case Types.TITLE: {
|
|
37
|
-
return _jsx(TitleStep, __assign({ step: step },
|
|
38
|
+
return _jsx(TitleStep, __assign({ step: step }, props), void 0);
|
|
38
39
|
}
|
|
39
40
|
case Types.SELECTOR: {
|
|
40
|
-
return _jsx(SelectorStep, __assign({ step: step },
|
|
41
|
+
return _jsx(SelectorStep, __assign({ step: step }, props), void 0);
|
|
41
42
|
}
|
|
42
43
|
case Types.CLASSIFIER_SELECTOR: {
|
|
43
|
-
return (_jsx(ClassifierSelectorStep, __assign({ step: step },
|
|
44
|
+
return (_jsx(ClassifierSelectorStep, __assign({ step: step }, props), void 0));
|
|
44
45
|
}
|
|
45
46
|
case Types.TEXTAREA: {
|
|
46
|
-
return _jsx(TextAreaStep, __assign({ step: step },
|
|
47
|
+
return _jsx(TextAreaStep, __assign({ step: step }, props), void 0);
|
|
47
48
|
}
|
|
48
49
|
case Types.TEXTINPUT: {
|
|
49
|
-
return _jsx(TextInputStep, __assign({ step: step },
|
|
50
|
+
return _jsx(TextInputStep, __assign({ step: step }, props), void 0);
|
|
50
51
|
}
|
|
51
52
|
case Types.DATEPICKER: {
|
|
52
|
-
return _jsx(DatePickerStep, __assign({ step: step },
|
|
53
|
+
return _jsx(DatePickerStep, __assign({ step: step }, props), void 0);
|
|
53
54
|
}
|
|
54
55
|
case Types.SEPARATOR: {
|
|
55
|
-
return _jsx(SeparatorStep, __assign({ step: step },
|
|
56
|
+
return _jsx(SeparatorStep, __assign({ step: step }, props), void 0);
|
|
56
57
|
}
|
|
57
58
|
case Types.FILEUPLOAD: {
|
|
58
|
-
return _jsx(FileUploadStep, __assign({ step: step },
|
|
59
|
+
return _jsx(FileUploadStep, __assign({ step: step }, props), void 0);
|
|
59
60
|
}
|
|
60
61
|
default:
|
|
61
|
-
|
|
62
|
+
console.log('TYPENOTFOUND', step.type);
|
|
63
|
+
var customStep = props.customSteps[step.type];
|
|
64
|
+
console.log(customStep);
|
|
65
|
+
if (customStep) {
|
|
66
|
+
return React.cloneElement(customStep, __assign({ step: step }, props));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return _jsx("div", {}, void 0);
|
|
70
|
+
}
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
73
|
export default StepComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Form } from '../../@Types/Form';
|
|
2
2
|
import { ClassifierSelector, FormSelector, FormStep } from '../../@Types/FormStep';
|
|
3
3
|
export declare function calcFillerSize(step: FormSelector | ClassifierSelector, steps: Record<string, FormStep>, values: Record<string, unknown>, form: Form): number;
|
|
4
|
-
export declare function recursivelyCheckOpenSize(
|
|
4
|
+
export declare function recursivelyCheckOpenSize(idStep: string, steps: Record<string, FormStep>, values: Record<string, any>): number;
|
|
5
5
|
export declare const calcStepWidth: (stepSize: 1 | 2 | 3 | 4, form: Form) => number;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import Types, { ClassifierOptionTypes, OptionTypes, } from '../../constants/FormStepTypes';
|
|
2
2
|
export function calcFillerSize(step, steps, values, form) {
|
|
3
3
|
if (step.maxSize < form.blockNum) {
|
|
4
|
-
var stepSize = step.maxSize - recursivelyCheckOpenSize(step, steps, values);
|
|
4
|
+
var stepSize = step.maxSize - recursivelyCheckOpenSize(step.id, steps, values);
|
|
5
5
|
return (form.blockSize * stepSize + form.spacingSize * (stepSize - 1) + 20);
|
|
6
6
|
}
|
|
7
7
|
else {
|
|
8
8
|
return 0;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
export function recursivelyCheckOpenSize(
|
|
12
|
-
var
|
|
11
|
+
export function recursivelyCheckOpenSize(idStep, steps, values) {
|
|
12
|
+
var step = steps[idStep];
|
|
13
|
+
var value = values[idStep];
|
|
13
14
|
if (step.type === Types.SELECTOR) {
|
|
14
15
|
var size = step.size;
|
|
15
16
|
if (value) {
|
|
@@ -18,8 +19,7 @@ export function recursivelyCheckOpenSize(step, steps, values) {
|
|
|
18
19
|
var optionSize = 0;
|
|
19
20
|
for (var _i = 0, _a = currentOption.steps; _i < _a.length; _i++) {
|
|
20
21
|
var pStepId = _a[_i];
|
|
21
|
-
|
|
22
|
-
optionSize += recursivelyCheckOpenSize(pStep, steps, values);
|
|
22
|
+
optionSize += recursivelyCheckOpenSize(pStepId, steps, values);
|
|
23
23
|
}
|
|
24
24
|
size += optionSize;
|
|
25
25
|
}
|
|
@@ -34,8 +34,7 @@ export function recursivelyCheckOpenSize(step, steps, values) {
|
|
|
34
34
|
var optionSize = 0;
|
|
35
35
|
for (var _b = 0, _c = currentOption.steps; _b < _c.length; _b++) {
|
|
36
36
|
var pStepId = _c[_b];
|
|
37
|
-
|
|
38
|
-
optionSize += recursivelyCheckOpenSize(pStep, steps, values);
|
|
37
|
+
optionSize += recursivelyCheckOpenSize(pStepId, steps, values);
|
|
39
38
|
}
|
|
40
39
|
size += optionSize;
|
|
41
40
|
}
|
|
@@ -35,6 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import axios from 'axios';
|
|
38
|
+
import axiosInstance from '../AxiosAPI';
|
|
38
39
|
export function getUploadUrls(files, domain) {
|
|
39
40
|
var _a;
|
|
40
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -46,15 +47,19 @@ export function getUploadUrls(files, domain) {
|
|
|
46
47
|
publicFile: false,
|
|
47
48
|
extension: file.name.split('.').pop(),
|
|
48
49
|
}); });
|
|
49
|
-
return [
|
|
50
|
-
|
|
51
|
-
domain: domain,
|
|
52
|
-
files: filesArray,
|
|
53
|
-
}
|
|
54
|
-
: filesArray)];
|
|
50
|
+
if (!domain) return [3 /*break*/, 2];
|
|
51
|
+
return [4 /*yield*/, axiosInstance.post('/uploadfile', filesArray)];
|
|
55
52
|
case 1:
|
|
56
53
|
response = _b.sent();
|
|
57
|
-
return [
|
|
54
|
+
return [3 /*break*/, 4];
|
|
55
|
+
case 2: return [4 /*yield*/, axios.post("https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/uploadfile", {
|
|
56
|
+
domain: domain,
|
|
57
|
+
files: filesArray,
|
|
58
|
+
})];
|
|
59
|
+
case 3:
|
|
60
|
+
response = _b.sent();
|
|
61
|
+
_b.label = 4;
|
|
62
|
+
case 4: return [2 /*return*/, (_a = response.data) !== null && _a !== void 0 ? _a : undefined];
|
|
58
63
|
}
|
|
59
64
|
});
|
|
60
65
|
});
|