@arquimedes.co/eureka-forms 3.0.46-new-steps → 3.0.48-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/@Types/Condition.d.ts +6 -4
- package/dist/@Types/ErkValue.d.ts +16 -0
- package/dist/@Types/ErkValue.js +1 -0
- package/dist/@Types/Form.d.ts +1 -0
- package/dist/@Types/FormStep.d.ts +8 -1
- package/dist/@Types/User.d.ts +13 -0
- package/dist/@Types/User.js +1 -0
- package/dist/App/App.js +1 -1
- package/dist/App/AppFunctions.js +8 -3
- package/dist/App/AppHooks.js +20 -1
- package/dist/Form/Form.js +6 -2
- package/dist/Form/Form.module.css +48 -39
- package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +8 -4
- package/dist/FormSteps/CBRStepMapper.js +1 -1
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +2 -2
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +52 -4
- package/dist/FormSteps/StepFunctions.js +6 -9
- package/dist/FormSteps/StepFunctions.test.js +3 -3
- package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +2 -1
- package/dist/Icons/@ErkIcon.d.ts +2 -2
- package/dist/Icons/@ErkIcon.js +2 -2
- package/dist/Icons/EmailIcon.d.ts +3 -0
- package/dist/Icons/EmailIcon.js +7 -0
- package/dist/Icons/Entities/SchoolIcon.d.ts +3 -0
- package/dist/Icons/Entities/SchoolIcon.js +7 -0
- package/dist/Icons/GroupIcon.d.ts +3 -0
- package/dist/Icons/GroupIcon.js +7 -0
- package/dist/Icons/LockedIcon.d.ts +3 -0
- package/dist/Icons/LockedIcon.js +7 -0
- package/dist/Login/Login.module.css +135 -0
- package/dist/Login/LoginLayout.module.css +68 -0
- package/dist/Login/LoginPage.d.ts +10 -0
- package/dist/Login/LoginPage.js +101 -0
- package/dist/Login/LoginTextField.d.ts +14 -0
- package/dist/Login/LoginTextField.js +29 -0
- package/dist/Services/ApiSelectorService.d.ts +366 -0
- package/dist/Services/ApiSelectorService.js +173 -0
- package/dist/Services/ApiSelectorService.test.d.ts +1 -0
- package/dist/Services/ApiSelectorService.test.js +87 -0
- package/dist/Services/DraftService.js +4 -1
- package/dist/Services/IntegrationService.d.ts +21 -0
- package/dist/Services/IntegrationService.js +22 -0
- package/dist/Services/UserService.d.ts +10 -0
- package/dist/Services/UserService.js +21 -0
- package/dist/Shared/ErkSelect/ErkSelect.d.ts +2 -2
- package/dist/Shared/InputIcon/InputIcon.js +6 -0
- package/dist/Shared/Navbar/Navbar.d.ts +2 -1
- package/dist/Shared/Navbar/Navbar.js +22 -3
- package/dist/Shared/Navbar/Navbar.module.css +22 -8
- package/dist/Shared/SmartDraftRenderer/LinkDecorator.d.ts +14 -0
- package/dist/Shared/SmartDraftRenderer/LinkDecorator.js +48 -0
- package/dist/Shared/SmartDraftRenderer/SmartDraftRenderer.js +8 -2
- package/dist/States/GlobalSlice.d.ts +4 -1
- package/dist/States/GlobalSlice.js +8 -1
- package/dist/constants/ErkIconTypes.d.ts +3 -1
- package/dist/constants/ErkIconTypes.js +2 -0
- package/dist/constants/ErkValueTypes.d.ts +6 -0
- package/dist/constants/ErkValueTypes.js +7 -0
- package/dist/constants/FormStepTypes.d.ts +2 -1
- package/dist/constants/FormStepTypes.js +1 -0
- package/dist/hooks.d.ts +3 -0
- package/dist/hooks.js +17 -1
- package/package.json +10 -3
- package/dist/@Types/AvailabilityFormStep.d.ts +0 -65
- package/dist/@Types/AvailabilityFormStep.js +0 -27
- package/dist/@Types/BankAccountFormStep.d.ts +0 -67
- package/dist/@Types/BankAccountFormStep.js +0 -14
- package/dist/@Types/CommunicationChannelFormStep.d.ts +0 -51
- package/dist/@Types/CommunicationChannelFormStep.js +0 -15
- package/dist/@Types/ConsentFormStep.d.ts +0 -36
- package/dist/@Types/ConsentFormStep.js +0 -8
- package/dist/@Types/EntityFormFormStep.d.ts +0 -66
- package/dist/@Types/EntityFormFormStep.js +0 -20
- package/dist/@Types/EventFormStep.d.ts +0 -52
- package/dist/@Types/EventFormStep.js +0 -13
- package/dist/@Types/ExternalReferenceFormStep.d.ts +0 -74
- package/dist/@Types/ExternalReferenceFormStep.js +0 -20
- package/dist/@Types/LocationFormStep.d.ts +0 -136
- package/dist/@Types/LocationFormStep.js +0 -33
- package/dist/@Types/NumericFormSteps.d.ts +0 -171
- package/dist/@Types/NumericFormSteps.js +0 -32
- package/dist/@Types/PredefinedSelectorFormStep.d.ts +0 -51
- package/dist/@Types/PredefinedSelectorFormStep.js +0 -39
- package/dist/@Types/StepRef.d.ts +0 -79
- package/dist/@Types/StepRef.js +0 -27
|
@@ -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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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 {};
|
package/dist/@Types/Form.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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
8
|
export type FormStep = Title | TimePicker | Rating | CheckBox | TextArea | TextInput | DatePicker | FileUpload | Separator | FormSelector | ClassifierSelector | Collapsible | EntityValuePicker | ApiSelector | Mapper | DatePickerRange;
|
|
@@ -151,7 +152,7 @@ export interface ValueEntityValuePickerPath {
|
|
|
151
152
|
type: EntityValueDataTypes.VALUE;
|
|
152
153
|
idEntityValue: string | null;
|
|
153
154
|
}
|
|
154
|
-
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | CurrentAgentEntityValuePickerFilter;
|
|
155
|
+
export type EntityValuePickerFilter = StepEntityValuePickerFilter | ValueEntityValuePickerFilter | CurrentAgentEntityValuePickerFilter | IntegrationEntityValuePickerFilter;
|
|
155
156
|
export interface StepEntityValuePickerFilter {
|
|
156
157
|
idProperty: string;
|
|
157
158
|
type: EntityValueDataTypes.STEP;
|
|
@@ -168,6 +169,12 @@ export interface CurrentAgentEntityValuePickerFilter {
|
|
|
168
169
|
idProperty: string;
|
|
169
170
|
type: EntityValueDataTypes.CURRENT_AGENT;
|
|
170
171
|
}
|
|
172
|
+
export interface IntegrationEntityValuePickerFilter {
|
|
173
|
+
idProperty: string;
|
|
174
|
+
type: EntityValueDataTypes.INTEGRATION;
|
|
175
|
+
idIntegration: string;
|
|
176
|
+
values?: Record<string, ErkValue>;
|
|
177
|
+
}
|
|
171
178
|
export interface ApiSelector extends GSteps.GSmartSelect {
|
|
172
179
|
type: FormStepTypes.API_SELECTOR;
|
|
173
180
|
icon?: ErkIconTypes;
|
|
@@ -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(
|
|
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;
|
package/dist/App/AppFunctions.js
CHANGED
|
@@ -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;
|
package/dist/App/AppHooks.js
CHANGED
|
@@ -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
|
-
.
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
58
|
-
|
|
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]);
|
|
@@ -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:
|
|
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) {
|
|
@@ -135,7 +135,7 @@ export const calcDefaultValue = (step) => {
|
|
|
135
135
|
return undefined;
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
|
-
export const iterateNestedSteps = (idStep, steps, iteration, path = [
|
|
138
|
+
export const iterateNestedSteps = (idStep, steps, iteration, path = []) => {
|
|
139
139
|
const step = steps[idStep];
|
|
140
140
|
if (!step) {
|
|
141
141
|
console.error('Missing Step:', idStep);
|
|
@@ -144,15 +144,12 @@ export const iterateNestedSteps = (idStep, steps, iteration, path = [idStep]) =>
|
|
|
144
144
|
iteration(step, path);
|
|
145
145
|
if (step.type === FormStepTypes.MAPPER) {
|
|
146
146
|
for (const idStep of step.rootSteps) {
|
|
147
|
-
iterateNestedSteps(idStep, step.steps, iteration, [
|
|
148
|
-
...path,
|
|
149
|
-
step.id,
|
|
150
|
-
]);
|
|
147
|
+
iterateNestedSteps(idStep, step.steps, iteration, [...path, step.id]);
|
|
151
148
|
}
|
|
152
149
|
}
|
|
153
150
|
else {
|
|
154
151
|
for (const idSubStep of calcSubSteps(step.id, steps)) {
|
|
155
|
-
iterateNestedSteps(idSubStep, steps, iteration,
|
|
152
|
+
iterateNestedSteps(idSubStep, steps, iteration, path);
|
|
156
153
|
}
|
|
157
154
|
}
|
|
158
155
|
};
|
|
@@ -523,13 +520,13 @@ const evaluateEntityPropertyCondition = (condition, entity, entityValue) => {
|
|
|
523
520
|
case OperatorTypes.PAST_RELATIVE_MORE:
|
|
524
521
|
case OperatorTypes.FUTURE_RELATIVE_LESS:
|
|
525
522
|
case OperatorTypes.FUTURE_RELATIVE_MORE: {
|
|
526
|
-
const date = getRelativeDate(condition.days, condition.hours, condition.minutes, condition.propertyOperator === OperatorTypes.PAST_RELATIVE_LESS ||
|
|
523
|
+
const date = getRelativeDate(condition.value?.days, condition.value?.hours, condition.value?.minutes, condition.propertyOperator === OperatorTypes.PAST_RELATIVE_LESS ||
|
|
527
524
|
condition.propertyOperator === OperatorTypes.PAST_RELATIVE_MORE);
|
|
528
525
|
if (condition.propertyOperator === OperatorTypes.PAST_RELATIVE_LESS ||
|
|
529
526
|
condition.propertyOperator === OperatorTypes.FUTURE_RELATIVE_LESS)
|
|
530
|
-
return new Date().getTime()
|
|
527
|
+
return new Date(value).getTime() < date.getTime();
|
|
531
528
|
else
|
|
532
|
-
return new Date().getTime()
|
|
529
|
+
return new Date(value).getTime() > date.getTime();
|
|
533
530
|
}
|
|
534
531
|
}
|
|
535
532
|
return false;
|
|
@@ -565,9 +565,9 @@ describe('StepFunctions', function () {
|
|
|
565
565
|
const iterationMock = vi.fn();
|
|
566
566
|
iterateNestedSteps('idStep1', steps, iterationMock);
|
|
567
567
|
expect(iterationMock).toHaveBeenCalledTimes(3);
|
|
568
|
-
expect(iterationMock).toHaveBeenCalledWith(steps.idStep1);
|
|
569
|
-
expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep2);
|
|
570
|
-
expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep3);
|
|
568
|
+
expect(iterationMock).toHaveBeenCalledWith(steps.idStep1, []);
|
|
569
|
+
expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep2, ['idStep1']);
|
|
570
|
+
expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep3, ['idStep1']);
|
|
571
571
|
});
|
|
572
572
|
});
|
|
573
573
|
});
|
|
@@ -31,12 +31,13 @@ function TitleStep({ step }) {
|
|
|
31
31
|
return values;
|
|
32
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
33
|
}, [stableDepsValues]);
|
|
34
|
+
const path = useMemo(() => [...step.stepPath, step.id].join('.'), [step.stepPath, step.id]);
|
|
34
35
|
return (_jsxs("div", { className: styles.container, style: {
|
|
35
36
|
color: formStyle.textColor,
|
|
36
37
|
width: widthStats.currentBreakPoint <= size ? '100%' : calcStepWidth(size, form.size),
|
|
37
38
|
}, children: [_jsx("div", { className: styles.titleLbl, style: {
|
|
38
39
|
textAlign: widthStats.isMobile && widthStats.currentBreakPoint <= size ? 'center' : 'start',
|
|
39
|
-
}, children: _jsx(SmartDraftRenderer, { draft: title, dependencies: values, property: `${
|
|
40
|
+
}, children: _jsx(SmartDraftRenderer, { draft: title, dependencies: values, property: `${path}.title`, onChange: (title) => onChange({ ...value, title }) }) }), _jsx("div", { className: styles.descriptionPar, children: _jsx(SmartDraftRenderer, { draft: description, dependencies: values, margin: title ? '10px 0px' : '0px 0px 5px 0px', property: `${path}.description`, onChange: (description) => onChange({ ...value, description }) }) })] }));
|
|
40
41
|
}
|
|
41
42
|
export default TitleStep;
|
|
42
43
|
function calcBaseDraft(value) {
|
package/dist/Icons/@ErkIcon.d.ts
CHANGED
package/dist/Icons/@ErkIcon.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function EmailIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, version: "1.1", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-1 14H5c-.55 0-1-.45-1-1V8l6.94 4.34c.65.41 1.47.41 2.12 0L20 8v9c0 .55-.45 1-1 1zm-7-7L4 6h16l-8 5z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default EmailIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from '../@ErkIcon';
|
|
3
|
+
function SchoolIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, version: "1.1", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M5 13.18v2.81c0 .73.4 1.41 1.04 1.76l5 2.73c.6.33 1.32.33 1.92 0l5-2.73c.64-.35 1.04-1.03 1.04-1.76v-2.81l-6.04 3.3c-.6.33-1.32.33-1.92 0zm6.04-9.66-8.43 4.6c-.69.38-.69 1.38 0 1.76l8.43 4.6c.6.33 1.32.33 1.92 0L21 10.09V16c0 .55.45 1 1 1s1-.45 1-1V9.59c0-.37-.2-.7-.52-.88l-9.52-5.19a2.04 2.04 0 0 0-1.92 0" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default SchoolIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function GroupIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, version: "1.1", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M12 12.75c1.63 0 3.07.39 4.24.9 1.08.48 1.76 1.56 1.76 2.73V17c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-.61c0-1.18.68-2.26 1.76-2.73 1.17-.52 2.61-.91 4.24-.91M4 13c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m1.13 1.1c-.37-.06-.74-.1-1.13-.1-.99 0-1.93.21-2.78.58C.48 14.9 0 15.62 0 16.43V17c0 .55.45 1 1 1h3.5v-1.61c0-.83.23-1.61.63-2.29M20 13c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m4 3.43c0-.81-.48-1.53-1.22-1.85-.85-.37-1.79-.58-2.78-.58-.39 0-.76.04-1.13.1.4.68.63 1.46.63 2.29V18H23c.55 0 1-.45 1-1zM12 6c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default GroupIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function LockedIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, version: "1.1", viewBox: "0 0 100 100", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M81.9,49.6c0-9-0.4-9.4-9.3-9.7c0,0,0,0,0,0c0-4,0-9-0.1-12.1C72,16,64.7,8.9,53,8.7c-2,0-4,0-6.1,0 c-13,0.1-20.6,8-20.4,20.9c0,0,0,0.1,0,0.1V40c-0.7,0-1.4,0-2.2,0c-5.8,0-7.1,1.4-7.1,7.2c0,12.3,0.1,24.6-0.1,36.9 c-0.1,4.7,1.8,6.9,6.5,6.9c17.4,0,34.7,0,52.1,0c4.4,0,6.4-2,6.3-6.5C81.8,72.9,81.9,61.3,81.9,49.6z M53.1,67.5v5.8 c0,2-1.6,3.5-3.5,3.5S46,75.2,46,73.3v-5.8c-2.9-1.3-5-4.3-5-7.8c0-4.7,3.8-8.5,8.5-8.5c4.7,0,8.5,3.8,8.5,8.5 C58.1,63.2,56,66.2,53.1,67.5z M61.7,39.9C61.7,39.9,61.7,39.9,61.7,39.9c-8.1,0-16.1,0.1-24.2,0.1v-8.5c0.1-0.6,0.1-1.2,0.1-1.7 c-0.1-7.3,4-10.3,13-10.1c7.4,0.1,11.1,3.6,11.1,10.6C61.7,33.5,61.7,36.7,61.7,39.9z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default LockedIcon;
|