@truedat/core 4.56.0 → 4.56.1
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/CHANGELOG.md +6 -0
- package/package.json +3 -2
- package/src/api.js +2 -5
- package/src/hooks/index.js +1 -0
- package/src/hooks/useMessages.js +13 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "4.56.
|
|
3
|
+
"version": "4.56.1",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"redux-saga-routines": "^3.2.3",
|
|
106
106
|
"slate": "^0.47.3",
|
|
107
107
|
"slate-react": "^0.22.3",
|
|
108
|
+
"swr": "^1.3.0",
|
|
108
109
|
"validator": "^13.6.0"
|
|
109
110
|
},
|
|
110
111
|
"peerDependencies": {
|
|
@@ -112,5 +113,5 @@
|
|
|
112
113
|
"react-dom": ">= 16.8.6 < 17",
|
|
113
114
|
"semantic-ui-react": ">= 0.88.2 < 2.1"
|
|
114
115
|
},
|
|
115
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "d2b3dcb36b7d81889ee5642699595439750c0801"
|
|
116
117
|
}
|
package/src/api.js
CHANGED
package/src/hooks/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { compile } from "path-to-regexp";
|
|
2
|
+
import useSWRImmutable from "swr/immutable";
|
|
3
|
+
import { API_LOCALE_MESSAGES } from "../api";
|
|
4
|
+
import { apiJson } from "../services/api";
|
|
5
|
+
|
|
6
|
+
const toApiPath = compile(API_LOCALE_MESSAGES);
|
|
7
|
+
|
|
8
|
+
export const useMessages = (lang) => {
|
|
9
|
+
const url = toApiPath({ lang });
|
|
10
|
+
const { data, error } = useSWRImmutable(url, apiJson);
|
|
11
|
+
const messages = data?.data;
|
|
12
|
+
return { messages, error, loading: !error && !data };
|
|
13
|
+
};
|