@hedia/recommendation-screen 1.8.2 → 2.0.2

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 (283) hide show
  1. package/.github/workflows/ci.yml +0 -0
  2. package/.github/workflows/publish.yml +48 -0
  3. package/.github/workflows/version-check.yml +45 -0
  4. package/.linguirc +0 -0
  5. package/.npmpackagejsonlintrc.json +0 -0
  6. package/.prettierignore +0 -0
  7. package/.prettierrc +0 -0
  8. package/App.d.ts +4 -5
  9. package/App.jsx +23 -34
  10. package/App.tsx +36 -41
  11. package/Changelog.md +0 -0
  12. package/README.md +0 -0
  13. package/android/app/BUCK +0 -0
  14. package/android/app/build.gradle +0 -0
  15. package/android/app/build_defs.bzl +0 -0
  16. package/android/app/debug.keystore +0 -0
  17. package/android/app/proguard-rules.pro +0 -0
  18. package/android/app/src/debug/AndroidManifest.xml +0 -0
  19. package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +0 -0
  20. package/android/app/src/main/AndroidManifest.xml +0 -0
  21. package/android/app/src/main/assets/fonts/AntDesign.ttf +0 -0
  22. package/android/app/src/main/assets/fonts/Entypo.ttf +0 -0
  23. package/android/app/src/main/assets/fonts/EvilIcons.ttf +0 -0
  24. package/android/app/src/main/assets/fonts/Feather.ttf +0 -0
  25. package/android/app/src/main/assets/fonts/FontAwesome.ttf +0 -0
  26. package/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf +0 -0
  27. package/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf +0 -0
  28. package/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf +0 -0
  29. package/android/app/src/main/assets/fonts/Foundation.ttf +0 -0
  30. package/android/app/src/main/assets/fonts/Ionicons.ttf +0 -0
  31. package/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf +0 -0
  32. package/android/app/src/main/assets/fonts/MaterialIcons.ttf +0 -0
  33. package/android/app/src/main/assets/fonts/Octicons.ttf +0 -0
  34. package/android/app/src/main/assets/fonts/Roboto-Black.ttf +0 -0
  35. package/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf +0 -0
  36. package/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
  37. package/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf +0 -0
  38. package/android/app/src/main/assets/fonts/Roboto-Italic.ttf +0 -0
  39. package/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
  40. package/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf +0 -0
  41. package/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
  42. package/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf +0 -0
  43. package/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
  44. package/android/app/src/main/assets/fonts/Roboto-Thin.ttf +0 -0
  45. package/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf +0 -0
  46. package/android/app/src/main/assets/fonts/SimpleLineIcons.ttf +0 -0
  47. package/android/app/src/main/assets/fonts/Zocial.ttf +0 -0
  48. package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +0 -0
  49. package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +0 -0
  50. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  51. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  52. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  53. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  54. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  55. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  56. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  57. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  58. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  59. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  60. package/android/app/src/main/res/values/color.xml +0 -0
  61. package/android/app/src/main/res/values/strings.xml +0 -0
  62. package/android/app/src/main/res/values/styles.xml +0 -0
  63. package/android/build.gradle +0 -0
  64. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  65. package/android/gradle/wrapper/gradle-wrapper.properties +0 -0
  66. package/android/gradle.properties +0 -0
  67. package/android/gradlew.bat +0 -0
  68. package/android/settings.gradle +0 -0
  69. package/app.json +0 -0
  70. package/assets/fonts/Roboto/LICENSE.txt +0 -0
  71. package/assets/fonts/Roboto/Roboto-Black.ttf +0 -0
  72. package/assets/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
  73. package/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
  74. package/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
  75. package/assets/fonts/Roboto/Roboto-Italic.ttf +0 -0
  76. package/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
  77. package/assets/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
  78. package/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
  79. package/assets/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  80. package/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  81. package/assets/fonts/Roboto/Roboto-Thin.ttf +0 -0
  82. package/assets/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
  83. package/babel.config.js +0 -0
  84. package/ignore-git.sh +1 -1
  85. package/ignore-publish.sh +2 -1
  86. package/index.d.ts +2 -2
  87. package/index.js +2 -3
  88. package/index.ts +2 -2
  89. package/ios/HediaRecommendationScreen/AppDelegate.h +0 -0
  90. package/ios/HediaRecommendationScreen/AppDelegate.m +0 -0
  91. package/ios/HediaRecommendationScreen/Base.lproj/LaunchScreen.xib +0 -0
  92. package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +0 -0
  93. package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +0 -0
  94. package/ios/HediaRecommendationScreen/Info.plist +0 -0
  95. package/ios/HediaRecommendationScreen/main.m +0 -0
  96. package/ios/HediaRecommendationScreen-tvOS/Info.plist +0 -0
  97. package/ios/HediaRecommendationScreen-tvOSTests/Info.plist +0 -0
  98. package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +0 -0
  99. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +0 -0
  100. package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +0 -0
  101. package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +0 -0
  102. package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  103. package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +0 -0
  104. package/ios/HediaRecommendationScreenTests/Info.plist +0 -0
  105. package/ios/Podfile +0 -0
  106. package/ios/Podfile.lock +0 -0
  107. package/jest.config.js +0 -0
  108. package/jest.mock.js +0 -0
  109. package/metro.config.js +0 -0
  110. package/package.json +8 -10
  111. package/react-native.config.js +0 -0
  112. package/src/RecommendationScreen.d.ts +18 -20
  113. package/src/RecommendationScreen.jsx +26 -15
  114. package/src/RecommendationScreen.tsx +60 -37
  115. package/src/__tests__/RecommendationScreen.test.d.ts +0 -0
  116. package/src/__tests__/RecommendationScreen.test.jsx +163 -138
  117. package/src/__tests__/RecommendationScreen.test.tsx +256 -159
  118. package/src/__tests__/RecommendationUtils.test.d.ts +0 -0
  119. package/src/__tests__/RecommendationUtils.test.js +30 -39
  120. package/src/__tests__/RecommendationUtils.test.ts +38 -43
  121. package/src/__tests__/Translate.test.d.ts +0 -0
  122. package/src/__tests__/Translate.test.jsx +13 -12
  123. package/src/__tests__/Translate.test.tsx +15 -14
  124. package/src/__tests__/Utils.test.d.ts +0 -0
  125. package/src/__tests__/Utils.test.js +22 -20
  126. package/src/__tests__/Utils.test.ts +32 -21
  127. package/src/__tests__/Validations.test.d.ts +0 -0
  128. package/src/__tests__/Validations.test.js +59 -33
  129. package/src/__tests__/Validations.test.ts +83 -41
  130. package/src/__tests__/components/Activity.test.d.ts +0 -0
  131. package/src/__tests__/components/Activity.test.jsx +39 -18
  132. package/src/__tests__/components/Activity.test.tsx +99 -45
  133. package/src/__tests__/components/Emotion.test.d.ts +0 -0
  134. package/src/__tests__/components/Emotion.test.jsx +34 -25
  135. package/src/__tests__/components/Emotion.test.tsx +41 -24
  136. package/src/__tests__/components/Header.test.d.ts +0 -0
  137. package/src/__tests__/components/Header.test.jsx +10 -9
  138. package/src/__tests__/components/Header.test.tsx +12 -11
  139. package/src/__tests__/components/InfoBars.test.d.ts +0 -0
  140. package/src/__tests__/components/InfoBars.test.jsx +1 -0
  141. package/src/__tests__/components/InfoBars.test.tsx +7 -6
  142. package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -0
  143. package/src/__tests__/components/InvisibleNumberInput.test.jsx +40 -24
  144. package/src/__tests__/components/InvisibleNumberInput.test.tsx +41 -17
  145. package/src/__tests__/components/LimitationMessage.test.d.ts +0 -0
  146. package/src/__tests__/components/LimitationMessage.test.jsx +11 -30
  147. package/src/__tests__/components/LimitationMessage.test.tsx +15 -13
  148. package/src/__tests__/components/MoodIcon.test.d.ts +0 -0
  149. package/src/__tests__/components/MoodIcon.test.jsx +12 -8
  150. package/src/__tests__/components/MoodIcon.test.tsx +13 -5
  151. package/src/__tests__/components/RecommendationModal.test.d.ts +0 -0
  152. package/src/__tests__/components/RecommendationModal.test.jsx +22 -21
  153. package/src/__tests__/components/RecommendationModal.test.tsx +29 -27
  154. package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -0
  155. package/src/__tests__/components/RecommendedCarbs.test.jsx +7 -10
  156. package/src/__tests__/components/RecommendedCarbs.test.tsx +9 -10
  157. package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -0
  158. package/src/__tests__/components/RecommendedInsulin.test.jsx +57 -41
  159. package/src/__tests__/components/RecommendedInsulin.test.tsx +57 -31
  160. package/src/__tests__/components/Remeasure.test.d.ts +0 -0
  161. package/src/__tests__/components/Remeasure.test.jsx +7 -3
  162. package/src/__tests__/components/Remeasure.test.tsx +11 -3
  163. package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -0
  164. package/src/__tests__/components/TransferToLogbook.test.jsx +2 -2
  165. package/src/__tests__/components/TransferToLogbook.test.tsx +2 -2
  166. package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -0
  167. package/src/__tests__/components/TwoOptionModal.test.jsx +5 -4
  168. package/src/__tests__/components/TwoOptionModal.test.tsx +6 -4
  169. package/src/__tests__/utils.d.ts +7 -2
  170. package/src/__tests__/utils.jsx +59 -15
  171. package/src/__tests__/utils.tsx +63 -16
  172. package/src/assets/activity/Cyclist.png +0 -0
  173. package/src/assets/activity/Other.png +0 -0
  174. package/src/assets/activity/Runner.png +0 -0
  175. package/src/assets/activity/Swimmer.png +0 -0
  176. package/src/assets/activity/Walk.png +0 -0
  177. package/src/assets/mood/happy.png +0 -0
  178. package/src/assets/mood/happy_active.png +0 -0
  179. package/src/assets/mood/neutral.png +0 -0
  180. package/src/assets/mood/neutral_active.png +0 -0
  181. package/src/assets/mood/sad.png +0 -0
  182. package/src/assets/mood/sad_active.png +0 -0
  183. package/src/assets/mood/semi_happy.png +0 -0
  184. package/src/assets/mood/semi_happy_active.png +0 -0
  185. package/src/assets/mood/semi_sad.png +0 -0
  186. package/src/assets/mood/semi_sad_active.png +0 -0
  187. package/src/components/Header.d.ts +0 -0
  188. package/src/components/Header.jsx +2 -1
  189. package/src/components/Header.tsx +2 -1
  190. package/src/components/Icon.js +0 -0
  191. package/src/components/InfoBars.d.ts +1 -1
  192. package/src/components/InfoBars.jsx +0 -0
  193. package/src/components/InfoBars.tsx +1 -1
  194. package/src/components/InvisibleNumberInput.d.ts +2 -1
  195. package/src/components/InvisibleNumberInput.jsx +7 -2
  196. package/src/components/InvisibleNumberInput.tsx +10 -3
  197. package/src/components/LimitationMessage.d.ts +1 -1
  198. package/src/components/LimitationMessage.jsx +3 -2
  199. package/src/components/LimitationMessage.tsx +3 -1
  200. package/src/components/LineSeparator.d.ts +0 -0
  201. package/src/components/LineSeparator.jsx +0 -0
  202. package/src/components/LineSeparator.tsx +0 -0
  203. package/src/components/RecentInsulin.d.ts +0 -0
  204. package/src/components/RecentInsulin.jsx +3 -2
  205. package/src/components/RecentInsulin.tsx +3 -0
  206. package/src/components/RecommendationModal.d.ts +4 -4
  207. package/src/components/RecommendationModal.jsx +10 -9
  208. package/src/components/RecommendationModal.tsx +19 -8
  209. package/src/components/RecommendedCarbs.d.ts +4 -3
  210. package/src/components/RecommendedCarbs.jsx +12 -9
  211. package/src/components/RecommendedCarbs.tsx +31 -16
  212. package/src/components/RecommendedInsulin.d.ts +7 -7
  213. package/src/components/RecommendedInsulin.jsx +11 -7
  214. package/src/components/RecommendedInsulin.tsx +24 -12
  215. package/src/components/Remeasure.d.ts +2 -2
  216. package/src/components/Remeasure.jsx +7 -2
  217. package/src/components/Remeasure.tsx +10 -4
  218. package/src/components/TransferToLogbook.d.ts +0 -0
  219. package/src/components/TransferToLogbook.jsx +2 -1
  220. package/src/components/TransferToLogbook.tsx +2 -0
  221. package/src/components/TwoOptionModal.d.ts +5 -3
  222. package/src/components/TwoOptionModal.jsx +44 -13
  223. package/src/components/TwoOptionModal.tsx +50 -14
  224. package/src/components/activity/Activity.d.ts +2 -3
  225. package/src/components/activity/Activity.jsx +5 -2
  226. package/src/components/activity/Activity.tsx +7 -5
  227. package/src/components/activity/ActivityIcon.d.ts +1 -1
  228. package/src/components/activity/ActivityIcon.jsx +9 -8
  229. package/src/components/activity/ActivityIcon.tsx +12 -10
  230. package/src/components/activity/ActivityIntensity.d.ts +1 -1
  231. package/src/components/activity/ActivityIntensity.jsx +2 -8
  232. package/src/components/activity/ActivityIntensity.tsx +3 -12
  233. package/src/components/mood/Emotion.d.ts +5 -4
  234. package/src/components/mood/Emotion.jsx +4 -3
  235. package/src/components/mood/Emotion.tsx +9 -7
  236. package/src/components/mood/MoodIcon.d.ts +2 -2
  237. package/src/components/mood/MoodIcon.jsx +3 -2
  238. package/src/components/mood/MoodIcon.tsx +4 -2
  239. package/src/locale/CleanLanguage.ts +0 -0
  240. package/src/locale/da/messages.js +1 -1
  241. package/src/locale/da/messages.po +115 -107
  242. package/src/locale/de/messages.js +1 -1
  243. package/src/locale/de/messages.po +115 -107
  244. package/src/locale/en/messages.js +1 -1
  245. package/src/locale/en/messages.po +118 -110
  246. package/src/locale/es/messages.js +1 -1
  247. package/src/locale/es/messages.po +112 -104
  248. package/src/locale/fr/messages.js +1 -1
  249. package/src/locale/fr/messages.po +111 -103
  250. package/src/locale/i18nUtils.d.ts +3 -4
  251. package/src/locale/i18nUtils.js +13 -12
  252. package/src/locale/i18nUtils.ts +14 -14
  253. package/src/locale/it/messages.js +1 -1
  254. package/src/locale/it/messages.po +113 -105
  255. package/src/types/enum.d.ts +52 -44
  256. package/src/types/enum.js +67 -56
  257. package/src/types/enum.ts +58 -34
  258. package/src/types/types.d.ts +9 -23
  259. package/src/types/types.js +0 -0
  260. package/src/types/types.ts +9 -25
  261. package/src/utils/AttentionMessages.d.ts +1 -4
  262. package/src/utils/AttentionMessages.jsx +8 -30
  263. package/src/utils/AttentionMessages.tsx +11 -16
  264. package/src/utils/Constants.d.ts +0 -0
  265. package/src/utils/Constants.js +0 -0
  266. package/src/utils/Constants.ts +0 -0
  267. package/src/utils/RecommendationError.d.ts +2 -0
  268. package/src/utils/RecommendationError.jsx +45 -40
  269. package/src/utils/RecommendationError.tsx +17 -4
  270. package/src/utils/RecommendationUtils.d.ts +7 -8
  271. package/src/utils/RecommendationUtils.js +15 -7
  272. package/src/utils/RecommendationUtils.ts +24 -14
  273. package/src/utils/Translations.d.ts +2 -0
  274. package/src/utils/Translations.js +10 -0
  275. package/src/utils/Translations.ts +9 -0
  276. package/src/utils/Utils.d.ts +4 -5
  277. package/src/utils/Utils.js +6 -5
  278. package/src/utils/Utils.ts +10 -8
  279. package/src/utils/Validations.d.ts +10 -9
  280. package/src/utils/Validations.js +61 -65
  281. package/src/utils/Validations.ts +76 -81
  282. package/tsconfig.json +2 -2
  283. package/tslint.json +0 -0
