@hedia/recommendation-screen 2.1.15 → 2.1.17-alpha

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 (105) hide show
  1. package/.github/workflows/publish-alpha.yaml +58 -0
  2. package/.github/workflows/publish.yml +3 -0
  3. package/coverage/clover.xml +586 -588
  4. package/coverage/coverage-final.json +27 -27
  5. package/coverage/lcov-report/index.html +7 -7
  6. package/coverage/lcov-report/src/RecommendationScreen.tsx.html +979 -10
  7. package/coverage/lcov-report/src/__tests__/index.html +1 -1
  8. package/coverage/lcov-report/src/__tests__/utils.tsx.html +29 -8
  9. package/coverage/lcov-report/src/components/Header.tsx.html +13 -4
  10. package/coverage/lcov-report/src/components/InfoBars.tsx.html +86 -2
  11. package/coverage/lcov-report/src/components/InvisibleNumberInput.tsx.html +196 -4
  12. package/coverage/lcov-report/src/components/LimitationMessage.tsx.html +20 -2
  13. package/coverage/lcov-report/src/components/LineSeparator.tsx.html +12 -3
  14. package/coverage/lcov-report/src/components/RecentInsulin.tsx.html +30 -3
  15. package/coverage/lcov-report/src/components/RecommendationModal.tsx.html +184 -4
  16. package/coverage/lcov-report/src/components/RecommendedCarbs.tsx.html +205 -7
  17. package/coverage/lcov-report/src/components/RecommendedInsulin.tsx.html +187 -19
  18. package/coverage/lcov-report/src/components/Remeasure.tsx.html +114 -3
  19. package/coverage/lcov-report/src/components/TransferToLogbook.tsx.html +67 -4
  20. package/coverage/lcov-report/src/components/TwoOptionModal.tsx.html +34 -10
  21. package/coverage/lcov-report/src/components/activity/Activity.tsx.html +58 -7
  22. package/coverage/lcov-report/src/components/activity/ActivityIcon.tsx.html +42 -3
  23. package/coverage/lcov-report/src/components/activity/ActivityIntensity.tsx.html +30 -6
  24. package/coverage/lcov-report/src/components/activity/index.html +1 -1
  25. package/coverage/lcov-report/src/components/index.html +10 -10
  26. package/coverage/lcov-report/src/components/mood/Emotion.tsx.html +78 -3
  27. package/coverage/lcov-report/src/components/mood/MoodIcon.tsx.html +80 -5
  28. package/coverage/lcov-report/src/components/mood/index.html +1 -1
  29. package/coverage/lcov-report/src/index.html +1 -1
  30. package/coverage/lcov-report/src/locale/i18nUtils.ts.html +41 -2
  31. package/coverage/lcov-report/src/locale/index.html +1 -1
  32. package/coverage/lcov-report/src/utils/AttentionMessages.tsx.html +231 -3
  33. package/coverage/lcov-report/src/utils/Constants.ts.html +71 -2
  34. package/coverage/lcov-report/src/utils/RecommendationError.tsx.html +89 -2
  35. package/coverage/lcov-report/src/utils/RecommendationUtils.ts.html +306 -9
  36. package/coverage/lcov-report/src/utils/Translations.ts.html +27 -3
  37. package/coverage/lcov-report/src/utils/Utils.ts.html +278 -2
  38. package/coverage/lcov-report/src/utils/Validations.ts.html +716 -14
  39. package/coverage/lcov-report/src/utils/index.html +1 -1
  40. package/coverage/lcov.info +1158 -1164
  41. package/ignore-git.sh +1 -0
  42. package/ignore-publish.sh +1 -0
  43. package/package.json +5 -3
  44. package/pre-release.sh +5 -0
  45. package/src/RecommendationScreen.d.ts +323 -6
  46. package/src/RecommendationScreen.js +234 -1
  47. package/src/__tests__/RecommendationScreen.test.js +1 -1
  48. package/src/__tests__/utils.d.ts +5 -5
  49. package/src/__tests__/utils.js +1 -1
  50. package/src/components/Header.d.ts +4 -43
  51. package/src/components/Header.js +3 -1
  52. package/src/components/Icon.d.ts +9 -2
  53. package/src/components/Icon.js +6 -1
  54. package/src/components/InfoBars.d.ts +28 -0
  55. package/src/components/InfoBars.js +23 -0
  56. package/src/components/InvisibleNumberInput.d.ts +66 -3
  57. package/src/components/InvisibleNumberInput.js +53 -0
  58. package/src/components/LimitationMessage.d.ts +6 -0
  59. package/src/components/LimitationMessage.js +4 -0
  60. package/src/components/LineSeparator.d.ts +4 -2
  61. package/src/components/LineSeparator.js +2 -0
  62. package/src/components/RecentInsulin.d.ts +10 -2
  63. package/src/components/RecentInsulin.js +7 -0
  64. package/src/components/RecommendationModal.d.ts +61 -3
  65. package/src/components/RecommendationModal.js +45 -0
  66. package/src/components/RecommendedCarbs.d.ts +71 -4
  67. package/src/components/RecommendedCarbs.js +56 -0
  68. package/src/components/RecommendedInsulin.d.ts +66 -4
  69. package/src/components/RecommendedInsulin.js +51 -5
  70. package/src/components/Remeasure.d.ts +38 -2
  71. package/src/components/Remeasure.js +31 -0
  72. package/src/components/TransferToLogbook.d.ts +23 -3
  73. package/src/components/TransferToLogbook.js +18 -0
  74. package/src/components/TwoOptionModal.d.ts +12 -1
  75. package/src/components/TwoOptionModal.js +3 -3
  76. package/src/components/activity/Activity.d.ts +21 -5
  77. package/src/components/activity/Activity.js +14 -0
  78. package/src/components/activity/ActivityIcon.d.ts +15 -0
  79. package/src/components/activity/ActivityIcon.js +14 -1
  80. package/src/components/activity/ActivityIntensity.d.ts +11 -4
  81. package/src/components/activity/ActivityIntensity.js +7 -0
  82. package/src/components/mood/Emotion.d.ts +26 -1
  83. package/src/components/mood/Emotion.js +20 -0
  84. package/src/components/mood/MoodIcon.d.ts +28 -2
  85. package/src/components/mood/MoodIcon.js +20 -2
  86. package/src/locale/i18nUtils.d.ts +13 -0
  87. package/src/locale/i18nUtils.js +13 -0
  88. package/src/types/enum.d.ts +10 -0
  89. package/src/types/enum.js +9 -0
  90. package/src/types/types.d.ts +9 -7
  91. package/src/utils/AttentionMessages.d.ts +65 -0
  92. package/src/utils/AttentionMessages.js +65 -1
  93. package/src/utils/Constants.d.ts +23 -0
  94. package/src/utils/Constants.js +23 -0
  95. package/src/utils/RecommendationError.d.ts +29 -0
  96. package/src/utils/RecommendationError.js +29 -0
  97. package/src/utils/RecommendationUtils.d.ts +98 -6
  98. package/src/utils/RecommendationUtils.js +92 -0
  99. package/src/utils/Translations.d.ts +7 -0
  100. package/src/utils/Translations.js +7 -0
  101. package/src/utils/Utils.d.ts +92 -0
  102. package/src/utils/Utils.js +92 -0
  103. package/src/utils/Validations.d.ts +232 -9
  104. package/src/utils/Validations.js +225 -2
  105. package/typedoc.json +13 -0
