@truedat/core 4.59.6 → 4.59.8
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/core",
|
|
3
|
-
"version": "4.59.
|
|
3
|
+
"version": "4.59.8",
|
|
4
4
|
"description": "Truedat Web Core",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"react-dom": ">= 16.8.6 < 17",
|
|
118
118
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "679895d762c466ab983d13bbdad90a58261da3b2"
|
|
121
121
|
}
|
package/src/hooks/useMessages.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { compile } from "path-to-regexp";
|
|
2
|
-
import
|
|
2
|
+
import { mutate } from "swr";
|
|
3
|
+
import useSWR from "swr";
|
|
3
4
|
import useSWRMutations from "swr/mutation";
|
|
4
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
API_LOCALE_MESSAGES,
|
|
7
|
+
API_MESSAGE,
|
|
8
|
+
API_MESSAGES,
|
|
9
|
+
API_LOCALES,
|
|
10
|
+
} from "../api";
|
|
5
11
|
import { apiJson, apiJsonPatch, apiJsonPost } from "../services/api";
|
|
6
12
|
|
|
7
13
|
const toApiLocaleMessagesPath = compile(API_LOCALE_MESSAGES);
|
|
@@ -9,14 +15,16 @@ const toApiMessagePath = compile(API_MESSAGE);
|
|
|
9
15
|
|
|
10
16
|
export const useMessages = (lang) => {
|
|
11
17
|
const url = toApiLocaleMessagesPath({ lang });
|
|
12
|
-
const { data, error } =
|
|
18
|
+
const { data, error } = useSWR(url, apiJson);
|
|
13
19
|
const messages = data?.data;
|
|
14
20
|
return { messages, error, loading: !error && !data };
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
export const useMessagePatch = (id) => {
|
|
18
24
|
const url = toApiMessagePath({ id });
|
|
19
|
-
return useSWRMutations(url, (url, { arg }) =>
|
|
25
|
+
return useSWRMutations(url, (url, { arg }) =>
|
|
26
|
+
apiJsonPatch(url, arg).then(() => mutate(API_LOCALES))
|
|
27
|
+
);
|
|
20
28
|
};
|
|
21
29
|
|
|
22
30
|
export const useMessagePost = () => {
|
|
@@ -9,12 +9,13 @@ export default function EditableCell({
|
|
|
9
9
|
value: propValue,
|
|
10
10
|
placeholder,
|
|
11
11
|
onChange,
|
|
12
|
+
clearable = false,
|
|
12
13
|
}) {
|
|
13
14
|
const [editionMode, setEditMode] = useState(false);
|
|
14
15
|
const [value, setValue] = useState(propValue || "");
|
|
15
16
|
|
|
16
17
|
const onBlur = () => {
|
|
17
|
-
if (_.isEmpty(value)) setValue(propValue);
|
|
18
|
+
if (!clearable && _.isEmpty(value)) setValue(propValue);
|
|
18
19
|
else if (value != propValue) onChange(value);
|
|
19
20
|
setEditMode(false);
|
|
20
21
|
};
|
|
@@ -50,4 +51,5 @@ EditableCell.propTypes = {
|
|
|
50
51
|
value: PropTypes.string,
|
|
51
52
|
placeholder: PropTypes.string,
|
|
52
53
|
onChange: PropTypes.func,
|
|
54
|
+
clearable: PropTypes.bool,
|
|
53
55
|
};
|