@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.56.1] 2022-11-21
4
+
5
+ ### Changed
6
+
7
+ - [TD-5338] Use intl messages retrieved from i18n service
8
+
3
9
  ## [4.56.0] 2022-11-17
4
10
 
5
11
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "4.56.0",
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": "17277e6b9438363c6baa26f8975a2ab585a61f76"
116
+ "gitHead": "d2b3dcb36b7d81889ee5642699595439750c0801"
116
117
  }
package/src/api.js CHANGED
@@ -1,5 +1,2 @@
1
- const API_COMMENTS = "/api/business_concepts/comments";
2
-
3
- export {
4
- API_COMMENTS,
5
- };
1
+ export const API_COMMENTS = "/api/business_concepts/comments";
2
+ export const API_LOCALE_MESSAGES = "/api/locales/:lang/messages";
@@ -1,6 +1,7 @@
1
1
  export * from "./useActiveRoute";
2
2
  export * from "./useActiveRoutes";
3
3
  export * from "./useAuthorized";
4
+ export * from "./useMessages";
4
5
  export * from "./usePath";
5
6
  export * from "./useOnScreen";
6
7
  export * from "./useOperators";
@@ -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
+ };