@@ -25,7 +25,7 @@
25
25
  <div class='fl pad1y space-right2'>
26
26
  <span class="strong">100% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>28/28</span>
28
+ <span class='fraction'>27/27</span>
29
29
  </div>
30
30
 
31
31
 
@@ -39,14 +39,14 @@
39
39
  <div class='fl pad1y space-right2'>
40
40
  <span class="strong">100% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>7/7</span>
42
+ <span class='fraction'>6/6</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
47
  <span class="strong">100% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>28/28</span>
49
+ <span class='fraction'>27/27</span>
50
50
  </div>
51
51
 
52
52
 
@@ -234,7 +234,63 @@
234
234
  <a name='L175'></a><a href='#L175'>175</a>
235
235
  <a name='L176'></a><a href='#L176'>176</a>
236
236
  <a name='L177'></a><a href='#L177'>177</a>
237
- <a name='L178'></a><a href='#L178'>178</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
237
+ <a name='L178'></a><a href='#L178'>178</a>
238
+ <a name='L179'></a><a href='#L179'>179</a>
239
+ <a name='L180'></a><a href='#L180'>180</a>
240
+ <a name='L181'></a><a href='#L181'>181</a>
241
+ <a name='L182'></a><a href='#L182'>182</a>
242
+ <a name='L183'></a><a href='#L183'>183</a>
243
+ <a name='L184'></a><a href='#L184'>184</a>
244
+ <a name='L185'></a><a href='#L185'>185</a>
245
+ <a name='L186'></a><a href='#L186'>186</a>
246
+ <a name='L187'></a><a href='#L187'>187</a>
247
+ <a name='L188'></a><a href='#L188'>188</a>
248
+ <a name='L189'></a><a href='#L189'>189</a>
249
+ <a name='L190'></a><a href='#L190'>190</a>
250
+ <a name='L191'></a><a href='#L191'>191</a>
251
+ <a name='L192'></a><a href='#L192'>192</a>
252
+ <a name='L193'></a><a href='#L193'>193</a>
253
+ <a name='L194'></a><a href='#L194'>194</a>
254
+ <a name='L195'></a><a href='#L195'>195</a>
255
+ <a name='L196'></a><a href='#L196'>196</a>
256
+ <a name='L197'></a><a href='#L197'>197</a>
257
+ <a name='L198'></a><a href='#L198'>198</a>
258
+ <a name='L199'></a><a href='#L199'>199</a>
259
+ <a name='L200'></a><a href='#L200'>200</a>
260
+ <a name='L201'></a><a href='#L201'>201</a>
261
+ <a name='L202'></a><a href='#L202'>202</a>
262
+ <a name='L203'></a><a href='#L203'>203</a>
263
+ <a name='L204'></a><a href='#L204'>204</a>
264
+ <a name='L205'></a><a href='#L205'>205</a>
265
+ <a name='L206'></a><a href='#L206'>206</a>
266
+ <a name='L207'></a><a href='#L207'>207</a>
267
+ <a name='L208'></a><a href='#L208'>208</a>
268
+ <a name='L209'></a><a href='#L209'>209</a>
269
+ <a name='L210'></a><a href='#L210'>210</a>
270
+ <a name='L211'></a><a href='#L211'>211</a>
271
+ <a name='L212'></a><a href='#L212'>212</a>
272
+ <a name='L213'></a><a href='#L213'>213</a>
273
+ <a name='L214'></a><a href='#L214'>214</a>
274
+ <a name='L215'></a><a href='#L215'>215</a>
275
+ <a name='L216'></a><a href='#L216'>216</a>
276
+ <a name='L217'></a><a href='#L217'>217</a>
277
+ <a name='L218'></a><a href='#L218'>218</a>
278
+ <a name='L219'></a><a href='#L219'>219</a>
279
+ <a name='L220'></a><a href='#L220'>220</a>
280
+ <a name='L221'></a><a href='#L221'>221</a>
281
+ <a name='L222'></a><a href='#L222'>222</a>
282
+ <a name='L223'></a><a href='#L223'>223</a>
283
+ <a name='L224'></a><a href='#L224'>224</a>
284
+ <a name='L225'></a><a href='#L225'>225</a>
285
+ <a name='L226'></a><a href='#L226'>226</a>
286
+ <a name='L227'></a><a href='#L227'>227</a>
287
+ <a name='L228'></a><a href='#L228'>228</a>
288
+ <a name='L229'></a><a href='#L229'>229</a>
289
+ <a name='L230'></a><a href='#L230'>230</a>
290
+ <a name='L231'></a><a href='#L231'>231</a>
291
+ <a name='L232'></a><a href='#L232'>232</a>
292
+ <a name='L233'></a><a href='#L233'>233</a>
293
+ <a name='L234'></a><a href='#L234'>234</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
238
294
  <span class="cline-any cline-neutral">&nbsp;</span>