File without changes
package/ios/Podfile CHANGED
File without changes
package/ios/Podfile.lock CHANGED
File without changes
package/jest.config.js CHANGED
File without changes
package/jest.mock.js CHANGED
File without changes
package/metro.config.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedia/recommendation-screen",
3
- "version": "1.8.2",
3
+ "version": "2.0.2",
4
4
  "description": "Hedia Recommendation Screen for Bolus and Carbohydrates",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,15 +15,12 @@
15
15
  "test-coverage": "npm run tsc-clean && jest --coverage",
16
16
  "tsc": "tsc",
17
17
  "tsc-clean": "tsc --build --clean",
18
- "prepublish": "npm run lint && npm run lint-pkg && npm run prettier && npm run test-coverage && npm run tsc",
19
- "publish-patch": "npm version patch && ./ignore-publish.sh && tsc && npm publish",
20
- "publish-minor": "npm version minor && ./ignore-publish.sh && tsc && npm publish",
21
- "publish-major": "npm version major && ./ignore-publish.sh && tsc && npm publish",
22
- "postpublish": "./ignore-git.sh && ./index-git.sh && npm run tsc-clean && git push",
18
+ "prepublish": "npm run lint && npm run lint-pkg && npm run test-coverage && npm run tsc",
23
19
  "add-locale": "lingui add-locale",
