datastake-daf 0.6.803 → 0.6.805

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.
Files changed (53) hide show
  1. package/dist/components/index.js +1716 -1364
  2. package/dist/layouts/index.js +2 -2
  3. package/dist/pages/index.js +564 -133
  4. package/dist/utils/index.js +6 -0
  5. package/package.json +1 -1
  6. package/public/Biodiversity/others-default.svg +38 -0
  7. package/public/Biodiversity/others.svg +38 -0
  8. package/public/Biodiversity/unidentified-pests-default.svg +33 -0
  9. package/public/Biodiversity/unidentified-pests.svg +33 -0
  10. package/src/@daf/core/components/Dashboard/Widget/FaunaWidget/config.js +15 -0
  11. package/src/@daf/core/components/Dashboard/Widget/FaunaWidget/index.jsx +83 -0
  12. package/src/@daf/core/components/Dashboard/Widget/InvasiveSpeciesWidget/config.js +11 -0
  13. package/src/@daf/core/components/Dashboard/Widget/InvasiveSpeciesWidget/index.jsx +87 -0
  14. package/src/@daf/core/components/EditForm/RenderForm.js +13 -1
  15. package/src/@daf/core/components/EditForm/_index.scss +4 -3
  16. package/src/@daf/core/components/EditForm/components/DataLink/flat.js +9 -2
  17. package/src/@daf/core/components/EditForm/components/DataLink/index.js +8 -1
  18. package/src/@daf/core/components/EditForm/components/DataLinkGroup/index.js +8 -1
  19. package/src/@daf/core/components/EditForm/components/Repeatable/index.js +11 -1
  20. package/src/@daf/core/components/EditForm/context/index.js +9 -0
  21. package/src/@daf/core/components/EditForm/form.jsx +5 -1
  22. package/src/@daf/core/components/EditForm/helper.js +25 -3
  23. package/src/@daf/core/components/Header/hook.js +4 -4
  24. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/columns.js +3 -3
  25. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/helper.js +3 -3
  26. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineLocation/index.jsx +3 -3
  27. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/columns.js +3 -3
  28. package/src/@daf/core/components/Screens/Admin/AdminModals/CombineSubjects/index.jsx +3 -3
  29. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/column.js +3 -3
  30. package/src/@daf/core/components/Screens/Admin/AdminTables/LocationTable/helper.js +1 -8
  31. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/columns.js +3 -3
  32. package/src/@daf/core/components/Screens/Admin/AdminTables/SubjectsTable/helper.js +1 -8
  33. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/helpers.js +3 -6
  34. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewLocation/index.jsx +2 -2
  35. package/src/@daf/core/components/Screens/Admin/AdminViews/ViewStakeholder/index.jsx +2 -1
  36. package/src/@daf/core/components/ViewForm/components/DataLink/flat.js +11 -1
  37. package/src/@daf/core/components/ViewForm/components/DataLink/index.js +11 -1
  38. package/src/@daf/core/components/ViewForm/components/DataLinkGroup/index.js +11 -1
  39. package/src/@daf/core/components/ViewForm/content.jsx +51 -28
  40. package/src/@daf/core/components/ViewForm/context/index.js +80 -0
  41. package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/columns.js +9 -5
  42. package/src/@daf/pages/Dashboards/SelfAssesment/components/AssociatedInformation/index.jsx +15 -3
  43. package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/columns.js +2 -2
  44. package/src/@daf/pages/Dashboards/SelfAssesment/components/OrganisationInformation/index.jsx +9 -5
  45. package/src/@daf/pages/Dashboards/SelfAssesment/index.jsx +1 -1
  46. package/src/@daf/pages/Edit/index.jsx +1 -0
  47. package/src/@daf/pages/Locations/MineSite/columns.js +5 -5
  48. package/src/@daf/pages/Stakeholders/Operators/columns.js +6 -8
  49. package/src/@daf/pages/Summary/Activities/Monitoring/components/BiodiversityAndHabitat/index.jsx +34 -31
  50. package/src/@daf/pages/View/index.jsx +1 -0
  51. package/src/helpers/adminLevels.js +4 -0
  52. package/src/index.js +2 -0
  53. package/src/utils.js +3 -1