239
295
  <span class="cline-any cline-neutral">&nbsp;</span>
240
296
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -264,13 +320,21 @@
264
320
  <span class="cline-any cline-neutral">&nbsp;</span>
265
321
  <span class="cline-any cline-neutral">&nbsp;</span>
266
322
  <span class="cline-any cline-neutral">&nbsp;</span>
267
- <span class="cline-any cline-yes">2x</span>
268
323
  <span class="cline-any cline-neutral">&nbsp;</span>
269
324
  <span class="cline-any cline-neutral">&nbsp;</span>
270
325
  <span class="cline-any cline-neutral">&nbsp;</span>
271
326
  <span class="cline-any cline-neutral">&nbsp;</span>
272
327
  <span class="cline-any cline-neutral">&nbsp;</span>
273
- <span class="cline-any cline-yes">81x</span>
328
+ <span class="cline-any cline-neutral">&nbsp;</span>
329
+ <span class="cline-any cline-neutral">&nbsp;</span>
330
+ <span class="cline-any cline-neutral">&nbsp;</span>
331
+ <span class="cline-any cline-neutral">&nbsp;</span>
332
+ <span class="cline-any cline-neutral">&nbsp;</span>
333
+ <span class="cline-any cline-neutral">&nbsp;</span>
334
+ <span class="cline-any cline-yes">2x</span>
335
+ <span class="cline-any cline-neutral">&nbsp;</span>
336
+ <span class="cline-any cline-neutral">&nbsp;</span>
337
+ <span class="cline-any cline-neutral">&nbsp;</span>
274
338
  <span class="cline-any cline-neutral">&nbsp;</span>
275
339
  <span class="cline-any cline-yes">81x</span>
276
340
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -278,16 +342,47 @@
278
342
  <span class="cline-any cline-neutral">&nbsp;</span>
279
343
  <span class="cline-any cline-neutral">&nbsp;</span>
280
344
  <span class="cline-any cline-neutral">&nbsp;</span>
345
+ <span class="cline-any cline-neutral">&nbsp;</span>
346
+ <span class="cline-any cline-neutral">&nbsp;</span>
347
+ <span class="cline-any cline-neutral">&nbsp;</span>
348
+ <span class="cline-any cline-neutral">&nbsp;</span>
349
+ <span class="cline-any cline-neutral">&nbsp;</span>
350
+ <span class="cline-any cline-neutral">&nbsp;</span>
351
+ <span class="cline-any cline-neutral">&nbsp;</span>
352
+ <span class="cline-any cline-neutral">&nbsp;</span>
353
+ <span class="cline-any cline-neutral">&nbsp;</span>
354
+ <span class="cline-any cline-neutral">&nbsp;</span>
355
+ <span class="cline-any cline-neutral">&nbsp;</span>
356
+ <span class="cline-any cline-neutral">&nbsp;</span>
281
357
  <span class="cline-any cline-yes">70x</span>
282
358
  <span class="cline-any cline-yes">70x</span>
283
359
  <span class="cline-any cline-yes">2x</span>
284
360
  <span class="cline-any cline-neutral">&nbsp;</span>
285
361
  <span class="cline-any cline-neutral">&nbsp;</span>
286
362
  <span class="cline-any cline-neutral">&nbsp;</span>
363
+ <span class="cline-any cline-neutral">&nbsp;</span>
364
+ <span class="cline-any cline-neutral">&nbsp;</span>
365
+ <span class="cline-any cline-neutral">&nbsp;</span>
366
+ <span class="cline-any cline-neutral">&nbsp;</span>
367
+ <span class="cline-any cline-neutral">&nbsp;</span>
368
+ <span class="cline-any cline-neutral">&nbsp;</span>
369
+ <span class="cline-any cline-neutral">&nbsp;</span>
287
370
  <span class="cline-any cline-yes">81x</span>
288
371
  <span class="cline-any cline-yes">1x</span>
289
372
  <span class="cline-any cline-neutral">&nbsp;</span>
290
373
  <span class="cline-any cline-neutral">&nbsp;</span>
