@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.
- package/.github/workflows/ci.yml +0 -0
- package/.github/workflows/publish.yml +48 -0
- package/.github/workflows/version-check.yml +45 -0
- package/.linguirc +0 -0
- package/.npmpackagejsonlintrc.json +0 -0
- package/.prettierignore +0 -0
- package/.prettierrc +0 -0
- package/App.d.ts +4 -5
- package/App.jsx +23 -34
- package/App.tsx +36 -41
- package/Changelog.md +0 -0
- package/README.md +0 -0
- package/android/app/BUCK +0 -0
- package/android/app/build.gradle +0 -0
- package/android/app/build_defs.bzl +0 -0
- package/android/app/debug.keystore +0 -0
- package/android/app/proguard-rules.pro +0 -0
- package/android/app/src/debug/AndroidManifest.xml +0 -0
- package/android/app/src/debug/java/com/hediarecommendationscreen/ReactNativeFlipper.java +0 -0
- package/android/app/src/main/AndroidManifest.xml +0 -0
- package/android/app/src/main/assets/fonts/AntDesign.ttf +0 -0
- package/android/app/src/main/assets/fonts/Entypo.ttf +0 -0
- package/android/app/src/main/assets/fonts/EvilIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Feather.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf +0 -0
- package/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf +0 -0
- package/android/app/src/main/assets/fonts/Foundation.ttf +0 -0
- package/android/app/src/main/assets/fonts/Ionicons.ttf +0 -0
- package/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/MaterialIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Octicons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Black.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Bold.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Italic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Light.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Medium.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Regular.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-Thin.ttf +0 -0
- package/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf +0 -0
- package/android/app/src/main/assets/fonts/SimpleLineIcons.ttf +0 -0
- package/android/app/src/main/assets/fonts/Zocial.ttf +0 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainActivity.java +0 -0
- package/android/app/src/main/java/com/hediarecommendationscreen/MainApplication.java +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/android/app/src/main/res/values/color.xml +0 -0
- package/android/app/src/main/res/values/strings.xml +0 -0
- package/android/app/src/main/res/values/styles.xml +0 -0
- package/android/build.gradle +0 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -0
- package/android/gradle.properties +0 -0
- package/android/gradlew.bat +0 -0
- package/android/settings.gradle +0 -0
- package/app.json +0 -0
- package/assets/fonts/Roboto/LICENSE.txt +0 -0
- package/assets/fonts/Roboto/Roboto-Black.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-BlackItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Italic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Light.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-LightItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Medium.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-Thin.ttf +0 -0
- package/assets/fonts/Roboto/Roboto-ThinItalic.ttf +0 -0
- package/babel.config.js +0 -0
- package/ignore-git.sh +1 -1
- package/ignore-publish.sh +2 -1
- package/index.d.ts +2 -2
- package/index.js +2 -3
- package/index.ts +2 -2
- package/ios/HediaRecommendationScreen/AppDelegate.h +0 -0
- package/ios/HediaRecommendationScreen/AppDelegate.m +0 -0
- package/ios/HediaRecommendationScreen/Base.lproj/LaunchScreen.xib +0 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/AppIcon.appiconset/Contents.json +0 -0
- package/ios/HediaRecommendationScreen/Images.xcassets/Contents.json +0 -0
- package/ios/HediaRecommendationScreen/Info.plist +0 -0
- package/ios/HediaRecommendationScreen/main.m +0 -0
- package/ios/HediaRecommendationScreen-tvOS/Info.plist +0 -0
- package/ios/HediaRecommendationScreen-tvOSTests/Info.plist +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/project.pbxproj +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen-tvOS.xcscheme +0 -0
- package/ios/HediaRecommendationScreen.xcodeproj/xcshareddata/xcschemes/HediaRecommendationScreen.xcscheme +0 -0
- package/ios/HediaRecommendationScreen.xcworkspace/contents.xcworkspacedata +0 -0
- package/ios/HediaRecommendationScreen.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- package/ios/HediaRecommendationScreenTests/HediaRecommendationScreenTests.m +0 -0
- package/ios/HediaRecommendationScreenTests/Info.plist +0 -0
- package/ios/Podfile +0 -0
- package/ios/Podfile.lock +0 -0
- package/jest.config.js +0 -0
- package/jest.mock.js +0 -0
- package/metro.config.js +0 -0
- package/package.json +8 -10
- package/react-native.config.js +0 -0
- package/src/RecommendationScreen.d.ts +18 -20
- package/src/RecommendationScreen.jsx +26 -15
- package/src/RecommendationScreen.tsx +60 -37
- package/src/__tests__/RecommendationScreen.test.d.ts +0 -0
- package/src/__tests__/RecommendationScreen.test.jsx +163 -138
- package/src/__tests__/RecommendationScreen.test.tsx +256 -159
- package/src/__tests__/RecommendationUtils.test.d.ts +0 -0
- package/src/__tests__/RecommendationUtils.test.js +30 -39
- package/src/__tests__/RecommendationUtils.test.ts +38 -43
- package/src/__tests__/Translate.test.d.ts +0 -0
- package/src/__tests__/Translate.test.jsx +13 -12
- package/src/__tests__/Translate.test.tsx +15 -14
- package/src/__tests__/Utils.test.d.ts +0 -0
- package/src/__tests__/Utils.test.js +22 -20
- package/src/__tests__/Utils.test.ts +32 -21
- package/src/__tests__/Validations.test.d.ts +0 -0
- package/src/__tests__/Validations.test.js +59 -33
- package/src/__tests__/Validations.test.ts +83 -41
- package/src/__tests__/components/Activity.test.d.ts +0 -0
- package/src/__tests__/components/Activity.test.jsx +39 -18
- package/src/__tests__/components/Activity.test.tsx +99 -45
- package/src/__tests__/components/Emotion.test.d.ts +0 -0
- package/src/__tests__/components/Emotion.test.jsx +34 -25
- package/src/__tests__/components/Emotion.test.tsx +41 -24
- package/src/__tests__/components/Header.test.d.ts +0 -0
- package/src/__tests__/components/Header.test.jsx +10 -9
- package/src/__tests__/components/Header.test.tsx +12 -11
- package/src/__tests__/components/InfoBars.test.d.ts +0 -0
- package/src/__tests__/components/InfoBars.test.jsx +1 -0
- package/src/__tests__/components/InfoBars.test.tsx +7 -6
- package/src/__tests__/components/InvisibleNumberInput.test.d.ts +0 -0
- package/src/__tests__/components/InvisibleNumberInput.test.jsx +40 -24
- package/src/__tests__/components/InvisibleNumberInput.test.tsx +41 -17
- package/src/__tests__/components/LimitationMessage.test.d.ts +0 -0
- package/src/__tests__/components/LimitationMessage.test.jsx +11 -30
- package/src/__tests__/components/LimitationMessage.test.tsx +15 -13
- package/src/__tests__/components/MoodIcon.test.d.ts +0 -0
- package/src/__tests__/components/MoodIcon.test.jsx +12 -8
- package/src/__tests__/components/MoodIcon.test.tsx +13 -5
- package/src/__tests__/components/RecommendationModal.test.d.ts +0 -0
- package/src/__tests__/components/RecommendationModal.test.jsx +22 -21
- package/src/__tests__/components/RecommendationModal.test.tsx +29 -27
- package/src/__tests__/components/RecommendedCarbs.test.d.ts +0 -0
- package/src/__tests__/components/RecommendedCarbs.test.jsx +7 -10
- package/src/__tests__/components/RecommendedCarbs.test.tsx +9 -10
- package/src/__tests__/components/RecommendedInsulin.test.d.ts +0 -0
- package/src/__tests__/components/RecommendedInsulin.test.jsx +57 -41
- package/src/__tests__/components/RecommendedInsulin.test.tsx +57 -31
- package/src/__tests__/components/Remeasure.test.d.ts +0 -0
- package/src/__tests__/components/Remeasure.test.jsx +7 -3
- package/src/__tests__/components/Remeasure.test.tsx +11 -3
- package/src/__tests__/components/TransferToLogbook.test.d.ts +0 -0
- package/src/__tests__/components/TransferToLogbook.test.jsx +2 -2
- package/src/__tests__/components/TransferToLogbook.test.tsx +2 -2
- package/src/__tests__/components/TwoOptionModal.test.d.ts +0 -0
- package/src/__tests__/components/TwoOptionModal.test.jsx +5 -4
- package/src/__tests__/components/TwoOptionModal.test.tsx +6 -4
- package/src/__tests__/utils.d.ts +7 -2
- package/src/__tests__/utils.jsx +59 -15
- package/src/__tests__/utils.tsx +63 -16
- package/src/assets/activity/Cyclist.png +0 -0
- package/src/assets/activity/Other.png +0 -0
- package/src/assets/activity/Runner.png +0 -0
- package/src/assets/activity/Swimmer.png +0 -0
- package/src/assets/activity/Walk.png +0 -0
- package/src/assets/mood/happy.png +0 -0
- package/src/assets/mood/happy_active.png +0 -0
- package/src/assets/mood/neutral.png +0 -0
- package/src/assets/mood/neutral_active.png +0 -0
- package/src/assets/mood/sad.png +0 -0
- package/src/assets/mood/sad_active.png +0 -0
- package/src/assets/mood/semi_happy.png +0 -0
- package/src/assets/mood/semi_happy_active.png +0 -0
- package/src/assets/mood/semi_sad.png +0 -0
- package/src/assets/mood/semi_sad_active.png +0 -0
- package/src/components/Header.d.ts +0 -0
- package/src/components/Header.jsx +2 -1
- package/src/components/Header.tsx +2 -1
- package/src/components/Icon.js +0 -0
- package/src/components/InfoBars.d.ts +1 -1
- package/src/components/InfoBars.jsx +0 -0
- package/src/components/InfoBars.tsx +1 -1
- package/src/components/InvisibleNumberInput.d.ts +2 -1
- package/src/components/InvisibleNumberInput.jsx +7 -2
- package/src/components/InvisibleNumberInput.tsx +10 -3
- package/src/components/LimitationMessage.d.ts +1 -1
- package/src/components/LimitationMessage.jsx +3 -2
- package/src/components/LimitationMessage.tsx +3 -1
- package/src/components/LineSeparator.d.ts +0 -0
- package/src/components/LineSeparator.jsx +0 -0
- package/src/components/LineSeparator.tsx +0 -0
- package/src/components/RecentInsulin.d.ts +0 -0
- package/src/components/RecentInsulin.jsx +3 -2
- package/src/components/RecentInsulin.tsx +3 -0
- package/src/components/RecommendationModal.d.ts +4 -4
- package/src/components/RecommendationModal.jsx +10 -9
- package/src/components/RecommendationModal.tsx +19 -8
- package/src/components/RecommendedCarbs.d.ts +4 -3
- package/src/components/RecommendedCarbs.jsx +12 -9
- package/src/components/RecommendedCarbs.tsx +31 -16
- package/src/components/RecommendedInsulin.d.ts +7 -7
- package/src/components/RecommendedInsulin.jsx +11 -7
- package/src/components/RecommendedInsulin.tsx +24 -12
- package/src/components/Remeasure.d.ts +2 -2
- package/src/components/Remeasure.jsx +7 -2
- package/src/components/Remeasure.tsx +10 -4
- package/src/components/TransferToLogbook.d.ts +0 -0
- package/src/components/TransferToLogbook.jsx +2 -1
- package/src/components/TransferToLogbook.tsx +2 -0
- package/src/components/TwoOptionModal.d.ts +5 -3
- package/src/components/TwoOptionModal.jsx +44 -13
- package/src/components/TwoOptionModal.tsx +50 -14
- package/src/components/activity/Activity.d.ts +2 -3
- package/src/components/activity/Activity.jsx +5 -2
- package/src/components/activity/Activity.tsx +7 -5
- package/src/components/activity/ActivityIcon.d.ts +1 -1
- package/src/components/activity/ActivityIcon.jsx +9 -8
- package/src/components/activity/ActivityIcon.tsx +12 -10
- package/src/components/activity/ActivityIntensity.d.ts +1 -1
- package/src/components/activity/ActivityIntensity.jsx +2 -8
- package/src/components/activity/ActivityIntensity.tsx +3 -12
- package/src/components/mood/Emotion.d.ts +5 -4
- package/src/components/mood/Emotion.jsx +4 -3
- package/src/components/mood/Emotion.tsx +9 -7
- package/src/components/mood/MoodIcon.d.ts +2 -2
- package/src/components/mood/MoodIcon.jsx +3 -2
- package/src/components/mood/MoodIcon.tsx +4 -2
- package/src/locale/CleanLanguage.ts +0 -0
- package/src/locale/da/messages.js +1 -1
- package/src/locale/da/messages.po +115 -107
- package/src/locale/de/messages.js +1 -1
- package/src/locale/de/messages.po +115 -107
- package/src/locale/en/messages.js +1 -1
- package/src/locale/en/messages.po +118 -110
- package/src/locale/es/messages.js +1 -1
- package/src/locale/es/messages.po +112 -104
- package/src/locale/fr/messages.js +1 -1
- package/src/locale/fr/messages.po +111 -103
- package/src/locale/i18nUtils.d.ts +3 -4
- package/src/locale/i18nUtils.js +13 -12
- package/src/locale/i18nUtils.ts +14 -14
- package/src/locale/it/messages.js +1 -1
- package/src/locale/it/messages.po +113 -105
- package/src/types/enum.d.ts +52 -44
- package/src/types/enum.js +67 -56
- package/src/types/enum.ts +58 -34
- package/src/types/types.d.ts +9 -23
- package/src/types/types.js +0 -0
- package/src/types/types.ts +9 -25
- package/src/utils/AttentionMessages.d.ts +1 -4
- package/src/utils/AttentionMessages.jsx +8 -30
- package/src/utils/AttentionMessages.tsx +11 -16
- package/src/utils/Constants.d.ts +0 -0
- package/src/utils/Constants.js +0 -0
- package/src/utils/Constants.ts +0 -0
- package/src/utils/RecommendationError.d.ts +2 -0
- package/src/utils/RecommendationError.jsx +45 -40
- package/src/utils/RecommendationError.tsx +17 -4
- package/src/utils/RecommendationUtils.d.ts +7 -8
- package/src/utils/RecommendationUtils.js +15 -7
- package/src/utils/RecommendationUtils.ts +24 -14
- package/src/utils/Translations.d.ts +2 -0
- package/src/utils/Translations.js +10 -0
- package/src/utils/Translations.ts +9 -0
- package/src/utils/Utils.d.ts +4 -5
- package/src/utils/Utils.js +6 -5
- package/src/utils/Utils.ts +10 -8
- package/src/utils/Validations.d.ts +10 -9
- package/src/utils/Validations.js +61 -65
- package/src/utils/Validations.ts +76 -81
- package/tsconfig.json +2 -2
- package/tslint.json +0 -0
|
File without changes
|
|
File without changes
|
|
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": "
|
|
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
|
|
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": "
|
|
45
|
-
"@hedia/types": "1.
|
|
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": "
|
|
71
|
+
"typescript": "4.1.3"
|
|
74
72
|
},
|
|
75
73
|
"dependencies": {
|
|
76
74
|
"moment": "2.27.0",
|
package/react-native.config.js
CHANGED
|
File without changes
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AppStateStatus } from "react-native";
|
|
3
|
-
import {
|
|
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
|
|
9
|
+
entered: number | null;
|
|
12
10
|
}
|
|
13
11
|
export interface IRecommendationProps {
|
|
14
12
|
bloodGlucoseUnit: BloodGlucoseUnit;
|
|
15
|
-
language:
|
|
13
|
+
language: Languages;
|
|
16
14
|
userReminder: number;
|
|
17
|
-
calculatorParams:
|
|
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
|
|
34
|
+
activityReduction: number | null;
|
|
37
35
|
wasLimited: boolean;
|
|
38
|
-
carbRecommendation: number;
|
|
36
|
+
carbRecommendation: number | null;
|
|
39
37
|
activeInsulin: number;
|
|
40
|
-
selectedMood
|
|
41
|
-
enteredCarbs
|
|
42
|
-
enteredInsulin
|
|
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:
|
|
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
|
|
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:
|
|
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 }, () =>
|
|
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,
|
|
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
|
-
|
|
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) =>
|
|
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:
|
|
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={`${
|
|
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={
|
|
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
|
|
39
|
+
entered: number | null;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
export interface IRecommendationProps {
|
|
44
43
|
// Values
|
|
45
44
|
bloodGlucoseUnit: BloodGlucoseUnit;
|
|
46
|
-
language:
|
|
45
|
+
language: Languages;
|
|
47
46
|
userReminder: number;
|
|
48
|
-
calculatorParams:
|
|
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
|
|
75
|
+
activityReduction: number | null;
|
|
77
76
|
wasLimited: boolean;
|
|
78
|
-
carbRecommendation: number;
|
|
77
|
+
carbRecommendation: number | null;
|
|
79
78
|
activeInsulin: number;
|
|
80
|
-
selectedMood
|
|
81
|
-
enteredCarbs
|
|
82
|
-
enteredInsulin
|
|
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
|
|
91
|
-
private readonly suggestedCarbs
|
|
89
|
+
private readonly timer!: ReturnType<typeof setTimeout>;
|
|
90
|
+
private readonly suggestedCarbs!: number;
|
|
92
91
|
private readonly hasError: boolean = false;
|
|
93
|
-
private readonly recommendationDate
|
|
94
|
-
private 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
|
-
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
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:
|
|
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={`${
|
|
352
|
+
enteredCarbs={`${providedCarbs}`}
|
|
330
353
|
changedRecommendedCarbs={this.updateCarbRecommendation}
|
|
331
|
-
recommendedCarbs={`${
|
|
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={
|
|
387
|
+
suggestedCarbohydrates={carbRecommendationProp}
|
|
365
388
|
attentionMessage={this.getBGLevelAttentionMessage()}
|
|
366
389
|
limitationMessage={this.getLimitationAttentionMessage()}
|
|
367
390
|
onClickOkButton={this.hideAttentionModal}
|
|
File without changes
|