@arquimedes.co/eureka-forms 3.0.49-new-steps → 3.0.50-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.
Files changed (145) hide show
  1. package/dist/@Types/Condition.d.ts +6 -4
  2. package/dist/@Types/ErkValue.d.ts +16 -0
  3. package/dist/@Types/ErkValue.js +1 -0
  4. package/dist/@Types/Form.d.ts +1 -0
  5. package/dist/@Types/FormStep.d.ts +10 -8
  6. package/dist/@Types/FormStep.js +1 -2
  7. package/dist/@Types/User.d.ts +13 -0
  8. package/dist/@Types/User.js +1 -0
  9. package/dist/App/App.js +1 -1
  10. package/dist/App/AppFunctions.js +8 -3
  11. package/dist/App/AppHooks.js +20 -1
  12. package/dist/Form/Form.js +6 -2
  13. package/dist/Form/Form.module.css +48 -39
  14. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +8 -4
  15. package/dist/FormSteps/CBRStepMapper.js +1 -1
  16. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +2 -2
  17. package/dist/FormSteps/DatePickerRangeStep/MaterialDatePickerRangeStep/MaterialDatePickerRangeStep.js +1 -1
  18. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +52 -4
  19. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.js +1 -1
  20. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/FileComponent/FileComponent.module.css +1 -1
  21. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.js +48 -17
  22. package/dist/FormSteps/FileUploadStep/MaterialFileUploadStep/MaterialFileUploadStep.module.css +16 -0
  23. package/dist/FormSteps/Step.js +0 -16
  24. package/dist/FormSteps/StepFunctions.js +6 -23
  25. package/dist/FormSteps/StepFunctions.test.js +3 -57
  26. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +2 -1
  27. package/dist/Icons/@ErkIcon.d.ts +2 -2
  28. package/dist/Icons/@ErkIcon.js +2 -2
  29. package/dist/Icons/EmailIcon.d.ts +3 -0
  30. package/dist/Icons/{EditIcon.js → EmailIcon.js} +3 -3
  31. package/dist/Icons/Entities/SchoolIcon.d.ts +3 -0
  32. package/dist/Icons/Entities/SchoolIcon.js +7 -0
  33. package/dist/Icons/GroupIcon.d.ts +3 -0
  34. package/dist/Icons/GroupIcon.js +7 -0
  35. package/dist/Icons/LockedIcon.d.ts +3 -0
  36. package/dist/Icons/LockedIcon.js +7 -0
  37. package/dist/Login/Login.module.css +135 -0
  38. package/dist/Login/LoginLayout.module.css +68 -0
  39. package/dist/Login/LoginPage.d.ts +10 -0
  40. package/dist/Login/LoginPage.js +101 -0
  41. package/dist/Login/LoginTextField.d.ts +14 -0
  42. package/dist/Login/LoginTextField.js +29 -0
  43. package/dist/Services/ApiSelectorService.d.ts +366 -0
  44. package/dist/Services/ApiSelectorService.js +173 -0
  45. package/dist/Services/ApiSelectorService.test.d.ts +1 -0
  46. package/dist/Services/ApiSelectorService.test.js +87 -0
  47. package/dist/Services/DraftService.js +4 -1
  48. package/dist/Services/IntegrationService.d.ts +21 -0
  49. package/dist/Services/IntegrationService.js +22 -0
  50. package/dist/Services/UserService.d.ts +10 -0
  51. package/dist/Services/UserService.js +21 -0
  52. package/dist/Shared/ErkDatePicker/ErkDatePicker.js +11 -4
  53. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +3 -2
  54. package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +10 -4
  55. package/dist/Shared/ErkSelect/ErkSelect.d.ts +2 -2
  56. package/dist/Shared/InputIcon/InputIcon.js +6 -0
  57. package/dist/Shared/Navbar/Navbar.d.ts +2 -1
  58. package/dist/Shared/Navbar/Navbar.js +22 -3
  59. package/dist/Shared/Navbar/Navbar.module.css +22 -8
  60. package/dist/Shared/SmartDraftRenderer/LinkDecorator.d.ts +14 -0
  61. package/dist/Shared/SmartDraftRenderer/LinkDecorator.js +48 -0
  62. package/dist/Shared/SmartDraftRenderer/SmartDraftRenderer.js +10 -3
  63. package/dist/States/GlobalSlice.d.ts +4 -1
  64. package/dist/States/GlobalSlice.js +8 -1
  65. package/dist/constants/ErkIconTypes.d.ts +3 -1
  66. package/dist/constants/ErkIconTypes.js +2 -0
  67. package/dist/constants/ErkValueTypes.d.ts +6 -0
  68. package/dist/constants/ErkValueTypes.js +7 -0
  69. package/dist/constants/FormStepTypes.d.ts +3 -6
  70. package/dist/constants/FormStepTypes.js +1 -4
  71. package/dist/hooks.d.ts +3 -0
  72. package/dist/hooks.js +17 -1
  73. package/package.json +9 -3
  74. package/dist/@Types/AvailabilityFormStep.d.ts +0 -48
  75. package/dist/@Types/AvailabilityFormStep.js +0 -24
  76. package/dist/@Types/BankAccountFormStep.d.ts +0 -67
  77. package/dist/@Types/BankAccountFormStep.js +0 -14
  78. package/dist/@Types/BookingFormStep.d.ts +0 -156
  79. package/dist/@Types/BookingFormStep.js +0 -44
  80. package/dist/@Types/CalendarFormStep.d.ts +0 -192
  81. package/dist/@Types/CalendarFormStep.js +0 -48
  82. package/dist/@Types/CommunicationChannelFormStep.d.ts +0 -51
  83. package/dist/@Types/CommunicationChannelFormStep.js +0 -15
  84. package/dist/@Types/ConsentFormStep.d.ts +0 -36
  85. package/dist/@Types/ConsentFormStep.js +0 -8
  86. package/dist/@Types/EntityFormFormStep.d.ts +0 -66
  87. package/dist/@Types/EntityFormFormStep.js +0 -20
  88. package/dist/@Types/EventFormStep.d.ts +0 -52
  89. package/dist/@Types/EventFormStep.js +0 -13
  90. package/dist/@Types/ExternalReferenceFormStep.d.ts +0 -74
  91. package/dist/@Types/ExternalReferenceFormStep.js +0 -20
  92. package/dist/@Types/LocationFormStep.d.ts +0 -159
  93. package/dist/@Types/LocationFormStep.js +0 -46
  94. package/dist/@Types/NumericFormSteps.d.ts +0 -108
  95. package/dist/@Types/NumericFormSteps.js +0 -20
  96. package/dist/@Types/PredefinedSelectorFormStep.d.ts +0 -51
  97. package/dist/@Types/PredefinedSelectorFormStep.js +0 -39
  98. package/dist/@Types/StepRef.d.ts +0 -135
  99. package/dist/@Types/StepRef.js +0 -49
  100. package/dist/FormSteps/BookingStep/BookingStep.d.ts +0 -17
  101. package/dist/FormSteps/BookingStep/BookingStep.js +0 -14
  102. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +0 -3
  103. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +0 -362
  104. package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.module.css +0 -174
  105. package/dist/FormSteps/CalendarStep/CalendarStep.d.ts +0 -7
  106. package/dist/FormSteps/CalendarStep/CalendarStep.js +0 -14
  107. package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.d.ts +0 -3
  108. package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.js +0 -269
  109. package/dist/FormSteps/CalendarStep/MaterialCalendarStep/MaterialCalendarStep.module.css +0 -531
  110. package/dist/FormSteps/LocationStep/LocationStep.d.ts +0 -10
  111. package/dist/FormSteps/LocationStep/LocationStep.js +0 -14
  112. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +0 -3
  113. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +0 -47
  114. package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +0 -18
  115. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +0 -3
  116. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +0 -168
  117. package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +0 -94
  118. package/dist/FormSteps/NumberStep/NumberStep.d.ts +0 -10
  119. package/dist/FormSteps/NumberStep/NumberStep.js +0 -14
  120. package/dist/Icons/AddIcon.d.ts +0 -3
  121. package/dist/Icons/AddIcon.js +0 -7
  122. package/dist/Icons/EditIcon.d.ts +0 -3
  123. package/dist/Icons/RemoveIcon.d.ts +0 -3
  124. package/dist/Icons/RemoveIcon.js +0 -7
  125. package/dist/Icons/ViewDayIcon.d.ts +0 -3
  126. package/dist/Icons/ViewDayIcon.js +0 -7
  127. package/dist/Icons/ViewWeekIcon.d.ts +0 -3
  128. package/dist/Icons/ViewWeekIcon.js +0 -7
  129. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +0 -19
  130. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +0 -80
  131. package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +0 -82
  132. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +0 -29
  133. package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +0 -139
  134. package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +0 -23
  135. package/dist/Shared/ErkLocationField/ErkLocationField.js +0 -73
  136. package/dist/Shared/ErkLocationField/ErkLocationField.module.css +0 -29
  137. package/dist/Shared/ErkLocationField/addressFields.d.ts +0 -12
  138. package/dist/Shared/ErkLocationField/addressFields.js +0 -34
  139. package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +0 -6
  140. package/dist/Shared/ErkLocationField/locationRestrictions.js +0 -51
  141. package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +0 -15
  142. package/dist/Shared/ErkLocationInput/ErkLocationInput.js +0 -499
  143. package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +0 -115
  144. package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +0 -42
  145. package/dist/Shared/ErkNumberField/ErkNumberField.js +0 -170