374
+ <span class="cline-any cline-neutral">&nbsp;</span>
375
+ <span class="cline-any cline-neutral">&nbsp;</span>
376
+ <span class="cline-any cline-neutral">&nbsp;</span>
377
+ <span class="cline-any cline-neutral">&nbsp;</span>
378
+ <span class="cline-any cline-neutral">&nbsp;</span>
379
+ <span class="cline-any cline-neutral">&nbsp;</span>
380
+ <span class="cline-any cline-neutral">&nbsp;</span>
381
+ <span class="cline-any cline-neutral">&nbsp;</span>
382
+ <span class="cline-any cline-neutral">&nbsp;</span>
383
+ <span class="cline-any cline-neutral">&nbsp;</span>
384
+ <span class="cline-any cline-neutral">&nbsp;</span>
385
+ <span class="cline-any cline-neutral">&nbsp;</span>
291
386
  <span class="cline-any cline-yes">81x</span>
292
387
  <span class="cline-any cline-neutral">&nbsp;</span>
293
388
  <span class="cline-any cline-yes">18x</span>
@@ -297,6 +392,19 @@
297
392
  <span class="cline-any cline-yes">18x</span>
298
393
  <span class="cline-any cline-neutral">&nbsp;</span>
299
394
  <span class="cline-any cline-neutral">&nbsp;</span>
395
+ <span class="cline-any cline-neutral">&nbsp;</span>
396
+ <span class="cline-any cline-neutral">&nbsp;</span>
397
+ <span class="cline-any cline-neutral">&nbsp;</span>
398
+ <span class="cline-any cline-neutral">&nbsp;</span>
399
+ <span class="cline-any cline-neutral">&nbsp;</span>
400
+ <span class="cline-any cline-neutral">&nbsp;</span>
401
+ <span class="cline-any cline-neutral">&nbsp;</span>
402
+ <span class="cline-any cline-neutral">&nbsp;</span>
403
+ <span class="cline-any cline-neutral">&nbsp;</span>
404
+ <span class="cline-any cline-neutral">&nbsp;</span>
405
+ <span class="cline-any cline-neutral">&nbsp;</span>
406
+ <span class="cline-any cline-neutral">&nbsp;</span>
407
+ <span class="cline-any cline-neutral">&nbsp;</span>
300
408
  <span class="cline-any cline-yes">81x</span>
301
409
  <span class="cline-any cline-yes">29x</span>
302
410
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -316,6 +424,10 @@
316
424
  <span class="cline-any cline-yes">16x</span>
317
425
  <span class="cline-any cline-neutral">&nbsp;</span>
318
426
  <span class="cline-any cline-neutral">&nbsp;</span>
427
+ <span class="cline-any cline-neutral">&nbsp;</span>
428
+ <span class="cline-any cline-neutral">&nbsp;</span>
429
+ <span class="cline-any cline-neutral">&nbsp;</span>
430
+ <span class="cline-any cline-neutral">&nbsp;</span>
319
431
  <span class="cline-any cline-yes">81x</span>
320
432
  <span class="cline-any cline-yes">151x</span>
321
433
  <span class="cline-any cline-yes">151x</span>
@@ -426,34 +538,54 @@ import InvisibleNumberInput from "./InvisibleNumberInput";
426
538
  &nbsp;
427
539
  const { RecommendedInsulinTestIds } = Testing.Id;
428
540
  &nbsp;
