@hortiview/modulebase 0.0.12628 → 0.0.13075
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/dist/hooks/useEntity.js +47 -44
- package/dist/types/ModuleApi.d.ts +5 -5
- package/dist/utils/fetches.js +7 -7
- package/package.json +1 -1
package/dist/hooks/useEntity.js
CHANGED
|
@@ -1,64 +1,67 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useBasePropsStore as
|
|
4
|
-
import { universalSelector as
|
|
5
|
-
import { getModuleDependedEntities as
|
|
6
|
-
import { useOption as
|
|
7
|
-
const
|
|
1
|
+
import { u as f } from "../useQuery-CwwWze9O.js";
|
|
2
|
+
import { useMemo as p } from "react";
|
|
3
|
+
import { useBasePropsStore as y } from "../stores/BasePropsStore.js";
|
|
4
|
+
import { universalSelector as E } from "../types/Requests.js";
|
|
5
|
+
import { getModuleDependedEntities as g, getFarmOrgEntities as R } from "../utils/fetches.js";
|
|
6
|
+
import { useOption as M, useModuleDependency as k } from "./useOption.js";
|
|
7
|
+
const D = {
|
|
8
8
|
farms: "farm",
|
|
9
9
|
fields: "field",
|
|
10
10
|
zones: "block",
|
|
11
11
|
irrigation_stations: "irrigationStation",
|
|
12
12
|
farm_organizations: "farmOrg",
|
|
13
13
|
alert_rules: "farmAlertRule"
|
|
14
|
-
},
|
|
14
|
+
}, F = {
|
|
15
15
|
farm_members: "member"
|
|
16
|
-
},
|
|
16
|
+
}, Q = {
|
|
17
17
|
Season: "season",
|
|
18
18
|
BlockPlantLayout: "blockPlantLayout"
|
|
19
|
-
},
|
|
19
|
+
}, q = {
|
|
20
|
+
...D,
|
|
20
21
|
...F,
|
|
21
|
-
...Q
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return n ? n.find((s) => s.registeredEntityName === t)?.id : void 0;
|
|
22
|
+
...Q
|
|
23
|
+
}, K = (t, e, a = !0) => {
|
|
24
|
+
const o = y((n) => n.moduleId), c = y((n) => n.organizationId), { data: u } = M("DataAreaGroup"), { data: i } = M("DataAreaEntity"), { data: s } = k(t === "ModuleDepended"), d = t === "ModuleDepended", b = p(() => {
|
|
25
|
+
if (d)
|
|
26
|
+
return s ? s.find((r) => r.registeredEntityName === e)?.id : void 0;
|
|
27
27
|
if (!u || !i) return;
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
}, [
|
|
28
|
+
const n = u.find((r) => r.key === t)?.id;
|
|
29
|
+
return n ? i.find((r) => r.description === n && r.value === e)?.id : void 0;
|
|
30
|
+
}, [d, u, i, s, e, t]), l = A(
|
|
31
31
|
o,
|
|
32
|
-
|
|
32
|
+
b,
|
|
33
|
+
c,
|
|
33
34
|
d,
|
|
34
|
-
m,
|
|
35
35
|
a
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
);
|
|
37
|
+
return p(() => {
|
|
38
|
+
const n = (l.data ?? []).map((m) => {
|
|
39
|
+
const r = q[e];
|
|
40
|
+
return m[r];
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
...l,
|
|
44
|
+
data: n
|
|
45
|
+
};
|
|
46
|
+
}, [e, l, d]);
|
|
47
|
+
}, A = (t, e, a, o, c = !0) => {
|
|
48
|
+
const u = f({
|
|
49
|
+
queryKey: [t, a, e],
|
|
50
|
+
queryFn: () => g(t ?? "", e ?? ""),
|
|
51
|
+
enabled: c && o && !!t && !!e && !!a,
|
|
52
|
+
select: (s) => E(s)
|
|
53
|
+
}), i = f({
|
|
54
|
+
queryKey: [t, a, e],
|
|
55
|
+
queryFn: () => R(t ?? "", e ?? ""),
|
|
56
|
+
enabled: c && !o && !!t && !!e && !!a,
|
|
57
|
+
select: (s) => E(s)
|
|
55
58
|
});
|
|
56
59
|
return o ? u : i;
|
|
57
60
|
};
|
|
58
61
|
export {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
q as AllEntitiesTypeResultMap,
|
|
63
|
+
F as FarmMemberEntitiesTypeResultMap,
|
|
64
|
+
D as FarmOrgEntitiesTypeResultMap,
|
|
65
|
+
Q as ModuleDependedEntityTypeResultMap,
|
|
63
66
|
K as useEntity
|
|
64
67
|
};
|
|
@@ -77,11 +77,11 @@ export interface Field {
|
|
|
77
77
|
farmId: string;
|
|
78
78
|
name: string;
|
|
79
79
|
description: string;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
fieldTechnologyTypeId: string;
|
|
81
|
+
fieldCoverageTypeId: string;
|
|
82
|
+
fieldShadingTypeId: string;
|
|
83
|
+
fieldSowingTypeId: string;
|
|
84
|
+
fieldSubstrateTypeId: string;
|
|
85
85
|
length: number | null;
|
|
86
86
|
width: number | null;
|
|
87
87
|
rows: number | null;
|
package/dist/utils/fetches.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { useBasePropsStore as u } from "../stores/BasePropsStore.js";
|
|
2
2
|
import { useEnvironmentStore as r } from "../stores/EnvironmentStore.js";
|
|
3
3
|
import { baseMutation as c, baseFetch as o } from "./baseFetches.js";
|
|
4
|
-
const
|
|
4
|
+
const d = (e, t, n = "POST", m, s) => c(e, t, n, m, s), I = (e, t) => i(`FarmOrgEntities/${e}/byId/${t}`), g = (e, t) => i(`ModuleDependentEntities/${e}/byId/${t}`), A = (e, t) => o(`${e}`, {}, t), i = (e) => {
|
|
5
5
|
const t = r.getState().environment, n = u.getState().organizationId;
|
|
6
6
|
return o(
|
|
7
7
|
`${t?.MODULE_AUTH_API}${t?.API_PREFIX}/${n}/${e}`,
|
|
8
8
|
{}
|
|
9
9
|
);
|
|
10
|
-
},
|
|
10
|
+
}, E = (e) => {
|
|
11
11
|
const t = r.getState().environment;
|
|
12
12
|
return o(`${t?.COMMON_API}${t?.API_PREFIX}/${e}`, {});
|
|
13
13
|
};
|
|
14
14
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
E as fetchFromCommonApi,
|
|
16
|
+
A as fetchFromCustomApi,
|
|
17
17
|
i as fetchFromModuleApi,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
I as getFarmOrgEntities,
|
|
19
|
+
g as getModuleDependedEntities,
|
|
20
|
+
d as mutateOnCustomApi
|
|
21
21
|
};
|
package/package.json
CHANGED