@openmrs/esm-react-utils 3.3.2-pre.71 → 3.4.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-react-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "React utilities for OpenMRS.",
|
|
6
6
|
"browser": "dist/openmrs-esm-react-utils.js",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"react-i18next": "11.x"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@openmrs/esm-api": "^3.
|
|
59
|
-
"@openmrs/esm-config": "^3.
|
|
60
|
-
"@openmrs/esm-error-handling": "^3.
|
|
61
|
-
"@openmrs/esm-extensions": "^3.
|
|
62
|
-
"@openmrs/esm-globals": "^3.
|
|
58
|
+
"@openmrs/esm-api": "^3.4.0",
|
|
59
|
+
"@openmrs/esm-config": "^3.4.0",
|
|
60
|
+
"@openmrs/esm-error-handling": "^3.4.0",
|
|
61
|
+
"@openmrs/esm-extensions": "^3.4.0",
|
|
62
|
+
"@openmrs/esm-globals": "^3.4.0",
|
|
63
63
|
"dayjs": "^1.10.8",
|
|
64
64
|
"i18next": "^19.6.0",
|
|
65
65
|
"react": "^16.13.1",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"rxjs": "^6.5.3",
|
|
69
69
|
"unistore": "^3.5.2"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "51e0d8495e4dbd18d18da19267ed4a792ab4fc6c"
|
|
72
72
|
}
|
package/src/useVisit.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import useSWR from "swr";
|
|
8
8
|
import dayjs from "dayjs";
|
|
9
9
|
import isToday from "dayjs/plugin/isToday";
|
|
10
|
+
import { useMemo } from "react";
|
|
10
11
|
|
|
11
12
|
dayjs.extend(isToday);
|
|
12
13
|
|
|
@@ -15,6 +16,7 @@ interface VisitReturnType {
|
|
|
15
16
|
mutate: () => void;
|
|
16
17
|
isValidating: boolean;
|
|
17
18
|
currentVisit: Visit | null;
|
|
19
|
+
isLoading: boolean;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
@@ -34,11 +36,20 @@ export function useVisit(patientUuid: string): VisitReturnType {
|
|
|
34
36
|
openmrsFetch
|
|
35
37
|
);
|
|
36
38
|
|
|
37
|
-
const currentVisit =
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const currentVisit = useMemo(
|
|
40
|
+
() =>
|
|
41
|
+
data?.data.results.find(
|
|
42
|
+
(visit) =>
|
|
43
|
+
visit.stopDatetime === null && dayjs(visit.startDatetime).isToday()
|
|
44
|
+
) ?? null,
|
|
45
|
+
[data?.data.results]
|
|
46
|
+
);
|
|
42
47
|
|
|
43
|
-
return {
|
|
48
|
+
return {
|
|
49
|
+
error,
|
|
50
|
+
mutate,
|
|
51
|
+
isValidating,
|
|
52
|
+
currentVisit,
|
|
53
|
+
isLoading: !data && !error,
|
|
54
|
+
};
|
|
44
55
|
}
|