@truedat/ai 6.11.1 → 6.12.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 +3 -3
- package/src/api.js +8 -0
- package/src/components/AiRoutes.js +26 -0
- package/src/components/actions/Action.js +90 -0
- package/src/components/actions/ActionActions.js +134 -0
- package/src/components/actions/ActionBreadcrumbs.js +22 -0
- package/src/components/actions/ActionDetail.js +41 -0
- package/src/components/actions/ActionEdit.js +70 -0
- package/src/components/actions/ActionForm.js +168 -0
- package/src/components/actions/ActionNew.js +50 -0
- package/src/components/actions/Actions.js +61 -0
- package/src/components/actions/ActionsContext.js +52 -0
- package/src/components/actions/ActionsTable.js +124 -0
- package/src/components/actions/__tests__/Action.spec.js +59 -0
- package/src/components/actions/__tests__/ActionActions.spec.js +47 -0
- package/src/components/actions/__tests__/ActionBreadcrumbs.spec.js +21 -0
- package/src/components/actions/__tests__/ActionDetail.spec.js +106 -0
- package/src/components/actions/__tests__/ActionEdit.spec.js +133 -0
- package/src/components/actions/__tests__/ActionForm.spec.js +146 -0
- package/src/components/actions/__tests__/ActionNew.spec.js +113 -0
- package/src/components/actions/__tests__/Actions.spec.js +21 -0
- package/src/components/actions/__tests__/ActionsTable.spec.js +72 -0
- package/src/components/actions/__tests__/__snapshots__/Action.spec.js.snap +159 -0
- package/src/components/actions/__tests__/__snapshots__/ActionActions.spec.js.snap +57 -0
- package/src/components/actions/__tests__/__snapshots__/ActionBreadcrumbs.spec.js.snap +25 -0
- package/src/components/actions/__tests__/__snapshots__/ActionDetail.spec.js.snap +46 -0
- package/src/components/actions/__tests__/__snapshots__/ActionEdit.spec.js.snap +316 -0
- package/src/components/actions/__tests__/__snapshots__/ActionForm.spec.js.snap +326 -0
- package/src/components/actions/__tests__/__snapshots__/ActionNew.spec.js.snap +518 -0
- package/src/components/actions/__tests__/__snapshots__/Actions.spec.js.snap +63 -0
- package/src/components/actions/__tests__/__snapshots__/ActionsTable.spec.js.snap +121 -0
- package/src/hooks/useActions.js +63 -0
- package/src/styles/aiActionEdit.less +19 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _ from "lodash/fp";
|
|
2
|
+
import { compile } from "path-to-regexp";
|
|
3
|
+
import useSWR from "swr";
|
|
4
|
+
import useSWRImmutable from "swr/immutable";
|
|
5
|
+
import useSWRMutations from "swr/mutation";
|
|
6
|
+
import {
|
|
7
|
+
apiJson,
|
|
8
|
+
apiJsonPost,
|
|
9
|
+
apiJsonPatch,
|
|
10
|
+
apiJsonDelete,
|
|
11
|
+
} from "@truedat/core/services/api";
|
|
12
|
+
import {
|
|
13
|
+
API_ACTIONS,
|
|
14
|
+
API_ACTIONS_SEARCH,
|
|
15
|
+
API_ACTION,
|
|
16
|
+
API_ACTION_SET_ACTIVE,
|
|
17
|
+
} from "../api";
|
|
18
|
+
|
|
19
|
+
export const useActions = () => {
|
|
20
|
+
const { data, error, mutate } = useSWR(API_ACTIONS, apiJson);
|
|
21
|
+
return { data: data?.data, error, loading: !error && !data, mutate };
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const useActionsSearch = () => {
|
|
25
|
+
return useSWRMutations(API_ACTIONS_SEARCH, (url, { arg }) =>
|
|
26
|
+
apiJsonPost(url, arg)
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const useAction = (id) => {
|
|
31
|
+
const url = compile(API_ACTION)({ id });
|
|
32
|
+
const { data, error, mutate } = useSWRImmutable(url, apiJson);
|
|
33
|
+
return {
|
|
34
|
+
data: data?.data,
|
|
35
|
+
action: data?.data?.data,
|
|
36
|
+
error,
|
|
37
|
+
loading: !error && !data,
|
|
38
|
+
mutate,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const useActionCreate = () => {
|
|
43
|
+
return useSWRMutations(API_ACTIONS, (url, { arg }) => apiJsonPost(url, arg));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const useActionUpdate = (id) => {
|
|
47
|
+
const url = compile(API_ACTION)({ id });
|
|
48
|
+
return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const useActionDelete = (payload) => {
|
|
52
|
+
const id = payload?.id || 0;
|
|
53
|
+
const logical = payload?.logical || true;
|
|
54
|
+
const url = compile(API_ACTION)({ id }) + "?logical=" + logical;
|
|
55
|
+
return useSWRMutations(url, (url, { arg }) => apiJsonDelete(url, arg));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const useActionSetActive = (payload) => {
|
|
59
|
+
const id = payload?.id || 0;
|
|
60
|
+
const active = _.propOr(true, "active")(payload);
|
|
61
|
+
const url = compile(API_ACTION_SET_ACTIVE)({ id }) + "?active=" + active;
|
|
62
|
+
return useSWRMutations(url, (url, { arg }) => apiJsonPost(url, arg));
|
|
63
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.ai-action-edit{
|
|
2
|
+
&-header{
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
&-active{
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
justify-content: flex-end;
|
|
10
|
+
gap: 15px;
|
|
11
|
+
align-items: center;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
&-form{
|
|
15
|
+
&-actions{
|
|
16
|
+
margin-top: 10px;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|