@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.
@@ -1,64 +1,67 @@
1
- import { u as l } from "../useQuery-CwwWze9O.js";
2
- import { useMemo as g } from "react";
3
- import { useBasePropsStore as p } from "../stores/BasePropsStore.js";
4
- import { universalSelector as y } from "../types/Requests.js";
5
- import { getModuleDependedEntities as R, getFarmOrgEntities as k } from "../utils/fetches.js";
6
- import { useOption as E, useModuleDependency as D } from "./useOption.js";
7
- const F = {
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
- }, Q = {
14
+ }, F = {
15
15
  farm_members: "member"
16
- }, q = {
16
+ }, Q = {
17
17
  Season: "season",
18
18
  BlockPlantLayout: "blockPlantLayout"
19
- }, A = {
19
+ }, q = {
20
+ ...D,
20
21
  ...F,
21
- ...Q,
22
- ...q
23
- }, K = (e, t, a = !0) => {
24
- const o = p((r) => r.moduleId), d = p((r) => r.organizationId), { data: u } = E("DataAreaGroup"), { data: i } = E("DataAreaEntity"), { data: n } = D(e === "ModuleDepended"), m = e === "ModuleDepended", M = g(() => {
25
- if (m)
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 r = u.find((s) => s.key === e)?.id;
29
- return r ? i.find((s) => s.description === r && s.value === t)?.id : void 0;
30
- }, [m, u, i, n, t, e]), f = O(
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
- M,
32
+ b,
33
+ c,
33
34
  d,
34
- m,
35
35
  a
36
- ), b = (f.data ?? []).map((r) => {
37
- const c = A[t];
38
- return r[c];
39
- });
40
- return {
41
- ...f,
42
- data: b
43
- };
44
- }, O = (e, t, a, o, d = !0) => {
45
- const u = l({
46
- queryKey: [e, a, t],
47
- queryFn: () => R(e ?? "", t ?? ""),
48
- enabled: d && o && !!e && !!t && !!a,
49
- select: (n) => y(n)
50
- }), i = l({
51
- queryKey: [e, a, t],
52
- queryFn: () => k(e ?? "", t ?? ""),
53
- enabled: d && !o && !!e && !!t && !!a,
54
- select: (n) => y(n)
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
- A as AllEntitiesTypeResultMap,
60
- Q as FarmMemberEntitiesTypeResultMap,
61
- F as FarmOrgEntitiesTypeResultMap,
62
- q as ModuleDependedEntityTypeResultMap,
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
- fieldTechnologyId: string;
81
- fieldCoverageId: string;
82
- fieldShadingId: string;
83
- fieldSowingId: string;
84
- fieldSubstrateId: string;
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;
@@ -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 g = (e, t, n = "POST", m, s) => c(e, t, n, m, s), A = (e, t) => i(`getAllFarmOrgEntities/${e}/${t}`), d = (e, t) => i(`ModuleDependedEntities/${e}/${t}`), E = (e, t) => o(`${e}`, {}, t), i = (e) => {
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
- }, F = (e) => {
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
- F as fetchFromCommonApi,
16
- E as fetchFromCustomApi,
15
+ E as fetchFromCommonApi,
16
+ A as fetchFromCustomApi,
17
17
  i as fetchFromModuleApi,
18
- A as getFarmOrgEntities,
19
- d as getModuleDependedEntities,
20
- g as mutateOnCustomApi
18
+ I as getFarmOrgEntities,
19
+ g as getModuleDependedEntities,
20
+ d as mutateOnCustomApi
21
21
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/modulebase",
3
3
  "description": "This is a base module for hortiview",
4
- "version": "0.0.12628",
4
+ "version": "0.0.13075",
5
5
  "type": "module",
6
6
  "author": "Falk Menge <falk.menge.ext@bayer.com>",
7
7
  "contributors": [