@hedia/recommendation-screen 2.1.34-alpha.3 → 2.1.34-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/.github/workflows/ci.yaml +17 -0
  2. package/.github/workflows/publish-release-package.yaml +17 -0
  3. package/index.d.ts +5 -0
  4. package/index.js +5 -0
  5. package/package.json +13 -6
  6. package/src/RecommendationScreen.d.ts +413 -0
  7. package/src/RecommendationScreen.js +493 -0
  8. package/src/__tests__/RecommendationScreen.test.d.ts +1 -0
  9. package/src/__tests__/RecommendationScreen.test.js +965 -0
  10. package/src/__tests__/RecommendationUtils.test.d.ts +1 -0
  11. package/src/__tests__/RecommendationUtils.test.js +216 -0
  12. package/src/__tests__/Translate.test.d.ts +1 -0
  13. package/src/__tests__/Translate.test.js +27 -0
  14. package/src/__tests__/Utils.test.d.ts +1 -0
  15. package/src/__tests__/Utils.test.js +66 -0
  16. package/src/__tests__/Validations.test.d.ts +1 -0
  17. package/src/__tests__/Validations.test.js +465 -0
  18. package/src/__tests__/components/Activity.test.d.ts +1 -0
  19. package/src/__tests__/components/Activity.test.js +86 -0
  20. package/src/__tests__/components/Emotion.test.d.ts +1 -0
  21. package/src/__tests__/components/Emotion.test.js +70 -0
  22. package/src/__tests__/components/Header.test.d.ts +1 -0
  23. package/src/__tests__/components/Header.test.js +36 -0
  24. package/src/__tests__/components/InfoBars.test.d.ts +1 -0
  25. package/src/__tests__/components/InfoBars.test.js +130 -0
  26. package/src/__tests__/components/InvisibleNumberInput.test.d.ts +1 -0
  27. package/src/__tests__/components/InvisibleNumberInput.test.js +160 -0
  28. package/src/__tests__/components/LimitationMessage.test.d.ts +1 -0
  29. package/src/__tests__/components/LimitationMessage.test.js +47 -0
  30. package/src/__tests__/components/MoodIcon.test.d.ts +1 -0
  31. package/src/__tests__/components/MoodIcon.test.js +30 -0
  32. package/src/__tests__/components/RecommendationModal.test.d.ts +1 -0
  33. package/src/__tests__/components/RecommendationModal.test.js +98 -0
  34. package/src/__tests__/components/RecommendedCarbs.test.d.ts +1 -0
  35. package/src/__tests__/components/RecommendedCarbs.test.js +120 -0
  36. package/src/__tests__/components/RecommendedInsulin.test.d.ts +1 -0
  37. package/src/__tests__/components/RecommendedInsulin.test.js +154 -0
  38. package/src/__tests__/components/Remeasure.test.d.ts +1 -0
  39. package/src/__tests__/components/Remeasure.test.js +78 -0
  40. package/src/__tests__/components/TransferToLogbook.test.d.ts +1 -0
  41. package/src/__tests__/components/TransferToLogbook.test.js +30 -0
  42. package/src/__tests__/components/TwoOptionModal.test.d.ts +1 -0
  43. package/src/__tests__/components/TwoOptionModal.test.js +65 -0
  44. package/src/__tests__/utils.d.ts +16 -0
  45. package/src/__tests__/utils.js +126 -0
  46. package/src/components/Header.d.ts +10 -0
  47. package/src/components/Header.js +75 -0
  48. package/src/components/Icon.d.ts +20 -0
  49. package/src/components/Icon.js +41 -0
  50. package/src/components/InfoBars.d.ts +103 -0
  51. package/src/components/InfoBars.js +129 -0
  52. package/src/components/InvisibleNumberInput.d.ts +89 -0
  53. package/src/components/InvisibleNumberInput.js +122 -0
  54. package/src/components/LimitationMessage.d.ts +14 -0
  55. package/src/components/LimitationMessage.js +31 -0
  56. package/src/components/LineSeparator.d.ts +10 -0
  57. package/src/components/LineSeparator.js +18 -0
  58. package/src/components/RecentInsulin.d.ts +17 -0
  59. package/src/components/RecentInsulin.js +94 -0
  60. package/src/components/RecommendationModal.d.ts +207 -0
  61. package/src/components/RecommendationModal.js +213 -0
  62. package/src/components/RecommendedCarbs.d.ts +94 -0
  63. package/src/components/RecommendedCarbs.js +251 -0
  64. package/src/components/RecommendedInsulin.d.ts +84 -0
  65. package/src/components/RecommendedInsulin.js +170 -0
  66. package/src/components/Remeasure.d.ts +49 -0
  67. package/src/components/Remeasure.js +125 -0
  68. package/src/components/TransferToLogbook.d.ts +34 -0
  69. package/src/components/TransferToLogbook.js +94 -0
  70. package/src/components/TwoOptionModal.d.ts +145 -0
  71. package/src/components/TwoOptionModal.js +148 -0
  72. package/src/components/activity/Activity.d.ts +26 -0
  73. package/src/components/activity/Activity.js +80 -0
  74. package/src/components/activity/ActivityIcon.d.ts +22 -0
  75. package/src/components/activity/ActivityIcon.js +58 -0
  76. package/src/components/activity/ActivityIntensity.d.ts +16 -0
  77. package/src/components/activity/ActivityIntensity.js +59 -0
  78. package/src/components/mood/Emotion.d.ts +38 -0
  79. package/src/components/mood/Emotion.js +65 -0
  80. package/src/components/mood/MoodIcon.d.ts +40 -0
  81. package/src/components/mood/MoodIcon.js +66 -0
  82. package/src/locale/i18nUtils.d.ts +18 -0
  83. package/src/locale/i18nUtils.js +39 -0
  84. package/src/types/enum.d.ts +122 -0
  85. package/src/types/enum.js +138 -0
  86. package/src/types/types.d.ts +17 -0
  87. package/src/types/types.js +1 -0
  88. package/src/utils/AttentionMessages.d.ts +96 -0
  89. package/src/utils/AttentionMessages.js +118 -0
  90. package/src/utils/Constants.d.ts +47 -0
  91. package/src/utils/Constants.js +47 -0
  92. package/src/utils/RecommendationError.d.ts +56 -0
  93. package/src/utils/RecommendationError.js +62 -0
  94. package/src/utils/RecommendationUtils.d.ts +100 -0
  95. package/src/utils/RecommendationUtils.js +199 -0
  96. package/src/utils/Translations.d.ts +9 -0
  97. package/src/utils/Translations.js +14 -0
  98. package/src/utils/Utils.d.ts +105 -0
  99. package/src/utils/Utils.js +141 -0
  100. package/src/utils/Validations.d.ts +250 -0
  101. package/src/utils/Validations.js +409 -0
  102. package/.github/workflows/on-post-merge-publish-package.yaml +0 -35
  103. package/.github/workflows/version-bump-publish-alpha.yaml +0 -49
