@arquimedes.co/eureka-forms 3.0.71-test → 3.0.72-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/README +33 -1
- package/dist/@Types/AvailabilityFormStep.d.ts +48 -0
- package/dist/@Types/AvailabilityFormStep.js +24 -0
- package/dist/@Types/BankAccountFormStep.d.ts +67 -0
- package/dist/@Types/BankAccountFormStep.js +14 -0
- package/dist/@Types/BookingFormStep.d.ts +249 -0
- package/dist/@Types/BookingFormStep.js +65 -0
- package/dist/@Types/CalendarFormStep.d.ts +209 -0
- package/dist/@Types/CalendarFormStep.js +55 -0
- package/dist/@Types/CommunicationChannelFormStep.d.ts +51 -0
- package/dist/@Types/CommunicationChannelFormStep.js +15 -0
- package/dist/@Types/ConsentFormStep.d.ts +36 -0
- package/dist/@Types/ConsentFormStep.js +8 -0
- package/dist/@Types/EntityFormFormStep.d.ts +66 -0
- package/dist/@Types/EntityFormFormStep.js +20 -0
- package/dist/@Types/EventFormStep.d.ts +52 -0
- package/dist/@Types/EventFormStep.js +13 -0
- package/dist/@Types/ExternalReferenceFormStep.d.ts +74 -0
- package/dist/@Types/ExternalReferenceFormStep.js +20 -0
- package/dist/@Types/FormStep.d.ts +7 -2
- package/dist/@Types/FormStep.js +2 -1
- package/dist/@Types/LocationFormStep.d.ts +159 -0
- package/dist/@Types/LocationFormStep.js +46 -0
- package/dist/@Types/NumericFormSteps.d.ts +108 -0
- package/dist/@Types/NumericFormSteps.js +20 -0
- package/dist/@Types/PredefinedSelectorFormStep.d.ts +51 -0
- package/dist/@Types/PredefinedSelectorFormStep.js +39 -0
- package/dist/@Types/StepRef.d.ts +135 -0
- package/dist/@Types/StepRef.js +49 -0
- package/dist/App/App.stories.d.ts +10 -0
- package/dist/App/App.stories.js +189 -0
- package/dist/App/App.submitError.test.d.ts +1 -0
- package/dist/App/App.submitError.test.js +53 -0
- package/dist/App/AppHooks.js +8 -0
- package/dist/App/AppHooks.test.js +8 -0
- package/dist/BookingManage/AppointmentText.d.ts +5 -0
- package/dist/BookingManage/AppointmentText.js +20 -0
- package/dist/BookingManage/BookingManagePage.d.ts +17 -0
- package/dist/BookingManage/BookingManagePage.js +177 -0
- package/dist/BookingManage/BookingManagePage.module.css +115 -0
- package/dist/BookingManage/BookingManagePage.test.d.ts +1 -0
- package/dist/BookingManage/BookingManagePage.test.js +149 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.d.ts +14 -5
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.js +8 -1
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.module.css +12 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.test.d.ts +1 -0
- package/dist/Form/ConfirmationDialog/ConfirmationDialog.test.js +21 -0
- package/dist/Form/Form.d.ts +3 -0
- package/dist/Form/Form.js +16 -8
- package/dist/Form/FormFunctions.d.ts +17 -0
- package/dist/Form/FormFunctions.js +22 -0
- package/dist/Form/FormFunctions.test.js +28 -1
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.d.ts +1 -1
- package/dist/Form/FormTypes/ColumnForm/ColumnForm.js +3 -2
- package/dist/Form/FormTypes/StepperForm/StepperForm.d.ts +1 -1
- package/dist/Form/FormTypes/StepperForm/StepperForm.js +3 -2
- package/dist/Form/SubmitError/SubmitError.d.ts +11 -0
- package/dist/Form/SubmitError/SubmitError.js +9 -0
- package/dist/Form/SubmitError/SubmitError.module.css +25 -0
- package/dist/Form/SubmitError/SubmitError.test.d.ts +1 -0
- package/dist/Form/SubmitError/SubmitError.test.js +34 -0
- package/dist/Form/SubmitError/SubmitErrorReason.d.ts +13 -0
- package/dist/Form/SubmitError/SubmitErrorReason.js +20 -0
- package/dist/FormSteps/AvailabilityStep/AvailabilityStep.d.ts +7 -0
- package/dist/FormSteps/AvailabilityStep/AvailabilityStep.js +14 -0
- package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.d.ts +8 -0
- package/dist/FormSteps/AvailabilityStep/MaterialAvailabilityStep/MaterialAvailabilityStep.js +32 -0
- package/dist/FormSteps/BookingStep/BookingStep.d.ts +17 -0
- package/dist/FormSteps/BookingStep/BookingStep.js +14 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.d.ts +21 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.js +289 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.test.d.ts +1 -0
- package/dist/FormSteps/BookingStep/MaterialBookingStep/MaterialBookingStep.test.js +275 -0
- package/dist/FormSteps/CheckBoxStep/CheckBoxStep.mobileLabel.test.js +20 -12
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.js +6 -13
- package/dist/FormSteps/CheckBoxStep/MaterialCheckBoxStep/MaterialCheckBoxStep.module.css +2 -13
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.d.ts +1 -0
- package/dist/FormSteps/ClassifierSelectorStep/ClassifierSelectorStep.lateClassifiers.test.js +70 -0
- package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +3 -1
- package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +26 -26
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.d.ts +12 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.js +35 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.d.ts +1 -0
- package/dist/FormSteps/EntityValueStep/entityValueDependencyValue.test.js +31 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.d.ts +27 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.js +64 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.d.ts +1 -0
- package/dist/FormSteps/EntityValueStep/entityValuePickerWatchedSteps.test.js +95 -0
- package/dist/FormSteps/LocationStep/LocationStep.d.ts +10 -0
- package/dist/FormSteps/LocationStep/LocationStep.js +14 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.d.ts +3 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.js +54 -0
- package/dist/FormSteps/LocationStep/MaterialLocationStep/MaterialLocationStep.module.css +18 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.d.ts +3 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.js +170 -0
- package/dist/FormSteps/NumberStep/MaterialNumberStep/MaterialNumberStep.module.css +96 -0
- package/dist/FormSteps/NumberStep/NumberStep.d.ts +10 -0
- package/dist/FormSteps/NumberStep/NumberStep.js +14 -0
- package/dist/FormSteps/Step.js +16 -0
- package/dist/FormSteps/StepFunctions.js +14 -0
- package/dist/FormSteps/StepFunctions.test.js +54 -0
- package/dist/FormSteps/StepHooks.d.ts +21 -0
- package/dist/FormSteps/StepHooks.js +55 -8
- package/dist/FormSteps/StepHooks.test.d.ts +1 -0
- package/dist/FormSteps/StepHooks.test.js +92 -0
- package/dist/FormSteps/isStepHiddenByCondition.test.d.ts +1 -0
- package/dist/FormSteps/isStepHiddenByCondition.test.js +42 -0
- package/dist/Icons/AddIcon.d.ts +3 -0
- package/dist/Icons/AddIcon.js +7 -0
- package/dist/Icons/EditIcon.d.ts +3 -0
- package/dist/Icons/EditIcon.js +7 -0
- package/dist/Icons/RemoveIcon.d.ts +3 -0
- package/dist/Icons/RemoveIcon.js +7 -0
- package/dist/Icons/ViewDayIcon.d.ts +3 -0
- package/dist/Icons/ViewDayIcon.js +7 -0
- package/dist/Icons/ViewWeekIcon.d.ts +3 -0
- package/dist/Icons/ViewWeekIcon.js +7 -0
- package/dist/Services/BookingService.d.ts +226 -0
- package/dist/Services/BookingService.js +264 -0
- package/dist/Services/BookingService.test.d.ts +1 -0
- package/dist/Services/BookingService.test.js +178 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.d.ts +19 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.js +80 -0
- package/dist/Shared/ErkAddressAutocomplete/ErkAddressAutocomplete.module.css +88 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.d.ts +29 -0
- package/dist/Shared/ErkAddressAutocomplete/googlePlaces.js +139 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.d.ts +25 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.js +112 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.module.css +88 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.d.ts +1 -0
- package/dist/Shared/ErkAvailabilityPicker/ErkAvailabilityPicker.test.js +73 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.d.ts +105 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.js +399 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.module.css +646 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.d.ts +36 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.js +177 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.d.ts +1 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.stories.test.js +47 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.d.ts +1 -0
- package/dist/Shared/ErkBookingPicker/ErkBookingPicker.test.js +440 -0
- package/dist/Shared/ErkDatePicker/ErkDatePicker.js +1 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.d.ts +2 -3
- package/dist/Shared/ErkDateRangePicker/ErkDateRangePicker.js +1 -2
- package/dist/Shared/ErkIconButton/ErkIconButton.d.ts +17 -0
- package/dist/Shared/ErkIconButton/ErkIconButton.js +11 -0
- package/dist/Shared/ErkIconButton/ErkIconButton.module.css +41 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.d.ts +24 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.js +128 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.module.css +164 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.test.d.ts +1 -0
- package/dist/Shared/ErkLocationField/ErkLocationField.test.js +82 -0
- package/dist/Shared/ErkLocationField/addressFields.d.ts +12 -0
- package/dist/Shared/ErkLocationField/addressFields.js +34 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.d.ts +6 -0
- package/dist/Shared/ErkLocationField/locationRestrictions.js +51 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.d.ts +15 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.js +502 -0
- package/dist/Shared/ErkLocationInput/ErkLocationInput.module.css +128 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.d.ts +42 -0
- package/dist/Shared/ErkNumberField/ErkNumberField.js +169 -0
- package/dist/Utils/AxiosWidget.js +9 -1
- package/dist/constants/FormStepTypes.d.ts +5 -1
- package/dist/constants/FormStepTypes.js +4 -0
- package/dist/index.lib.d.ts +4 -2
- package/dist/index.lib.js +3 -1
- package/dist/main.js +4 -1
- package/package.json +2 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import FormStepTypes, { EntityValueDataTypes } from '../constants/FormStepTypes';
|
|
3
|
+
import { calcDeepDependencies } from './StepHooks';
|
|
4
|
+
const form = (steps) => ({
|
|
5
|
+
steps: Object.entries(steps).reduce((acc, [id, step]) => ({
|
|
6
|
+
...acc,
|
|
7
|
+
[id]: { id, idSection: 'section', type: FormStepTypes.TEXTINPUT, ...step },
|
|
8
|
+
}), {}),
|
|
9
|
+
});
|
|
10
|
+
const picker = (step) => ({
|
|
11
|
+
type: FormStepTypes.ENTITYVALUEPICKER,
|
|
12
|
+
idEntity: 'entity',
|
|
13
|
+
path: [],
|
|
14
|
+
filters: [],
|
|
15
|
+
options: {},
|
|
16
|
+
...step,
|
|
17
|
+
});
|
|
18
|
+
const stepFilter = (idStep, required) => ({
|
|
19
|
+
idProperty: 'prop-' + idStep,
|
|
20
|
+
type: EntityValueDataTypes.STEP,
|
|
21
|
+
idStep,
|
|
22
|
+
any: false,
|
|
23
|
+
required,
|
|
24
|
+
});
|
|
25
|
+
describe('calcDeepDependencies', () => {
|
|
26
|
+
test('walks a linear chain deepest first, listing each id once', () => {
|
|
27
|
+
const deps = calcDeepDependencies('a', form({
|
|
28
|
+
a: { dependencies: ['b'] },
|
|
29
|
+
b: { dependencies: ['c'] },
|
|
30
|
+
c: {},
|
|
31
|
+
}));
|
|
32
|
+
expect(deps).toEqual(['c', 'b']);
|
|
33
|
+
});
|
|
34
|
+
test('lists a dependency shared by two branches once', () => {
|
|
35
|
+
const deps = calcDeepDependencies('a', form({
|
|
36
|
+
a: { dependencies: ['b', 'c'] },
|
|
37
|
+
b: { dependencies: ['d'] },
|
|
38
|
+
c: { dependencies: ['d'] },
|
|
39
|
+
d: {},
|
|
40
|
+
}));
|
|
41
|
+
expect(deps).toEqual(['d', 'b', 'c']);
|
|
42
|
+
});
|
|
43
|
+
test('terminates on an A -> B -> A cycle without listing the step itself', () => {
|
|
44
|
+
const deps = calcDeepDependencies('a', form({
|
|
45
|
+
a: { dependencies: ['b'] },
|
|
46
|
+
b: { dependencies: ['a'] },
|
|
47
|
+
}));
|
|
48
|
+
expect(deps).toEqual(['b']);
|
|
49
|
+
});
|
|
50
|
+
test('terminates on a cycle reached deeper in the walk', () => {
|
|
51
|
+
const deps = calcDeepDependencies('a', form({
|
|
52
|
+
a: { dependencies: ['b'] },
|
|
53
|
+
b: { dependencies: ['c'] },
|
|
54
|
+
c: { dependencies: ['b'] },
|
|
55
|
+
}));
|
|
56
|
+
expect(deps).toEqual(['c', 'b']);
|
|
57
|
+
});
|
|
58
|
+
test('terminates on a step that depends on itself', () => {
|
|
59
|
+
const deps = calcDeepDependencies('a', form({
|
|
60
|
+
a: { dependencies: ['b'] },
|
|
61
|
+
b: { dependencies: ['b'] },
|
|
62
|
+
}));
|
|
63
|
+
expect(deps).toEqual(['b']);
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* A draft an entity picker points back at itself with a required STEP filter: the filter is not
|
|
67
|
+
* in the saved `dependencies` yet, so it only reaches the walk through
|
|
68
|
+
* `entityValuePickerBlockingSteps`.
|
|
69
|
+
*/
|
|
70
|
+
test('terminates on a self reference through a required STEP filter of an entity picker', () => {
|
|
71
|
+
const deps = calcDeepDependencies('a', form({
|
|
72
|
+
a: { dependencies: ['picker'] },
|
|
73
|
+
picker: picker({ filters: [stepFilter('picker', true)] }),
|
|
74
|
+
}));
|
|
75
|
+
expect(deps).toEqual(['picker']);
|
|
76
|
+
});
|
|
77
|
+
test('terminates on a cycle closed by a required STEP filter of an entity picker', () => {
|
|
78
|
+
const deps = calcDeepDependencies('a', form({
|
|
79
|
+
a: { dependencies: ['picker'] },
|
|
80
|
+
picker: picker({ filters: [stepFilter('other', true)] }),
|
|
81
|
+
other: { dependencies: ['picker'] },
|
|
82
|
+
}));
|
|
83
|
+
expect(deps).toEqual(['other', 'picker']);
|
|
84
|
+
});
|
|
85
|
+
test('keeps a dependency whose step the draft has already deleted', () => {
|
|
86
|
+
const deps = calcDeepDependencies('a', form({ a: { dependencies: ['gone'] } }));
|
|
87
|
+
expect(deps).toEqual(['gone']);
|
|
88
|
+
});
|
|
89
|
+
test('answers nothing for a step the form does not hold', () => {
|
|
90
|
+
expect(calcDeepDependencies('missing', form({}))).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { isStepHiddenByCondition } from './StepHooks';
|
|
3
|
+
// A Selector shown only while the Proyecto picker holds a specific value — the shape the editor saves.
|
|
4
|
+
const PROYECTO = 'ENTITYVALUEPICKER-proyecto';
|
|
5
|
+
const condition = {
|
|
6
|
+
type: 'EXPRESSION',
|
|
7
|
+
expression: 'AND',
|
|
8
|
+
conditions: [
|
|
9
|
+
{ type: 'FORM_STEP', stepType: 'ENTITYVALUEPICKER', idStep: PROYECTO, operator: 'EXISTS' },
|
|
10
|
+
{ type: 'FORM_STEP', stepType: 'ENTITYVALUEPICKER', idStep: PROYECTO, operator: 'EQUAL', values: ['kai'] },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
const form = {
|
|
14
|
+
steps: {
|
|
15
|
+
[PROYECTO]: { id: PROYECTO, type: 'ENTITYVALUEPICKER' },
|
|
16
|
+
'SELECTOR-piso': { id: 'SELECTOR-piso', type: 'SELECTOR', condition },
|
|
17
|
+
'SELECTOR-libre': { id: 'SELECTOR-libre', type: 'SELECTOR' },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const dependency = (value) => ({
|
|
21
|
+
idOriginal: PROYECTO,
|
|
22
|
+
dependents: [],
|
|
23
|
+
value,
|
|
24
|
+
type: 'ENTITYVALUEPICKER',
|
|
25
|
+
});
|
|
26
|
+
describe('isStepHiddenByCondition', () => {
|
|
27
|
+
test('a step without condition is never hidden', () => {
|
|
28
|
+
expect(isStepHiddenByCondition('SELECTOR-libre', form, {})).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
test('a step whose condition evaluates false is hidden', () => {
|
|
31
|
+
expect(isStepHiddenByCondition('SELECTOR-piso', form, { [PROYECTO]: dependency({ _id: 'otro' }) })).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
test('a step whose condition evaluates true is shown', () => {
|
|
34
|
+
expect(isStepHiddenByCondition('SELECTOR-piso', form, { [PROYECTO]: dependency({ _id: 'kai' }) })).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
test('an undecidable condition (its step is not in the store) counts as shown', () => {
|
|
37
|
+
expect(isStepHiddenByCondition('SELECTOR-piso', form, {})).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
test('a step unknown to the form counts as shown', () => {
|
|
40
|
+
expect(isStepHiddenByCondition('MAPPER-x-espacio', form, {})).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function AddIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default AddIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function EditIcon(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: "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default EditIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function RemoveIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M19 13H5v-2h14v2z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default RemoveIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function ViewDayIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M2 21h19v-2H2v2zm0-4h19v-8H2v8zm0-10h19V5H2v2z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default ViewDayIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useIconProps } from './@ErkIcon';
|
|
3
|
+
function ViewWeekIcon(props) {
|
|
4
|
+
const iconProps = useIconProps(props);
|
|
5
|
+
return (_jsx("svg", { ...iconProps, viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M6 5H3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm14 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1zm-7 0h-3c-.55 0-1 .45-1 1v12c0 .55.45 1 1 1h3c.55 0 1-.45 1-1V6c0-.55-.45-1-1-1z" }) }));
|
|
6
|
+
}
|
|
7
|
+
export default ViewWeekIcon;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { BookingSlot, BookingValue } from '../@Types/BookingFormStep';
|
|
2
|
+
/**
|
|
3
|
+
* Cómo llegar al paso BOOKING de un formulario publicado. Misma regla que el envío del formulario:
|
|
4
|
+
* un form embebido o interno nombra su organización y sale por el dominio de forms; uno servido por
|
|
5
|
+
* el subdominio de la organización habla con `/api` en el mismo origen.
|
|
6
|
+
*/
|
|
7
|
+
export interface BookingRoute {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
idStep: string;
|
|
10
|
+
idOrganization?: string;
|
|
11
|
+
internal?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Una persona agendable tal como la publica el backend: un handle opaco, nunca un id de agente. */
|
|
14
|
+
export interface BookingOfferPerson {
|
|
15
|
+
token: string;
|
|
16
|
+
name: string;
|
|
17
|
+
role?: string;
|
|
18
|
+
avatarUrl?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
}
|
|
21
|
+
/** An event template of the step as the offer publishes it: a signed handle, never the template's id. */
|
|
22
|
+
export interface BookingOfferEventTemplate {
|
|
23
|
+
token: string;
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
/** The template's own duration, or the step's when the template has none. */
|
|
27
|
+
durationMinutes: number;
|
|
28
|
+
bookingMode?: string;
|
|
29
|
+
}
|
|
30
|
+
/** The event template an appointment was booked with: what the summary and the manage page show. */
|
|
31
|
+
export interface BookingEventTemplateSummary {
|
|
32
|
+
name: string;
|
|
33
|
+
durationMinutes: number;
|
|
34
|
+
}
|
|
35
|
+
/** Lo que el picker necesita para dibujarse: en qué zona horaria leer las horas y qué días tienen cupo. */
|
|
36
|
+
export interface BookingOffer {
|
|
37
|
+
timeZone: string;
|
|
38
|
+
durationMinutes: number;
|
|
39
|
+
bookingMode: string;
|
|
40
|
+
personSelection: 'NONE' | 'OPTIONAL' | 'REQUIRED';
|
|
41
|
+
persons?: BookingOfferPerson[];
|
|
42
|
+
/** Días con al menos un slot, `YYYY-MM-DD` en la zona horaria de la organización. */
|
|
43
|
+
days: string[];
|
|
44
|
+
from: string;
|
|
45
|
+
to: string;
|
|
46
|
+
/** The step's event templates with something on offer; empty when the step has none. */
|
|
47
|
+
eventTemplates?: BookingOfferEventTemplate[];
|
|
48
|
+
/** The requester picks an event template first: the step lets them and there are two or more. */
|
|
49
|
+
requesterPicksType?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** What narrows a read of the offer: one person's calendar, one event template's slots and duration. */
|
|
52
|
+
export interface BookingOfferQuery {
|
|
53
|
+
person?: string;
|
|
54
|
+
eventTemplate?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Un slot tal como lo ofrece el backend: instantes ISO y el handle firmado que lo nombra. */
|
|
57
|
+
export interface BookingOfferSlot {
|
|
58
|
+
start: string;
|
|
59
|
+
end: string;
|
|
60
|
+
token: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Un slot retirado de la oferta mientras se termina el formulario. `start`/`end` son los instantes
|
|
64
|
+
* reales reservados y `person` es quien atenderá (el servidor la elige cuando hay varias libres).
|
|
65
|
+
*/
|
|
66
|
+
export interface BookingHold {
|
|
67
|
+
appointment: string;
|
|
68
|
+
/** Secreto del dueño de la reserva: viaja con el envío del formulario. */
|
|
69
|
+
hold: string;
|
|
70
|
+
lockedUntil: string;
|
|
71
|
+
/** Token para la próxima renovación; vive hasta `lockedUntil` y cada renovación devuelve uno nuevo. */
|
|
72
|
+
renew: string;
|
|
73
|
+
start: string;
|
|
74
|
+
end: string;
|
|
75
|
+
/** Falta solo si el agente dejó la organización. */
|
|
76
|
+
person?: BookingOfferPerson;
|
|
77
|
+
/** The event template the hold was made with, when the requester picked one. */
|
|
78
|
+
eventTemplate?: BookingEventTemplateSummary;
|
|
79
|
+
}
|
|
80
|
+
export interface BookingContact {
|
|
81
|
+
name: string;
|
|
82
|
+
email: string;
|
|
83
|
+
phone?: string;
|
|
84
|
+
}
|
|
85
|
+
/** Los códigos con los que el borde de agendamiento explica un rechazo. */
|
|
86
|
+
export declare enum BookingErrorCodes {
|
|
87
|
+
INVALID_REQUEST = "INVALID_REQUEST",
|
|
88
|
+
NOT_FOUND = "NOT_FOUND",
|
|
89
|
+
FORBIDDEN = "FORBIDDEN",
|
|
90
|
+
/** Un token de persona o de cupo venció: hay que recargar la oferta (o las horas). */
|
|
91
|
+
STALE_OFFER = "STALE_OFFER",
|
|
92
|
+
CONTACT_REQUIRED = "CONTACT_REQUIRED",
|
|
93
|
+
SLOT_TAKEN = "SLOT_TAKEN",
|
|
94
|
+
/** La renovación llegó tarde: la reserva ya venció. */
|
|
95
|
+
HOLD_EXPIRED = "HOLD_EXPIRED",
|
|
96
|
+
/** El enlace de la cita venció, fue alterado o ya no nombra ninguna cita. */
|
|
97
|
+
INVALID_LINK = "INVALID_LINK",
|
|
98
|
+
/** La cita ya no se puede cancelar ni mover: está cancelada o su paso ya no existe. */
|
|
99
|
+
APPOINTMENT_CLOSED = "APPOINTMENT_CLOSED",
|
|
100
|
+
RATE_LIMITED = "RATE_LIMITED",
|
|
101
|
+
METHOD_NOT_ALLOWED = "METHOD_NOT_ALLOWED",
|
|
102
|
+
INTERNAL = "INTERNAL"
|
|
103
|
+
}
|
|
104
|
+
/** Un rechazo del borde ya leído: el mensaje es apto para mostrarse a quien agenda. */
|
|
105
|
+
export declare class BookingEdgeError extends Error {
|
|
106
|
+
readonly code?: string;
|
|
107
|
+
readonly status?: number;
|
|
108
|
+
constructor(message: string, code?: string, status?: number);
|
|
109
|
+
}
|
|
110
|
+
/** El texto que muestra el picker cuando la renovación de la reserva falla para siempre. */
|
|
111
|
+
export declare const HOLD_LAPSED_MESSAGE = "Tu reserva venci\u00F3; elige la hora de nuevo.";
|
|
112
|
+
/**
|
|
113
|
+
* Una cita ya agendada, vista desde el enlace de sus correos: cuándo, con quién y cómo, y lo que quien
|
|
114
|
+
* la agendó todavía puede hacer con ella.
|
|
115
|
+
*/
|
|
116
|
+
export interface BookingAppointment {
|
|
117
|
+
/** El handle del enlace para esta cita; cambia cuando la cita se mueve, y el siguiente pedido usa este. */
|
|
118
|
+
token: string;
|
|
119
|
+
status: 'CONFIRMED' | 'CANCELLED';
|
|
120
|
+
start: string;
|
|
121
|
+
end: string;
|
|
122
|
+
/** La zona horaria de la organización, en la que se muestran `start` y `end`. */
|
|
123
|
+
timeZone: string;
|
|
124
|
+
person?: Omit<BookingOfferPerson, 'token'>;
|
|
125
|
+
bookingMode?: string;
|
|
126
|
+
eventTemplateName?: string;
|
|
127
|
+
eventTemplate?: BookingEventTemplateSummary;
|
|
128
|
+
joinUrl?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Cómo ofrecer otra hora con la misma persona; falta cuando la cita ya no se puede mover desde aquí.
|
|
131
|
+
* `eventTemplate` is the handle of the appointment's template, so the new hour keeps its type.
|
|
132
|
+
*/
|
|
133
|
+
reschedule?: {
|
|
134
|
+
apiKey: string;
|
|
135
|
+
idStep: string;
|
|
136
|
+
person: string;
|
|
137
|
+
durationMinutes: number;
|
|
138
|
+
eventTemplate?: string;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** La cita que nombra el enlace. Un enlace vencido o alterado responde 404 `INVALID_LINK`. */
|
|
142
|
+
export declare function fetchBookingAppointment(token: string, idOrganization?: string): Promise<BookingAppointment>;
|
|
143
|
+
/** Cancela la cita; responde la cita ya cancelada. Una cita que ya no está vigente responde 409 `APPOINTMENT_CLOSED`. */
|
|
144
|
+
export declare function cancelBookingAppointment(token: string, idOrganization?: string): Promise<BookingAppointment>;
|
|
145
|
+
/**
|
|
146
|
+
* Mueve la cita al cupo `slot` (un handle de la oferta del mismo paso y la misma persona). Responde la
|
|
147
|
+
* cita movida con su handle nuevo; 409 `SLOT_TAKEN` si alguien tomó la hora primero.
|
|
148
|
+
*/
|
|
149
|
+
export declare function moveBookingAppointment(token: string, slot: string, idOrganization?: string): Promise<BookingAppointment>;
|
|
150
|
+
/**
|
|
151
|
+
* La oferta del paso; con `person`, la oferta de esa persona (los días que ella tiene libres), y con
|
|
152
|
+
* `eventTemplate`, los días de ese tipo de atención con su duración.
|
|
153
|
+
*/
|
|
154
|
+
export declare function fetchBookingOffer(route: BookingRoute, query?: BookingOfferQuery): Promise<BookingOffer>;
|
|
155
|
+
/** Los slots de un día, `date` en `YYYY-MM-DD` de la zona horaria de la organización. */
|
|
156
|
+
export declare function fetchBookingSlots(route: BookingRoute, date: string, query?: BookingOfferQuery): Promise<BookingOfferSlot[]>;
|
|
157
|
+
/**
|
|
158
|
+
* Bloquea un slot a nombre de quien agenda. El borde responde 409 `SLOT_TAKEN` cuando nadie quedó
|
|
159
|
+
* libre a esa hora y 422 `CONTACT_REQUIRED` sin nombre o sin correo válido. `eventTemplate` is the
|
|
160
|
+
* handle of the type the requester picked; the appointment takes that type's duration.
|
|
161
|
+
*/
|
|
162
|
+
export declare function holdBookingSlot(route: BookingRoute, body: {
|
|
163
|
+
slot: string;
|
|
164
|
+
contact: BookingContact;
|
|
165
|
+
eventTemplate?: string;
|
|
166
|
+
}): Promise<BookingHold>;
|
|
167
|
+
/**
|
|
168
|
+
* Extiende una reserva propia con el `renew` de la última respuesta. No depende del token del cupo,
|
|
169
|
+
* así que una reserva renovada a tiempo vive lo que tarde el formulario. Una reserva ya vencida
|
|
170
|
+
* responde 409 `HOLD_EXPIRED`.
|
|
171
|
+
*/
|
|
172
|
+
export declare function renewBookingHold(route: BookingRoute, body: {
|
|
173
|
+
renew: string;
|
|
174
|
+
hold: string;
|
|
175
|
+
}): Promise<BookingHold>;
|
|
176
|
+
/** Devuelve un slot antes de que venza su bloqueo, para que se ofrezca de nuevo de inmediato. */
|
|
177
|
+
export declare function releaseBookingSlot(route: BookingRoute, body: {
|
|
178
|
+
appointment: string;
|
|
179
|
+
hold: string;
|
|
180
|
+
}): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* La hora `HH:mm` de un instante en la zona horaria de la organización. El picker muestra el reloj de
|
|
183
|
+
* quien recibe la cita, no el del navegador: un slot de las 09:00 en Bogotá es a las 09:00 aunque el
|
|
184
|
+
* que agenda esté en Madrid.
|
|
185
|
+
*/
|
|
186
|
+
export declare function clockIn(iso: string, timeZone: string): string;
|
|
187
|
+
/** El día `YYYY-MM-DD` de un instante en una zona horaria. */
|
|
188
|
+
export declare function dayIn(iso: string, timeZone: string): string;
|
|
189
|
+
/** La zona horaria del navegador, o `undefined` si no se puede leer. */
|
|
190
|
+
export declare function browserTimeZone(): string | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Cómo se nombra la zona de la organización junto a las horas: "hora de Bogotá (GMT-5)". El desfase
|
|
193
|
+
* se calcula en `at`, porque en las zonas con horario de verano cambia según el día.
|
|
194
|
+
*/
|
|
195
|
+
export declare function zoneLabel(timeZone: string, at?: Date): string;
|
|
196
|
+
/** Un slot de la oferta como lo consume el picker: el handle es su id y las horas van en el reloj de la organización. */
|
|
197
|
+
export declare function toPickerSlot(slot: BookingOfferSlot, timeZone: string): BookingSlot;
|
|
198
|
+
/**
|
|
199
|
+
* Las horas de un día como las muestra el picker: una por instante y en orden. El borde ya agrupa por
|
|
200
|
+
* instante; si llegara un instante repetido, gana el primero y el servidor elige a la persona al reservar.
|
|
201
|
+
*/
|
|
202
|
+
export declare function toPickerSlots(slots: BookingOfferSlot[], timeZone: string): BookingSlot[];
|
|
203
|
+
/**
|
|
204
|
+
* Lo que la reserva aporta al valor del paso: día y horas reales en el reloj de la organización, la
|
|
205
|
+
* persona asignada y el tipo de atención elegido.
|
|
206
|
+
*/
|
|
207
|
+
export declare function holdToValue(held: BookingHold, timeZone: string): Pick<BookingValue, 'appointment' | 'hold' | 'lockedUntil' | 'date' | 'startTime' | 'endTime'> & Partial<Pick<BookingValue, 'personId' | 'personName' | 'eventTemplate'>>;
|
|
208
|
+
/** Un texto opcional de un campo de contacto: vacío o solo espacios cuenta como no dado. */
|
|
209
|
+
export declare function nonEmpty(text?: string): string | undefined;
|
|
210
|
+
/** Si un texto es un correo con forma válida (lo mismo que exige el borde al reservar). */
|
|
211
|
+
export declare function isValidEmail(text?: string): boolean;
|
|
212
|
+
/** El código HTTP de un error del cliente HTTP, si lo hay. */
|
|
213
|
+
export declare function statusOf(error: unknown): number | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Lee un rechazo del borde. El borde responde `{ code, message }` con el mensaje en español; los
|
|
216
|
+
* errores que el gateway responde antes de la lambda siguen llegando como texto plano.
|
|
217
|
+
*/
|
|
218
|
+
export declare function toBookingError(error: unknown, fallback?: string): BookingEdgeError;
|
|
219
|
+
/** El motivo de un rechazo del borde, o un mensaje genérico. */
|
|
220
|
+
export declare function bookingErrorMessage(error: unknown, fallback?: string): string;
|
|
221
|
+
/**
|
|
222
|
+
* Si una renovación fallida significa que la reserva ya no existe: el borde lo dice (`HOLD_EXPIRED`,
|
|
223
|
+
* o el token venció), o el plazo pasó sin una renovación que llegara. Un corte de red o un 429 antes
|
|
224
|
+
* del plazo se reintenta en la siguiente vuelta.
|
|
225
|
+
*/
|
|
226
|
+
export declare function holdLapsed(error: BookingEdgeError, lockedUntil: string | undefined, now?: number): boolean;
|