@hedia/recommendation-screen 2.0.1 → 2.1.0

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 (138) hide show
  1. package/App.d.ts +2 -2
  2. package/App.jsx +3 -20
  3. package/coverage/clover.xml +700 -0
  4. package/coverage/coverage-final.json +28 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +79 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +201 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +170 -0
  13. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +1460 -0
  14. package/coverage/lcov-report/src/__tests__/index.html +111 -0
  15. package/coverage/lcov-report/src/__tests__/utils.tsx.html +512 -0
  16. package/coverage/lcov-report/src/components/Header.tsx.html +347 -0
  17. package/coverage/lcov-report/src/components/InfoBars.tsx.html +404 -0
  18. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +374 -0
  19. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +191 -0
  20. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +152 -0
  21. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +383 -0
  22. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +737 -0
  23. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +857 -0
  24. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +605 -0
  25. package/coverage/lcov-report/src/components/Remeasure.tsx.html +440 -0
  26. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +380 -0
  27. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +635 -0
  28. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +311 -0
  29. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +242 -0
  30. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +257 -0
  31. package/coverage/lcov-report/src/components/activity/index.html +141 -0
  32. package/coverage/lcov-report/src/components/index.html +276 -0
  33. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +278 -0
  34. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +260 -0
  35. package/coverage/lcov-report/src/components/mood/index.html +126 -0
  36. package/coverage/lcov-report/src/index.html +111 -0
  37. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +161 -0
  38. package/coverage/lcov-report/src/locale/index.html +111 -0
  39. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +326 -0
  40. package/coverage/lcov-report/src/utils/Constants.ts.html +176 -0
  41. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +500 -0
  42. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +467 -0
  43. package/coverage/lcov-report/src/utils/Translations.ts.html +107 -0
  44. package/coverage/lcov-report/src/utils/Utils.ts.html +263 -0
  45. package/coverage/lcov-report/src/utils/Validations.ts.html +815 -0
  46. package/coverage/lcov-report/src/utils/index.html +201 -0
  47. package/coverage/lcov.info +1581 -0
  48. package/jest.config.js +2 -1
  49. package/package.json +2 -2
  50. package/src/RecommendationScreen.d.ts +2 -3
  51. package/src/__tests__/RecommendationUtils.test.js +6 -29
  52. package/src/__tests__/Utils.test.js +1 -1
  53. package/src/__tests__/Validations.test.js +19 -7
  54. package/src/__tests__/components/Emotion.test.jsx +7 -8
  55. package/src/__tests__/utils.d.ts +3 -1
  56. package/src/__tests__/utils.jsx +38 -9
  57. package/src/components/Icon.d.ts +13 -0
  58. package/src/components/Icon.jsx +42 -0
  59. package/src/components/LimitationMessage.d.ts +1 -2
  60. package/src/components/RecommendationModal.d.ts +2 -3
  61. package/src/components/RecommendationModal.jsx +2 -1
  62. package/src/components/activity/ActivityIntensity.jsx +4 -3
  63. package/src/locale/da/messages.js +1 -1
  64. package/src/locale/da/messages.po +14 -10
  65. package/src/locale/de/messages.js +1 -1
  66. package/src/locale/de/messages.po +14 -10
  67. package/src/locale/en/messages.js +1 -1
  68. package/src/locale/en/messages.po +14 -10
  69. package/src/locale/es/messages.js +1 -1
  70. package/src/locale/es/messages.po +14 -10
  71. package/src/locale/fr/messages.js +1 -1
  72. package/src/locale/fr/messages.po +14 -10
  73. package/src/locale/it/messages.js +1 -1
  74. package/src/locale/it/messages.po +14 -10
  75. package/src/types/enum.d.ts +9 -8
  76. package/src/types/enum.js +9 -8
  77. package/src/utils/AttentionMessages.d.ts +16 -10
  78. package/src/utils/AttentionMessages.jsx +15 -10
  79. package/src/utils/RecommendationError.d.ts +1 -0
  80. package/src/utils/RecommendationError.jsx +3 -1
  81. package/src/utils/RecommendationUtils.d.ts +2 -3
  82. package/src/utils/RecommendationUtils.js +10 -6
  83. package/src/utils/Utils.d.ts +2 -1
  84. package/src/utils/Utils.js +5 -1
  85. package/src/utils/Validations.d.ts +2 -1
  86. package/src/utils/Validations.js +25 -13
  87. package/tsconfig.json +7 -5
  88. package/App.tsx +0 -157
  89. package/index.ts +0 -6
  90. package/src/RecommendationScreen.tsx +0 -461
  91. package/src/__tests__/RecommendationScreen.test.tsx +0 -1231
  92. package/src/__tests__/RecommendationUtils.test.ts +0 -356
  93. package/src/__tests__/Translate.test.tsx +0 -31
  94. package/src/__tests__/Utils.test.ts +0 -91
  95. package/src/__tests__/Validations.test.ts +0 -625
  96. package/src/__tests__/components/Activity.test.tsx +0 -163
  97. package/src/__tests__/components/Emotion.test.tsx +0 -110
  98. package/src/__tests__/components/Header.test.tsx +0 -44
  99. package/src/__tests__/components/InfoBars.test.tsx +0 -152
  100. package/src/__tests__/components/InvisibleNumberInput.test.tsx +0 -294
  101. package/src/__tests__/components/LimitationMessage.test.tsx +0 -58
  102. package/src/__tests__/components/MoodIcon.test.tsx +0 -45
  103. package/src/__tests__/components/RecommendationModal.test.tsx +0 -169
  104. package/src/__tests__/components/RecommendedCarbs.test.tsx +0 -234
  105. package/src/__tests__/components/RecommendedInsulin.test.tsx +0 -241
  106. package/src/__tests__/components/Remeasure.test.tsx +0 -97
  107. package/src/__tests__/components/TransferToLogbook.test.tsx +0 -38
  108. package/src/__tests__/components/TwoOptionModal.test.tsx +0 -72
  109. package/src/__tests__/utils.tsx +0 -116
  110. package/src/components/Header.tsx +0 -89
  111. package/src/components/Icon.js +0 -41
  112. package/src/components/InfoBars.tsx +0 -108
  113. package/src/components/InvisibleNumberInput.tsx +0 -98
  114. package/src/components/LimitationMessage.tsx +0 -38
  115. package/src/components/LineSeparator.tsx +0 -24
  116. package/src/components/RecentInsulin.tsx +0 -101
  117. package/src/components/RecommendationModal.tsx +0 -224
  118. package/src/components/RecommendedCarbs.tsx +0 -259
  119. package/src/components/RecommendedInsulin.tsx +0 -175
  120. package/src/components/Remeasure.tsx +0 -120
  121. package/src/components/TransferToLogbook.tsx +0 -100
  122. package/src/components/TwoOptionModal.tsx +0 -185
  123. package/src/components/activity/Activity.tsx +0 -77
  124. package/src/components/activity/ActivityIcon.tsx +0 -54
  125. package/src/components/activity/ActivityIntensity.tsx +0 -58
  126. package/src/components/mood/Emotion.tsx +0 -66
  127. package/src/components/mood/MoodIcon.tsx +0 -60
  128. package/src/locale/CleanLanguage.ts +0 -13
  129. package/src/locale/i18nUtils.ts +0 -27
  130. package/src/types/enum.ts +0 -107
  131. package/src/types/types.ts +0 -16
  132. package/src/utils/AttentionMessages.tsx +0 -75
  133. package/src/utils/Constants.ts +0 -32
  134. package/src/utils/RecommendationError.tsx +0 -133
  135. package/src/utils/RecommendationUtils.ts +0 -125
  136. package/src/utils/Translations.ts +0 -9
  137. package/src/utils/Utils.ts +0 -57
  138. package/src/utils/Validations.ts +0 -233