@@ -0,0 +1,17 @@
1
+ name: Version Bump & Publish Alpha
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+ types: [opened, reopened, synchronize]
8
+
9
+ env:
10
+ HEDIA_BOT_NPM_TOKEN: ${{ secrets.HEDIA_BOT_NPM_TOKEN }}
11
+
12
+ jobs:
13
+ ci:
14
+ uses: hedia-team/service-workflows/.github/workflows/ci-package.yaml@hda-1973-refactor-service-actions
15
+ secrets:
16
+ HEDIA_BOT_NPM_TOKEN: ${{ secrets.HEDIA_BOT_NPM_TOKEN }}
17
+ HEDIA_BOT_GITHUB_PAT: ${{ secrets.HEDIA_BOT_GITHUB_PAT }}
@@ -0,0 +1,17 @@
1
+ name: On post-merge - Publish package
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+ types: [closed]
8
+
9
+ env:
10
+ HEDIA_BOT_NPM_TOKEN: ${{ secrets.HEDIA_BOT_NPM_TOKEN }}
11
+
12
+ jobs:
13
+ ci:
14
+ uses: hedia-team/service-workflows/.github/workflows/bump-and-publish-npm-package.yaml@hda-1973-refactor-service-actions
15
+ secrets:
16
+ HEDIA_BOT_NPM_TOKEN: ${{ secrets.HEDIA_BOT_NPM_TOKEN }}
17
+ HEDIA_BOT_GITHUB_PAT: ${{ secrets.HEDIA_BOT_GITHUB_PAT }}
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import RecommendationScreen from "./src/RecommendationScreen";
2
+ import * as Errors from "./src/utils/RecommendationError";
3
+ export default RecommendationScreen;
4
+ export { Errors };
5
+ export * from "./src/types/enum";
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import RecommendationScreen from "./src/RecommendationScreen";
2
+ import * as Errors from "./src/utils/RecommendationError";
3
+ export default RecommendationScreen;
4
+ export { Errors };
5
+ export * from "./src/types/enum";
package/package.json CHANGED
@@ -1,25 +1,31 @@
1
1
  {
2
2
  "name": "@hedia/recommendation-screen",
3
- "version": "2.1.34-alpha.3",
3
+ "version": "2.1.34-alpha.5",
4
4
  "description": "Hedia Recommendation Screen for Bolus and Carbohydrates",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "a": "index-git.sh && cd android && gradlew clean && cd .. && react-native run-android",
7
+ "a": "./index-git.sh && cd android && ./gradlew clean && cd .. && react-native run-android",
8
8
  "start": "react-native start",
9
9
  "la": "./index-git.sh && cd ./android && ./gradlew clean && cd .. && gnome-terminal -- /bin/bash -c \"wmctrl -c 'Terminal';react-native start $SHELL\" && react-native run-android",
10
+ "test": "npm run clean && jest",
11
+ "test-coverage": "npm run clean && jest --coverage",
10
12
  "lint": "tslint --project .",
11
13
  "lint-fix": "tslint --fix --project .",
12
14
  "lint-pkg": "npmPkgJsonLint .",
13
15
  "prettier": "prettier --check \"src/**/*.{ts,tsx}\"",
14
- "test": "npm run tsc-clean && jest",
15
- "test-coverage": "npm run tsc-clean && jest --coverage",
16
+ "prettier-fix": "prettier --write \"src/**/*.{gts,tsx}\"",
17
+ "pkg-json-lint": "npmPkgJsonLint .",
18
+ "package-audit": "npm-audit --critical",
16
19
  "tsc": "tsc",
17
- "tsc-clean": "tsc --build --clean",
20
+ "clean": "tsc --build --clean",
21
+ "build": "tsc --build",
18
22
  "add-locale": "lingui add-locale",
19
23
  "extract": "lingui extract",
20
24
  "extract-clean": "lingui extract --clean",
21
25
  "compile": "npm run cleanLanguage && lingui compile",
22
- "cleanLanguage": "node ./src/locale/CleanLanguage.ts"
26
+ "cleanLanguage": "node ./src/locale/CleanLanguage.ts",
27
+ "prepublishOnly": "npm ci && npm run build",
28
+ "postpublish": "npm run clean"
23
29
  },
