@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
@@ -24,10 +24,6 @@ import CustomContext from '../Contexts/CustomContext';
24
24
  import { selectOriginalValue, useCondition } from './StepHooks';
25
25
  import TimePickerStep from './TimePickerStep/TimePickerStep';
26
26
  import PhoneInputStep from './PhoneInputStep/PhoneInputStep';
27
- import LocationStepComponent from './LocationStep/LocationStep';
28
- import NumberStepComponent from './NumberStep/NumberStep';
29
- import BookingStepComponent from './BookingStep/BookingStep';
30
- import CalendarStepComponent from './CalendarStep/CalendarStep';
31
27
  function StepComponent({ step, ...props }) {
32
28
  const { postview, partial } = useAppSelector((state) => state.global);
33
29
  const { customSteps, customClientInfoStep } = useContext(CustomContext);
@@ -78,18 +74,6 @@ function StepComponent({ step, ...props }) {
78
74
  case FormStepTypes.DATEPICKER: {
79
75
  return _jsx(DatePickerStep, { ...props, step: step, editable: editable });
80
76
  }
81
- case FormStepTypes.LOCATION: {
82
- return _jsx(LocationStepComponent, { ...props, step: step, editable: editable });
83
- }
84
- case FormStepTypes.NUMBER: {
85
- return _jsx(NumberStepComponent, { ...props, step: step, editable: editable });
86
- }
87
- case FormStepTypes.BOOKING: {
88
- return _jsx(BookingStepComponent, { ...props, step: step, editable: editable });
89
- }
90
- case FormStepTypes.CALENDAR: {
91
- return _jsx(CalendarStepComponent, { ...props, step: step, editable: editable });
92
- }
93
77
  case FormStepTypes.DATEPICKER_RANGE: {
94
78
  return _jsx(DatePickerRangeStep, { ...props, step: step, editable: editable });
95
79
  }
@@ -1,4 +1,3 @@
1
- import { NumberStepType, } from '../@Types/FormStep';
2
1
  import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueDataTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
3
2
  import CBRFormStepTypes from '../constants/CBRFormStepTypes';
4
3
  import AYFFormStepTypes from '../constants/AYFFormStepTypes';
@@ -88,8 +87,6 @@ function recursivelyCheckOpenSize(idStep, steps, values) {
88
87
  return size;
89
88
  }
90
89
  case FormStepTypes.DATEPICKER:
91
- case FormStepTypes.LOCATION:
92
- case FormStepTypes.NUMBER:
93
90
  case FormStepTypes.TEXTINPUT: {
94
91
  return step.size;
95
92
  }
@@ -120,17 +117,6 @@ export const calcDefaultValue = (step) => {
120
117
  return getRawText();
121
118
  else
122
119
  return '';
123
- case FormStepTypes.LOCATION:
124
- return step.defaultValue ?? null;
125
- case FormStepTypes.NUMBER: {
126
- const numStep = step;
127
- if (numStep.numberType === NumberStepType.MONEY ||
128
- numStep.numberType === NumberStepType.MEASURE ||
129
- numStep.numberType === NumberStepType.UNIT_PRICE) {
130
- return numStep.defaultValue ?? null;
131
- }
132
- return numStep.defaultValue ?? '';
133
- }
134
120
  case FormStepTypes.RATING:
135
121
  case FormStepTypes.DATEPICKER:
136
122
  case FormStepTypes.DATEPICKER_RANGE:
@@ -149,7 +135,7 @@ export const calcDefaultValue = (step) => {
149
135
  return undefined;
150
136
  }
151
137
  };
152
- export const iterateNestedSteps = (idStep, steps, iteration, path = [idStep]) => {
138
+ export const iterateNestedSteps = (idStep, steps, iteration, path = []) => {
153
139
  const step = steps[idStep];
154
140
  if (!step) {
155
141
  console.error('Missing Step:', idStep);
@@ -158,15 +144,12 @@ export const iterateNestedSteps = (idStep, steps, iteration, path = [idStep]) =>
158
144
  iteration(step, path);
159
145
  if (step.type === FormStepTypes.MAPPER) {
160
146
  for (const idStep of step.rootSteps) {
161
- iterateNestedSteps(idStep, step.steps, iteration, [
162
- ...path,
163
- step.id,
164
- ]);
147
+ iterateNestedSteps(idStep, step.steps, iteration, [...path, step.id]);
165
148
  }
166
149
  }
167
150
  else {
168
151
  for (const idSubStep of calcSubSteps(step.id, steps)) {
169
- iterateNestedSteps(idSubStep, steps, iteration, [...path, step.id]);
152
+ iterateNestedSteps(idSubStep, steps, iteration, path);
170
153
  }
171
154
  }
172
155
  };
@@ -537,13 +520,13 @@ const evaluateEntityPropertyCondition = (condition, entity, entityValue) => {
537
520
  case OperatorTypes.PAST_RELATIVE_MORE:
538
521
  case OperatorTypes.FUTURE_RELATIVE_LESS:
539
522
  case OperatorTypes.FUTURE_RELATIVE_MORE: {
540
- 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 ||
541
524
  condition.propertyOperator === OperatorTypes.PAST_RELATIVE_MORE);
542
525
  if (condition.propertyOperator === OperatorTypes.PAST_RELATIVE_LESS ||
543
526
  condition.propertyOperator === OperatorTypes.FUTURE_RELATIVE_LESS)
544
- return new Date().getTime() > date.getTime();
527
+ return new Date(value).getTime() < date.getTime();
545
528
  else
546
- return new Date().getTime() < date.getTime();
529
+ return new Date(value).getTime() > date.getTime();
547
530
  }
548
531
  }
549
532
  return false;
@@ -1,4 +1,3 @@
1
- import * as Steps from '../@Types/FormStep';
2
1
  import AYFFormStepTypes from '../constants/AYFFormStepTypes';
3
2
  import CBRFormStepTypes from '../constants/CBRFormStepTypes';
4
3
  import FormStepTypes, { ApiSelectorOptionTypes, ClassifierOptionTypes, EntityValueOptionTypes, OptionTypes, } from '../constants/FormStepTypes';
@@ -497,13 +496,6 @@ describe('StepFunctions', function () {
497
496
  const defaultValue = calcDefaultValue(step);
498
497
  expect(defaultValue).toBe(null);
499
498
  });
500
- test('Location step type', async () => {
501
- const step = {
502
- type: FormStepTypes.LOCATION,
503
- };
504
- const defaultValue = calcDefaultValue(step);
505
- expect(defaultValue).toBe(null);
506
- });
507
499
  test('Mapper, FileUpload, CBRFormStep types', async () => {
508
500
  const step1 = {
509
501
  type: FormStepTypes.MAPPER,
@@ -535,52 +527,6 @@ describe('StepFunctions', function () {
535
527
  const defaultValue = calcDefaultValue(step);
536
528
  expect(defaultValue).toBeUndefined();
537
529
  });
538
- test('Number step type without defaultValue', async () => {
539
- const step1 = {
540
- type: FormStepTypes.NUMBER,
541
- numberType: Steps.NumberStepType.INTEGER,
542
- };
543
- const step2 = {
544
- type: FormStepTypes.NUMBER,
545
- numberType: Steps.NumberStepType.DECIMAL,
546
- };
547
- const step3 = {
548
- type: FormStepTypes.NUMBER,
549
- numberType: Steps.NumberStepType.PERCENTAGE,
550
- };
551
- const step4 = {
552
- type: FormStepTypes.NUMBER,
553
- numberType: Steps.NumberStepType.MONEY,
554
- };
555
- const step5 = {
556
- type: FormStepTypes.NUMBER,
557
- numberType: Steps.NumberStepType.MEASURE,
558
- };
559
- const step6 = {
560
- type: FormStepTypes.NUMBER,
561
- numberType: Steps.NumberStepType.UNIT_PRICE,
562
- };
563
- expect(calcDefaultValue(step1)).toBe('');
564
- expect(calcDefaultValue(step2)).toBe('');
565
- expect(calcDefaultValue(step3)).toBe('');
566
- expect(calcDefaultValue(step4)).toBe(null);
567
- expect(calcDefaultValue(step5)).toBe(null);
568
- expect(calcDefaultValue(step6)).toBe(null);
569
- });
570
- test('Number step type with defaultValue', async () => {
571
- const step1 = {
572
- type: FormStepTypes.NUMBER,
573
- numberType: Steps.NumberStepType.INTEGER,
574
- defaultValue: 42,
575
- };
576
- const step2 = {
577
- type: FormStepTypes.NUMBER,
578
- numberType: Steps.NumberStepType.MONEY,
579
- defaultValue: { value: 100, currency: 'USD' },
580
- };
581
- expect(calcDefaultValue(step1)).toBe(42);
582
- expect(calcDefaultValue(step2)).toEqual({ value: 100, currency: 'USD' });
583
- });
584
530
  });
585
531
  describe('iterateNestedSteps', function () {
586
532
  test('should iterate over nested steps', async () => {
@@ -619,9 +565,9 @@ describe('StepFunctions', function () {
619
565
  const iterationMock = vi.fn();
620
566
  iterateNestedSteps('idStep1', steps, iterationMock);
621
567
  expect(iterationMock).toHaveBeenCalledTimes(3);
622
- expect(iterationMock).toHaveBeenCalledWith(steps.idStep1, ['idStep1']);
623
- expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep2, ['idStep1', 'idStep1']);
624
- expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep3, ['idStep1', 'idStep1', 'idStep2']);
568
+ expect(iterationMock).toHaveBeenCalledWith(steps.idStep1, []);
569
+ expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep2, ['idStep1']);
570
+ expect(iterationMock).toHaveBeenCalledWith(steps.idStep1.steps.idStep3, ['idStep1']);
625
571
  });
626
572
  });
627
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: `${step.stepPath.join('.')}.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: `${step.stepPath.join('.')}.description`, onChange: (description) => onChange({ ...value, description }) }) })] }));
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) {
@@ -9,6 +9,6 @@ export interface IconProps {
9
9
  preserveAspectRatio?: 'none';
10
10
  }
11
11
  export declare function useIconProps(props: IconProps): IconProps & {
12
- width?: number;
13
- height?: number;
12
+ width?: number | string;
13
+ height?: number | string;
14
14
  };
@@ -1,7 +1,7 @@
1
1
  export function useIconProps(props) {
2
2
  return {
3
- width: props.size,
4
- height: props.size,
3
+ width: props.size ?? '1em',
4
+ height: props.size ?? '1em',
5
5
  className: props.className ? props.className + ' ErkIcon' : 'ErkIcon',
6
6
  fill: 'currentColor',
7
7
  ...props,
@@ -0,0 +1,3 @@
1
+ import { IconProps } from './@ErkIcon';
2
+ declare function EmailIcon(props: IconProps): JSX.Element;
3
+ export default EmailIcon;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useIconProps } from './@ErkIcon';
3
- function EditIcon(props) {
3
+ function EmailIcon(props) {
4
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" }) }));
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
6
  }
7
- export default EditIcon;
7
+ export default EmailIcon;
@@ -0,0 +1,3 @@
1
+ import { IconProps } from '../@ErkIcon';
2
+ declare function SchoolIcon(props: IconProps): JSX.Element;
3
+ export default SchoolIcon;
@@ -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,3 @@
1
+ import { IconProps } from './@ErkIcon';
2
+ declare function GroupIcon(props: IconProps): JSX.Element;
3
+ export default GroupIcon;
@@ -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,3 @@
1
+ import { IconProps } from './@ErkIcon';
2
+ declare function LockedIcon(props: IconProps): JSX.Element;
3
+ export default LockedIcon;
@@ -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;
@@ -0,0 +1,135 @@
1
+ .rightPanel {
2
+ background-color: #3d5a7f;
3
+ display: flex;
4
+ border-radius: 0 20px 20px 0;
5
+ flex-grow: 0;
6
+ max-width: 41.666667%;
7
+ flex-basis: 41.666667%;
8
+ }
9
+ .rightPanelMessage {
10
+ margin: auto;
11
+ text-align: center;
12
+ padding: 0 30px 0 30px;
13
+ }
14
+ .rightPanelMessage h1 {
15
+ color: white;
16
+ font-size: 40px;
17
+ font-weight: 900;
18
+ }
19
+ .rightPanelMessage p {
20
+ color: white;
21
+ }
22
+ .leftPanel {
23
+ display: flex;
24
+ text-align: center;
25
+ flex-direction: column;
26
+ flex-grow: 1;
27
+ max-width: 100%;
28
+ min-height: fit-content;
29
+ flex-basis: 0;
30
+ position: relative;
31
+ justify-content: center;
32
+ }
33
+ .leftPanel h1 {
34
+ margin-left: auto;
35
+ margin-right: auto;
36
+ color: #3d5a7f;
37
+ font-size: 40px;
38
+ font-weight: 900;
39
+ margin-top: 40px;
40
+ padding-left: 20px;
41
+ padding-right: 20px;
42
+ margin-bottom: 40px;
43
+ }
44
+ .leftPanel a {
45
+ font-size: 22px;
46
+ cursor: pointer;
47
+ -moz-user-select: none;
48
+ -khtml-user-select: none;
49
+ -webkit-user-select: none;
50
+ -ms-user-select: none;
51
+ user-select: none;
52
+ padding-left: 20px;
53
+ padding-right: 20px;
54
+ margin: 0px auto 25px auto;
55
+ text-decoration: underline;
56
+ }
57
+ .loginButton {
58
+ background-color: #3d5a7f;
59
+ border-radius: 40px;
60
+ padding: 22px 50px;
61
+ margin: 0 auto 0 auto;
62
+ color: white;
63
+ font-weight: 800;
64
+ font-size: 22px;
65
+ cursor: pointer;
66
+ -moz-user-select: none;
67
+ -khtml-user-select: none;
68
+ -webkit-user-select: none;
69
+ -ms-user-select: none;
70
+ user-select: none;
71
+ width: fit-content;
72
+ max-width: calc(100% - 40px);
73
+ height: fit-content;
74
+ position: relative;
75
+ display: flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ }
79
+ .loginButton[disabled] {
80
+ pointer-events: none;
81
+ opacity: 0.5;
82
+ }
83
+ .loaderContainer {
84
+ position: absolute;
85
+ margin: auto;
86
+ height: 40px;
87
+ width: 40px;
88
+ }
89
+ .logo {
90
+ position: absolute;
91
+ display: flex;
92
+ flex-direction: row;
93
+ justify-content: center;
94
+ left: 40px;
95
+ top: 33px;
96
+ height: 65px;
97
+ margin-right: auto;
98
+ }
99
+ .loginInputsContainer {
100
+ width: 60%;
101
+ margin: 0 auto 0 auto;
102
+ }
103
+ .loginInput {
104
+ min-height: 80px;
105
+ }
106
+ @media screen and (max-width: 825px) {
107
+ .rightPanel {
108
+ display: none;
109
+ }
110
+ .loginInputsContainer {
111
+ width: 70%;
112
+ margin: 0 auto 0 auto;
113
+ }
114
+ .leftPanel h1 {
115
+ margin-top: 5%;
116
+ }
117
+ }
118
+
119
+ @media screen and (max-width: 678px) {
120
+ .logo {
121
+ display: none;
122
+ }
123
+ .loginInputsContainer {
124
+ width: 80%;
125
+ }
126
+ }
127
+
128
+ @media screen and (max-height: 720px) {
129
+ .logo {
130
+ display: none;
131
+ }
132
+ .loginButton {
133
+ margin-bottom: 40px;
134
+ }
135
+ }
@@ -0,0 +1,68 @@
1
+ .loginLayout {
2
+ height: 100vh;
3
+ display: flex;
4
+ width: 100vw;
5
+ overflow: hidden;
6
+ background-color: #f0f0f0;
7
+
8
+ position: relative;
9
+ }
10
+ .semiCircle {
11
+ margin-top: auto;
12
+ width: 30vmin;
13
+ height: 30vmin;
14
+ min-width: 100px;
15
+ min-height: 100px;
16
+ object-fit: contain;
17
+ background-color: #98c1d9;
18
+ border-top-left-radius: 0%;
19
+ border-top-right-radius: 100%;
20
+ border-bottom-left-radius: 0%;
21
+ border-bottom-right-radius: 0%;
22
+ }
23
+ .triangle {
24
+ width: 0;
25
+ height: 0;
26
+ border-bottom: 500px solid #ee6c4d;
27
+ border-left: 500px solid transparent;
28
+ margin-left: auto;
29
+ transform: translateY(-300px) translateX(150px) rotate(10deg);
30
+ }
31
+ .cardLayout {
32
+ height: 100%;
33
+ width: 100%;
34
+ display: flex;
35
+ position: absolute;
36
+ left: 0;
37
+ right: 0;
38
+ top: 0;
39
+ bottom: 0;
40
+ overflow: hidden;
41
+ overflow-y: auto;
42
+ }
43
+ .loginCard {
44
+ margin: 7.5vh auto;
45
+ z-index: 2;
46
+ width: 85vw;
47
+ background-color: white;
48
+ border-radius: 20px;
49
+ min-height: 85vh;
50
+ height: fit-content;
51
+ display: flex;
52
+ flex-direction: column;
53
+ }
54
+ .cardContainer {
55
+ display: flex;
56
+ flex-grow: 1;
57
+ flex-direction: row;
58
+ height: 100%;
59
+ }
60
+
61
+ @media screen and (max-width: 320px) {
62
+ .loginCard {
63
+ width: 100vw;
64
+ height: 100vh;
65
+ margin: 0px;
66
+ border-radius: 0px;
67
+ }
68
+ }
@@ -0,0 +1,10 @@
1
+ import { Form } from '../@Types';
2
+ interface LoginPageProps {
3
+ form: Form;
4
+ }
5
+ /**
6
+ * Displays the specific login component depending on the url
7
+ * @returns the respective component
8
+ */
9
+ declare function LoginPage({ form }: LoginPageProps): JSX.Element;
10
+ export default LoginPage;
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import layoutStyles from './LoginLayout.module.css';
4
+ import styles from './Login.module.css';
5
+ import Loader from '../Shared/Loader/Loader';
6
+ import { Controller, useForm } from 'react-hook-form';
7
+ import axiosInstance from '../Utils/AxiosAPI';
8
+ import { useAppDispatch, useAppSelector } from '../hooks';
9
+ import { login } from '../Services/UserService';
10
+ import { setUser } from '../States/GlobalSlice';
11
+ import { jwtDecode } from 'jwt-decode';
12
+ import LoginTextField from './LoginTextField';
13
+ import MaterialProviders from '../Utils/MaterialProviders';
14
+ const EMAIL_REGEX =
15
+ // eslint-disable-next-line no-control-regex
16
+ /^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
17
+ /**
18
+ * Displays the specific login component depending on the url
19
+ * @returns the respective component
20
+ */
21
+ function LoginPage({ form }) {
22
+ const dispatch = useAppDispatch();
23
+ const formStyle = useAppSelector((state) => state.global.formStyle);
24
+ /** If login has errors */
25
+ const [wrongLogin, setWrongLogin] = useState(false);
26
+ /** if waiting for response */
27
+ const [loading, setLoading] = useState(false);
28
+ const { getValues, clearErrors, formState: { errors }, setError, trigger, control, } = useForm({
29
+ mode: 'onTouched',
30
+ });
31
+ /**
32
+ * Handles login, redirects the user if the current subdomain is not valid
33
+ */
34
+ const handleLogin = async () => {
35
+ const isValid = await trigger();
36
+ const values = getValues();
37
+ const isInternal = ['andres'].includes(values.email);
38
+ if ((isValid || isInternal) && form.apiKey) {
39
+ try {
40
+ setLoading(true);
41
+ const payload = values;
42
+ if (isInternal) {
43
+ payload.email = values.email + '@capta.co';
44
+ }
45
+ const token = await login(form.apiKey, payload);
46
+ localStorage.setItem('token', token);
47
+ const user = jwtDecode(token);
48
+ axiosInstance.defaults.headers.Authorization = 'Bearer ' + token;
49
+ dispatch(setUser(user));
50
+ }
51
+ catch (err) {
52
+ setLoading(false);
53
+ if (err?.response?.status !== 400) {
54
+ console.error(err);
55
+ }
56
+ if (err?.response?.data === 'Invalid Organization') {
57
+ setError('password', {
58
+ type: 'pattern',
59
+ message: 'Organización inválida',
60
+ });
61
+ }
62
+ else {
63
+ setError('password', {
64
+ type: 'pattern',
65
+ message: 'Correo o contraseña incorrecta',
66
+ });
67
+ }
68
+ setError('email', {
69
+ type: 'pattern',
70
+ message: '',
71
+ });
72
+ setWrongLogin(true);
73
+ }
74
+ }
75
+ };
76
+ /**
77
+ * Function that clears errors if there are any.
78
+ */
79
+ const clearWrongLogin = () => {
80
+ if (wrongLogin) {
81
+ setWrongLogin(false);
82
+ clearErrors(['email', 'password']);
83
+ }
84
+ };
85
+ return (_jsx(MaterialProviders, { formStyle: formStyle, children: _jsxs("div", { className: layoutStyles.loginLayout, children: [_jsx("div", { className: layoutStyles.semiCircle }), _jsx("div", { className: layoutStyles.triangle }), _jsx("div", { className: layoutStyles.cardLayout, children: _jsx("div", { className: layoutStyles.loginCard, children: _jsxs("div", { className: layoutStyles.cardContainer, children: [_jsxs("div", { className: styles.leftPanel, children: [_jsx("div", { className: styles.logo, children: _jsx("img", { alt: 'Capta', className: 'capta-logo', src: '/Capta.svg' }) }), _jsx("h1", { children: "Inicia sesi\u00F3n en Capta" }), _jsxs("div", { className: styles.loginInputsContainer, children: [_jsx("div", { className: styles.loginInput, children: _jsx(Controller, { name: "email", control: control, defaultValue: "", rules: {
86
+ required: 'El correo es obligatorio',
87
+ pattern: {
88
+ value: EMAIL_REGEX,
89
+ message: 'El correo no es válido',
90
+ },
91
+ }, render: ({ field }) => (_jsx(LoginTextField, { ...field, "data-testid": "login_email", handleEnter: handleLogin, handleChange: clearWrongLogin, email: true, name: "email", disabled: loading, placeholder: "Correo", error: !!errors.email, helperText: errors.email?.message ?? '' })) }) }), _jsx("div", { className: styles.loginInput, children: _jsx(Controller, { name: "password", control: control, defaultValue: "", rules: {
92
+ required: 'La contraseña es obligatoria',
93
+ }, render: ({ field }) => (_jsx(LoginTextField, { ...field, disabled: loading, "data-testid": "login_password", handleEnter: handleLogin, handleChange: clearWrongLogin, name: "password", placeholder: "Contrase\u00F1a", error: !!errors.password, helperText: errors.password?.message ?? '' })) }) })] }), _jsxs("button", { "data-testid": "login_submit", className: styles.loginButton, onClick: () => {
94
+ if (!loading) {
95
+ void handleLogin();
96
+ }
97
+ }, disabled: loading, children: [_jsx("label", { style: {
98
+ visibility: loading ? 'hidden' : 'visible',
99
+ }, children: "Inicia sesi\u00F3n" }), loading && (_jsx("div", { className: styles.loaderContainer, children: _jsx(Loader, { color: "white" }) }))] })] }), _jsx("div", { className: styles.rightPanel, children: _jsxs("div", { className: styles.rightPanelMessage, children: [_jsx("h1", { children: "\u00A1Bienvenid@!" }), _jsx("p", { children: "Ingresa tu correo y contrase\u00F1a para ingresar al formulario." })] }) })] }) }) })] }) }));
100
+ }
101
+ export default LoginPage;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ interface LoginTextFieldProps {
3
+ /** Function called on Enter */
4
+ handleEnter?: () => void | Promise<void>;
5
+ /** If the field is of type email (otherwise password) */
6
+ email?: boolean;
7
+ /** Native change handler forwarded from react-hook-form */
8
+ onChange?: React.ChangeEventHandler;
9
+ /** Extra handler called on every change (clears the wrong-login state) */
10
+ handleChange?: () => void;
11
+ [key: string]: unknown;
12
+ }
13
+ declare function LoginTextField({ handleEnter, email, onChange, handleChange, ...others }: LoginTextFieldProps): JSX.Element;
14
+ export default LoginTextField;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import TextField from '@mui/material/TextField';
3
+ import InputAdornment from '@mui/material/InputAdornment';
4
+ import EmailIcon from '../Icons/EmailIcon';
5
+ import LockedIcon from '../Icons/LockedIcon';
6
+ function LoginTextField({ handleEnter, email, onChange, handleChange, ...others }) {
7
+ return (_jsx(TextField, { ...others, variant: "outlined", size: "small", fullWidth: true, type: email ? 'email' : 'password', onChange: (event) => {
8
+ handleChange?.();
9
+ onChange?.(event);
10
+ }, slotProps: {
11
+ input: {
12
+ onKeyDown: (event) => {
13
+ if (handleEnter && event.key === 'Enter') {
14
+ void handleEnter();
15
+ }
16
+ },
17
+ startAdornment: (_jsx(InputAdornment, { position: "start", children: email ? _jsx(EmailIcon, {}) : _jsx(LockedIcon, {}) })),
18
+ sx: {
19
+ borderRadius: '10px',
20
+ backgroundColor: '#ebebeb',
21
+ paddingRight: '7px',
22
+ '& input': { padding: '6px 0px', fontWeight: 300, height: 40 },
23
+ '&.Mui-focused fieldset': { borderColor: '#3d5a7f' },
24
+ '&:hover fieldset': { borderColor: '#3d5a7f' },
25
+ },
26
+ },
27
+ }, sx: { '& label.Mui-focused': { color: '#3d5a7f' } } }));
28
+ }
29
+ export default LoginTextField;