@@ -1,233 +0,0 @@
1
- import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
2
- import moment from "moment";
3
- import { IRecommendationProps } from "../RecommendationScreen";
4
- import { ActivitySettings, IActivityParams, IRecentBolus, IRecommendationParams } from "../types/types";
5
- import {
6
- ACTIVITY_BUFFER_MINUTES,
7
- ACTIVITY_DURATION_MINUTES_LIMITS,
8
- ACTIVITY_SETTINGS_INTERVAL_LIMITS,
9
- ACTIVITY_TARGET_BGL_MMOL_LIMITS,
10
- BOLUS_SECONDS_PASSED_LIMITS,
11
- CARBOHYDRATES_LIMTS,
12
- CURRENT_BGL_MMOL_LIMITS,
13
- CURRENT_BKL_MMOL_LIMITS,
14
- INSULIN_DOSE_LIMITS,
15
- INSULIN_SENSITIVITY_MMOL_LIMITS,
16
- INSULIN_TO_CARBS_RATIO_LIMITS,
17
- ONE_HOUR_MINUTES,
18
- REMINDER_HOURS_LIMITS,
19
- TARGET_BGL_MMOL_LIMITS,
20
- } from "./Constants";
21
- import {
22
- ActivityDateError,
23
- ActivityDurationError,
24
- ActivityIntensityError,
25
- ActivitySettingsError,
26
- ActivityTargetBGLError,
27
- ActivityTypeError,
28
- BloodGlucoseUnitError,
29
- BloodKetoneUnitError,
30
- BolusInsulinDoseError,
31
- BolusInsulinSecondsPassedError,
32
- CarbohydrateLimitError,
33
- CurrentBGLError,
34
- CurrentBKLError,
35
- InjectionMethodError,
36
- InsulinSensitivityError,
37
- InsulinToCarbsRatioError,
38
- LanguageError,
39
- RecentBolusError,
40
- TargetBGLError,
41
- UserReminderError,
42
- } from "./RecommendationError";
43
- import { Utils } from "./Utils";
44
-
45
- const { hard } = Activity.Enums.ActivityIntensity;
46
- const { fromFortysix } = Activity.Enums.ActivityReductionIntervals;
47
-
48
- export function validateParams(props: IRecommendationProps): void {
49
- checkCalculatorParams(props.calculatorParams);
50
- checkBGLUnit(props.bloodGlucoseUnit);
51
-
52
- checkBKLUnit(props.bloodKetoneUnit);
53
- checkBloodKetoneLevel(props.currentBKL);
54
-
55
- checkInjectionMethod(props.injectionMethod);
56
- checkUserReminder(props.userReminder);
57
- checkLanguage(props.language);
58
- if (props?.calculatorParams?.activity && props?.activityDisplayProps) {
59
- checkActivityType(props.activityDisplayProps.activityType);
60
- }
61
- }
62
-
63
- export function checkLanguage(language: Languages): void {
64
- if (!Object.values(Languages).includes(language)) {
65
- throw LanguageError();
66
- }
67
- }
68
-
69
- export function checkInjectionMethod(injectionMethod: UserSettings.Enums.InjectionMethod): void {
70
- const check = Object.values(UserSettings.Enums.InjectionMethod).some(
71
- (method): boolean => method === injectionMethod,
72
- );
73
- if (!check) {
74
- throw InjectionMethodError();
75
- }
76
- }
77
-
78
- export function checkBGLUnit(unit: BloodGlucoseUnit): void {
79
- const check = Object.values(BloodGlucoseUnit).some((enumUnit): boolean => enumUnit === unit);
80
- if (!check) {
81
- throw BloodGlucoseUnitError();
82
- }
83
- }
84
- export function checkBKLUnit(unit: BloodKetonesUnit): void {
85
- const check = Object.values(BloodKetonesUnit).some((enumUnit): boolean => enumUnit === unit);
86
- if (!check) {
87
- throw BloodKetoneUnitError();
88
- }
89
- }
90
-
91
- export function checkUserReminder(userReminder: number): void {
92
- if (!Utils.isInClosedInterval(userReminder, REMINDER_HOURS_LIMITS)) {
93
- throw UserReminderError();
94
- }
95
- }
96
-
97
- function checkCalculatorParams(calculatorParams: IRecommendationParams): void {
98
- checkActivity(calculatorParams.activity);
99
- checkCarbohydrates(calculatorParams.carbohydrates);
100
- checkCurrentBGL(calculatorParams.currentBGL);
101
- checkTargetBGL(calculatorParams.targetBGL);
102
- checkInsulinToCarbRatio(calculatorParams.carbohydrateRatio);
103
- checkInsulinSensitivity(calculatorParams.insulinSensitivity);
104
- checkRecentBolus(calculatorParams.recentBoluses);
105
- checkRecentBolusesInsulinDose(calculatorParams.recentBoluses);
106
- checkRecentBolusesSecondsPassed(calculatorParams.recentBoluses);
107
- }
108
-
109
- export function checkActivity(activity: IActivityParams | null): void {
110
- if (activity) {
111
- checkActivityDate(activity);
112
- checkActivityDuration(activity.activityDuration);
113
- checkActivityIntensity(activity.activityIntensity);
114
- checkActivitySettings(activity.activitySettings);
115
- checkActivityTargetBGL(activity.activitySettings.target);
116
- }
117
- }
118
-
119
- export function checkRecentBolus(recentBoluses: Array<IRecentBolus>): void {
120
- if (recentBoluses === null || recentBoluses === undefined) {
121
- throw RecentBolusError();
122
- }
123
- }
124
-
125
- export function checkRecentBolusesInsulinDose(recentBoluses: Array<IRecentBolus>): void {
126
- recentBoluses.forEach((bolus: IRecentBolus): void => {
127
- if (!Utils.isInClosedInterval(bolus.insulinDose, INSULIN_DOSE_LIMITS)) {
128
- throw BolusInsulinDoseError();
129
- }
130
- });
131
- }
132
-
133
- export function checkRecentBolusesSecondsPassed(recentBoluses: Array<IRecentBolus>): void {
134
- recentBoluses.forEach((bolus: IRecentBolus): void => {
135
- if (!Utils.isInClosedInterval(bolus.secondsPassed, BOLUS_SECONDS_PASSED_LIMITS)) {
136
- throw BolusInsulinSecondsPassedError();
137
- }
138
- });
139
- }
140
-
141
- export function checkActivityDuration(activityDuration: number): void {
142
- if (!Utils.isInClosedInterval(activityDuration, ACTIVITY_DURATION_MINUTES_LIMITS)) {
143
- throw ActivityDurationError();
144
- }
145
- }
146
-
147
- export function checkActivityIntensity(activityIntensity: Activity.Enums.ActivityIntensity): void {
148
- const check = Object.values(Activity.Enums.ActivityIntensity).some(
149
- (method): boolean => method === activityIntensity,
150
- );
151
- if (!check) {
152
- throw ActivityIntensityError();
153
- }
154
- }
155
-
156
- export function checkActivityType(activityType: Activity.Enums.ActivityEnum | null): void {
157
- const check = Object.values(Activity.Enums.ActivityEnum).some((method): boolean => method === activityType);
158
- if (!check) {
159
- throw ActivityTypeError();
160
- }
161
- }
162
-
163
- export function checkActivityDate(activity: IActivityParams): void {
164
- const maximumDate = moment
165
- .utc(activity.activityDate)
166
- .add(activity.activityDuration + ONE_HOUR_MINUTES * 4 + ACTIVITY_BUFFER_MINUTES, `minutes`);
167
- if (moment.utc().isAfter(maximumDate)) {
168
- throw ActivityDateError();
169
- }
170
- }
171
-
172
- export function checkActivitySettings(activitySettings: ActivitySettings): void {
173
- for (const intensity of Object.keys(activitySettings) as Array<Activity.Enums.ActivityIntensity>) {
174
- const reductionIntervals = activitySettings[intensity];
175
- for (const interval of Object.keys(reductionIntervals) as Array<keyof typeof reductionIntervals>) {
176
- const value = activitySettings[intensity][interval];
177
- const isInInterval: boolean = Utils.isInClosedInterval(value, ACTIVITY_SETTINGS_INTERVAL_LIMITS);
178
- if (intensity === hard && interval === fromFortysix) {
179
- if (!isInInterval && value !== null) {
180
- throw ActivitySettingsError();
181
- }
182
- } else if (!isInInterval) {
183
- throw ActivitySettingsError();
184
- }
185
- }
186
- }
187
- }
188
-
189
- export function checkActivityTargetBGL(activitySettingsTargetBGL: number): void {
190
- if (!Utils.isInClosedInterval(activitySettingsTargetBGL, ACTIVITY_TARGET_BGL_MMOL_LIMITS)) {
191
- throw ActivityTargetBGLError();
192
- }
193
- }
194
-
195
- export function checkCurrentBGL(currentBGL: number): void {
196
- if (currentBGL !== null) {
197
- if (!Utils.isInClosedInterval(currentBGL, CURRENT_BGL_MMOL_LIMITS)) {
198
- throw CurrentBGLError();
199
- }
200
- }
201
- }
202
-
203
- export function checkTargetBGL(targetBGL: number): void {
204
- if (!Utils.isInClosedInterval(targetBGL, TARGET_BGL_MMOL_LIMITS)) {
205
- throw TargetBGLError();
206
- }
207
- }
208
-
209
- export function checkBloodKetoneLevel(currentBKL: number): void {
210
- if (currentBKL !== null) {
211
- if (!Utils.isInClosedInterval(currentBKL, CURRENT_BKL_MMOL_LIMITS)) {
212
- throw CurrentBKLError();
213
- }
214
- }
215
- }
216
-
217
- export function checkInsulinSensitivity(insulinSensitivity: number): void {
218
- if (!Utils.isInClosedInterval(insulinSensitivity, INSULIN_SENSITIVITY_MMOL_LIMITS)) {
219
- throw InsulinSensitivityError();
220
- }
221
- }
222
-
223
- export function checkInsulinToCarbRatio(insulinToCarbRatio: number): void {
224
- if (!Utils.isInClosedInterval(insulinToCarbRatio, INSULIN_TO_CARBS_RATIO_LIMITS)) {
225
- throw InsulinToCarbsRatioError();
226
- }
227
- }
228
-
229
- export function checkCarbohydrates(carbohydrates: number): void {
230
- if (!Utils.isInClosedInterval(carbohydrates, CARBOHYDRATES_LIMTS)) {
231
- throw CarbohydrateLimitError();
232
- }
233
- }