24
30
  "keywords": [
25
31
  "Hedia",
@@ -39,6 +45,7 @@
39
45
  "@babel/preset-react": "7.10.1",
40
46
  "@babel/preset-typescript": "7.10.1",
41
47
  "@babel/runtime": "7.12.5",
48
+ "@hedia/npm-audit-pipeline": "0.5.0",
42
49
  "@hedia/recommendation-calculator": "2.0.11",
43
50
  "@react-native-community/slider": "3.0.0",
44
51
  "@testing-library/jest-native": "3.1.0",
@@ -0,0 +1,413 @@
1
+ import React from "react";
2
+ import { AppStateStatus } from "react-native";
3
+ import { BloodGlucoseUnit, BloodKetonesUnit, BolusCalculator, Languages, Logbook, UserSettings } from "@hedia/types";
4
+ import { RecommendationError } from "./utils/RecommendationError";
5
+ import { IActivityDisplayProps } from "./types/types";
6
+ /** Represents both a suggestion by HDA and an actual amount of either insulin or carbohydrates. */
7
+ export interface IResult {
8
+ /** The suggested amount (of insulin in units or carbohydrates in grams) */
9
+ suggested: number;
10
+ /** The actual amount (of insulin in units or carbohydrates in grams) */
11
+ entered: number | null;
12
+ }
13
+ export interface IRecommendationProps {
14
+ /** The blood glucose measurement unit that the user prefers. */
15
+ bloodGlucoseUnit: BloodGlucoseUnit;
16
+ /** The user’s preferred language. */
17
+ language: Languages;
18
+ /** The user’s preferred default reminder time in hours when they enter carbohydrates or an activity. */
19
+ userReminder: number;
20
+ /** The values needed to make an insulin recommendation calculation. */
21
+ calculatorParams: BolusCalculator.Types.IRecommendationParams;
22
+ /** Indicates which method the user uses to inject insulin and thus how insulin amounts should be rounded. */
23
+ injectionMethod: UserSettings.Enums.InjectionMethod;
24
+ /** The user’s entered current blood ketones value. Null if no blood ketones value was entered. */
25
+ currentBKL: number | null;
26
+ /** The blood ketones measurement unit that the user prefers. Null if the user hasn’t selected a preferred blood ketones unit. */
27
+ bloodKetoneUnit: BloodKetonesUnit | null;
28
+ /** The latest logbook entry (if any) from the last 6 hours. */
29
+ latestLogbookFrom6Hours: Logbook.Types.ILogbookEntry | null;
30
+ /** The properties of the entered activity that are not used for making the calculation itself, but will be used on the recommendation screen. */
31
+ activityDisplayProps: IActivityDisplayProps | null;
32
+ /**
33
+ * Callback function taking a single boolean argument and returning nothing.
34
+ * To be called when the user decides on a presented carbohydrate recommendation.
35
+ * @param carbRecommendationAnswer Whether the user chose to accept (true) or reject (false) the carbohydrate recommendation.
36
+ */
37
+ carbRecommendationAnswer(carbRecommendationAnswer: boolean): void;
38
+ /**
39
+ * Callback function without arguments or return values.
40
+ * To be called if the user decides to exit the recommendation screen without transferring any of the data to the logbook.
41
+ * The unsaved logbook data shall be cleared.
42
+ */
43
+ closeCalculationCallback(): void;
44
+ /**
45
+ * Callback function without arguments or return values.
46
+ * To be called if the user closes the recommendation screen by tapping the cancel button in the header.
47
+ */
48
+ exitCallback(): void;
49
+ /**
50
+ * Callback function without arguments or return values.
51
+ * To be called if the user taps “Yes” when asked if they have taken insulin recently.
52
+ * Should allow the user to enter when they injected insulin and how much.
53
+ */
54
+ onRecentInsulinYes(): void;
55
+ /**
56
+ * To be called when the “Transfer to Logbook” button is pressed.
57
+ * @param carbs The suggested and entered amount of carbohydrates.
58
+ * @param insulin The suggested and entered amount of insulin.
59
+ * @param reminder The amount of time in hours until the user should get a reminder to measure their BGL again.
60
+ * @param recommendationDate The date and time when the recommendation calculation was made.
61
+ * @param mood The mood the user has selected
62
+ */
63
+ transferToLogbook(carbs: IResult, insulin: IResult, reminder: number, recommendationDate: Date, mood: Logbook.Enums.MoodEnum | null): void;
64
+ /**
65
+ * Callback function taking a single argument of type RecommendationError.
66
+ * To be called in case a serious issue with the validity of input data is detected.
67
+ * @param error The detected error.
68
+ */
69
+ onError(error: RecommendationError): void;
70
+ /**
71
+ * Callback function taking a single argument of type boolean.
72
+ * To be called to hide the bottom navigation bar while displaying modal dialogs.
73
+ * @param toggle Showing (true) or hiding (false) the bottom navigation bar on the calculation flow screens.
74
+ */
75
+ showBolusBar(toggle: boolean): void;
76
+ /**
77
+ * Callback function taking no arguments.
78
+ * To be called if the user chooses to restart the calculation.
79
+ */
80
+ restartCalculation(): void;
81
+ }
82
+ interface IState {
83
+ /** The time in hours in hours until a reminder notification will be sent to the user. If 0 then no notification will be sent. */
84
+ remeasureTime: number;
85
+ /**
86
+ * If true then the user will see the insulin input field with their recommendation.
87
+ * Otherwise, the user will be presented with a card that asks them whether they have taken bolus insulin within the last 4 hours
88
+ */
89
+ isRecommendationDisplayed: boolean;
90
+ /** The suggested amount of insulin. */
91
+ insulinRecommendation: number;
92
+ /** The fraction by which the recommendation was multiplied to get the reduced amount */
93
+ activityReduction: number | null;
94
+ /** Indicates whether or not the insulin recommendation was limited by the maximum threshold. */
95
+ wasLimited: boolean;
96
+ /** The suggested amount of additional carbs. */
97
+ carbRecommendation: number | null;
98
+ /** The amount of IOB that was estimated during the recommendation calculation. */
99
+ activeInsulin: number;
100
+ /** The mood that is currently selected or null if no mood is selected. */
101
+ selectedMood: Logbook.Enums.MoodEnum | null;
102
+ /** The amount of carbs that are being shown in the additional carbs input field. */
103
+ enteredCarbs: number | null;
104
+ /** The current insulin value in the insulin recommendation/input field. */
105
+ enteredInsulin: number | null;
106
+ /** Indicates whether or not the modal for displaying warnings and other special messages should be visible. */
107
+ recommendationModal: boolean;
108
+ /**
109
+ * Keeps track of whether or not the exit modal should be displayed.
110
+ * The exit modal prompts the user to consider saving the calculation to a logbook entry before closing the recommendation screen.
111
+ */
112
+ showExitModal: boolean;
113
+ /** Keeps track of whether or not a message about insulin limitation should be displayed. */
114
+ showLimitationMessage: boolean;
115
+ /** Keeps track of whether or not a message about the recommendation being too old should be displayed. */
116
+ showTimeoutModal: boolean;
117
+ }
118
+ /**
119
+ * The RecommendationScreen is the React component that passes relevant inputs to the recommendation calculation module and presents
120
+ * the resulting recommendation along with related messages or warnings to the user.
121
+ * The RecommendationScreen component accepts properties with the user’s settings/preferences and other inputs needed for calculating a recommendation.
122
+ * @noInheritDoc
123
+ */
124
+ export default class RecommendationScreen extends React.Component<IRecommendationProps, IState> {
125
+ /** Reference to the timer that prompts the user to make a new calculation after 15 minutes. */
126
+ private readonly timer;
127
+ /**
128
+ * The carbohydrate recommendation for the user.
129
+ * This value is saved in a member variable because we want to store it unmodified if the logbook entry
130
+ * gets saved regardless of what other changes were made on the recommendation screen.
131
+ */
132
+ private readonly suggestedCarbs;
133
+ /**
134
+ * A guard against displaying wrong or dangerous information to the user.
135
+ * If an error has occurred, this variable will be set to true and an empty placeholder will be rendered instead of the normal recommendation screen.
136
+ */
137
+ private readonly hasError;
138
+ /** The timestamp when the current recommendation was made. For determining if the recommendation is too old and should be hidden from the user. */
139
+ private readonly recommendationDate;
140
+ /**
141
+ * A reference to the screens scrollview allowing us to programmatically scroll the screen in the handleNoRecentInsulin() method.
142
+ * The member is initiated without a value but will be set as soon as the component is being rendered.
143
+ */
144
+ private scrollViewRef?;
145
+ /**
146
+ * A reference to the eventSubscription that'll be returned by AppState.addEventListener().
147
+ * It'll allow us to later remove the subscription.
148
+ */
149
+ private appStateSubscription?;
150
+ /**
151
+ * A reference to the eventSubscription that'll be returned by BackHandler.addEventListener().
152
+ * It'll allow us to later remove the subscription.
153
+ */
154
+ private backHandlerSubscription?;
155
+ /**
156
+ * Steps:
157
+ * 1. Call the super() method with the props.
158
+ * 2. Execute the following steps and if an exception is thrown, catch it, set the hasError member variable to true and call the onError callback prop with the caught exception as argument:
159
+ * - Call the validateParams() method with the props as argument
160
+ * - Set the recommendationDate member to the current date and time
161
+ * - Set the language by using the language prop as argument for calling changeLanguage()
162
+ * - Unpack recentBoluses from the calculatorParams prop.
163
+ * - Use the calculatorParams prop as argument for calling calculateRecommendation() and unpack all of the resulting values.
164
+ * - Copy the carbRecommendation to the suggestedCarbs member variable.
165
+ * - Set the following state variables:
166
+ * - Set remeasureTime to the return value from calling the getBGLevelRemeasurementReminder() method.
167
+ * - Set isRecommendationDisplayed to be false if the length of recentBoluses is 0 or false otherwise.
168
+ * - Set insulinRecommendation to be the bolus insulin recommendation rounded using roundValue().
169
+ * - Set wasLimited to the wasLimited return value from calling calculateRecommendation() above.
170
+ * - Set activityReduction to the reduction returned from the calculation result.
171
+ * - Set carbRecommendation to the recommendation returned from the calculation result.
172
+ * - Set activeInsulin to the estimation returned from the calculation result.
173
+ * - Set enteredCarbs, enteredInsulin, selectedMood to null.
174
+ * - Set recommendationModal to be true if wasLimited is true or if carbRecommendation after being rounded is truthy or if the return value from calling the getBGLevelAttentionMessage() method is truthy.
175
+ * - Set showExitModal, showLimitationMessage, showTimeoutModal to be false.
176
+ * 3. Start a 15 minute timer assigned to the timer member variable using the setTimeout() function. When the timer expires, call the showTimeoutModal() method.
177
+ * @param props The data required to initialise the Recommendation Screen
178
+ */
179
+ constructor(props: IRecommendationProps);
180
+ /**
181
+ * Called immediately after a component is mounted. Setting state here will trigger re-rendering.
182
+ *
183
+ * Steps:
184
+ * 1. If there is no error, create a listener to call the handleAppStateChange() method when the app state changes.
185
+ */
186
+ componentDidMount(): void;
187
+ /**
188
+ * Called immediately before a component is destroyed.
189
+ * Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.
190
+ *
191
+ * Clear the 15 minute timer that was set in the constructor during initialisation so it doesn't keep running and gets triggered after the recommendation screen was closed.
192
+ *
193
+ * Steps:
194
+ * 1. Call clearTimeout on the timer member variable.
195
+ * 2. Remove the listener for app state changes that was set by the componentDidMount() method.
196
+ */
197
+ componentWillUnmount(): void;
198
+ /**
199
+ * Steps:
200
+ * 1. Evaluate a boolean called isOlderThan15Minutes to indicate whether the recommendationDate member variable represents a time more than 15 minutes ago.
201
+ * 2. If nextAppState is ‘active’ and isOlderThan15Minutes is true then call the showTimeoutModal() method.
202
+ * @param nextAppState The new state of the app.
203
+ */
204
+ handleAppStateChange: (nextAppState: AppStateStatus) => void;
205
+ /**
206
+ * Steps:
207
+ * 1. Set the showTimeoutModal state variable to be true. Use a callback function to call the showBolusBar prop callback function with false as argument when the state has been updated.
208
+ * */
209
+ showTimeoutModal: () => void;
210
+ /**
211
+ * Make a new insulin calculation and set the result to be displayed to the user.
212
+ *
213
+ * Steps:
214
+ * 1. Use calculatorParams as an argument for calling calculateRecommendation(). Unpack bolus, wasLimited, and activityReduction from the result.
215
+ * 2. Set the following state variables:
216
+ * - Set insulinRecommendation to the bolus rounded using the roundValue() function.
217
+ * - Set enteredInsulin to be undefined.
218
+ * - Set wasLimited to be the value returned from the insulin calculator.
219
+ * - Set activityReduction to be the value returned from the insulin calculator.
220
+ * - Set showLimitationMessage to be the wasLimited value returned from the insulin calculator.
221
+ * @param calculatorParams The input values for the bolus calculator itself.
222
+ */
223
+ recalculateInsulin: (calculatorParams: BolusCalculator.Types.IRecommendationParams) => void;
224
+ /**
225
+ * Handle presses on the exit button in the header bar.
226
+ *
227
+ * Steps:
228
+ * 1. If the insulin recommendation is being displayed (the isRecommendationDisplayed state variable is true):
229
+ * - Set the showExitModal state variable to true. When the state has been updated, call the showBolusBar prop callback function with the inverse value of the showExitModal state variable as argument.
230
+ * 2. Else:
231
+ * - Call the exitCallback prop callback function.
232
+ */
233
+ onExit: () => void;
234
+ /**
235
+ * Callback to be executed by the back handler listener.
236
+ *
237
+ * Steps:
238
+ * 1. Call the onExist method
239
+ * 2. Return true so that the default behaviour is overwritten.
240
+ */
241
+ onBackHandlerPress: () => boolean;
242
+ /**
243
+ * Hide the modal that shows attention messages.
244
+ *
245
+ * Steps:
246
+ * 1. Set the recommendationModal state variable to false.
247
+ */
248
+ hideAttentionModal: () => void;
249
+ /**
250
+ * Hide the modal that shows attention messages.
251
+ *
252
+ * Steps:
253
+ * 1. Set the showLimitationMessage state variable to false.
254
+ */
255
+ hideLimitationMessage: () => void;
256
+ /**
257
+ * Hide the exit modal. To be used when the user closes the modal directly or in some way exits the recommendation screen.
258
+ *
259
+ * Steps:
260
+ * 1. Set the showExitModal state variable to false.
261
+ * When the state has been updated, call the showBolusBar prop callback function with the inverse value of the showExitModal state variable as argument.
262
+ */
263
+ hideExitModal: () => void;
264
+ /**
265
+ * Hide the modal that warns the user that their recommendation is old.
266
+ *
267
+ * Steps:
268
+ * 1. Set the showTimeoutModal state variable to false.
269
+ * When the state has been updated, call the showBolusBar prop callback function with the inverse value of the showTimeoutModal state variable as argument.
270
+ */
271
+ hideTimeoutModal: () => void;
272
+ /**
273
+ * Used as a callback function for the Remeasure component to update the state when the remeasure time slider’s value changes.
274
+ *
275
+ * Steps:
276
+ * 1. Set the remeasureTime state variable to the value of the remeasureTime argument.
277
+ * @param remeasureTime The number of hours for which to wait before reminding the user to measure their BGL again. 0 indicates that the user should not be reminded.
278
+ */
279
+ updateRemeasureTime: (remeasureTime: number) => void;
280
+ /**
281
+ * Handle what happens if the user taps “No” to the question about injecting insulin within the last 4 hours.
282
+ * The card that prompts the user to answer if they have injected insulin within the last 4 hours shall be hidden and
283
+ * the screen shall automatically be scrolled to the bottom so the user can see the now visible “Transfer to logbook” button.
284
+ *
285
+ * Steps:
286
+ * 1. Set the isRecommendationDisplayed state variable to be true.
287
+ * 2. As a callback to the setState() method, define a new anonymous function that calls the scrollToEnd() method
288
+ * of the scrollView member, with the animated argument set to true.
289
+ * This ensures that the scroll event happens after all other events that get queued to happen at the same time,
290
+ * so all relevant elements are visible on the screen and the scroll happens reliably.
291
+ */
292
+ handleNoRecentInsulin: () => void;
293
+ /**
294
+ * Handle what happens when the user changes the content of the additional carbohydrates input field.
295
+ *
296
+ * Steps:
297
+ * 1. Set the enteredCarbs state variable to the value of the enteredCarbs argument.
298
+ * 2. As a callback to the setState() method, define a new anonymous function that calls the recalculateInsulin() function using
299
+ * a copy of the calculatorParams prop where the carbohydrates property has been overwritten to be
300
+ * the sum of the carbohydrates property of the calculatorParams prop and the enteredCarbs argument.
301
+ * @param enteredCarbs The amount of carbohydrates in grams that has been entered in the additional carbohydrates input field.
302
+ */
303
+ updateCarbRecommendation: (enteredCarbs: number) => void;
304
+ /**
305
+ * Handle what happens when the cross button by the additional carbohydrates button is tapped.
306
+ *
307
+ * Steps:
308
+ * 1. Set both the enteredCarbs and the carbRecommendation state variables to null.
309
+ * 2. As a callback to the setState() method, define a new anonymous function that calls the recalculateInsulin() function using a copy of the calculatorParams prop.
310
+ */
311
+ removeCarbRecommendation: () => void;
312
+ /**
313
+ * Handle what happens when the user is recommended to eat additional carbohydrates but taps the decline button.
314
+ *
315
+ * Steps:
316
+ * 1. Call the hideAttentionModal() method.
317
+ * 2. Call the removeCarbRecommendation() method.
318
+ * 3. Call the carbRecommendationAnswer() prop callback function with false as argument.
319
+ */
320
+ declineCarbRecommendation: () => void;
321
+ /**
322
+ * Handle what happens when the user is recommended to eat additional carbohydrates and they tap the accept button.
323
+ *
324
+ * Steps:
325
+ * 1. Call the hideAttentionModal() method.
326
+ * 2. Call the carbRecommendationAnswer() prop callback function with true as argument.
327
+ */
328
+ acceptCarbRecommendation: () => void;
329
+ /**
330
+ * Handles what happens when the user hits the “close calculation”-button on the exit modal.
331
+ *
332
+ * Steps:
333
+ * 1. If the showExitModal state variable is true then call the hideExitModal() method. Otherwise, call the hideTimeoutModal() method
334
+ * 2. Call the closeCalculationCallback prop callback function.
335
+ */
336
+ closeCalculation: () => void;
337
+ /**
338
+ * Close the current recommendation and start a new bolus calculation.
339
+ *
340
+ * Steps:
341
+ * 1. Call the hideTimeoutModal() method.
342
+ * 2. Call the restartCalculation prop callback function.
343
+ */
344
+ restartCalculation: () => void;
345
+ /**
346
+ * Used as a callback function for the Emotion component to update the state when a mood icon is tapped.
347
+ *
348
+ * Steps:
349
+ * 1. Set the selectedMood state variable to the value of the selectedMood argument.
350
+ * @param selectedMood he mood that should be selected going forward or null if no mood should be selected.
351
+ */
352
+ handleMoodSelected: (selectedMood: IState["selectedMood"]) => void;
353
+ /**
354
+ * Handle what happens when the user changes the content of the insulin input field.
355
+ *
356
+ * Steps:
357
+ * 1. Set the enteredInsulin state variable to the value of the enteredInsulin argument.
358
+ * @param enteredInsulin The amount of insulin (in units) that has been entered in the insulin input field.
359
+ */
360
+ updateInsulinRecommendation: (enteredInsulin: number) => void;
361
+ /**
362
+ * Handle what happens when the “Transfer to Logbook” button is pressed.
363
+ * Namely, the entered data should be saved in a logbook entry and the recommendation screen should be closed.
364
+ *
365
+ * Steps:
366
+ * 1. Unpack the enteredCarbs, enteredInsulin, insulinRecommendation, remeasureTime, and showExitModal state variables
367
+ * 2. Create an IResult object called carbs consisting of suggestedCarbs and enteredCarbs.
368
+ * 3. Create an IResult object called Insulin consisting of insulinRecommendation and enteredInsulin.
369
+ * 4. If showExitModal is true then call the hideExitModal() method. otherwise call the hideTimeoutModal() method.
370
+ * 5. Call the transferToLogbook prop callback function with the following arguments:
371
+ * - Set the carbs argument to the carbs IResult object.
372
+ * - Set the insulin argument to the insulin IResult object.
373
+ * - Set the reminder argument to the remeasureTime state variable.
374
+ * - Set the recommendationDate argument to the recommendationDate member variable.
375
+ */
376
+ handleTransfer: () => void;
377
+ /**
378
+ * Get the attention message that should be displayed for the user to draw their attention to noteworthy circumstances regarding their current blood glucose level.
379
+ *
380
+ * Steps:
381
+ * 1. Unpack calculatorParams and latestLogbookFrom6Hours from the props.
382
+ * 2. Unpack currentBGL and activity from calculatorparams.
383
+ * 3. Get bgLevel, the categorisation of the blood glucose level, by calling the getBGLevel() function with the currentBGL and latestLogbookFrom6Hours as arguments.
384
+ * 4. Return the attention message that is returned when calling getAttentionMessage() using bgLevel and activity as arguments.
385
+ * @returns A string describing what the user needs to be aware of regarding their current blood glucose level.
386
+ * If there is nothing noteworthy, null will be returned instead.
387
+ */
388
+ getBGLevelAttentionMessage: () => string | null;
389
+ /**
390
+ * Get the initial value for the remeasurement reminder time slider depending on the user’s entered information.
391
+ *
392
+ * Steps:
393
+ * 1. Unpack calculatorParams, userReminder, and latestLogbookFrom6Hours from the props.
394
+ * 2. Unpack currentBGL, activity, and carbohydrates from calculatorParams.
395
+ * 3. Get bgLevel, the categorisation of the blood glucose level, by calling the getBGLevel() function with the currentBGL and latestLogbookFrom6Hours as arguments.
396
+ * 4. Return the attention message that is returned when calling getReminder() using bgLevel, carbohydrates, userReminder, and activity as arguments.
397
+ * @returns The time interval in hours that should be used as the initial value for the remeasurement reminder time slider.
398
+ */
399
+ getBGLevelRemeasurementReminder: () => number;
400
+ /**
401
+ * Get the attention message that should be displayed to the user to let them know that the insulin recommendation that
402
+ * is being displayed to them was limited by the maximum insulin threshold.
403
+ *
404
+ * Steps:
405
+ * 1. Unpack the wasLimited and activityReduction state variables.
406
+ * 2. Return the result from calling getLimitationMessage() with wasLimited and activityReduction as arguments.
407
+ * @returns A message to inform the user how the insulin recommendation was limited. If there is no limitation attention message, null will be returned instead.
408
+ */
409
+ getLimitationAttentionMessage: () => string | null;
410
+ /** Render a JSX element for displaying the insulin recommendation screen. */
411
+ render(): JSX.Element;
412
+ }
413
+ export {};