@@ -120,10 +120,12 @@ export interface EntityDateCondition extends EntityPropertyConditionBase {
120
120
  export interface EntityRelativeDateCondition extends EntityPropertyConditionBase {
121
121
  propertyType: EntityPropertyTypes.DATEPICKER;
122
122
  propertyOperator: OperatorTypes.PAST_RELATIVE_LESS | OperatorTypes.PAST_RELATIVE_MORE | OperatorTypes.FUTURE_RELATIVE_LESS | OperatorTypes.FUTURE_RELATIVE_MORE;
123
- days: number;
124
- hours: number;
125
- minutes: number;
126
- working: boolean;
123
+ value: {
124
+ days: number;
125
+ hours: number;
126
+ minutes: number;
127
+ working: boolean;
128
+ };
127
129
  }
128
130
  export type EntityTimeCondition = BaseEntityTimeCondition | WorkingEntityTimeCondition;
129
131
  export interface BaseEntityTimeCondition extends EntityPropertyConditionBase {
@@ -0,0 +1,16 @@
1
+ import ErkValueTypes from '../constants/ErkValueTypes';
2
+ import { EurekaDraft } from './Draft/Draft';
3
+ export type ErkValue = StepErkValue | DraftErkValue | BooleanErkValue;
4
+ interface StepErkValue {
5
+ type: ErkValueTypes.STEP;
6
+ idStep: string;
7
+ }
8
+ interface DraftErkValue {
9
+ type: ErkValueTypes.DRAFT;
10
+ value: EurekaDraft;
11
+ }
12
+ interface BooleanErkValue {
13
+ type: ErkValueTypes.BOOLEAN;
14
+ value: boolean;
15
+ }
16
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -11,6 +11,7 @@ export interface Form {
11
11
  size: FormSize;
12
12
  firstSection: string;
13
13
  type?: FormTypes;
14
+ hasLogin?: boolean;
14
15
  hasCaptcha?: boolean;
15
16
  isStandAlone?: boolean;
16
17
  style?: FormStyle;
@@ -2,15 +2,10 @@ import { ErkIconTypes } from '../constants/ErkIconTypes';
2
2
  import FormStepTypes, { ClassifierOptionTypes, OptionTypes, RatingTypes, MapperStyleTypes, EntityValueOptionTypes, EntityValueDataTypes, ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../constants/FormStepTypes';
3
3
  import { Condition } from './Condition';
4
4
  import { EurekaDraft } from './Draft/Draft';
5
+ import { ErkValue } from './ErkValue';
5
6
  import * as GSteps from './GenericFormSteps';
6
7
  import { Time } from './Time';
7
- import { LocationStep } from './LocationFormStep';
8
- import { NumberStep, NumberStepType } from './NumericFormSteps';
9
- import { BookingStep } from './BookingFormStep';
10
- import { CalendarStep } from './CalendarFormStep';
11
- export type { LocationStep, NumberStep, BookingStep, CalendarStep };
12
- export { NumberStepType };
13
- export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper | DatePickerRange | LocationStep | NumberStep | BookingStep | CalendarStep;
8
+ export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper | DatePickerRange;
14
9
  export interface Title extends GSteps.GBaseStep {
15
10
  type: FormStepTypes.TITLE;
16
11
  title?: EurekaDraft;
@@ -157,7 +152,7 @@ export interface ValueEntityValuePickerPath {
157
152
  type: EntityValueDataTypes.VALUE;
158
153
  idEntityValue: string | null;
159
154
  }
160
- export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | CurrentAgentEntityValuePickerFilter;
155
+ export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | CurrentAgentEntityValuePickerFilter | IntegrationEntityValuePickerFilter;
161
156
  export interface StepEntityValuePickerFilter {
162
157
  idProperty: string;
163
158
  type: EntityValueDataTypes.STEP;
@@ -174,6 +169,12 @@ export interface CurrentAgentEntityValuePickerFilter {
174
169
  idProperty: string;
175
170
  type: EntityValueDataTypes.CURRENT_AGENT;
176
171
  }
172
+ export interface IntegrationEntityValuePickerFilter {
173
+ idProperty: string;
174
+ type: EntityValueDataTypes.INTEGRATION;
175
+ idIntegration: string;
176
+ values?: Record<string, ErkValue>;
177
+ }
177
178
  export interface ApiSelector extends GSteps.GSmartSelect {
178
179
  type: FormStepTypes.API_SELECTOR;
179
180
  icon?: ErkIconTypes;
@@ -231,3 +232,4 @@ export interface Mapper extends GSteps.GBaseStep {
231
232
  deletable?: boolean;
232
233
  max?: number;
233
234
  }
235
+ export {};
@@ -1,2 +1 @@
1
- import { NumberStepType } from './NumericFormSteps';
2
- export { NumberStepType };
1
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The currently active user
3
+ */
4
+ export interface User {
5
+ /** The User's id (if capta agent)*/
6
+ _id?: string;
7
+ /** The User's name */
8
+ name?: string;
9
+ /** The user's Email*/
10
+ email: string;
11
+ /** The expiration of the token */
12
+ exp: number;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/App/App.js CHANGED
@@ -13,7 +13,7 @@ import { nanoid } from '@reduxjs/toolkit';
13
13
  import { IdFormContext } from '../Contexts/FormContext';
14
14
  import { StoreContext } from '../Utils/StoreContext';
15
15
  function AppComponent({ formData, valuesData, ...props }) {
16
- const [idForm] = React.useState(nanoid(6));
16
+ const [idForm] = React.useState(nanoid(20));
17
17
  return (_jsx(IdFormContext.Provider, { value: idForm, children: _jsx(Provider, { store: store, context: StoreContext, children: _jsx(App, { formData: formData, valuesData: valuesData, ...props }) }) }));
18
18
  }
19
19
  export default AppComponent;
@@ -14,11 +14,11 @@ export const calcValuesStore = async (orgInfo, form, originalValues = {}, postvi
14
14
  await Promise.all(Object.keys(originalValues).map(async (idValue) => {
15
15
  const step = form.steps[idValue];
16
16
  if (step) {
17
+ if (!values.sections[step.idSection])
18
+ values.sections[step.idSection] = {};
17
19
  const value = await mapOriginalValue(orgInfo, step, originalValues[step.id], values, form);
18
20
  if (value !== undefined) {
19
21
  if (!form.hiddenSteps?.includes(step.id)) {
20
- if (!values.sections[step.idSection])
21
- values.sections[step.idSection] = {};
22
22
  values.sections[step.idSection][step.id] = value;
23
23
  }
24
24
  else {
@@ -163,7 +163,7 @@ export const mapOriginalValue = async (orgInfo, step, value, values, form, path
163
163
  }
164
164
  case FormStepTypes.ENTITYVALUEPICKER: {
165
165
  if (!value._id) {
166
- const params = new URLSearchParams(value);
166
+ const params = typeof value !== 'string' ? new URLSearchParams(value) : new URLSearchParams();
167
167
  const url = `${orgInfo.idOrganization}/entities/${step.idEntity}?${params.toString()}`;
168
168
  const entityValues = (await widgetInstance.get(url)).data;
169
169
  if (entityValues.length === 1) {
@@ -172,6 +172,11 @@ export const mapOriginalValue = async (orgInfo, step, value, values, form, path
172
172
  return undefined;
173
173
  return entityValues[0];
174
174
  }
175
+ if (typeof value === 'string') {
176
+ if (step.options[value]?.type === EntityValueOptionTypes.HIDE)
177
+ return undefined;
178
+ return entityValues.find((ev) => ev._id === value);
179
+ }
175
180
  return null;
176
181
  }
177
182
  return value;
@@ -4,6 +4,7 @@ import { fetchOrganization } from '../Services/OrganizationService';
4
4
  import { fetchForm } from '../Services/FormService';
5
5
  import { calcCbrForm } from '../Utils/CBRFunctions';
6
6
  import { calcInitialSections, calcValuesStore } from './AppFunctions';
7
+ import { jwtDecode } from 'jwt-decode';
7
8
  import { useAppDispatch } from '../hooks';
8
9
  import InternalFormStyle from '../constants/InternalFormStyle';
9
10
  import { calcDependencies } from '../Form/FormFunctions';
@@ -39,6 +40,7 @@ export const useSetupApp = (isEmbedded, props) => {
39
40
  const loadData = async () => {
40
41
  let idOrganization = others.idOrganization;
41
42
  let organization = null;
43
+ let user = null;
42
44
  let form = formData ?? null;
43
45
  if (form && preview && form.isStandAlone) {
44
46
  organization = await loadOrg();
@@ -90,7 +92,24 @@ export const useSetupApp = (isEmbedded, props) => {
90
92
  return;
91
93
  const dependencies = {};
92
94
  const values = await calcValuesStore({ idOrganization, countryCode }, form, valuesData, postview, customSteps);
95
+ if (form.hasLogin && !internal && !preview) {
96
+ const token = localStorage.getItem('token');
97
+ if (token) {
98
+ try {
99
+ user = jwtDecode(token);
100
+ if (user && Date.now() / 1000 >= user.exp) {
101
+ user = null;
102
+ localStorage.removeItem('token');
103
+ }
104
+ }
105
+ catch {
106
+ user = null;
107
+ localStorage.removeItem('token');
108
+ }
109
+ }
110
+ }
93
111
  dispatch(reset({
112
+ user,
94
113
  apiKey,
95
114
  formStyle: internal
96
115
  ? InternalFormStyle
@@ -104,7 +123,7 @@ export const useSetupApp = (isEmbedded, props) => {
104
123
  },
105
124
  internal: !!internal,
106
125
  idOrganization,
107
- idCurrentAgent,
126
+ idCurrentAgent: user?._id ?? idCurrentAgent,
108
127
  preview: !!preview,
109
128
  partial: !!partial,
110
129
  postview: !!postview,
package/dist/Form/Form.js CHANGED
@@ -17,9 +17,10 @@ import { useWidthStats } from './FormHooks';
17
17
  import { useAppDispatch, useAppSelector } from '../hooks';
18
18
  import FormContext, { IdFormContext } from '../Contexts/FormContext';
19
19
  import { getAppState } from '../Utils/store';
20
+ import LoginPage from '../Login/LoginPage';
20
21
  import { focusStep } from '../States/SiteSlice';
21
22
  function FormComponent({ form, apiKey, reload, isWidget, branding, setSubmit, scrollToTop, customSteps, containerRef, customSubmit, customSubmitBtns, customConfirmation, }) {
22
- const { idOrganization, internal, postview } = useAppSelector((state) => state.global);
23
+ const { idOrganization, internal, postview, user } = useAppSelector((state) => state.global);
23
24
  const formMethods = useForm({
24
25
  mode: 'onTouched',
25
26
  shouldFocusError: true,
@@ -100,8 +101,11 @@ function FormComponent({ form, apiKey, reload, isWidget, branding, setSubmit, sc
100
101
  }, children: _jsx("div", { className: styles.widgetFormContainer, ref: containerRef, children: renderForm() }) }));
101
102
  }
102
103
  else {
104
+ if (user === null && form.hasLogin) {
105
+ return (_jsx("div", { className: styles.loginContainer, children: _jsx(LoginPage, { form: form }) }));
106
+ }
103
107
  //Standalone cant have widget
104
- return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { logo: branding?.images.logoUrl, color: branding?.colors?.navbarColor ?? branding?.colors?.primaryColor }), _jsx("div", { className: styles.standAloneFormContainer, ref: containerRef, style: {
108
+ return (_jsxs(React.Fragment, { children: [_jsx(Navbar, { apiKey: form.apiKey, logo: branding?.images.logoUrl, color: branding?.colors?.navbarColor ?? branding?.colors?.primaryColor }), _jsx("div", { className: styles.standAloneFormContainer, ref: containerRef, style: {
105
109
  background: form.style?.standAloneBackgroundColor ?? '#ffffff',
106
110
  }, children: _jsx("div", { className: isResponsive ? styles.fullScreenStandAloneForm : styles.standAloneFormCard, style: {
107
111
  backgroundColor: form.style?.backgroundColor ?? InternalFormStyle.backgroundColor,
@@ -1,39 +1,48 @@
1
- .standAloneFormContainer {
2
- width: 100%;
3
- max-width: 100%;
4
- overflow: hidden;
5
- min-height: calc(100vh - 60px);
6
- display: flex;
7
- overflow-x: hidden;
8
- }
9
-
10
- .fullScreenStandAloneForm {
11
- width: 100%;
12
- padding: 20px;
13
- min-height: 100%;
14
- overflow: hidden;
15
- }
16
-
17
- .standAloneFormCard {
18
- -webkit-box-shadow: -6px 0px 8px 5px rgba(0, 0, 0, 0.2);
19
- -moz-box-shadow: -6px 0px 8px 5px rgba(0, 0, 0, 0.2);
20
- box-shadow: -6px 0px 8px 5px rgba(0, 0, 0, 0.2);
21
- margin-top: 30px;
22
- margin-left: auto;
23
- margin-right: auto;
24
- height: fit-content;
25
- width: fit-content;
26
- border-radius: 15px;
27
- padding: 20px;
28
- margin-bottom: 30px;
29
- }
30
-
31
- .widgetFormContainer {
32
- padding-top: 10px;
33
- padding-bottom: 10px;
34
- margin-left: auto;
35
- margin-right: auto;
36
- height: fit-content;
37
- width: fit-content;
38
- max-width: 100%;
39
- }
1
+ .standAloneFormContainer {
2
+ width: 100%;
3
+ max-width: 100%;
4
+ overflow: hidden;
5
+ min-height: calc(100vh - 60px);
6
+ display: flex;
7
+ overflow-x: hidden;
8
+ }
9
+
10
+ .fullScreenStandAloneForm {
11
+ width: 100%;
12
+ padding: 20px;
13
+ min-height: 100%;
14
+ overflow: hidden;
15
+ }
16
+
17
+ .loginContainer {
18
+ width: 100%;
19
+ max-width: 100%;
20
+ overflow: hidden;
21
+ min-height: 100vh;
22
+ display: flex;
23
+ overflow-x: hidden;
24
+ }
25
+
26
+ .standAloneFormCard {
27
+ -webkit-box-shadow: -6px 0px 8px 5px rgba(0, 0, 0, 0.2);
28
+ -moz-box-shadow: -6px 0px 8px 5px rgba(0, 0, 0, 0.2);
29
+ box-shadow: -6px 0px 8px 5px rgba(0, 0, 0, 0.2);
30
+ margin-top: 30px;
31
+ margin-left: auto;
32
+ margin-right: auto;
33
+ height: fit-content;
34
+ width: fit-content;
35
+ border-radius: 15px;
36
+ padding: 20px;
37
+ margin-bottom: 30px;
38
+ }
39
+
40
+ .widgetFormContainer {
41
+ padding-top: 10px;
42
+ padding-bottom: 10px;
43
+ margin-left: auto;
44
+ margin-right: auto;
45
+ height: fit-content;
46
+ width: fit-content;
47
+ max-width: 100%;
48
+ }
@@ -3,13 +3,12 @@ import React, { useContext, useMemo } from 'react';
3
3
  import FormStepTypes, { ApiSelectorOptionTypes, ApiSelectorParamTypes } from '../../../constants/FormStepTypes';
4
4
  import StepComponent from '../../Step';
5
5
  import SmartSelect from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
6
- import widgetInstance from '../../../Utils/AxiosWidget';
7
- import axiosInstance from '../../../Utils/AxiosAPI';
8
6
  import InputIcon from '../../../Shared/InputIcon/InputIcon';
9
7
  import FormContext from '../../../Contexts/FormContext';
10
8
  import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
11
9
  import { recursivelyCalcConditionSteps } from '../../StepHooks';
12
10
  import { evaluateCondition } from '../../StepFunctions';
11
+ import { fetchApiSelectorOptionsThrottled } from '../../../Services/ApiSelectorService';
13
12
  function ApiSelectorComponent({ step, editable, ...others }) {
14
13
  const form = useContext(FormContext);
15
14
  function calcOptionId(option) {
@@ -34,6 +33,9 @@ function ApiSelectorComponent({ step, editable, ...others }) {
34
33
  }
35
34
  else if (typeof currentValue === 'string')
36
35
  params.set(filter.key, currentValue);
36
+ else if (step.url.includes('capta.co') && currentValue._id) {
37
+ params.set(filter.key, currentValue._id);
38
+ }
37
39
  else
38
40
  params.set(filter.key, currentValue.label ?? currentValue.id);
39
41
  }
@@ -54,8 +56,10 @@ function ApiSelectorComponent({ step, editable, ...others }) {
54
56
  if (!step.url.includes('?'))
55
57
  url += '?';
56
58
  url += params.toString();
57
- const response = await (idOrganization ? widgetInstance.get(url) : axiosInstance.get(url));
58
- return response.data.filter((option) => calcOptionId(option) && step.options[calcOptionId(option)]?.type !== ApiSelectorOptionTypes.HIDE);
59
+ // Use the throttled fetch function that limits concurrent requests per URL
60
+ const response = await fetchApiSelectorOptionsThrottled(url, idOrganization);
61
+ return response.filter((option) => calcOptionId(option) !== undefined &&
62
+ step.options[calcOptionId(option)]?.type !== ApiSelectorOptionTypes.HIDE);
59
63
  }, [form]);
60
64
  return (_jsx(StepFillerContainer, { step: step, children: _jsx(SmartSelect, { ...others, editable: editable, step: step, IconComponent: () => (step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined), getOptions: getApiOptions, getOptionSelected: (option, value) => calcOptionId(option) === calcOptionId(value), calcDepError: (steps) => {
61
65
  for (const step of steps) {
@@ -54,7 +54,7 @@ function CBRStepMapper(props) {
54
54
  case CBRFormStepTypes.CBR_EMAIL:
55
55
  return (_jsx(TextInputStep, { ...props, step: props.step, validation: {
56
56
  type: 'EMAIL',
57
- value: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
57
+ value: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@(?!(gmal|gmai|gmil|hotmil|hotmal|hotmai|yaho|yhoo|yahoo|outlok|outloo|outluk)\.)((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
58
58
  .source,
59
59
  message: 'El correo no es válido',
60
60
  } }));
@@ -34,7 +34,7 @@ function ClassifierSelectorStep({ step, editable }) {
34
34
  const form = useContext(FormContext);
35
35
  const classifier = form.classifiers?.[step.idClassifier ?? ''];
36
36
  const options = useMemo(() => {
37
- return classifier?.children
37
+ return (classifier?.children
38
38
  ?.filter((idClassifier) => {
39
39
  const option = step.options[idClassifier];
40
40
  if (option?.type === ClassifierOptionTypes.HIDE || !form.classifiers?.[idClassifier]) {
@@ -48,7 +48,7 @@ function ClassifierSelectorStep({ step, editable }) {
48
48
  value: classifier?._id,
49
49
  label: classifier?.clientName?.trim?.() && preview ? classifier?.clientName : classifier?.name,
50
50
  };
51
- });
51
+ }) ?? []);
52
52
  },
53
53
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
54
  [dependenciesValues]);
@@ -29,6 +29,6 @@ function MaterialDatePickerRangeStep({ step, editable, defaultValue }) {
29
29
  }, [onChange]);
30
30
  const [minDate, maxDate] = [safeDate(step.minDate), safeDate(step.maxDate)];
31
31
  const dateRangeValue = value?.length === 2 ? [safeDate(value[0]) ?? null, safeDate(value[1]) ?? null] : [null, null];
32
- return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkDateRangePicker, { ...field, value: dateRangeValue, inputRef: ref, error: !!error, minDate: minDate, maxDate: maxDate, labelMargin: 0, onChange: handleChange, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
32
+ return (_jsx(MaterialInputContainer, { step: step, editable: editable, children: _jsx(ErkDateRangePicker, { ...field, value: dateRangeValue, inputRef: ref, error: !!error, minDate: minDate, maxDate: maxDate, labelMargin: 0, label: step.label, onChange: handleChange, required: step.required, readOnly: !editable || postview, helperText: error?.message ?? step.description }) }));
33
33
  }
34
34
  export default MaterialDatePickerRangeStep;
@@ -3,16 +3,30 @@ import React, { useCallback, useContext, useMemo, useState } from 'react';
3
3
  import FormStepTypes, { EntityValueDataTypes, EntityValueOptionTypes } from '../../../constants/FormStepTypes';
4
4
  import SmartSelect from '../../SmartSelectStep/MaterialSmartSelectStep/MaterialSmartSelectStep';
5
5
  import widgetInstance from '../../../Utils/AxiosWidget';
6
- import FormContext from '../../../Contexts/FormContext';
6
+ import FormContext, { IdFormContext } from '../../../Contexts/FormContext';
7
7
  import StepFillerContainer from '../../Utils/@StepFiller/StepFiller';
8
8
  import { recursivelyCalcConditionSteps, selectDependencies } from '../../StepHooks';
9
- import { useAppSelector } from '../../../hooks';
9
+ import { useApiSubscribe, useAppSelector } from '../../../hooks';
10
10
  import MaterialEntityValueDialog from './MaterialEntityValueDialog/MaterialEntityValueDialog';
11
11
  import InputIcon from '../../../Shared/InputIcon/InputIcon';
12
12
  import { evaluateCondition } from '../../StepFunctions';
13
13
  import StepComponent from '../../Step';
14
+ import ErkValueTypes from '../../../constants/ErkValueTypes';
15
+ import { IntegrationsApi } from '../../../Services/IntegrationService';
14
16
  function EntityValuePickerStep({ step, editable }) {
15
17
  const form = useContext(FormContext);
18
+ const subscribe = useApiSubscribe();
19
+ const idForm = useContext(IdFormContext);
20
+ const fetchFilterIntegration = useCallback(async (idIntegration, payload) => {
21
+ return ((await subscribe(IntegrationsApi.endpoints.fetchFilterIntegration.initiate({
22
+ idForm,
23
+ payload,
24
+ idIntegration,
25
+ }))) ?? []);
26
+ }, [subscribe, idForm]);
27
+ const getOptions = useCallback(async (step, dependencyStore, ids) => {
28
+ return await getEntityValueOptions(step, dependencyStore, ids, fetchFilterIntegration);
29
+ }, [fetchFilterIntegration]);
16
30
  const [dialogs, setDialogs] = useState();
17
31
  const dialogsIdStepDeps = useMemo(() => {
18
32
  const ids = [];
@@ -34,7 +48,7 @@ function EntityValuePickerStep({ step, editable }) {
34
48
  }
35
49
  : undefined);
36
50
  }, []);
37
- return (_jsxs(React.Fragment, { children: [dialogs !== undefined && form.entities?.[step.idEntity] && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: form.entities?.[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, { step: step, children: _jsx(SmartSelect, { step: step, editable: editable, getOptions: getEntityValueOptions, getOptionalDependencies: getOptionalDependencies, IconComponent: () => (step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined), getOptionSelected: (option, value) => option._id === value._id, calcDepError: (steps) => {
51
+ return (_jsxs(React.Fragment, { children: [dialogs !== undefined && form.entities?.[step.idEntity] && (_jsx(MaterialEntityValueDialog, { type: dialogs.current.type, entity: form.entities?.[step.idEntity], entityValue: dialogs.value, message: dialogs.current.message, handleClose: handleCloseDialog })), _jsx(StepFillerContainer, { step: step, children: _jsx(SmartSelect, { step: step, editable: editable, getOptions: getOptions, getOptionalDependencies: getOptionalDependencies, IconComponent: () => (step.icon ? _jsx(InputIcon, { icon: step.icon }) : undefined), getOptionSelected: (option, value) => option._id === value._id, calcDepError: (steps) => {
38
52
  for (const step of steps) {
39
53
  if (step.type === FormStepTypes.ENTITYVALUEPICKER) {
40
54
  return 'Selecciona un ' + step.label;
@@ -97,7 +111,7 @@ function EntityValuePickerStep({ step, editable }) {
97
111
  } }) })] }));
98
112
  }
99
113
  export default EntityValuePickerStep;
100
- const getEntityValueOptions = async (step, dependencyStore, { idOrganization, idCurrentAgent, }) => {
114
+ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, idCurrentAgent, }, fetchFilterIntegration) => {
101
115
  if (!idOrganization)
102
116
  return null;
103
117
  let urlPath = '';
@@ -124,6 +138,40 @@ const getEntityValueOptions = async (step, dependencyStore, { idOrganization, id
124
138
  const params = new URLSearchParams({});
125
139
  for (const filter of step.filters) {
126
140
  switch (filter.type) {
141
+ case EntityValueDataTypes.INTEGRATION: {
142
+ const payload = {};
143
+ for (const [key, erkValue] of Object.entries(filter.values ?? {})) {
144
+ switch (erkValue.type) {
145
+ case ErkValueTypes.BOOLEAN:
146
+ payload[key] = erkValue.value;
147
+ break;
148
+ case ErkValueTypes.DRAFT: {
149
+ //TODO: Hacer esto bien, la lambda tiene que ser capaz de calcular un draft en un filtro
150
+ // values[key] = await mapDraftEntities(
151
+ // `filters[${index}].values.${key}`
152
+ // );
153
+ break;
154
+ }
155
+ case ErkValueTypes.STEP: {
156
+ const currentValue = dependencyStore[erkValue.idStep]?.value;
157
+ if (currentValue) {
158
+ if (typeof currentValue === 'string')
159
+ payload[key] = currentValue;
160
+ else if (currentValue instanceof Date)
161
+ payload[key] = currentValue.toISOString();
162
+ else
163
+ payload[key] = currentValue._id ?? currentValue.id;
164
+ }
165
+ else
166
+ payload[key] = null;
167
+ break;
168
+ }
169
+ }
170
+ }
171
+ const filtered = await fetchFilterIntegration(filter.idIntegration, payload);
172
+ params.set(filter.idProperty, filtered.join(','));
173
+ break;
174
+ }
127
175
  case EntityValueDataTypes.STEP: {
128
176
  const currentValue = dependencyStore[filter.idStep]?.value;
129
177
  if (currentValue) {
@@ -64,6 +64,6 @@ function FileUploadComponent({ file, formStyle, error, editable, handleRemove, f
64
64
  }
65
65
  }, children: file.file?.name ?? file.fileName }), editable && (_jsx("div", { className: styles.deletBtn, onClick: () => {
66
66
  handleRemove();
67
- }, children: _jsx(CloseIcon, { style: { fontSize: 'inherit' } }) }))] }));
67
+ }, children: _jsx(CloseIcon, { size: 24 }) }))] }));
68
68
  }
69
69
  export default FileUploadComponent;
@@ -34,7 +34,7 @@
34
34
  font-size: 26px;
35
35
  height: 26px;
36
36
  margin-left: 5px;
37
- color: '#787878';
37
+ color: #787878;
38
38
  cursor: pointer;
39
39
  }
40
40
  .loaderContainer {
@@ -23,7 +23,23 @@ function FileUploadStep({ step, editable }) {
23
23
  const { clearErrors } = useFormContext();
24
24
  const [error, setError] = useState(undefined);
25
25
  const [fileChange, setFileChange] = useState([]);
26
+ const [dragging, setDragging] = useState(false);
26
27
  const inputRef = useRef(null);
28
+ const handleFiles = useCallback((files) => {
29
+ const maxFiles = files.filter((file) => file.size > maxSize);
30
+ if (maxFiles.length > 0) {
31
+ setError('El tamaño máximo de carga es de 30Mb.');
32
+ }
33
+ else {
34
+ setFileChange(files
35
+ .filter((file) => value.find((val) => val.file === file) === undefined)
36
+ .map((file) => ({
37
+ state: 'STARTING',
38
+ file,
39
+ postInfo: null,
40
+ })));
41
+ }
42
+ }, [value]);
27
43
  const getLinks = useCallback(async (pFiles) => {
28
44
  try {
29
45
  const fileLinks = await getUploadUrls(pFiles.map((file) => file.file), idOrganization);
@@ -122,25 +138,40 @@ function FileUploadStep({ step, editable }) {
122
138
  }
123
139
  return '';
124
140
  };
125
- return (_jsxs("div", { className: styles.container + (error || !!fieldError ? ' Erk-error' : ''), style: {
141
+ return (_jsxs("div", { className: styles.container +
142
+ (error || !!fieldError ? ' Erk-error' : '') +
143
+ (dragging ? ' ' + styles.dragging : ''), style: {
126
144
  minHeight: editable === false || postview ? undefined : '100px',
127
- }, "data-testid": step.id, children: [_jsx("div", { className: styles.labelLabel, children: step.label }), step.description && (_jsx("div", { className: styles.stepDescriptionLabel, style: { color: formStyle.descriptionTextColor }, children: step.description })), _jsx("input", { type: "file", ref: inputRef, className: styles.filesInput, onChange: (e) => {
145
+ }, "data-testid": step.id, onDragOver: (e) => {
146
+ if (!editable || postview)
147
+ return;
148
+ e.preventDefault();
149
+ }, onDragEnter: (e) => {
150
+ if (!editable || postview)
151
+ return;
152
+ e.preventDefault();
153
+ setDragging(true);
154
+ }, onDragLeave: (e) => {
155
+ if (!editable || postview)
156
+ return;
157
+ if (e.currentTarget.contains(e.relatedTarget))
158
+ return;
159
+ setDragging(false);
160
+ }, onDrop: (e) => {
161
+ if (!editable || postview)
162
+ return;
163
+ e.preventDefault();
164
+ setDragging(false);
165
+ clearErrors(step.id);
166
+ setError(undefined);
167
+ const files = e.dataTransfer.files;
168
+ if (files && files.length > 0) {
169
+ handleFiles(Array.from(files));
170
+ }
171
+ }, children: [_jsx("div", { className: styles.labelLabel, children: step.label }), step.description && (_jsx("div", { className: styles.stepDescriptionLabel, style: { color: formStyle.descriptionTextColor }, children: step.description })), _jsx("input", { type: "file", ref: inputRef, className: styles.filesInput, onChange: (e) => {
128
172
  const files = e.target.files;
129
173
  if (files) {
130
- const filesArray = Array.from(files);
131
- const maxFiles = filesArray.filter((file) => file.size > maxSize);
132
- if (maxFiles.length > 0) {
133
- setError('El tamaño máximo de carga es de 30Mb.');
134
- }
135
- else {
136
- setFileChange(filesArray
137
- .filter((file) => value.find((val) => val.file === file) === undefined)
138
- .map((file) => ({
139
- state: 'STARTING',
140
- file,
141
- postInfo: null,
142
- })));
143
- }
174
+ handleFiles(Array.from(files));
144
175
  inputRef.current.value = '';
145
176
  }
146
177
  }, multiple: true, accept: getAcceptedExtensions() }), _jsxs("div", { className: styles.btnContainer, children: [_jsx("input", { ref: ref, className: 'hidden-input' }), _jsx(ErkButton, { disabled: !editable || postview, text: 'Examinar' + (step.required ? ' *' : ''), onClick: () => {
@@ -152,7 +183,7 @@ function FileUploadStep({ step, editable }) {
152
183
  input.click();
153
184
  }
154
185
  }
155
- } })] }), _jsx("div", { className: styles.filesContainer, children: value.map((file, index) => (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!fieldError && file.state !== 'DONE') ||
186
+ } })] }), editable && !postview && (_jsx("div", { className: styles.dragHint, style: { color: formStyle.descriptionTextColor }, children: "o arrastra y suelta los archivos aqu\u00ED" })), _jsx("div", { className: styles.filesContainer, children: value.map((file, index) => (_jsx(FileComponent, { formStyle: formStyle, file: file, error: (!!fieldError && file.state !== 'DONE') ||
156
187
  file.state === 'ERROR', editable: editable && !postview, handleRemove: () => {
157
188
  if (value.filter((val) => val.state === 'ERROR').length === 1) {
158
189
  clearErrors(step.id);
@@ -32,6 +32,12 @@
32
32
  text-overflow: ellipsis;
33
33
  }
34
34
 
35
+ .dragging {
36
+ border: 2px dashed currentColor;
37
+ border-radius: 10px;
38
+ opacity: 0.85;
39
+ }
40
+
35
41
  .filesInput {
36
42
  display: none;
37
43
  }
@@ -41,6 +47,16 @@
41
47
  margin-bottom: 3px;
42
48
  width: fit-content;
43
49
  }
50
+ .dragHint {
51
+ font-size: 0.75rem;
52
+ margin-left: 14px;
53
+ margin-top: 4px;
54
+ opacity: 0.8;
55
+ -moz-user-select: none;
56
+ -webkit-user-select: none;
57
+ -ms-user-select: none;
58
+ user-select: none;
59
+ }
44
60
  .errorMsg {
45
61
  font-size: 0.75rem;
46
62
  margin-top: 5px;