24
20
  "extract": "lingui extract",
25
21
  "compile": "npm run cleanLanguage && lingui compile",
26
- "cleanLanguage": "node ./src/locale/CleanLanguage.ts"
22
+ "cleanLanguage": "node ./src/locale/CleanLanguage.ts",
23
+ "upgrade": "npm i --save-exact @hedia/types@latest @hedia/recommendation-calculator@latest"
27
24
  },
28
25
  "keywords": [
29
26
  "Hedia",
@@ -41,8 +38,8 @@
41
38
  "@babel/preset-env": "7.10.2",
42
39
  "@babel/preset-react": "7.10.1",
43
40
  "@babel/preset-typescript": "7.10.1",
44
- "@hedia/recommendation-calculator": "1.3.0",
45
- "@hedia/types": "1.0.2",
41
+ "@hedia/recommendation-calculator": "2.0.1",
42
+ "@hedia/types": "2.1.9",
46
43
  "@lingui/babel-preset-react": "2.9.1",
47
44
  "@lingui/cli": "2.9.1",
48
45
  "@lingui/macro": "2.9.1",
@@ -55,6 +52,7 @@
55
52
  "@types/lingui__react": "2.8.2",
56
53
  "@types/react": "16.9.35",
57
54
  "@types/react-native": "0.62.13",
55
+ "@types/react-test-renderer": "17.0.1",
58
56
  "babel-core": "7.0.0-bridge.0",
59
57
  "babel-jest": "26.0.1",
60
58
  "babel-loader": "8.1.0",
@@ -70,7 +68,7 @@
70
68
  "react-test-renderer": "16.13.1",
71
69
  "tslint": "6.1.2",
72
70
  "tslint-config-prettier": "1.18.0",
73
- "typescript": "3.9.5"
71
+ "typescript": "4.1.3"
74
72
  },