@@ -0,0 +1,80 @@
1
+ import { createContext, useContext } from "react";
2
+
3
+ const ViewContext = createContext({
4
+ user: null,
5
+ isReview: false,
6
+ t: (s) => s,
7
+ errors: {},
8
+ changeErrors: () => { },
9
+ ajaxOptions: {},
10
+ getAppHeader: () => { },
11
+ getApiBaseUrl: () => { },
12
+ changeAjaxOptions: () => { },
13
+ changeAjaxForms: () => { },
14
+ getMainApiUrl: () => { },
15
+ app: null,
16
+ ajaxForms: {},
17
+ query: null,
18
+ goTo: () => { },
19
+ maxWidth: "75%",
20
+ staticWidth: "614px",
21
+ fullWidth: false,
22
+ });
23
+
24
+ export const ViewProvider = ({
25
+ t,
26
+ user,
27
+ ajaxForms,
28
+ isReview,
29
+ children,
30
+ ajaxOptions,
31
+ highlightMandatory,
32
+ getAppHeader,
33
+ getApiBaseUrl,
34
+ changeAjaxOptions,
35
+ getMainApiUrl,
36
+ app,
37
+ query,
38
+ goTo,
39
+ errors,
40
+ changeErrors,
41
+ changeAjaxForms,
42
+ evaluationConfig,
43
+ maxWidth,
44
+ staticWidth,
45
+ fullWidth,
46
+ }) => {
47
+ const values = {
48
+ t,
49
+ errors,
50
+ changeErrors,
51
+ user,
52
+ ajaxForms,
53
+ isReview,
54
+ changeAjaxOptions,
55
+ getMainApiUrl,
56
+ ajaxOptions,
57
+ highlightMandatory,
58
+ app,
59
+ changeAjaxForms,
60
+ getAppHeader,
61
+ getApiBaseUrl,
62
+ query,
63
+ evaluationConfig,
64
+ goTo,
65
+ maxWidth,
66
+ staticWidth,
67
+ fullWidth,
68
+ };
69
+
70
+ return (
71
+ <ViewContext.Provider value={values}>
72
+ {children}
73
+ </ViewContext.Provider>
74
+ );
75
+ }
76
+
77
+ export const useViewContext = () => {
78
+ const values = useContext(ViewContext);
79
+ return values;
80
+ }
@@ -4,6 +4,7 @@ import { renderDateFormatted } from '../../../../../../helpers/Forms.js';
4
4
  import { findOptions, getLinkValue } from '../../../../../../helpers/StringHelper.js';
5
5
  import CustomIcon from '../../../../../core/components/Icon/CustomIcon.jsx';
6
6
  import NavigationAction from '../../../../../core/components/Table/NavigationAction/index.jsx';
7
+ import { getAdminLevelName } from '../../../../../../helpers/adminLevels.js';
7
8
 
8
9
 
9
10
  export const getColumns = ({ t, activeTab, options, user, goTo, getRedirectLink, theme }) =>
