@arquimedes.co/eureka-forms 0.2.7 → 0.2.10-test

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.js CHANGED
@@ -64,6 +64,7 @@ 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
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"]);
@@ -73,17 +74,21 @@ function App(_a) {
73
74
  //
74
75
  function fetchOrgData(domain) {
75
76
  return __awaiter(this, void 0, void 0, function () {
76
- var url, response, currentOrg, favicon;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
77
+ var response, _a, currentOrg, favicon;
78
+ return __generator(this, function (_b) {
79
+ switch (_b.label) {
79
80
  case 0:
80
- url = 'https://xkmqdd6tr6.execute-api.us-east-1.amazonaws.com/Prod/organization';
81
- if (domain) {
82
- url += "?domain=" + domain;
83
- }
84
- 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)];
85
83
  case 1:
86
- response = _a.sent();
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;
87
92
  if (response === null || response === void 0 ? void 0 : response.data) {
88
93
  currentOrg = response.data;
89
94
  favicon = document.getElementById('favicon');
@@ -100,7 +105,7 @@ function App(_a) {
100
105
  var response;
101
106
  return __generator(this, function (_a) {
102
107
  switch (_a.label) {
103
- case 0: return [4 /*yield*/, axios.get('https://xkmqdd6tr6.execute-api.us-east-1.amazonaws.com/Prod/organization')];
108
+ case 0: return [4 /*yield*/, axios.get("https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/organization")];
104
109
  case 1:
105
110
  response = _a.sent();
106
111
  if (response.data) {
@@ -115,6 +120,7 @@ function App(_a) {
115
120
  }
116
121
  useEffect(function () {
117
122
  if (formData !== undefined) {
123
+ console.log('!');
118
124
  if (preview && formData.isStandAlone) {
119
125
  fetchPreview(formData);
120
126
  }
@@ -147,12 +153,9 @@ function App(_a) {
147
153
  switch (_b.label) {
148
154
  case 0:
149
155
  _b.trys.push([0, 2, , 3]);
150
- url = "https://xkmqdd6tr6.execute-api.us-east-1.amazonaws.com/Prod/form/" + apiKey;
151
- if (domain) {
152
- url += "?domain=" + domain;
153
- }
156
+ url = "https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/form/" + apiKey + "?domain=" + domain;
154
157
  return [4 /*yield*/, Promise.all([
155
- axios.get(url),
158
+ domain ? axios.get(url) : axiosInstance.get("/form/" + apiKey),
156
159
  fetchOrgData(domain),
157
160
  ])];
158
161
  case 1:
@@ -173,6 +176,7 @@ function App(_a) {
173
176
  return [3 /*break*/, 3];
174
177
  case 2:
175
178
  error_1 = _b.sent();
179
+ console.error(error_1);
176
180
  setForm(null);
177
181
  setOrganizationInfo(null);
178
182
  return [3 /*break*/, 3];
@@ -0,0 +1,2 @@
1
+ declare const axiosInstance: import("axios").AxiosInstance;
2
+ export default axiosInstance;
@@ -0,0 +1,8 @@
1
+ import axios from 'axios';
2
+ var headers = {};
3
+ var axiosInstance = axios.create({
4
+ baseURL: '/api',
5
+ timeout: 30000,
6
+ headers: headers,
7
+ });
8
+ export default axiosInstance;
@@ -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
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: mapValues(originalValues, form),
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 (_b) {
82
- switch (_b.label) {
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*/, 5];
85
+ if (!(apiKey || internal)) return [3 /*break*/, 8];
85
86
  return [4 /*yield*/, trigger()];
86
87
  case 1:
87
- valid = _b.sent();
88
+ valid = _c.sent();
88
89
  values = getValues();
89
90
  if (!!valid) return [3 /*break*/, 2];
90
91
  console.log('ERRORS:', errors);
@@ -92,34 +93,40 @@ function ColumnForm(_a) {
92
93
  setTimeout(function () {
93
94
  setTempError(false);
94
95
  }, 500);
95
- return [3 /*break*/, 5];
96
+ return [3 /*break*/, 8];
96
97
  case 2:
97
- _b.trys.push([2, 4, , 5]);
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://xkmqdd6tr6.execute-api.us-east-1.amazonaws.com/Prod/ticket?apiKey=" + (internal ? form.apiKey : apiKey);
104
- if (domain) {
105
- url += "&domain=" + domain;
106
- }
104
+ url = "https://" + domain + ".forms." + process.env.REACT_APP_DOMAIN + "/api/ticket?apiKey=" + (internal ? form.apiKey : apiKey) + "&domain=" + domain;
107
105
  console.log(values);
108
- return [4 /*yield*/, axios.post(url, {
109
- formValues: { steps: values },
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
- resp = _b.sent();
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*/, 5];
117
- case 4:
118
- error_1 = _b.sent();
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*/, 5];
122
- case 5: return [2 /*return*/];
128
+ return [3 /*break*/, 8];
129
+ case 8: return [2 /*return*/];
123
130
  }
124
131
  });
125
132
  }); };
@@ -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
- }
@@ -46,7 +46,7 @@ function FormComponent(_a) {
46
46
  if (currentWidth !== undefined) {
47
47
  var currentBreakPoint = blockNum;
48
48
  while (currentWidth <
49
- (blockSize + spacingSize) * currentBreakPoint + 40) {
49
+ (blockSize + spacingSize) * currentBreakPoint) {
50
50
  currentBreakPoint--;
51
51
  }
52
52
  setWidthStats({
@@ -21,7 +21,7 @@ function DatePickerStep(_a) {
21
21
  ? '100%'
22
22
  : calcStepWidth(step.size, form),
23
23
  minHeight: step.description || step.required ? '55px' : '43px',
24
- } }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: new Date(), rules: {
24
+ } }, { children: _jsx(Controller, { name: step.id, control: control, defaultValue: null, rules: {
25
25
  required: step.required
26
26
  ? 'Este campo es obligatorio'
27
27
  : undefined,
@@ -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(step: FormStep, steps: Record<string, FormStep>, values: Record<string, any>): number;
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(step, steps, values) {
12
- var value = values[step.id];
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
- var pStep = steps[pStepId];
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
- var pStep = steps[pStepId];
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 [4 /*yield*/, axios.post('https://xkmqdd6tr6.execute-api.us-east-1.amazonaws.com/Prod/uploadfile', domain
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 [2 /*return*/, (_a = response.data) !== null && _a !== void 0 ? _a : undefined];
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
  });
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": "0.2.7",
4
+ "version": "0.2.10-test",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
7
7
  "build": "react-scripts build",
@@ -57,6 +57,7 @@
57
57
  "@types/react-router-dom": "^5.1.7",
58
58
  "@typescript-eslint/eslint-plugin": "^4.24.0",
59
59
  "@typescript-eslint/parser": "^4.24.0",
60
+ "dotenv-webpack": "^7.0.3",
60
61
  "eslint": "^7.27.0",
61
62
  "eslint-config-prettier": "^8.3.0",
62
63
  "eslint-plugin-prettier": "^3.4.0",