75
73
  "dependencies": {
76
74
  "moment": "2.27.0",
File without changes
@@ -1,30 +1,28 @@
1
1
  import React from "react";
2
2
  import { AppStateStatus } from "react-native";
3
- import { InjectionMethod, Language, MoodEnum } from "./types/enum";
4
- import * as Calculator from "@hedia/recommendation-calculator";
5
- import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
3
+ import { BloodGlucoseUnit, BloodKetonesUnit, Languages, Logbook, UserSettings } from "@hedia/types";
6
4
  import { RecommendationError } from "./utils/RecommendationError";
7
- import { IActivityDisplayProps, logbookEntry } from "./types/types";
5
+ import { IActivityDisplayProps, IRecommendationParams, logbookEntry } from "./types/types";
8
6
  import { AttentionMessage } from "./utils/AttentionMessages";
9
7
  interface IResult {
10
8
  suggested: number;
11
- entered?: number;
9
+ entered: number | null;
12
10
  }
13
11
  export interface IRecommendationProps {
14
12
  bloodGlucoseUnit: BloodGlucoseUnit;
15
- language: Language;
13
+ language: Languages;
16
14
  userReminder: number;
17
- calculatorParams: Calculator.IRecommendationParams;
18
- injectionMethod: InjectionMethod;
15
+ calculatorParams: IRecommendationParams;
16
+ injectionMethod: UserSettings.Enums.InjectionMethod;
19
17
  currentBKL: number;
20
18
  bloodKetoneUnit: BloodKetonesUnit;
21
- latestLogbookFrom6Hours: logbookEntry;
22
- activityDisplayProps: IActivityDisplayProps;
19
+ latestLogbookFrom6Hours: logbookEntry | null;
20
+ activityDisplayProps: IActivityDisplayProps | null;
23
21
  carbRecommendationAnswer(carbRecommendationAnswer: boolean): void;
24
22
  closeCalculationCallback(): void;
25
23
  exitCallback(): void;
26
24
  onRecentInsulinYes(): void;
27
- transferToLogbook(carbs: IResult, insulin: IResult, reminder: number, recommendationDate: Date, mood: MoodEnum): void;
25
+ transferToLogbook(carbs: IResult, insulin: IResult, reminder: number, recommendationDate: Date, mood: Logbook.Enums.MoodEnum | null): void;
28
26
  onError(error: RecommendationError): void;
29
27
  showBolusBar(toggle: boolean): void;
30
28
  restartCalculation(): void;
@@ -33,13 +31,13 @@ interface IState {
33
31
  remeasureTime: number;
34
32
  isRecommendationDisplayed: boolean;
35
33
  insulinRecommendation: number;
36
- activityReduction?: number;
34
+ activityReduction: number | null;
37
35
  wasLimited: boolean;
38
- carbRecommendation: number;
36
+ carbRecommendation: number | null;
39
37
  activeInsulin: number;
40
- selectedMood?: MoodEnum;
41
- enteredCarbs?: number;
42
- enteredInsulin?: number;
38
+ selectedMood: Logbook.Enums.MoodEnum | null;
39
+ enteredCarbs: number | null;
40
+ enteredInsulin: number | null;
43
41
  recommendationModal: boolean;
44
42
  showExitModal: boolean;
45
43
  showLimitationMessage: boolean;
@@ -50,13 +48,13 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
50
48
  private readonly suggestedCarbs;
51
49
  private readonly hasError;
52
50
  private readonly recommendationDate;
53
- private scrollView;
51
+ private scrollView?;
54
52
  constructor(props: IRecommendationProps);
55
53
  componentDidMount(): void;
56
54
  componentWillUnmount(): void;
57
55
  handleAppStateChange: (nextAppState: AppStateStatus) => void;
58
56
  showTimeoutModal: () => void;
59
- recalculateInsulin: (calculatorParams: Calculator.IRecommendationParams) => void;
57
+ recalculateInsulin: (calculatorParams: IRecommendationParams) => void;
60
58
  onExit: () => void;
61
59
  hideAttentionModal: () => void;
62
60
  hideLimitationMessage: () => void;
@@ -73,9 +71,9 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
73
71
  handleMoodSelected: (selectedMood: IState["selectedMood"]) => void;
74
72
  updateInsulinRecommendation: (enteredInsulin: number) => void;
75
73
  handleTransfer: () => void;
76
- getBGLevelAttentionMessage: () => AttentionMessage;
74
+ getBGLevelAttentionMessage: () => AttentionMessage | null;
77
75
  getBGLevelRemeasurementReminder: () => number;
78
- getLimitationAttentionMessage: () => AttentionMessage;
76
+ getLimitationAttentionMessage: () => AttentionMessage | null;
79
77
  render(): JSX.Element;
80
78
  }
81
79
  export {};
@@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
14
14
  var __importStar = (this && this.__importStar) || function (mod) {
15
15
  if (mod && mod.__esModule) return mod;
16
16
  var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
@@ -24,7 +24,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  const react_1 = __importDefault(require("react"));
26
26
  const react_native_1 = require("react-native");
27
- const enum_1 = require("./types/enum");
28
27
  const Constants_1 = require("./utils/Constants");
29
28
  const Header_1 = __importDefault(require("./components/Header"));
30
29
  const InfoBars_1 = __importStar(require("./components/InfoBars"));
@@ -33,6 +32,7 @@ const RecommendedCarbs_1 = __importDefault(require("./components/RecommendedCarb
33
32
  const RecommendedInsulin_1 = __importDefault(require("./components/RecommendedInsulin"));
34
33
  const Remeasure_1 = __importDefault(require("./components/Remeasure"));
35
34
  const Calculator = __importStar(require("@hedia/recommendation-calculator"));
35
+ const types_1 = require("@hedia/types");
36
36
  const react_2 = require("@lingui/react");
37
37
  const Emotion_1 = __importDefault(require("./components/mood/Emotion"));
38
38
  const TransferToLogbook_1 = __importDefault(require("./components/TransferToLogbook"));
@@ -54,7 +54,8 @@ class RecommendationScreen extends react_1.default.Component {
54
54
  super(props);
55
55
  this.hasError = false;
56
56
  this.handleAppStateChange = (nextAppState) => {
57
- const isOlderThan15Minutes = global.Date.now() - this.recommendationDate.getTime() > enum_1.Milliseconds.Minute * 15;
57
+ const time = this.recommendationDate.getTime();
58
+ const isOlderThan15Minutes = global.Date.now() - time > types_1.Milliseconds.Minute * 15;
58
59
  if (nextAppState === `active` && isOlderThan15Minutes) {
59
60
  this.showTimeoutModal();
60
61
  }
@@ -66,7 +67,7 @@ class RecommendationScreen extends react_1.default.Component {
66
67
  const { bolus, wasLimited, activityReduction } = Calculator.calculateRecommendation(calculatorParams);
67
68
  this.setState({
68
69
  insulinRecommendation: Utils_1.Utils.roundValue(bolus, this.props.injectionMethod),
69
- enteredInsulin: undefined,
70
+ enteredInsulin: null,
70
71
  wasLimited,
71
72
  activityReduction,
72
73
  showLimitationMessage: wasLimited,
@@ -104,7 +105,9 @@ class RecommendationScreen extends react_1.default.Component {
104
105
  };
105
106
  this.updateCarbRecommendation = (enteredCarbs) => {
106
107
  const providedCarbs = this.props.calculatorParams.carbohydrates;
107
- this.setState({ enteredCarbs }, () => this.recalculateInsulin({ ...this.props.calculatorParams, carbohydrates: providedCarbs + enteredCarbs }));
108
+ this.setState({ enteredCarbs }, () => {
109
+ this.recalculateInsulin({ ...this.props.calculatorParams, carbohydrates: providedCarbs + enteredCarbs });
110
+ });
108
111
  };
109
112
  this.removeCarbRecommendation = () => {
110
113
  this.setState({ enteredCarbs: null, carbRecommendation: null }, () => this.recalculateInsulin({ ...this.props.calculatorParams }));
@@ -170,13 +173,15 @@ class RecommendationScreen extends react_1.default.Component {
170
173
  activityReduction,
171
174
  carbRecommendation,
172
175
  activeInsulin,
176
+ enteredCarbs: null,
177
+ enteredInsulin: null,
173
178
  selectedMood: null,
174
179
  recommendationModal: wasLimited || !!Math.round(carbRecommendation) || !!this.getBGLevelAttentionMessage(),
175
180
  showExitModal: false,
176
181
  showLimitationMessage: false,
177
182
  showTimeoutModal: false,
178
183
  };
179
- this.timer = setTimeout(this.showTimeoutModal, enum_1.Milliseconds.Minute * 15);
184
+ this.timer = setTimeout(this.showTimeoutModal, types_1.Milliseconds.Minute * 15);
180
185
  }
181
186
  catch (error) {
182
187
  this.hasError = true;
@@ -187,20 +192,28 @@ class RecommendationScreen extends react_1.default.Component {
187
192
  react_native_1.AppState.addEventListener(`change`, this.handleAppStateChange);
188
193
  }
189
194
  componentWillUnmount() {
190
- clearTimeout(this.timer);
195
+ if (this.timer !== undefined) {
196
+ clearTimeout(this.timer);
197
+ }
191
198
  react_native_1.AppState.removeEventListener(`change`, this.handleAppStateChange);
192
199
  }
193
200
  render() {
194
201
  if (this.hasError) {
195
202
  return <react_native_1.View style={containerStyles.container}/>;
196
203
  }
197
- const { activeInsulin, recommendationModal, carbRecommendation, enteredCarbs, enteredInsulin, insulinRecommendation, activityReduction, isRecommendationDisplayed, } = this.state;
204
+ const { activeInsulin, recommendationModal, carbRecommendation: carbRecommendationProp, enteredCarbs, enteredInsulin, insulinRecommendation, activityReduction, isRecommendationDisplayed, } = this.state;
205
+ const carbRecommendation = carbRecommendationProp !== null ? Math.round(carbRecommendationProp) : null;
206
+ const recommendedCarbs = enteredCarbs ?? carbRecommendation;
198
207
  const { calculatorParams, bloodGlucoseUnit, currentBKL, bloodKetoneUnit } = this.props;
199
- const { currentBGL, carbohydrates } = calculatorParams;
208
+ const { currentBGL, carbohydrates: providedCarbs } = calculatorParams;
200
209
  const displayedBGL = Utils_1.Utils.displayedBGLValue(currentBGL, bloodGlucoseUnit);
201
210
  const displayedBKL = Utils_1.Utils.displayedBKLValue(currentBKL, bloodKetoneUnit);
202
211
  return (<react_2.I18nProvider language={this.props.language} i18n={i18nUtils_1.i18n}>
203
- <react_native_1.ScrollView style={containerStyles.container} ref={(view) => (this.scrollView = view)}>
212
+ <react_native_1.ScrollView style={containerStyles.container} ref={(view) => {
213
+ if (view !== null) {
214
+ this.scrollView = view;
215
+ }
216
+ }}>
204
217
  <Header_1.default exitCallback={this.onExit}/>
205
218
  <InfoBars_1.default label={i18nUtils_1.i18n._(macro_1.t `Active Insulin`)} value={activeInsulin ? `${activeInsulin.toFixed(1)}` : null} unit={i18nUtils_1.i18n._(macro_1.t `units`)} showNullAsDash={false}/>
206
219
  <InfoBars_1.default label={i18nUtils_1.i18n._(macro_1.t `Blood Glucose Level`)} value={currentBGL ? `${displayedBGL}` : null} unit={this.props.bloodGlucoseUnit} showNullAsDash={true}/>
@@ -210,12 +223,10 @@ class RecommendationScreen extends react_1.default.Component {
210
223
  <react_native_1.View style={[
211
224
  containerStyles.calcBorder,
212
225
  {
213
- borderColor: Math.round(carbRecommendation)
214
- ? Constants_1.BORDER_COLOUR_TEAL
215
- : Constants_1.BORDER_COLOUR_GREY,
226
+ borderColor: recommendedCarbs ? Constants_1.BORDER_COLOUR_TEAL : Constants_1.BORDER_COLOUR_GREY,
216
227
  },
217
228
  ]}>
218
- <RecommendedCarbs_1.default enteredCarbs={`${carbohydrates}`} changedRecommendedCarbs={this.updateCarbRecommendation} recommendedCarbs={`${enteredCarbs ?? Math.round(carbRecommendation)}`} removeRecommendedCarbs={this.removeCarbRecommendation}/>
229
+ <RecommendedCarbs_1.default enteredCarbs={`${providedCarbs}`} changedRecommendedCarbs={this.updateCarbRecommendation} recommendedCarbs={`${recommendedCarbs}`} removeRecommendedCarbs={this.removeCarbRecommendation}/>
219
230
  </react_native_1.View>
220
231
  </react_native_1.View>
221
232
  </react_native_1.View>
@@ -224,7 +235,7 @@ class RecommendationScreen extends react_1.default.Component {
224
235
  {!this.state.isRecommendationDisplayed ? (<RecentInsulin_1.default onRecentInsulinYes={this.props.onRecentInsulinYes} onRecentInsulinNo={this.handleNoRecentInsulin}/>) : (<RecommendedInsulin_1.default injectionMethod={this.props.injectionMethod} insulinRecommendation={insulinRecommendation} enteredInsulin={enteredInsulin} activityReduction={activityReduction} updateRecommendedInsulin={this.updateInsulinRecommendation}/>)}
225
236
  <Emotion_1.default moodSelected={this.handleMoodSelected} currentMood={this.state.selectedMood}/>
226
237
  <TransferToLogbook_1.default visible={isRecommendationDisplayed} transfer={this.handleTransfer}/>
227
- <RecommendationModal_1.default isVisible={recommendationModal} suggestedCarbohydrates={Math.round(carbRecommendation)} attentionMessage={this.getBGLevelAttentionMessage()} limitationMessage={this.getLimitationAttentionMessage()} onClickOkButton={this.hideAttentionModal} onAcceptCarbohydrates={this.acceptCarbRecommendation} onDeclineCarbohydrates={this.declineCarbRecommendation}/>
238
+ <RecommendationModal_1.default isVisible={recommendationModal} suggestedCarbohydrates={carbRecommendationProp} attentionMessage={this.getBGLevelAttentionMessage()} limitationMessage={this.getLimitationAttentionMessage()} onClickOkButton={this.hideAttentionModal} onAcceptCarbohydrates={this.acceptCarbRecommendation} onDeclineCarbohydrates={this.declineCarbRecommendation}/>
228
239
  </react_native_1.ScrollView>
229
240
  {this.state.showExitModal ? (<TwoOptionModal_1.default title={i18nUtils_1.i18n._(macro_1.t `Save data before closing?`)} message={i18nUtils_1.i18n._(macro_1.t `Your saved data will be used for future calculations.`)} textFirstOption={i18nUtils_1.i18n._(macro_1.t `Save to logbook`)} textSecondOption={i18nUtils_1.i18n._(macro_1.t `Close calculation`)} isCancelable={true} rowAsButtonLayout={true} firstOption={this.handleTransfer} secondOption={this.closeCalculation} onClose={this.hideExitModal}/>) : null}
230
241
  {this.state.showLimitationMessage ? (<react_native_1.View style={TwoOptionModal_1.modalStyle.container}>
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { AppState, AppStateStatus, ScrollView, StyleSheet, View, YellowBox } from "react-native";
3
3
 
4
- import { InjectionMethod, Language, Milliseconds, MoodEnum } from "./types/enum";
5
4
  import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "./utils/Constants";
6
5
 
7
6
  import Header from "./components/Header";
@@ -12,7 +11,7 @@ import RecommendedInsulin from "./components/RecommendedInsulin";
12
11
  import Remeasure from "./components/Remeasure";
13
12
 
14
13
  import * as Calculator from "@hedia/recommendation-calculator";
15
- import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
14
+ import { BloodGlucoseUnit, BloodKetonesUnit, Languages, Logbook, Milliseconds, UserSettings } from "@hedia/types";
16
15
  import { I18nProvider } from "@lingui/react";
17
16
  import Emotion from "./components/mood/Emotion";
18
17
  import TransferToLogbook from "./components/TransferToLogbook";
@@ -25,7 +24,7 @@ import LimitationMessage from "./components/LimitationMessage";
25
24
  import RecommendationModal from "./components/RecommendationModal";
26
25
  import TwoOptionModal, { modalStyle } from "./components/TwoOptionModal";
27
26
  import { changeLanguage, i18n } from "./locale/i18nUtils";
28
- import { IActivityDisplayProps, logbookEntry } from "./types/types";
27
+ import { IActivityDisplayProps, IRecommendationParams, logbookEntry } from "./types/types";
29
28
  import { AttentionMessage, Messages } from "./utils/AttentionMessages";
30
29
  import { getAttentionMessage, getBGLevel, getLimitationMessage, getReminder } from "./utils/RecommendationUtils";
31
30
  import { Utils } from "./utils/Utils";
@@ -37,20 +36,20 @@ YellowBox.ignoreWarnings([`Setting a timer`]);
37
36
 
38
37
  interface IResult {
39
38
  suggested: number;
40
- entered?: number;
39
+ entered: number | null;
41
40
  }
42
41
 
43
42
  export interface IRecommendationProps {
44
43
  // Values
45
44
  bloodGlucoseUnit: BloodGlucoseUnit;
46
- language: Language;
45
+ language: Languages;
47
46
  userReminder: number;
48
- calculatorParams: Calculator.IRecommendationParams;
49
- injectionMethod: InjectionMethod;
47
+ calculatorParams: IRecommendationParams;
48
+ injectionMethod: UserSettings.Enums.InjectionMethod;
50
49
  currentBKL: number;
51
50
  bloodKetoneUnit: BloodKetonesUnit;
52
- latestLogbookFrom6Hours: logbookEntry;
53
- activityDisplayProps: IActivityDisplayProps;
51
+ latestLogbookFrom6Hours: logbookEntry | null;
52
+ activityDisplayProps: IActivityDisplayProps | null;
54
53
 
55
54
  // Callbacks
56
55
  carbRecommendationAnswer(carbRecommendationAnswer: boolean): void;
@@ -62,7 +61,7 @@ export interface IRecommendationProps {
62
61
  insulin: IResult,
63
62
  reminder: number,
64
63
  recommendationDate: Date,
65
- mood: MoodEnum,
64
+ mood: Logbook.Enums.MoodEnum | null,
66
65
  ): void;
67
66
  onError(error: RecommendationError): void;
68
67
  showBolusBar(toggle: boolean): void;
@@ -73,13 +72,13 @@ interface IState {
73
72
  remeasureTime: number;
74
73
  isRecommendationDisplayed: boolean;
75
74
  insulinRecommendation: number;
76
- activityReduction?: number;
75
+ activityReduction: number | null;
77
76
  wasLimited: boolean;
78
- carbRecommendation: number;
77
+ carbRecommendation: number | null;
79
78
  activeInsulin: number;
80
- selectedMood?: MoodEnum;
81
- enteredCarbs?: number;
82
- enteredInsulin?: number;
79
+ selectedMood: Logbook.Enums.MoodEnum | null;
80
+ enteredCarbs: number | null;
81
+ enteredInsulin: number | null;
83
82
  recommendationModal: boolean;
84
83
  showExitModal: boolean;
85
84
  showLimitationMessage: boolean;
@@ -87,11 +86,11 @@ interface IState {
87
86
  }
88
87
 
89
88
  export default class RecommendationScreen extends React.Component<IRecommendationProps, IState> {
90
- private readonly timer: ReturnType<typeof setTimeout>;
91
- private readonly suggestedCarbs: number;
89
+ private readonly timer!: ReturnType<typeof setTimeout>;
90
+ private readonly suggestedCarbs!: number;
92
91
  private readonly hasError: boolean = false;
93
- private readonly recommendationDate: Date;
94
- private scrollView: ScrollView;
92
+ private readonly recommendationDate!: Date;
93
+ private scrollView?: ScrollView;
95
94
 
96
95
  constructor(props: IRecommendationProps) {
97
96
  super(props);
@@ -119,6 +118,8 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
119
118
  activityReduction,
120
119
  carbRecommendation,
121
120
  activeInsulin,
121
+ enteredCarbs: null,
122
+ enteredInsulin: null,
122
123
  selectedMood: null,
123
124
  recommendationModal:
124
125
  wasLimited || !!Math.round(carbRecommendation) || !!this.getBGLevelAttentionMessage(),
@@ -133,30 +134,35 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
133
134
  props.onError(error);
134
135
  }
135
136
  }
137
+
136
138
  public componentDidMount(): void {
137
139
  AppState.addEventListener(`change`, this.handleAppStateChange);
138
140
  }
139
141
 
140
142
  public componentWillUnmount(): void {
141
- clearTimeout(this.timer);
143
+ if (this.timer !== undefined) {
144
+ clearTimeout(this.timer);
145
+ }
142
146
  AppState.removeEventListener(`change`, this.handleAppStateChange);
143
147
  }
144
148
 
145
149
  public handleAppStateChange = (nextAppState: AppStateStatus): void => {
146
- const isOlderThan15Minutes = global.Date.now() - this.recommendationDate.getTime() > Milliseconds.Minute * 15;
150
+ const time = this.recommendationDate.getTime();
151
+ const isOlderThan15Minutes = global.Date.now() - time > Milliseconds.Minute * 15;
147
152
  if (nextAppState === `active` && isOlderThan15Minutes) {
148
153
  this.showTimeoutModal();
149
154
  }
150
155
  };
156
+
151
157
  public showTimeoutModal = (): void => {
152
158
  this.setState({ showTimeoutModal: true }, (): void => this.props.showBolusBar(!this.state.showTimeoutModal));
153
159
  };
154
160
 
155
- public recalculateInsulin = (calculatorParams: Calculator.IRecommendationParams): void => {
161
+ public recalculateInsulin = (calculatorParams: IRecommendationParams): void => {
156
162
  const { bolus, wasLimited, activityReduction } = Calculator.calculateRecommendation(calculatorParams);
157
163
  this.setState({
158
164
  insulinRecommendation: Utils.roundValue(bolus, this.props.injectionMethod),
159
- enteredInsulin: undefined,
165
+ enteredInsulin: null,
160
166
  wasLimited,
161
167
  activityReduction,
162
168
  showLimitationMessage: wasLimited,
@@ -174,12 +180,15 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
174
180
  public hideAttentionModal = (): void => {
175
181
  this.setState({ recommendationModal: false });
176
182
  };
183
+
177
184
  public hideLimitationMessage = (): void => {
178
185
  this.setState({ showLimitationMessage: false });
179
186
  };
187
+
180
188
  public hideExitModal = (): void => {
181
189
  this.setState({ showExitModal: false }, (): void => this.props.showBolusBar(!this.state.showExitModal));
182
190
  };
191
+
183
192
  public hideTimeoutModal = (): void => {
184
193
  this.setState({ showTimeoutModal: false }, (): void => this.props.showBolusBar(!this.state.showTimeoutModal));
185
194
  };
@@ -198,9 +207,9 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
198
207
 
199
208
  public updateCarbRecommendation = (enteredCarbs: number): void => {
200
209
  const providedCarbs = this.props.calculatorParams.carbohydrates;
201
- this.setState({ enteredCarbs }, (): void =>
202
- this.recalculateInsulin({ ...this.props.calculatorParams, carbohydrates: providedCarbs + enteredCarbs }),
203
- );
210
+ this.setState({ enteredCarbs }, (): void => {
211
+ this.recalculateInsulin({ ...this.props.calculatorParams, carbohydrates: providedCarbs + enteredCarbs });
212
+ });
204
213
  };
205
214
 
206
215
  public removeCarbRecommendation = (): void => {
@@ -214,6 +223,7 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
214
223
  this.removeCarbRecommendation();
215
224
  this.props.carbRecommendationAnswer(false);
216
225
  };
226
+
217
227
  public acceptCarbRecommendation = (): void => {
218
228
  this.hideAttentionModal();
219
229
  this.props.carbRecommendationAnswer(true);
@@ -223,6 +233,7 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
223
233
  this.state.showExitModal ? this.hideExitModal() : this.hideTimeoutModal();
224
234
  this.props.closeCalculationCallback();
225
235
  };
236
+
226
237
  public restartCalculation = (): void => {
227
238
  this.hideTimeoutModal();
228
239
  this.props.restartCalculation();
@@ -252,10 +263,11 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
252
263
  this.props.transferToLogbook(carbs, insulin, remeasureTime, this.recommendationDate, selectedMood);
253
264
  };
254
265
 
255
- public getBGLevelAttentionMessage = (): AttentionMessage => {
266
+ public getBGLevelAttentionMessage = (): AttentionMessage | null => {
256
267
  const { calculatorParams, latestLogbookFrom6Hours } = this.props;
257
268
  const { currentBGL, activity } = calculatorParams;
258
269
  const bgLevel = getBGLevel(currentBGL, latestLogbookFrom6Hours);
270
+
259
271
  return getAttentionMessage(bgLevel, activity);
260
272
  };
261
273
 
@@ -263,11 +275,13 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
263
275
  const { calculatorParams, userReminder, latestLogbookFrom6Hours } = this.props;
264
276
  const { currentBGL, activity, carbohydrates } = calculatorParams;
265
277
  const bgLevel = getBGLevel(currentBGL, latestLogbookFrom6Hours);
278
+
266
279
  return getReminder(bgLevel, carbohydrates, userReminder, activity);
267
280
  };
268
281
 
269
- public getLimitationAttentionMessage = (): AttentionMessage => {
282
+ public getLimitationAttentionMessage = (): AttentionMessage | null => {
270
283
  const { wasLimited, activityReduction } = this.state;
284
+
271
285
  return getLimitationMessage(wasLimited, activityReduction);
272
286
  };
273
287
 
@@ -279,21 +293,32 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
279
293
  const {
280
294
  activeInsulin,
281
295
  recommendationModal,
282
- carbRecommendation,
296
+ carbRecommendation: carbRecommendationProp,
283
297
  enteredCarbs,
284
298
  enteredInsulin,
285
299
  insulinRecommendation,
286
300
  activityReduction,
287
301
  isRecommendationDisplayed,
288
302
  } = this.state;
303
+
304
+ const carbRecommendation = carbRecommendationProp !== null ? Math.round(carbRecommendationProp) : null;
305
+ const recommendedCarbs = enteredCarbs ?? carbRecommendation;
306
+
289
307
  const { calculatorParams, bloodGlucoseUnit, currentBKL, bloodKetoneUnit } = this.props;
290
- const { currentBGL, carbohydrates } = calculatorParams;
308
+ const { currentBGL, carbohydrates: providedCarbs } = calculatorParams;
291
309
  const displayedBGL = Utils.displayedBGLValue(currentBGL, bloodGlucoseUnit);
292
310
  const displayedBKL = Utils.displayedBKLValue(currentBKL, bloodKetoneUnit);
293
311
 
294
312
  return (
295
313
  <I18nProvider language={this.props.language} i18n={i18n}>
296
- <ScrollView style={containerStyles.container} ref={(view): ScrollView => (this.scrollView = view)}>
314
+ <ScrollView
315
+ style={containerStyles.container}
316
+ ref={(view): void => {
317
+ if (view !== null) {
318
+ this.scrollView = view;
319
+ }
320
+ }}
321
+ >
297
322
  <Header exitCallback={this.onExit} />
298
323
  <InfoBars
299
324
  label={i18n._(t`Active Insulin`)}
@@ -319,16 +344,14 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
319
344
  style={[
320
345
  containerStyles.calcBorder,
321
346
  {
322
- borderColor: Math.round(carbRecommendation)
323
- ? BORDER_COLOUR_TEAL
324
- : BORDER_COLOUR_GREY,
347
+ borderColor: recommendedCarbs ? BORDER_COLOUR_TEAL : BORDER_COLOUR_GREY,
325
348
  },
326
349
  ]}
327
350
  >
328
351
  <RecommendedCarbs
329
- enteredCarbs={`${carbohydrates}`}
352
+ enteredCarbs={`${providedCarbs}`}
330
353
  changedRecommendedCarbs={this.updateCarbRecommendation}
331
- recommendedCarbs={`${enteredCarbs ?? Math.round(carbRecommendation)}`}
354
+ recommendedCarbs={`${recommendedCarbs}`}
332
355
  removeRecommendedCarbs={this.removeCarbRecommendation}
333
356
  />
334
357
  </View>
@@ -361,7 +384,7 @@ export default class RecommendationScreen extends React.Component<IRecommendatio
361
384
  <TransferToLogbook visible={isRecommendationDisplayed} transfer={this.handleTransfer} />
362
385
  <RecommendationModal
363
386
  isVisible={recommendationModal}
364
- suggestedCarbohydrates={Math.round(carbRecommendation)}
387
+ suggestedCarbohydrates={carbRecommendationProp}
365
388
  attentionMessage={this.getBGLevelAttentionMessage()}
366
389
  limitationMessage={this.getLimitationAttentionMessage()}
367
390
  onClickOkButton={this.hideAttentionModal}
File without changes