@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
package/src/__tests__/utils.tsx
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ActivityIntensity, IActivityParams } from "@hedia/recommendation-calculator/src/RecommendationCalculator";
|
|
3
|
-
import { BloodGlucoseUnit, BloodKetonesUnit } from "@hedia/types";
|
|
1
|
+
import { Activity, BloodGlucoseUnit, BloodKetonesUnit, Languages, UserSettings } from "@hedia/types";
|
|
4
2
|
import { I18nProvider } from "@lingui/react";
|
|
5
3
|
import React from "react";
|
|
6
4
|
import { RenderAPI } from "react-native-testing-library";
|
|
5
|
+
import { ReactTestInstance } from "react-test-renderer";
|
|
7
6
|
import { i18n } from "../locale/i18nUtils";
|
|
8
7
|
import { IRecommendationProps } from "../RecommendationScreen";
|
|
9
|
-
import {
|
|
8
|
+
import { TestIdEnum } from "../types/enum";
|
|
9
|
+
import { IActivityParams, IRecommendationParams, logbookEntry } from "../types/types";
|
|
10
|
+
|
|
11
|
+
const ActivityEnum = Activity.Enums.ActivityEnum;
|
|
12
|
+
const ActivityIntensity = Activity.Enums.ActivityIntensity;
|
|
13
|
+
const InjectionMethod = UserSettings.Enums.InjectionMethod;
|
|
14
|
+
|
|
15
|
+
const { Run } = ActivityEnum;
|
|
16
|
+
const { moderate } = ActivityIntensity;
|
|
17
|
+
const { PenHalf } = InjectionMethod;
|
|
10
18
|
|
|
11
19
|
export function getRecommendationProps(partials?: Partial<IRecommendationProps>): IRecommendationProps {
|
|
12
20
|
return {
|
|
13
21
|
currentBKL: partials?.currentBKL ?? 0.1,
|
|
14
22
|
bloodKetoneUnit: partials?.bloodKetoneUnit ?? BloodKetonesUnit.MMOL_L,
|
|
15
23
|
bloodGlucoseUnit: partials?.bloodGlucoseUnit ?? BloodGlucoseUnit.MMOL_L,
|
|
16
|
-
language: partials?.language ??
|
|
24
|
+
language: partials?.language ?? Languages.en,
|
|
17
25
|
userReminder: partials?.userReminder ?? 1.5,
|
|
18
|
-
latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours,
|
|
26
|
+
latestLogbookFrom6Hours: partials?.latestLogbookFrom6Hours ?? generateDefaultLogbook(),
|
|
19
27
|
calculatorParams: partials?.calculatorParams ?? generateDefaultCalculatorParams(),
|
|
20
|
-
injectionMethod: partials?.injectionMethod ??
|
|
28
|
+
injectionMethod: partials?.injectionMethod ?? PenHalf,
|
|
21
29
|
transferToLogbook: partials?.transferToLogbook ?? jest.fn(),
|
|
22
30
|
onError: partials?.onError ?? jest.fn(),
|
|
23
31
|
onRecentInsulinYes: partials?.onRecentInsulinYes ?? jest.fn(),
|
|
@@ -28,7 +36,7 @@ export function getRecommendationProps(partials?: Partial<IRecommendationProps>)
|
|
|
28
36
|
restartCalculation: partials?.restartCalculation ?? jest.fn(),
|
|
29
37
|
activityDisplayProps: partials?.activityDisplayProps ?? {
|
|
30
38
|
activityTitle: `Activity Title Test`,
|
|
31
|
-
activityType:
|
|
39
|
+
activityType: Run,
|
|
32
40
|
},
|
|
33
41
|
};
|
|
34
42
|
}
|
|
@@ -50,6 +58,7 @@ export function generateDefaultCalculatorParams(): IRecommendationParams {
|
|
|
50
58
|
secondsPassed: 10000,
|
|
51
59
|
},
|
|
52
60
|
],
|
|
61
|
+
activity: null,
|
|
53
62
|
};
|
|
54
63
|
}
|
|
55
64
|
|
|
@@ -57,14 +66,42 @@ export function generateActivityProps(): IActivityParams {
|
|
|
57
66
|
return {
|
|
58
67
|
activityDate: new Date(),
|
|
59
68
|
activityDuration: 30,
|
|
60
|
-
activityIntensity:
|
|
61
|
-
activitySettings:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
69
|
+
activityIntensity: moderate,
|
|
70
|
+
activitySettings: generateDefaultActivitySettings(),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function generateDefaultActivitySettings(): IActivityParams["activitySettings"] {
|
|
75
|
+
return {
|
|
76
|
+
hard: { fromFortysix: null, fromThirty: 0.25, fromZero: 1 },
|
|
77
|
+
light: { fromFortysix: 0.5, fromThirty: 0.75, fromZero: 1 },
|
|
78
|
+
moderate: { fromFortysix: 0.25, fromThirty: 0.5, fromZero: 1 },
|
|
79
|
+
post: { fromFortysix: 0.5, fromThirty: 0.5, fromZero: 1 },
|
|
80
|
+
target: 9,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export function generateDefaultLogbook(): logbookEntry {
|
|
84
|
+
return {
|
|
85
|
+
blood_glucose_millimolar: 6,
|
|
86
|
+
carbohydrates_entered_grams: 25,
|
|
87
|
+
carbohydrates_suggested_grams: 25,
|
|
88
|
+
client_timestamp: `25`,
|
|
89
|
+
client_version: `25`,
|
|
90
|
+
entry_timestamp: `25`,
|
|
91
|
+
event_uuid: null,
|
|
92
|
+
insulin_entered_units: 25,
|
|
93
|
+
insulin_suggested_units: 25,
|
|
94
|
+
is_deleted: null,
|
|
95
|
+
mood: 2,
|
|
96
|
+
settings_uuid: `25`,
|
|
97
|
+
uuid: `aaa`,
|
|
98
|
+
device_and_os: `ios 12.1.2`,
|
|
99
|
+
overwritten_by_id: null,
|
|
100
|
+
server_timestamp: null,
|
|
101
|
+
server_version: null,
|
|
102
|
+
utc_timezone_offset: null,
|
|
103
|
+
blood_ketones_millimolar: null,
|
|
104
|
+
carbohydrates_modified_suggested_grams: null,
|
|
68
105
|
};
|
|
69
106
|
}
|
|
70
107
|
|
|
@@ -78,6 +115,12 @@ export function expectTextExists(component: RenderAPI, text: string | RegExp): v
|
|
|
78
115
|
return expect(element).not.toBeNull();
|
|
79
116
|
}
|
|
80
117
|
|
|
118
|
+
export function queryTextFromComponent(wrapper: RenderAPI, testID: TestIdEnum): string {
|
|
119
|
+
const component = wrapper.getByTestId(testID);
|
|
120
|
+
const values = component.children;
|
|
121
|
+
return values.join(``);
|
|
122
|
+
}
|
|
123
|
+
|
|
81
124
|
export function expectTextNotExists(component: RenderAPI, text: string | RegExp): void {
|
|
82
125
|
const element = component.queryByText(text);
|
|
83
126
|
/*
|
|
@@ -95,3 +138,7 @@ export function i18nProvided(element: JSX.Element): JSX.Element {
|
|
|
95
138
|
</I18nProvider>
|
|
96
139
|
);
|
|
97
140
|
}
|
|
141
|
+
|
|
142
|
+
export function getIcon(wrapper: RenderAPI, name: string, active: boolean): ReactTestInstance | null {
|
|
143
|
+
return wrapper.queryByA11yLabel(`${name}_${active}`);
|
|
144
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/assets/mood/sad.png
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,6 +8,7 @@ const macro_1 = require("@lingui/macro");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const react_native_1 = require("react-native");
|
|
10
10
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
11
|
+
const enum_1 = require("../types/enum");
|
|
11
12
|
const Constants_1 = require("../utils/Constants");
|
|
12
13
|
const Icon_1 = __importDefault(require("./Icon"));
|
|
13
14
|
class Header extends react_1.default.Component {
|
|
@@ -18,7 +19,7 @@ class Header extends react_1.default.Component {
|
|
|
18
19
|
<react_native_1.View style={exports.headerStyles.margin}>
|
|
19
20
|
<react_native_1.View style={exports.headerStyles.exitButtonContainer}>
|
|
20
21
|
<react_native_1.View style={exports.headerStyles.exitButton}>
|
|
21
|
-
<react_native_1.TouchableOpacity testID=
|
|
22
|
+
<react_native_1.TouchableOpacity testID={enum_1.HeaderTestIds.ExitCalculation} accessibilityLabel="exitButton" style={exports.headerStyles.exitButton} onPress={this.props.exitCallback}>
|
|
22
23
|
<Icon_1.default iconIdentifier={`Ionicons/ios-close-circle-outline`} style={exports.headerStyles.iconStyle}/>
|
|
23
24
|
</react_native_1.TouchableOpacity>
|
|
24
25
|
<react_native_1.View style={exports.headerStyles.headerFiller}/>
|
|
@@ -2,6 +2,7 @@ import { t } from "@lingui/macro";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Dimensions, SafeAreaView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { i18n } from "../locale/i18nUtils";
|
|
5
|
+
import { HeaderTestIds } from "../types/enum";
|
|
5
6
|
import { BACKGROUND_COLOUR_PURPLE, BORDER_COLOUR_GREY } from "../utils/Constants";
|
|
6
7
|
import Icon from "./Icon";
|
|
7
8
|
|
|
@@ -19,7 +20,7 @@ export default class Header extends React.Component<IProps> {
|
|
|
19
20
|
<View style={headerStyles.exitButtonContainer}>
|
|
20
21
|
<View style={headerStyles.exitButton}>
|
|
21
22
|
<TouchableOpacity
|
|
22
|
-
testID=
|
|
23
|
+
testID={HeaderTestIds.ExitCalculation}
|
|
23
24
|
accessibilityLabel="exitButton"
|
|
24
25
|
style={headerStyles.exitButton}
|
|
25
26
|
onPress={this.props.exitCallback}
|
package/src/components/Icon.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -6,6 +6,7 @@ interface IProps {
|
|
|
6
6
|
cleanPartialInput: boolean;
|
|
7
7
|
negativeAllowed: boolean;
|
|
8
8
|
maxLength?: number;
|
|
9
|
+
testID: string;
|
|
9
10
|
visible(toggle: () => void): void;
|
|
10
11
|
onEnd?(value: number): void;
|
|
11
12
|
partialInput?(value: string): void;
|
|
@@ -14,7 +15,7 @@ interface IState {
|
|
|
14
15
|
value: string;
|
|
15
16
|
}
|
|
16
17
|
export default class InvisibleNumberInput extends React.Component<IProps, IState> {
|
|
17
|
-
textInput
|
|
18
|
+
textInput?: TextInput;
|
|
18
19
|
state: IState;
|
|
19
20
|
componentDidMount(): void;
|
|
20
21
|
cleanInput: (text: string) => string;
|
|
@@ -47,11 +47,16 @@ class InvisibleNumberInput extends react_1.default.Component {
|
|
|
47
47
|
this.setState({
|
|
48
48
|
value: this.props.startValue ?? `0`,
|
|
49
49
|
});
|
|
50
|
-
return this.textInput
|
|
50
|
+
return this.textInput?.focus();
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
render() {
|
|
54
|
-
|
|
54
|
+
const { testID } = this.props;
|
|
55
|
+
return (<react_native_1.TextInput testID={testID} accessibilityLabel="InvisibleNumberInput" value={`${this.state.value}`} ref={(textInput) => {
|
|
56
|
+
if (textInput !== null) {
|
|
57
|
+
this.textInput = textInput;
|
|
58
|
+
}
|
|
59
|
+
}} style={inputStyles.textInput} keyboardType="numeric" onChangeText={this.handleOnChangeText} onEndEditing={this.onEndEdit} maxLength={this.props.maxLength} selectTextOnFocus/>);
|
|
55
60
|
}
|
|
56
61
|
}
|
|
57
62
|
exports.default = InvisibleNumberInput;
|
|
@@ -7,6 +7,7 @@ interface IProps {
|
|
|
7
7
|
cleanPartialInput: boolean;
|
|
8
8
|
negativeAllowed: boolean;
|
|
9
9
|
maxLength?: number;
|
|
10
|
+
testID: string;
|
|
10
11
|
visible(toggle: () => void): void;
|
|
11
12
|
onEnd?(value: number): void;
|
|
12
13
|
partialInput?(value: string): void;
|
|
@@ -17,7 +18,7 @@ interface IState {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export default class InvisibleNumberInput extends React.Component<IProps, IState> {
|
|
20
|
-
public textInput
|
|
21
|
+
public textInput?: TextInput;
|
|
21
22
|
|
|
22
23
|
public state: IState = {
|
|
23
24
|
value: `0`,
|
|
@@ -31,7 +32,7 @@ export default class InvisibleNumberInput extends React.Component<IProps, IState
|
|
|
31
32
|
this.setState({
|
|
32
33
|
value: this.props.startValue ?? `0`,
|
|
33
34
|
});
|
|
34
|
-
return this.textInput
|
|
35
|
+
return this.textInput?.focus();
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -66,11 +67,17 @@ export default class InvisibleNumberInput extends React.Component<IProps, IState
|
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
public render(): JSX.Element {
|
|
70
|
+
const { testID } = this.props;
|
|
69
71
|
return (
|
|
70
72
|
<TextInput
|
|
73
|
+
testID={testID}
|
|
71
74
|
accessibilityLabel="InvisibleNumberInput"
|
|
72
75
|
value={`${this.state.value}`}
|
|
73
|
-
ref={(textInput):
|
|
76
|
+
ref={(textInput): void => {
|
|
77
|
+
if (textInput !== null) {
|
|
78
|
+
this.textInput = textInput;
|
|
79
|
+
}
|
|
80
|
+
}}
|
|
74
81
|
style={inputStyles.textInput}
|
|
75
82
|
keyboardType="numeric"
|
|
76
83
|
onChangeText={this.handleOnChangeText}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { AttentionMessage } from "../utils/AttentionMessages";
|
|
3
3
|
export interface ILimitationMessageProps {
|
|
4
|
-
limitationMessage: AttentionMessage;
|
|
4
|
+
limitationMessage: AttentionMessage | null;
|
|
5
5
|
onPressNextButton(): void;
|
|
6
6
|
}
|
|
7
7
|
export default class LimitationMessage extends React.Component<ILimitationMessageProps> {
|
|
@@ -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
|
};
|
|
@@ -23,6 +23,7 @@ const macro_1 = require("@lingui/macro");
|
|
|
23
23
|
const React = __importStar(require("react"));
|
|
24
24
|
const react_native_1 = require("react-native");
|
|
25
25
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
26
|
+
const enum_1 = require("../types/enum");
|
|
26
27
|
const RecommendationModal_1 = require("./RecommendationModal");
|
|
27
28
|
class LimitationMessage extends React.Component {
|
|
28
29
|
constructor() {
|
|
@@ -37,7 +38,7 @@ class LimitationMessage extends React.Component {
|
|
|
37
38
|
<react_native_1.Text style={RecommendationModal_1.stylesModal.textMessage}>{limitationMessage}</react_native_1.Text>
|
|
38
39
|
</react_native_1.View>
|
|
39
40
|
<react_native_1.View style={RecommendationModal_1.stylesModal.containerAcceptButton}>
|
|
40
|
-
<react_native_1.TouchableOpacity accessibilityLabel="nextButtonModal" style={RecommendationModal_1.stylesModal.okButton} onPress={this.props.onPressNextButton}>
|
|
41
|
+
<react_native_1.TouchableOpacity testID={enum_1.LimitationMessageTestIds.OkButton} accessibilityLabel="nextButtonModal" style={RecommendationModal_1.stylesModal.okButton} onPress={this.props.onPressNextButton}>
|
|
41
42
|
<react_native_1.Text style={RecommendationModal_1.stylesModal.buttonText}>{i18nUtils_1.i18n._(macro_1.t `OK`)}</react_native_1.Text>
|
|
42
43
|
</react_native_1.TouchableOpacity>
|
|
43
44
|
</react_native_1.View>
|
|
@@ -2,11 +2,12 @@ import { t } from "@lingui/macro";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Text, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { i18n } from "../locale/i18nUtils";
|
|
5
|
+
import { LimitationMessageTestIds } from "../types/enum";
|
|
5
6
|
import { AttentionMessage } from "../utils/AttentionMessages";
|
|
6
7
|
import { stylesModal } from "./RecommendationModal";
|
|
7
8
|
|
|
8
9
|
export interface ILimitationMessageProps {
|
|
9
|
-
limitationMessage: AttentionMessage;
|
|
10
|
+
limitationMessage: AttentionMessage | null;
|
|
10
11
|
onPressNextButton(): void;
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -23,6 +24,7 @@ export default class LimitationMessage extends React.Component<ILimitationMessag
|
|
|
23
24
|
</View>
|
|
24
25
|
<View style={stylesModal.containerAcceptButton}>
|
|
25
26
|
<TouchableOpacity
|
|
27
|
+
testID={LimitationMessageTestIds.OkButton}
|
|
26
28
|
accessibilityLabel="nextButtonModal"
|
|
27
29
|
style={stylesModal.okButton}
|
|
28
30
|
onPress={this.props.onPressNextButton}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -7,6 +7,7 @@ const macro_1 = require("@lingui/macro");
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_native_1 = require("react-native");
|
|
9
9
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
10
|
+
const enum_1 = require("../types/enum");
|
|
10
11
|
const InfoBars_1 = require("./InfoBars");
|
|
11
12
|
class RecentInsulin extends react_1.default.Component {
|
|
12
13
|
constructor() {
|
|
@@ -23,10 +24,10 @@ class RecentInsulin extends react_1.default.Component {
|
|
|
23
24
|
</react_native_1.View>
|
|
24
25
|
<react_native_1.View style={recentInsulinStyles.buttonContainer}>
|
|
25
26
|
<react_native_1.View style={recentInsulinStyles.filler}/>
|
|
26
|
-
<react_native_1.TouchableOpacity onPress={this.props.onRecentInsulinYes} style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}>
|
|
27
|
+
<react_native_1.TouchableOpacity testID={enum_1.RecentInsulinTestIds.Yes} onPress={this.props.onRecentInsulinYes} style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}>
|
|
27
28
|
<react_native_1.Text style={recentInsulinStyles.yesNoText}>{i18nUtils_1.i18n._(macro_1.t `Yes`)}</react_native_1.Text>
|
|
28
29
|
</react_native_1.TouchableOpacity>
|
|
29
|
-
<react_native_1.TouchableOpacity onPress={this.props.onRecentInsulinNo} style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}>
|
|
30
|
+
<react_native_1.TouchableOpacity testID={enum_1.RecentInsulinTestIds.No} onPress={this.props.onRecentInsulinNo} style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}>
|
|
30
31
|
<react_native_1.Text style={recentInsulinStyles.yesNoText}>{i18nUtils_1.i18n._(macro_1.t `No`)}</react_native_1.Text>
|
|
31
32
|
</react_native_1.TouchableOpacity>
|
|
32
33
|
<react_native_1.View style={recentInsulinStyles.filler}/>
|
|
@@ -2,6 +2,7 @@ import { t } from "@lingui/macro";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { i18n } from "../locale/i18nUtils";
|
|
5
|
+
import { RecentInsulinTestIds } from "../types/enum";
|
|
5
6
|
import { infoStyles } from "./InfoBars";
|
|
6
7
|
|
|
7
8
|
interface IProps {
|
|
@@ -24,12 +25,14 @@ export default class RecentInsulin extends React.Component<IProps> {
|
|
|
24
25
|
<View style={recentInsulinStyles.buttonContainer}>
|
|
25
26
|
<View style={recentInsulinStyles.filler} />
|
|
26
27
|
<TouchableOpacity
|
|
28
|
+
testID={RecentInsulinTestIds.Yes}
|
|
27
29
|
onPress={this.props.onRecentInsulinYes}
|
|
28
30
|
style={[recentInsulinStyles.yesNoContainer, { marginRight: `2%` }]}
|
|
29
31
|
>
|
|
30
32
|
<Text style={recentInsulinStyles.yesNoText}>{i18n._(t`Yes`)}</Text>
|
|
31
33
|
</TouchableOpacity>
|
|
32
34
|
<TouchableOpacity
|
|
35
|
+
testID={RecentInsulinTestIds.No}
|
|
33
36
|
onPress={this.props.onRecentInsulinNo}
|
|
34
37
|
style={[recentInsulinStyles.yesNoContainer, { marginLeft: `2%` }]}
|
|
35
38
|
>
|
|
@@ -2,9 +2,9 @@ import * as React from "react";
|
|
|
2
2
|
import { AttentionMessage } from "../utils/AttentionMessages";
|
|
3
3
|
interface IModalProps {
|
|
4
4
|
isVisible: boolean;
|
|
5
|
-
suggestedCarbohydrates
|
|
6
|
-
attentionMessage: AttentionMessage;
|
|
7
|
-
limitationMessage: AttentionMessage;
|
|
5
|
+
suggestedCarbohydrates: number | null;
|
|
6
|
+
attentionMessage: AttentionMessage | null;
|
|
7
|
+
limitationMessage: AttentionMessage | null;
|
|
8
8
|
onClickOkButton(): void;
|
|
9
9
|
onAcceptCarbohydrates(): void;
|
|
10
10
|
onDeclineCarbohydrates(): void;
|
|
@@ -16,7 +16,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
16
16
|
constructor(props: IModalProps);
|
|
17
17
|
onPressNextButton: () => void;
|
|
18
18
|
recommendationButtons: () => JSX.Element;
|
|
19
|
-
recommendCarbohydrates: () => JSX.Element;
|
|
19
|
+
recommendCarbohydrates: (suggestedCarbohydrates: number) => JSX.Element;
|
|
20
20
|
secondPage: () => JSX.Element;
|
|
21
21
|
firstPage: () => JSX.Element;
|
|
22
22
|
render(): JSX.Element;
|
|
@@ -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
|
};
|
|
@@ -28,6 +28,7 @@ const React = __importStar(require("react"));
|
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
29
|
const react_native_modal_1 = __importDefault(require("react-native-modal"));
|
|
30
30
|
const i18nUtils_1 = require("../locale/i18nUtils");
|
|
31
|
+
const enum_1 = require("../types/enum");
|
|
31
32
|
const Constants_1 = require("../utils/Constants");
|
|
32
33
|
const LimitationMessage_1 = __importDefault(require("./LimitationMessage"));
|
|
33
34
|
class RecommendationModal extends React.Component {
|
|
@@ -40,16 +41,16 @@ class RecommendationModal extends React.Component {
|
|
|
40
41
|
};
|
|
41
42
|
this.recommendationButtons = () => {
|
|
42
43
|
return (<react_native_1.View style={exports.stylesModal.recommendationButtonsContainer}>
|
|
43
|
-
<react_native_1.TouchableOpacity accessibilityLabel="yesButtonModal" style={exports.stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
|
|
44
|
+
<react_native_1.TouchableOpacity testID={enum_1.RecommendationModalTestIds.AcceptCarbs} accessibilityLabel="yesButtonModal" style={exports.stylesModal.affirmativeCarbsButton} onPress={this.props.onAcceptCarbohydrates}>
|
|
44
45
|
<react_native_1.Text style={exports.stylesModal.affirmativeCarbsText}>{i18nUtils_1.i18n._(macro_1.t `OK`)}</react_native_1.Text>
|
|
45
46
|
</react_native_1.TouchableOpacity>
|
|
46
|
-
<react_native_1.TouchableOpacity accessibilityLabel="noButtonModal" style={exports.stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
|
|
47
|
+
<react_native_1.TouchableOpacity testID={enum_1.RecommendationModalTestIds.DeclineCarbs} accessibilityLabel="noButtonModal" style={exports.stylesModal.negativeCarbsButton} onPress={this.props.onDeclineCarbohydrates}>
|
|
47
48
|
<react_native_1.Text style={exports.stylesModal.negativeCarbsText}>{i18nUtils_1.i18n._(macro_1.t `NO`)}</react_native_1.Text>
|
|
48
49
|
</react_native_1.TouchableOpacity>
|
|
49
50
|
</react_native_1.View>);
|
|
50
51
|
};
|
|
51
|
-
this.recommendCarbohydrates = () => {
|
|
52
|
-
const
|
|
52
|
+
this.recommendCarbohydrates = (suggestedCarbohydrates) => {
|
|
53
|
+
const displayCarbs = Math.round(suggestedCarbohydrates);
|
|
53
54
|
return (<React.Fragment>
|
|
54
55
|
<react_native_1.View style={exports.stylesModal.innerView}>
|
|
55
56
|
<react_native_1.View style={exports.stylesModal.recommendationRow}>
|
|
@@ -59,7 +60,7 @@ class RecommendationModal extends React.Component {
|
|
|
59
60
|
</react_native_1.View>
|
|
60
61
|
<react_native_1.View style={exports.stylesModal.suggestedContainer}>
|
|
61
62
|
<react_native_1.Text style={exports.stylesModal.textCenter}>
|
|
62
|
-
<react_native_1.Text style={exports.stylesModal.suggestedCarbs}>{`${
|
|
63
|
+
<react_native_1.Text style={exports.stylesModal.suggestedCarbs} testID={enum_1.RecommendationModalTestIds.SuggestedCarbs}>{`${displayCarbs} `}</react_native_1.Text>
|
|
63
64
|
<react_native_1.Text style={exports.stylesModal.carbohydrateText}>{i18nUtils_1.i18n._(macro_1.t `grams of carbohydrates`)}</react_native_1.Text>
|
|
64
65
|
</react_native_1.Text>
|
|
65
66
|
</react_native_1.View>
|
|
@@ -77,17 +78,17 @@ class RecommendationModal extends React.Component {
|
|
|
77
78
|
};
|
|
78
79
|
this.secondPage = () => {
|
|
79
80
|
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
80
|
-
const willRecommendCarbs = suggestedCarbohydrates && suggestedCarbohydrates > 0;
|
|
81
|
+
const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
|
|
81
82
|
return (<React.Fragment>
|
|
82
83
|
<react_native_1.View style={exports.stylesModal.container}>
|
|
83
84
|
<react_native_1.View style={exports.stylesModal.titleContainer}>
|
|
84
85
|
<react_native_1.Text style={exports.stylesModal.textTittleMessage}>{i18nUtils_1.i18n._(macro_1.t `Attention`)}</react_native_1.Text>
|
|
85
86
|
</react_native_1.View>
|
|
86
87
|
<react_native_1.Text style={exports.stylesModal.textMessage}>{attentionMessage}</react_native_1.Text>
|
|
87
|
-
{willRecommendCarbs ? this.recommendCarbohydrates() : null}
|
|
88
|
+
{willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates) : null}
|
|
88
89
|
</react_native_1.View>
|
|
89
90
|
{willRecommendCarbs ? null : (<react_native_1.View style={exports.stylesModal.containerAcceptButton}>
|
|
90
|
-
<react_native_1.TouchableOpacity accessibilityLabel="okayButtonModal" style={exports.stylesModal.okButton} onPress={this.props.onClickOkButton}>
|
|
91
|
+
<react_native_1.TouchableOpacity testID={enum_1.RecommendationModalTestIds.OkButton} accessibilityLabel="okayButtonModal" style={exports.stylesModal.okButton} onPress={this.props.onClickOkButton}>
|
|
91
92
|
<react_native_1.Text style={exports.stylesModal.buttonText}>{i18nUtils_1.i18n._(macro_1.t `OK`)}</react_native_1.Text>
|
|
92
93
|
</react_native_1.TouchableOpacity>
|
|
93
94
|
</react_native_1.View>)}
|
|
@@ -3,15 +3,16 @@ import * as React from "react";
|
|
|
3
3
|
import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import ReactNativeModal from "react-native-modal";
|
|
5
5
|
import { i18n } from "../locale/i18nUtils";
|
|
6
|
+
import { RecommendationModalTestIds } from "../types/enum";
|
|
6
7
|
import { AttentionMessage } from "../utils/AttentionMessages";
|
|
7
8
|
import { BORDER_COLOUR_TEAL } from "../utils/Constants";
|
|
8
9
|
import LimitationMessage from "./LimitationMessage";
|
|
9
10
|
|
|
10
11
|
interface IModalProps {
|
|
11
12
|
isVisible: boolean;
|
|
12
|
-
suggestedCarbohydrates
|
|
13
|
-
attentionMessage: AttentionMessage;
|
|
14
|
-
limitationMessage: AttentionMessage;
|
|
13
|
+
suggestedCarbohydrates: number | null;
|
|
14
|
+
attentionMessage: AttentionMessage | null;
|
|
15
|
+
limitationMessage: AttentionMessage | null;
|
|
15
16
|
onClickOkButton(): void;
|
|
16
17
|
onAcceptCarbohydrates(): void;
|
|
17
18
|
onDeclineCarbohydrates(): void;
|
|
@@ -26,15 +27,18 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
26
27
|
firstPageVisible: !!this.props.limitationMessage,
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
|
|
29
31
|
public onPressNextButton = (): void => {
|
|
30
32
|
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
31
33
|
const isPageVisible = !!attentionMessage || !!suggestedCarbohydrates;
|
|
32
34
|
return isPageVisible ? this.setState({ firstPageVisible: false }) : this.props.onClickOkButton();
|
|
33
35
|
};
|
|
36
|
+
|
|
34
37
|
public recommendationButtons = (): JSX.Element => {
|
|
35
38
|
return (
|
|
36
39
|
<View style={stylesModal.recommendationButtonsContainer}>
|
|
37
40
|
<TouchableOpacity
|
|
41
|
+
testID={RecommendationModalTestIds.AcceptCarbs}
|
|
38
42
|
accessibilityLabel="yesButtonModal"
|
|
39
43
|
style={stylesModal.affirmativeCarbsButton}
|
|
40
44
|
onPress={this.props.onAcceptCarbohydrates}
|
|
@@ -42,6 +46,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
42
46
|
<Text style={stylesModal.affirmativeCarbsText}>{i18n._(t`OK`)}</Text>
|
|
43
47
|
</TouchableOpacity>
|
|
44
48
|
<TouchableOpacity
|
|
49
|
+
testID={RecommendationModalTestIds.DeclineCarbs}
|
|
45
50
|
accessibilityLabel="noButtonModal"
|
|
46
51
|
style={stylesModal.negativeCarbsButton}
|
|
47
52
|
onPress={this.props.onDeclineCarbohydrates}
|
|
@@ -52,8 +57,9 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
52
57
|
);
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
public recommendCarbohydrates = (): JSX.Element => {
|
|
56
|
-
const
|
|
60
|
+
public recommendCarbohydrates = (suggestedCarbohydrates: number): JSX.Element => {
|
|
61
|
+
const displayCarbs = Math.round(suggestedCarbohydrates);
|
|
62
|
+
|
|
57
63
|
return (
|
|
58
64
|
<React.Fragment>
|
|
59
65
|
<View style={stylesModal.innerView}>
|
|
@@ -64,7 +70,10 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
64
70
|
</View>
|
|
65
71
|
<View style={stylesModal.suggestedContainer}>
|
|
66
72
|
<Text style={stylesModal.textCenter}>
|
|
67
|
-
<Text
|
|
73
|
+
<Text
|
|
74
|
+
style={stylesModal.suggestedCarbs}
|
|
75
|
+
testID={RecommendationModalTestIds.SuggestedCarbs}
|
|
76
|
+
>{`${displayCarbs} `}</Text>
|
|
68
77
|
<Text style={stylesModal.carbohydrateText}>{i18n._(t`grams of carbohydrates`)}</Text>
|
|
69
78
|
</Text>
|
|
70
79
|
</View>
|
|
@@ -84,7 +93,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
84
93
|
|
|
85
94
|
public secondPage = (): JSX.Element => {
|
|
86
95
|
const { attentionMessage, suggestedCarbohydrates } = this.props;
|
|
87
|
-
const willRecommendCarbs = suggestedCarbohydrates && suggestedCarbohydrates > 0;
|
|
96
|
+
const willRecommendCarbs = suggestedCarbohydrates !== null && suggestedCarbohydrates > 0;
|
|
88
97
|
|
|
89
98
|
return (
|
|
90
99
|
<React.Fragment>
|
|
@@ -93,11 +102,12 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
93
102
|
<Text style={stylesModal.textTittleMessage}>{i18n._(t`Attention`)}</Text>
|
|
94
103
|
</View>
|
|
95
104
|
<Text style={stylesModal.textMessage}>{attentionMessage}</Text>
|
|
96
|
-
{willRecommendCarbs ? this.recommendCarbohydrates() : null}
|
|
105
|
+
{willRecommendCarbs ? this.recommendCarbohydrates(suggestedCarbohydrates!) : null}
|
|
97
106
|
</View>
|
|
98
107
|
{willRecommendCarbs ? null : (
|
|
99
108
|
<View style={stylesModal.containerAcceptButton}>
|
|
100
109
|
<TouchableOpacity
|
|
110
|
+
testID={RecommendationModalTestIds.OkButton}
|
|
101
111
|
accessibilityLabel="okayButtonModal"
|
|
102
112
|
style={stylesModal.okButton}
|
|
103
113
|
onPress={this.props.onClickOkButton}
|
|
@@ -109,6 +119,7 @@ export default class RecommendationModal extends React.Component<IModalProps, IM
|
|
|
109
119
|
</React.Fragment>
|
|
110
120
|
);
|
|
111
121
|
};
|
|
122
|
+
|
|
112
123
|
public firstPage = (): JSX.Element => {
|
|
113
124
|
return (
|
|
114
125
|
<LimitationMessage
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { RecommendedCarbsTestIds } from "../types/enum";
|
|
2
3
|
interface ICalculationRow {
|
|
3
4
|
label: string;
|
|
4
5
|
value: string;
|
|
@@ -11,16 +12,16 @@ interface IProps {
|
|
|
11
12
|
changedRecommendedCarbs(value: number): void;
|
|
12
13
|
}
|
|
13
14
|
interface IState {
|
|
14
|
-
partialInput
|
|
15
|
+
partialInput?: string;
|
|
15
16
|
}
|
|
16
17
|
export default class RecommendedCarbs extends React.Component<IProps, IState> {
|
|
17
18
|
state: IState;
|
|
18
|
-
callbackInput
|
|
19
|
+
callbackInput?: () => void;
|
|
19
20
|
showTextInput: () => void;
|
|
20
21
|
handlePartialInput: (partialInput: string) => void;
|
|
21
22
|
handleChangedCarbs: (carbs: number) => void;
|
|
22
23
|
renderRecommendedCarbs: () => JSX.Element;
|
|
23
|
-
renderRow: (row: ICalculationRow) => JSX.Element;
|
|
24
|
+
renderRow: (row: ICalculationRow, testID: RecommendedCarbsTestIds) => JSX.Element;
|
|
24
25
|
render(): JSX.Element;
|
|
25
26
|
}
|
|
26
27
|
export {};
|