@@ -62,7 +63,10 @@ export const getColumns = ({ t, activeTab, options, user, goTo, getRedirectLink,
62
63
  if (all.empty) {
63
64
  return <div className="daf-default-cell" />;
64
65
  }
65
- const label = findOptions(v, options?.categoriesOptions) || "-";
66
+
67
+ const categoriesOptions = [...(options?.categoriesOptions || []), ...(options?.locationCategories || [])]
68
+
69
+ const label = findOptions(v, categoriesOptions) || "-";
66
70
 
67
71
  return (
68
72
  <Tooltip title={label}>{label || "-"}</Tooltip>
@@ -79,7 +83,7 @@ export const getColumns = ({ t, activeTab, options, user, goTo, getRedirectLink,
79
83
  return <div className="daf-default-cell" />;
80
84
  }
81
85
 
82
- const label = findOptions(v, options?.subCategoriesOptionsSbgi) || "-";
86
+ const label = findOptions(v, options?.subCategoriesOptions) || "-";
83
87
 
84
88
  return (
85
89
  <Tooltip title={label}>{label || "-"}</Tooltip>
@@ -113,7 +117,7 @@ export const getColumns = ({ t, activeTab, options, user, goTo, getRedirectLink,
113
117
  return <div className="daf-default-cell" />
114
118
  }
115
119
 
116
- const region = getLinkValue(all?.administrativeLevel1, all?.linking?.SCL);
120
+ const region = getAdminLevelName(all?.linking?.SCL, "level_1");
117
121
 
118
122
  return region ? <Tooltip title={region}>{region}</Tooltip> : '-';
119
123
  },
@@ -128,7 +132,7 @@ export const getColumns = ({ t, activeTab, options, user, goTo, getRedirectLink,
128
132
  return <div className="daf-default-cell" />
129
133
  }
130
134
 
131
- const district = getLinkValue(all?.administrativeLevel2, all?.linking?.SCL);
135
+ const district = getAdminLevelName(all?.linking?.SCL, "level_2");
132
136
 
133
137
  return district ? <Tooltip title={district}>{district}</Tooltip> : '-';
134
138
  },
@@ -167,7 +171,7 @@ export const getColumns = ({ t, activeTab, options, user, goTo, getRedirectLink,
167
171
  },
168
172
  },
169
173
  {
170
- dataIndex: "lastUpdated",
174
+ dataIndex: "lastUpdate",
171
175
  title: t("Last Update"),
172
176
  ellipsis: true,
173
177
  show: true,
@@ -5,6 +5,7 @@ import SearchFilters from '../../../../../core/components/Filters/searchFilters/
5
5
  import DafTable from '../../../../../core/components/Table/index.jsx';
6
6
  import TabsHeader from '../../../../../core/components/Header/TabsHeader/index.jsx';
7
7
  import { getColumns } from './columns.js';
8
+ import { useWidgetFetch } from '../../../../../hooks/useWidgetFetch.js';
8
9
 
9
10
  function AssociatedInformation({
10
11
  t = () => {},
@@ -12,6 +13,7 @@ function AssociatedInformation({
12
13
  goTo = () => {},
13
14
  getRedirectLink = () => {},
14
15
  options = {},
16
+ theme = {},
15
17
  }) {
16
18
  const tabs = [
17
19
  { value: "stakeholders", label: t("Stakeholders") },
@@ -21,11 +23,20 @@ function AssociatedInformation({
21
23
  ];
22
24
  const [activeTab, setActiveTab] = useState("stakeholders");
23
25
 
24
- const data = [];
26
+ const defaultConfig = useMemo(
27
+ () => ({
28
+ basepath: "stakeholder",
29
+ url: "/kyc/associatedInformation",
30
+ }),
31
+ [],
32
+ );
33
+
34
+ const { data, loading } = useWidgetFetch({config: defaultConfig});
35
+ console.log({data})
25
36
 
26
37
  const columns = useMemo(
27
- () => getColumns({ t, isMonitoring: false, activeTab, options, getRedirectLink, user }),
28
- [t, activeTab, options, getRedirectLink, user],
38
+ () => getColumns({ t, isMonitoring: false, activeTab, options, getRedirectLink, user, theme, goTo }),
39
+ [t, activeTab, options, getRedirectLink, user, theme, goTo],
29
40
  );
30
41
 
31
42
  return (
@@ -33,6 +44,7 @@ function AssociatedInformation({
33
44
  title={t("Associated Information")}
34
45
  expandable
35
46
  className="with-border-header no-px-body overflow-hidden"
47
+ loading={loading}
36
48
  >
37
49
  <div style={{ display: "flex", flexDirection: "column", gap: "24px", marginLeft: "12px" }}>
38
50
  <TabsHeader
@@ -33,9 +33,9 @@ export const getColumns = ({
33
33
  if (all.empty) {
34
34
  return <div className="daf-default-cell" />
35
35
  }
36
- const published = false;
36
+ const published = all?.published || false;
37
37
 
38
- return <ProgressBarWithIcon published={published} data={v} t={t} />
38
+ return <ProgressBarWithIcon published={published} data={all} t={t} />
39
39
  }
40
40
  },
41
41
  {
@@ -9,22 +9,25 @@ function OrganisationInformation({
9
9
  goTo = () => {},
10
10
  getRedirectLink = () => {},
11
11
  theme = {},
12
+ data,
13
+ loading,
12
14
  }) {
13
- const organistionInfo = [
15
+ const organisationInfo = [
14
16
  {key: 'kyc', label: t("My KYC")},
15
17
  {key: 'management-systems', label: t("Management Systems")},
16
18
  ]
17
19
 
18
20
  const tableData = useMemo(() => {
19
- return organistionInfo.map((item) => {
21
+ return organisationInfo.map((item) => {
20
22
  return {
21
23
  key: item.key,
22
24
  name: item.label,
23
- completion: 0,
24
- lastUpdate: "",
25
+ completion: data?.data?.[`${item.key}Data`]?.meta?.completion?.percentage || 0,
26
+ lastUpdate: data?.data?.[`${item.key}Data`]?.updatedAt || "",
27
+ ...data?.data?.[`${item.key}Data`],
25
28
  }
26
29
  })
27
- }, [organistionInfo])
30
+ }, [organisationInfo, data])
28
31
 
29
32
  const columns = useMemo(() => {
30
33
  return getColumns({ t, data: tableData, user, goTo, getRedirectLink, theme })
@@ -34,6 +37,7 @@ function OrganisationInformation({
34
37
  <Widget
35
38
  title={t("Organisation Information")}
36
39
  className="with-border-header daf-table-wrapper no-pagination no-px-body"
40
+ loading={loading}
37
41
  >
38
42
  <DAFTable columns={columns} data={tableData} />
39
43
  </Widget>
@@ -32,7 +32,7 @@ function SelfAssesment({
32
32
  <ProductionSites t={t} options={options} user={user} goTo={goTo} getRedirectLink={getRedirectLink} data={data} loading={loading} />
33
33
  </section>
34
34
  <section>
35
- <AssociatedInformation t={t} user={user} goTo={goTo} getRedirectLink={getRedirectLink} data={data} loading={loading} />
35
+ <AssociatedInformation t={t} user={user} goTo={goTo} getRedirectLink={getRedirectLink} data={data} loading={loading} theme={theme} options={options} />
36
36
  </section>
37
37
  </DashboardLayout>
38
38
  )
@@ -331,6 +331,7 @@ const Edit = ({
331
331
  linkingForms={linkingForms}
332
332
  form={selectedForm}
333
333
  data={data}
334
+ fullWidth
334
335
  {...{
335
336
  t,
336
337
  user,
@@ -158,11 +158,6 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
158
158
  goTo(getRedirectLink(link));
159
159
  };
160
160
  const moreMenuItems = [
161
- {
162
- label: t("Details"),
163
- value: "details",
164
- onClick: onClick,
165
- },
166
161
  {
167
162
  label: t("Summary"),
168
163
  value: "Summary",
@@ -175,6 +170,11 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
175
170
  },
176
171
  // disabled: true,
177
172
  },
173
+ {
174
+ label: t("Details"),
175
+ value: "details",
176
+ onClick: onClick,
177
+ },
178
178
  ];
179
179
  return <div >
180
180
  <MoreMenu items={moreMenuItems} />
@@ -162,11 +162,6 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
162
162
  goTo(getRedirectLink(link));
163
163
  };
164
164
  const moreMenuItems = [
165
- {
166
- label: t("Details"),
167
- value: "details",
168
- onClick: onClick,
169
- },
170
165
  {
171
166
  label: t("Summary"),
172
167
  value: "Summary",
@@ -179,10 +174,13 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
179
174
  },
180
175
  // disabled: true,
181
176
  },
177
+ {
178
+ label: t("Details"),
179
+ value: "details",
180
+ onClick: onClick,
181
+ },
182
182
  ];
183
- return <div >
184
- <MoreMenu items={moreMenuItems} />
185
- </div>;
183
+ return <MoreMenu items={moreMenuItems} />
186
184
  }
187
185
  }
188
186
  ].filter((column) => column.show !== false);
@@ -1,21 +1,27 @@
1
- import React, { useMemo } from 'react';
2
- import { ActivityIndicators, Widget } from '../../../../../../../../src/index.js';
1
+ import React from 'react';
2
+ import { Widget, FaunaWidget, InvasiveSpeciesWidget } from '../../../../../../../../src/index.js';
3
3
  import styled from 'styled-components';
4
- import {
5
- generateFaunaConfig,
6
- generateInvasiveSpeciesConfig
7
- } from './helper';
8
4
 
9
- const Container = styled.div`
10
- display: grid;
11
- grid-template-columns: 70% 28.5%;
5
+ const BiodiversityContainer = styled.div`
6
+ display: flex;
12
7
  gap: 24px;
13
8
  width: 100%;
9
+
14
10
  @media (max-width: 768px) {
15
- grid-template-columns: 1fr;
11
+ flex-direction: column;
16
12
  }
17
13
  `;
18
14
 
15
+ const FaunaSection = styled.section`
16
+ width: 60%;
17
+ min-width: 0;
18
+ `;
19
+
20
+ const InvasiveSpeciesSection = styled.section`
21
+ width: 38.5%;
22
+ `;
23
+
24
+
19
25
  const BiodiversityAndHabitat = ({
20
26
  faunaPresent = [],
21
27
  invasiveSpecies = [],
@@ -23,40 +29,37 @@ const BiodiversityAndHabitat = ({
23
29
  loading = false,
24
30
  t = (s) => s
25
31
  }) => {
26
- const observedFaunaConfig = useMemo(() =>
27
- generateFaunaConfig(faunaPresent, t),
28
- [faunaPresent, t]
29
- );
30
-
31
- const invasiveSpeciesConfig = useMemo(() =>
32
- generateInvasiveSpeciesConfig(invasiveSpecies, hasInvasiveSpecies, t),
33
- [invasiveSpecies, hasInvasiveSpecies, t]
34
- );
35
-
36
32
  return (
37
33
  <Widget
38
34
  title={t("Biodiversity & Habitat")}
39
35
  className="with-border-header h-w-btn-header"
40
36
  >
41
- <section>
42
- <Container>
43
- <ActivityIndicators
37
+ <BiodiversityContainer>
38
+ <FaunaSection>
39
+ <FaunaWidget
44
40
  title={t("Observed Fauna")}
45
- config={observedFaunaConfig}
41
+ faunaPresent={faunaPresent}
42
+ columnsPerRow={5}
43
+ itemWidth={120}
44
+ itemHeight={120}
46
45
  loading={loading}
47
- widgetClassName="h-w-btn-header"
48
46
  t={t}
49
47
  />
50
- <ActivityIndicators
48
+ </FaunaSection>
49
+
50
+ <InvasiveSpeciesSection>
51
+ <InvasiveSpeciesWidget
51
52
  title={t("Invasive Species")}
52
- config={invasiveSpeciesConfig}
53
+ invasiveSpecies={invasiveSpecies}
54
+ hasInvasiveSpecies={hasInvasiveSpecies}
55
+ columnsPerRow={3}
56
+ itemWidth={100}
57
+ itemHeight={100}
53
58
  loading={loading}
54
- className="single-column"
55
- widgetClassName="h-w-btn-header"
56
59
  t={t}
57
60
  />
58
- </Container>
59
- </section>
61
+ </InvasiveSpeciesSection>
62
+ </BiodiversityContainer>
60
63
  </Widget>
61
64
  );
62
65
  };
@@ -304,6 +304,7 @@ const View = ({
304
304
  getApiBaseUrl={getApiBaseUrl}
305
305
  getAppHeader={getAppHeader}
306
306
  user={user}
307
+ fullWidth
307
308
  />
308
309
  )}
309
310
  </div>
@@ -0,0 +1,4 @@
1
+ export const getAdminLevelName = (data, level) => {
2
+ const entry = Object.values(data || {}).find(item => item.level === level);
3
+ return entry?.name || "-";
4
+ };
package/src/index.js CHANGED
@@ -79,6 +79,8 @@ export { default as CarouselWidget } from "./@daf/core/components/Dashboard/Widg
79
79
  export { default as ImageCarousel } from "./@daf/core/components/Dashboard/Widget/ImageCarousel/index.jsx";
80
80
  export { default as StatCard } from "./@daf/core/components/Dashboard/Widget/StatCard/index.js";
81
81
  export { default as VegetationHealth } from "./@daf/core/components/Dashboard/Widget/VegetationWidget/index.jsx";
82
+ export { default as FaunaWidget } from "./@daf/core/components/Dashboard/Widget/FaunaWidget/index.jsx";
83
+ export { default as InvasiveSpeciesWidget } from "./@daf/core/components/Dashboard/Widget/InvasiveSpeciesWidget/index.jsx";
82
84
  // export { default as WidgetCatalogue } from "./@daf/core/components/Dashboard/Widget/WidgetCatalogue/index.jsx";
83
85
 
84
86
  // Forms
package/src/utils.js CHANGED
@@ -64,4 +64,6 @@ export { renderBreadCrumbs, buildBreadCrumbs as buildBreadCrumbsHelper } from '.
64
64
 
65
65
  export { copyToClipboard } from './helpers/copyToClipboard.js'
66
66
 
67
- export { isArrayOfObjects } from './@daf/utils/arrays.js'
67
+ export { isArrayOfObjects } from './@daf/utils/arrays.js'
68
+
69
+ export { getAdminLevelName } from './helpers/adminLevels.js'