429
- interface IProps {
430
- // Values
541
+ export interface IProps {
542
+ /** The amount of insulin in units to display to the user as a recommendation. */
431
543
  insulinRecommendation: number;
544
+ /** The amount of insulin introduced by the user. */
432
545
  enteredInsulin: number | null;
546
+ /**
547
+ * The factor by which the recommendation was multiplied to get the reduced insulin amount.
548
+ * Used by the RecommendedInsulin component to check that the user’s input doesn’t exceed the maximum allowed.
549
+ * If no activity has been entered, this prop should be null.
550
+ * */
433
551
  activityReduction: number | null;
552
+ /** Used to determine how the insulin amount should be rounded. */
434
553
  injectionMethod: UserSettings.Enums.InjectionMethod;
435
554
  &nbsp;
436
- // Callbacks
555
+ /**
556
+ * Callback function taking a number as argument and giving no return value.
557
+ * To be called with the new value every time the content of the insulin input field gets changed.
558
+ */
437
559
  updateRecommendedInsulin(value: number): void;
438
560
  }
439
561
  &nbsp;
440
- interface IState {
562
+ export interface IState {
563
+ /** The entered amount of insulin as a string. */
441
564
  partialInput?: string;
442
565
  }
443
566
  &nbsp;
444
567
  const SAFETY_INSULIN_LIMIT = BolusCalculator.Constants.SAFETY_INSULIN_LIMIT;
445
568
  &nbsp;
569
+ /** Input field for displaying the entered amount of insulin (which defaults to HDA’s recommendation) and allowing the user to edit it. */
446
570
  export default class RecommendedInsulin extends React.Component&lt;IProps, IState&gt; {
571
+ /** Initialise the state partialInput variable with undefined */
572
+ public state: IState = {
573
+ partialInput: undefined,
574
+ };
575
+ /**
576
+ * Function taking no arguments and returning no value.
577
+ * Will be bound to the function that activates input for InvisibleNumberInput when that component has been mounted.
578
+ */
447
579
  public callbackInput?: () =&gt; void;
448
580
  &nbsp;
449
- constructor(props: IProps) {
450
- super(props);
451
- &nbsp;
452
- this.state = {
453
- partialInput: undefined,
454
- };
455
- }
456
- &nbsp;
581
+ /**
582
+ * Called immediately after updating occurs. Not called for the initial render.
583
+ * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
584
+ *
585
+ * Steps:
586
+ * 1. If the value of the enteredInsulin prop was changed, set the partialInput state variable to the new value.
587
+ * @param prevProps The previous component props
588
+ */
457
589
  public componentDidUpdate(prevProps: IProps): void {
458
590
  const { enteredInsulin } = this.props;
459
591
  if (prevProps.enteredInsulin !== enteredInsulin) {
@@ -461,10 +593,29 @@ export default class RecommendedInsulin extends React.Component&lt;IProps, IStat
461
593
  }
462
594
  }
463
595
  &nbsp;
596
+ /**
597
+ * Handle what should happen when the InsulinRecommendation component has been pressed.
598
+ * Uses the InvisibleNumberInput child component to enable the user to input the amount of insulin that hey are taking.
599
+ *
600
+ * Steps:
601
+ * 1. Call the callbackInput() member method.
602
+ */
464
603
  public handleOnPress = (): void =&gt; {
465
604
  this.callbackInput?.();
466
605
  };
467
606
  &nbsp;
607
+ /**
608
+ * Passed to the InvisibleNumberInput child component as a callback function to be called every time the content of the input field changes.
609
+ *
610
+ * Steps:
611
+ * 1. Assign a new local variable, replacedZero, with the value of the insulin argument string
612
+ * except for the first character if insulin is longer than 1 character and starts with a '0' but doesn’t start with ‘0.’.
613
+ * Otherwise set it to insulin. This would be better handled by converting it to a number: replacedZero = Number(insulin);
614
+ * 2. Save replacedZero to the partialInput state variable.
615
+ * 3. Return replacedZero
616
+ * @param insulin The contents of the input field.
617
+ * @returns The partially cleaned input.
618
+ */
468
619
  public updatePartially = (insulin: string): string =&gt; {
469
620
  const replacedZero =
470
621
  insulin.length &gt; 1 &amp;&amp; insulin.startsWith(`0`) &amp;&amp; !insulin.startsWith(`0.`) ? insulin.substring(1) : insulin;
@@ -474,6 +625,19 @@ export default class RecommendedInsulin extends React.Component&lt;IProps, IStat
474
625
  return replacedZero;
475
626
  };
476
627
  &nbsp;
628
+ /**
629
+ * Handle what happens when input in the InvisibleNumberInput child component is completed.
630
+ *
631
+ * Steps:
632
+ * 1. Get the rounded insulin amount using the value argument and the injectionMethod prop as arguments for the Utils.roundValue() function.
633
+ * 2. Get the adjusted safety insulin limit (due to activity) by multiplying the activity reduction factor (which is 1 minus the activityReduction prop) with the SAFETY_INSULIN_LIMIT constant.
634
+ * 3. If the rounded value exceeds the adjusted safety threshold:
635
+ * - Call the updatePartially() method with the adjusted safety threshold to set the insulin amount to the capped value.
636
+ * - Return an Alert with a message about the insulin limit.
637
+ * 4. Call the updatePartially() method with the rounded value to set the entered insulin value.
638
+ * 5. Call the updateRecommendedInsulin callback function prop with rounded as the argument to report back the updated insulin amount to the parent RecommendationScreen component.
639
+ * @param value The numerical value of the input field at completion.
640
+ */
477
641
  public handleUpdatedInsulin = (value: number): void =&gt; {
478
642
  const rounded = Utils.roundValue(value, this.props.injectionMethod);
479
643
  &nbsp;
@@ -493,6 +657,10 @@ export default class RecommendedInsulin extends React.Component&lt;IProps, IStat
493
657
  this.props.updateRecommendedInsulin(rounded);
494
658
  };
495
659
  &nbsp;
660
+ /**
661
+ * Render a JSX element to display the insulin input field with the current insulin amount value
662
+ * and using an InvisibleNumberInput component to enable input when the insulin amount is tapped.
663
+ */
496
664
  public render = (): JSX.Element =&gt; {
497
665
  const paddingBottom = Platform.OS === `ios` ? `3%` : `1%`;
498
666
  const shownInsulin = this.state.partialInput ?? this.props.insulinRecommendation ?? `0`;
@@ -595,7 +763,7 @@ const recommendedInsulinStyles = StyleSheet.create({
595
763
  <div class='footer quiet pad2 space-top1 center small'>
596
764
  Code coverage generated by
597
765
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
598
- at Fri Jul 09 2021 12:31:53 GMT+0000 (Coordinated Universal Time)
766
+ at Mon Aug 16 2021 10:59:26 GMT+0000 (Coordinated Universal Time)
599
767
  </div>
600
768
  </div>
601
769
  <script src="../../prettify.js"></script>
@@ -177,7 +177,65 @@
177
177
  <a name='L118'></a><a href='#L118'>118</a>
178
178
  <a name='L119'></a><a href='#L119'>119</a>
179
179
  <a name='L120'></a><a href='#L120'>120</a>
180
- <a name='L121'></a><a href='#L121'>121</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
180
+ <a name='L121'></a><a href='#L121'>121</a>
181
+ <a name='L122'></a><a href='#L122'>122</a>
182
+ <a name='L123'></a><a href='#L123'>123</a>
183
+ <a name='L124'></a><a href='#L124'>124</a>
184
+ <a name='L125'></a><a href='#L125'>125</a>
185
+ <a name='L126'></a><a href='#L126'>126</a>
186
+ <a name='L127'></a><a href='#L127'>127</a>
187
+ <a name='L128'></a><a href='#L128'>128</a>
188
+ <a name='L129'></a><a href='#L129'>129</a>
189
+ <a name='L130'></a><a href='#L130'>130</a>
190
+ <a name='L131'></a><a href='#L131'>131</a>
191
+ <a name='L132'></a><a href='#L132'>132</a>
192
+ <a name='L133'></a><a href='#L133'>133</a>
193
+ <a name='L134'></a><a href='#L134'>134</a>
194
+ <a name='L135'></a><a href='#L135'>135</a>
195
+ <a name='L136'></a><a href='#L136'>136</a>
196
+ <a name='L137'></a><a href='#L137'>137</a>
197
+ <a name='L138'></a><a href='#L138'>138</a>
198
+ <a name='L139'></a><a href='#L139'>139</a>
199
+ <a name='L140'></a><a href='#L140'>140</a>
200
+ <a name='L141'></a><a href='#L141'>141</a>
201
+ <a name='L142'></a><a href='#L142'>142</a>
202
+ <a name='L143'></a><a href='#L143'>143</a>
203
+ <a name='L144'></a><a href='#L144'>144</a>
204
+ <a name='L145'></a><a href='#L145'>145</a>
205
+ <a name='L146'></a><a href='#L146'>146</a>
206
+ <a name='L147'></a><a href='#L147'>147</a>
207
+ <a name='L148'></a><a href='#L148'>148</a>
208
+ <a name='L149'></a><a href='#L149'>149</a>
209
+ <a name='L150'></a><a href='#L150'>150</a>
210
+ <a name='L151'></a><a href='#L151'>151</a>
211
+ <a name='L152'></a><a href='#L152'>152</a>
212
+ <a name='L153'></a><a href='#L153'>153</a>
213
+ <a name='L154'></a><a href='#L154'>154</a>
214
+ <a name='L155'></a><a href='#L155'>155</a>
215
+ <a name='L156'></a><a href='#L156'>156</a>
216
+ <a name='L157'></a><a href='#L157'>157</a>
217
+ <a name='L158'></a><a href='#L158'>158</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
218
+ <span class="cline-any cline-neutral">&nbsp;</span>
219
+ <span class="cline-any cline-neutral">&nbsp;</span>
220
+ <span class="cline-any cline-neutral">&nbsp;</span>
221
+ <span class="cline-any cline-neutral">&nbsp;</span>
222
+ <span class="cline-any cline-neutral">&nbsp;</span>
223
+ <span class="cline-any cline-neutral">&nbsp;</span>
224
+ <span class="cline-any cline-neutral">&nbsp;</span>
225
+ <span class="cline-any cline-neutral">&nbsp;</span>
226
+ <span class="cline-any cline-neutral">&nbsp;</span>
227
+ <span class="cline-any cline-neutral">&nbsp;</span>
228
+ <span class="cline-any cline-neutral">&nbsp;</span>
229
+ <span class="cline-any cline-neutral">&nbsp;</span>
230
+ <span class="cline-any cline-neutral">&nbsp;</span>
231
+ <span class="cline-any cline-neutral">&nbsp;</span>
232
+ <span class="cline-any cline-neutral">&nbsp;</span>
233
+ <span class="cline-any cline-neutral">&nbsp;</span>
234
+ <span class="cline-any cline-neutral">&nbsp;</span>
235
+ <span class="cline-any cline-neutral">&nbsp;</span>
236
+ <span class="cline-any cline-neutral">&nbsp;</span>
237
+ <span class="cline-any cline-neutral">&nbsp;</span>
238
+ <span class="cline-any cline-neutral">&nbsp;</span>
181
239
  <span class="cline-any cline-neutral">&nbsp;</span>
182
240
  <span class="cline-any cline-neutral">&nbsp;</span>
183
241
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -200,16 +258,32 @@
200
258
  <span class="cline-any cline-neutral">&nbsp;</span>
201
259
  <span class="cline-any cline-neutral">&nbsp;</span>
202
260
  <span class="cline-any cline-neutral">&nbsp;</span>
261
+ <span class="cline-any cline-neutral">&nbsp;</span>
262
+ <span class="cline-any cline-neutral">&nbsp;</span>
263
+ <span class="cline-any cline-neutral">&nbsp;</span>
264
+ <span class="cline-any cline-neutral">&nbsp;</span>
265
+ <span class="cline-any cline-neutral">&nbsp;</span>
266
+ <span class="cline-any cline-neutral">&nbsp;</span>
203
267
  <span class="cline-any cline-yes">78x</span>
204
268
  <span class="cline-any cline-yes">17x</span>
205
269
  <span class="cline-any cline-yes">17x</span>
206
270
  <span class="cline-any cline-neutral">&nbsp;</span>
207
271
  <span class="cline-any cline-neutral">&nbsp;</span>
272
+ <span class="cline-any cline-neutral">&nbsp;</span>
273
+ <span class="cline-any cline-neutral">&nbsp;</span>
274
+ <span class="cline-any cline-neutral">&nbsp;</span>
275
+ <span class="cline-any cline-neutral">&nbsp;</span>
276
+ <span class="cline-any cline-neutral">&nbsp;</span>
277
+ <span class="cline-any cline-neutral">&nbsp;</span>
208
278
  <span class="cline-any cline-yes">78x</span>
209
279
  <span class="cline-any cline-yes">178x</span>
210
280
  <span class="cline-any cline-neutral">&nbsp;</span>
211
281
  <span class="cline-any cline-neutral">&nbsp;</span>
212
282
  <span class="cline-any cline-neutral">&nbsp;</span>
283
+ <span class="cline-any cline-neutral">&nbsp;</span>
284
+ <span class="cline-any cline-neutral">&nbsp;</span>
285
+ <span class="cline-any cline-neutral">&nbsp;</span>
286
+ <span class="cline-any cline-neutral">&nbsp;</span>
213
287
  <span class="cline-any cline-yes">161x</span>
214
288
  <span class="cline-any cline-yes">161x</span>
215
289
  <span class="cline-any cline-yes">161x</span>
@@ -306,29 +380,66 @@ import { Testing } from "../types/enum";
306
380
  import { BORDER_COLOUR_GREY, BORDER_COLOUR_TEAL } from "../utils/Constants";
307
381
  import { infoStyles } from "./InfoBars";
308
382
  &nbsp;
309
- interface IProps {
383
+ export interface IProps {
384
+ /** The initial time (in hours) after which the user should be reminded to measure their BGL. */
310
385
  remeasureTime: number;
386
+ /**
387
+ * Callback function taking a single number (the new remeasurement time) as argument
388
+ * Function to be called every time the slider component is changed to a new value.
389
+ */
311
390
  onSliderChange(value: number): void;
312
391
  }
313
392
  &nbsp;
393
+ /**
394
+ * The Remeasure component has a slider child component that the user can drag to change
395
+ * when they will get a reminder notification about measuring their BGL again.
396
+ */
314
397
  export default class Remeasure extends React.Component&lt;IProps&gt; {
398
+ /** For holding a reference to the slider component so its initial value can be set (only one time) when the Remeasure component has been mounted. */
315
399
  private slider?: Slider;
316
400
  &nbsp;
401
+ /**
402
+ * Called immediately after a component is mounted. Setting state here will trigger re-rendering.
403
+ *
404
+ * If the value of a slider component in React Native is set to track an outside state,
405
+ * the slider indicator may jump back and forth while updates to the value are propagated through the affected objects and components.
406
+ * Since we don’t need to change the value of the slider from the outside after initialising it to the default value,
407
+ * we simply set the default value (using setNativeProp) upon initialisation instead of using the slider’s normal value prop to set it.
408
+ *
409
+ * Steps:
410
+ * 1. Call the setNativeProps() method on the slider to set its value to the remeasureTime prop.
411
+ */
317
412
  public componentDidMount(): void {
318
413
  this.slider?.setNativeProps({
319
414
  value: this.props.remeasureTime,
320
415
  });
321
416
  }
322
417
  &nbsp;
418
+ /**
419
+ * Steps:
420
+ * 1. Use limitTime() to limit/clamp the value of remeasureTime in the range 0 to 6.
421
+ * 2. Call the onSliderChange prop callback function with the limited value as argument.
422
+ * @param remeasureTime The value of the remeasurement slider.
423
+ */
323
424
  public handleSliderChange = (remeasureTime: number): void =&gt; {
324
425
  const limited = this.limitTime(remeasureTime);
325
426
  this.props.onSliderChange(limited);
326
427
  };
327
428
  &nbsp;
429
+ /**
430
+ * Steps:
431
+ * 1.Use Math.min() and Math.max() to clamp remeasureTime in the range 0 to 6 and return the result.
432
+ * @param remeasureTime The value of the remeasurement slider.
433
+ * @returns The limited remeasurement time in hours
434
+ */
328
435
  public limitTime = (remeasureTime: number): number =&gt; {
329
436
  return Math.min(Math.max(0, remeasureTime), 6);
330
437
  };
331
438
  &nbsp;
439
+ /**
440
+ * Compose a JSX element for displaying the currently selected remeasurement time along
441
+ * with a horizontal slider for changing it in increments of 0.5 hours in the range 0 to 6.
442
+ */
332
443
  public render(): JSX.Element {
333
444
  const measure = this.props.remeasureTime &gt; 0;
334
445
  const limited = this.limitTime(this.props.remeasureTime);
@@ -424,7 +535,7 @@ const variantStyles = StyleSheet.create({
424
535
  <div class='footer quiet pad2 space-top1 center small'>
425
536
  Code coverage generated by
426
537
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
427
- at Fri Jul 09 2021 12:31:53 GMT+0000 (Coordinated Universal Time)
538
+ at Mon Aug 16 2021 10:59:26 GMT+0000 (Coordinated Universal Time)
428
539
  </div>
429
540
  </div>
430
541
  <script src="../../prettify.js"></script>
@@ -157,7 +157,36 @@
157
157
  <a name='L98'></a><a href='#L98'>98</a>
158
158
  <a name='L99'></a><a href='#L99'>99</a>
159
159
  <a name='L100'></a><a href='#L100'>100</a>
160
- <a name='L101'></a><a href='#L101'>101</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
160
+ <a name='L101'></a><a href='#L101'>101</a>
161
+ <a name='L102'></a><a href='#L102'>102</a>
162
+ <a name='L103'></a><a href='#L103'>103</a>
163
+ <a name='L104'></a><a href='#L104'>104</a>
164
+ <a name='L105'></a><a href='#L105'>105</a>
165
+ <a name='L106'></a><a href='#L106'>106</a>
166
+ <a name='L107'></a><a href='#L107'>107</a>
167
+ <a name='L108'></a><a href='#L108'>108</a>
168
+ <a name='L109'></a><a href='#L109'>109</a>
169
+ <a name='L110'></a><a href='#L110'>110</a>
170
+ <a name='L111'></a><a href='#L111'>111</a>
171
+ <a name='L112'></a><a href='#L112'>112</a>
172
+ <a name='L113'></a><a href='#L113'>113</a>
173
+ <a name='L114'></a><a href='#L114'>114</a>
174
+ <a name='L115'></a><a href='#L115'>115</a>
175
+ <a name='L116'></a><a href='#L116'>116</a>
176
+ <a name='L117'></a><a href='#L117'>117</a>
177
+ <a name='L118'></a><a href='#L118'>118</a>
178
+ <a name='L119'></a><a href='#L119'>119</a>
179
+ <a name='L120'></a><a href='#L120'>120</a>
180
+ <a name='L121'></a><a href='#L121'>121</a>
181
+ <a name='L122'></a><a href='#L122'>122</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span>
182
+ <span class="cline-any cline-neutral">&nbsp;</span>
183
+ <span class="cline-any cline-neutral">&nbsp;</span>
184
+ <span class="cline-any cline-neutral">&nbsp;</span>
185
+ <span class="cline-any cline-neutral">&nbsp;</span>
186
+ <span class="cline-any cline-neutral">&nbsp;</span>
187
+ <span class="cline-any cline-neutral">&nbsp;</span>
188
+ <span class="cline-any cline-neutral">&nbsp;</span>
189
+ <span class="cline-any cline-neutral">&nbsp;</span>
161
190
  <span class="cline-any cline-neutral">&nbsp;</span>
162
191
  <span class="cline-any cline-neutral">&nbsp;</span>
163
192
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -179,6 +208,13 @@
179
208
  <span class="cline-any cline-neutral">&nbsp;</span>
180
209
  <span class="cline-any cline-neutral">&nbsp;</span>
181
210
  <span class="cline-any cline-neutral">&nbsp;</span>
211
+ <span class="cline-any cline-neutral">&nbsp;</span>
212
+ <span class="cline-any cline-neutral">&nbsp;</span>
213
+ <span class="cline-any cline-neutral">&nbsp;</span>
214
+ <span class="cline-any cline-neutral">&nbsp;</span>
215
+ <span class="cline-any cline-neutral">&nbsp;</span>
216
+ <span class="cline-any cline-neutral">&nbsp;</span>
217
+ <span class="cline-any cline-neutral">&nbsp;</span>
182
218
  <span class="cline-any cline-yes">65x</span>
183
219
  <span class="cline-any cline-yes">6x</span>
184
220
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -187,6 +223,12 @@
187
223
  <span class="cline-any cline-neutral">&nbsp;</span>
188
224
  <span class="cline-any cline-neutral">&nbsp;</span>
189
225
  <span class="cline-any cline-neutral">&nbsp;</span>
226
+ <span class="cline-any cline-neutral">&nbsp;</span>
227
+ <span class="cline-any cline-neutral">&nbsp;</span>
228
+ <span class="cline-any cline-neutral">&nbsp;</span>
229
+ <span class="cline-any cline-neutral">&nbsp;</span>
230
+ <span class="cline-any cline-neutral">&nbsp;</span>
231
+ <span class="cline-any cline-neutral">&nbsp;</span>
190
232
  <span class="cline-any cline-yes">135x</span>
191
233
  <span class="cline-any cline-yes">45x</span>
192
234
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -265,20 +307,35 @@ import { i18n } from "../locale/i18nUtils";
265
307
  import { Testing } from "../types/enum";
266
308
  import Icon from "./Icon";
267
309
  &nbsp;
268
- interface IProps {
310
+ export interface IProps {
311
+ /** Whether or not the transfer button shall be visible on the screen. */
269
312
  visible: boolean;
313
+ /** To be called when the button is pressed. */
270
314
  transfer(): void;
271
315
  }
272
316
  &nbsp;
273
- interface IState {
317
+ export interface IState {
318
+ /** Keeps track of whether the button was already pressed and thus should be displayed in the inactive visually distinct pressed state. */
274
319
  pressed: boolean;
275
320
  }
276
321
  &nbsp;
322
+ /**
323
+ * Render a button for transferring the recommendation to a logbook entry.
324
+ * The button has a visually distinct pressed state to signal to the user that the button was actually activated before returning to the dashboard screen.
325
+ */
277
326
  export default class TransferToLogbook extends React.Component&lt;IProps, IState&gt; {
327
+ /** Initialise the state pressed variable with false */
278
328
  public state: IState = {
279
329
  pressed: false,
280
330
  };
281
331
  &nbsp;
332
+ /**
333
+ * Handle what happens when the button is pressed.
334
+ *
335
+ * Steps:
336
+ * 1. Toggle the pressed state to the opposite of its current value.
337
+ * 2. Call the transfer prop callback function.
338
+ */
282
339
  public handlePress = (): void =&gt; {
283
340
  this.setState({
284
341
  pressed: !this.state.pressed,
@@ -286,6 +343,12 @@ export default class TransferToLogbook extends React.Component&lt;IProps, IState
286
343
  this.props.transfer();
287
344
  };
288
345
  &nbsp;
346
+ /**
347
+ * Steps:
348
+ * 1. If the visible prop is false, display an empty space to keep the correct margins in the screen.
349
+ * 2. Return a JSX element to display a touchable button (that is disabled when the pressed state is true)
350
+ * @returns JSX element for displaying the transfer button
351
+ */
289
352
  public render(): JSX.Element {
290
353
  if (!this.props.visible) {
291
354
  return &lt;View style={addToLogbookStyles.marginContainer} /&gt;;
@@ -364,7 +427,7 @@ const addToLogbookStyles = StyleSheet.create({
364
427
  <div class='footer quiet pad2 space-top1 center small'>
365
428
  Code coverage generated by
366
429
  <a href="https://istanbul.js.org/" target="_blank">istanbul</a>
367
- at Fri Jul 09 2021 12:31:53 GMT+0000 (Coordinated Universal Time)
430
+ at Mon Aug 16 2021 10:59:26 GMT+0000 (Coordinated Universal Time)
368
431
  </div>
369
432
  </div>
370
433
  <script src="../../prettify.js"></script>