datastake-daf 0.6.746 → 0.6.748

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 (48) hide show
  1. package/dist/components/index.js +769 -461
  2. package/dist/hooks/index.js +2 -2
  3. package/dist/layouts/index.js +497 -440
  4. package/dist/pages/index.js +3414 -683
  5. package/dist/services/index.js +23 -1
  6. package/dist/utils/index.js +497 -440
  7. package/package.json +1 -1
  8. package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/ActivityIndicators.stories.js +252 -0
  9. package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/config.js +76 -0
  10. package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/index.jsx +184 -0
  11. package/src/@daf/core/components/Dashboard/Widget/ActivityIndicators/style.js +119 -0
  12. package/src/@daf/core/components/Icon/configs/Aid.js +10 -0
  13. package/src/@daf/core/components/Icon/configs/Bear.js +8 -0
  14. package/src/@daf/core/components/Icon/configs/Minus.js +10 -0
  15. package/src/@daf/core/components/Icon/configs/Security.js +12 -0
  16. package/src/@daf/core/components/Icon/configs/index.js +8 -0
  17. package/src/@daf/hooks/useSources.js +1 -1
  18. package/src/@daf/pages/Summary/Activities/Restoration/helper.js +86 -2
  19. package/src/@daf/pages/Summary/Activities/Restoration/index.jsx +20 -19
  20. package/src/@daf/pages/Summary/Minesite/components/LocationMap/index.js +61 -0
  21. package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/config.js +77 -0
  22. package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/index.js +47 -0
  23. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/config.js +26 -0
  24. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/helper.js +64 -0
  25. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/index.js +56 -0
  26. package/src/@daf/pages/Summary/Minesite/index.jsx +162 -0
  27. package/src/@daf/pages/Summary/Operator/components/Governance/config.js +26 -0
  28. package/src/@daf/pages/Summary/Operator/components/Governance/helper.js +61 -0
  29. package/src/@daf/pages/Summary/Operator/components/Governance/index.js +55 -0
  30. package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +84 -0
  31. package/src/@daf/pages/Summary/Operator/components/KeyInformation/index.js +46 -0
  32. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/config.js +40 -0
  33. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +98 -0
  34. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +160 -0
  35. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +83 -0
  36. package/src/@daf/pages/Summary/Operator/hook.js +176 -0
  37. package/src/@daf/pages/Summary/Operator/index.jsx +170 -0
  38. package/src/@daf/pages/Summary/components/InformationAvailability/components/Contributions/index.js +36 -0
  39. package/src/@daf/pages/Summary/components/InformationAvailability/components/InformationCompleteness/index.js +58 -0
  40. package/src/@daf/pages/Summary/components/InformationAvailability/index.js +42 -0
  41. package/src/@daf/pages/Summary/hook.js +188 -0
  42. package/src/@daf/services/OperatorService.js +16 -0
  43. package/src/@daf/services/SourceService.js +1 -1
  44. package/src/helpers/StringHelper.js +7 -0
  45. package/src/index.js +1 -0
  46. package/src/pages.js +2 -2
  47. package/src/@daf/pages/Summary/minesite/index.js +0 -0
  48. package/src/@daf/pages/Summary/operator/index.jsx +0 -76
@@ -0,0 +1,162 @@
1
+ import React from 'react'
2
+ import { useSummary } from '../hook.js'
3
+ import DashboardLayout from '../../../core/components/Dashboard/DashboardLayout/index.jsx'
4
+ import Header from '../../../core/components/Header/index.jsx'
5
+ import Multiselect from '../../../core/components/Select/MultiSelect/index.jsx'
6
+ import { Select, Spin } from 'antd'
7
+ import MineSiteDetails from './components/MineSiteDetails/index.js'
8
+ import LocationMap from './components/LocationMap/index.js'
9
+ import InformationAvailability from '../components/InformationAvailability/index.js'
10
+ import StakeholderMapping from './components/StakeholderMapping/index.js'
11
+
12
+ const MineSummary = ({
13
+ hasSelect = false,
14
+ loading = false,
15
+ getSingleData = () => {},
16
+ getMultipleData = () => {},
17
+ data = [],
18
+ id = '',
19
+ storageKey = '',
20
+ isPdf = false,
21
+ params = {},
22
+ partners = [],
23
+ selectedPartners = {},
24
+ user = {},
25
+ t = () => {},
26
+ theme = {},
27
+ service,
28
+ options = {},
29
+ goTo = () => {},
30
+ getRedirectLink = () => {},
31
+ goBack = () => {},
32
+ onIdChange = () => {},
33
+ }) => {
34
+ const {
35
+ selectedItem,
36
+ setSelectedItem,
37
+ dataOptions,
38
+ search,
39
+ debouncedSearch,
40
+ onSearch,
41
+ setSearch,
42
+ setDebouncedSearch,
43
+ sourceOptions,
44
+ setSelectedPartners,
45
+ singleItemData,
46
+ loading: loadingData,
47
+ } = useSummary({
48
+ getOne: getSingleData,
49
+ getMultiple: getMultipleData,
50
+ id,
51
+ hasSelect,
52
+ storageKey,
53
+ data,
54
+ isPdf: false,
55
+ params,
56
+ partners,
57
+ selectedPartners,
58
+ user,
59
+ t,
60
+ theme,
61
+ service,
62
+ onIdChange,
63
+ });
64
+
65
+ return (
66
+ <DashboardLayout
67
+ header={
68
+ <Header
69
+ title={t('Mine Summary')}
70
+ className="with-border-header h-w-btn-header no-px-body"
71
+ goBackTo={!hasSelect && goBack}
72
+ addedHeaderFirst
73
+ actionButtons={[
74
+ {
75
+ tooltip: t("Details"),
76
+ icon: "FileEdit",
77
+ onClick: () => {
78
+ goTo(getRedirectLink(`/app/view/production-sites/${params?.id ? params?.id : selectedItem}`));
79
+ },
80
+ },
81
+ {
82
+ tooltip: t("Find Data"),
83
+ icon: "Search",
84
+ onClick: () => {},
85
+ disabled: true,
86
+ },
87
+ ]}
88
+ addedHeader={
89
+ <div className="flex flex-row gap-4" style={{ marginRight: 8 }}>
90
+ <Multiselect
91
+ options={[...sourceOptions]}
92
+ isAvatarGroup
93
+ selectionType="checkbox"
94
+ key={partners?.length}
95
+ canUnselectLast={false}
96
+ onChange={(selected) => {
97
+ setSelectedPartners((prev) => ({
98
+ ...prev,
99
+ partners: selected,
100
+ loading: false,
101
+ }));
102
+ }}
103
+ dropDownWidth={200}
104
+ defaultSelected={(partners || []).map((p) => p.id) || []}
105
+ />
106
+ </div>
107
+ }
108
+ />
109
+ }
110
+ >
111
+ {hasSelect && (
112
+ <section>
113
+ <Select
114
+ showSearch
115
+ debounceTimeout={300}
116
+ onSearch={onSearch}
117
+ isSingle
118
+ style={{ height: "40px", width: "100%" }}
119
+ value={selectedItem}
120
+ onChange={setSelectedItem}
121
+ options={dataOptions}
122
+ filterOption={false}
123
+ loading={loading}
124
+ notFoundContent={loading ? <Spin size="small" /> : null}
125
+ />
126
+ </section>
127
+ )}
128
+ <section>
129
+ <MineSiteDetails
130
+ locationData={hasSelect ? singleItemData : data}
131
+ loading={loadingData}
132
+ t={t}
133
+ options={options}
134
+ />
135
+ <LocationMap
136
+ selectedPartners={selectedPartners}
137
+ t={t}
138
+ params={params}
139
+ locationData={hasSelect ? singleItemData : data}
140
+ loading={loadingData}
141
+ />
142
+ </section>
143
+ <section>
144
+ <InformationAvailability
145
+ selectedPartners={selectedPartners}
146
+ t={t}
147
+ id={params?.id || selectedItem}
148
+ />
149
+ </section>
150
+ <section>
151
+ <StakeholderMapping
152
+ selectedPartners={selectedPartners}
153
+ t={t}
154
+ id={params?.id || selectedItem}
155
+ locationData={hasSelect ? singleItemData : data}
156
+ />
157
+ </section>
158
+ </DashboardLayout>
159
+ )
160
+ }
161
+
162
+ export default MineSummary
@@ -0,0 +1,26 @@
1
+ export const IconNodesConfig = {
2
+ beneficiaries: {
3
+ name: "nashiriki::beneficiaries",
4
+ icon: "CoinsHand",
5
+ order: 3,
6
+ emptyName: "no-beneficiaries",
7
+ },
8
+ boardMembers: {
9
+ name: "nashiriki::board-members",
10
+ icon: "Users",
11
+ order: 1,
12
+ emptyName: "no-board-members",
13
+ },
14
+ management: {
15
+ name: "nashiriki::management",
16
+ icon: "Filters",
17
+ order: 2,
18
+ emptyName: "no-management",
19
+ },
20
+ shareholders: {
21
+ name: "nashiriki::stakeholders",
22
+ icon: "PercentCircle",
23
+ order: 4,
24
+ emptyName: "no-stakeholders",
25
+ },
26
+ };
@@ -0,0 +1,61 @@
1
+ import { IconNodesConfig } from './config.js';
2
+
3
+ export const getGovernanceData = ({data, operatorData, id, options, t, goTo, selectedPartners}) => {
4
+ const { sources, ...rest } = data;
5
+
6
+ const _data = rest;
7
+
8
+ return {
9
+ id: operatorData?.datastakeId || id,
10
+ name: t(operatorData?.name || ""),
11
+ country: {
12
+ label:
13
+ options?.countries?.find((country) => country.value === operatorData?.country)
14
+ ?.label || "",
15
+ value: (operatorData?.country || "").toLowerCase() || "",
16
+ },
17
+ onClick: () => {
18
+ goTo(`/app/view/operators/${operatorData?.datastakeId || id}`);
19
+ },
20
+ totalSources: selectedPartners?.partners?.length || 0,
21
+
22
+ children: Object.keys(_data)?.map((key, index) => {
23
+ return {
24
+ id: key,
25
+ name: t(IconNodesConfig[key]?.name),
26
+ icon: IconNodesConfig[key]?.icon,
27
+ order: IconNodesConfig[key]?.order || index + 1,
28
+ emptyName: t(`${IconNodesConfig[key]?.emptyName}`),
29
+ activeColour: "#b6f5ec",
30
+ iconHoverColor: "#fff",
31
+ hoverColor: "#36cfca",
32
+ content: _data[key].length,
33
+ children: _data[key]?.map((child) => {
34
+ return {
35
+ id: child?.datastakeId || "",
36
+ name: child?.name || "",
37
+ country: {
38
+ label:
39
+ options?.countries?.find(
40
+ (country) => country.value === child?.country,
41
+ )?.label || "",
42
+ value: (child?.country || "").toLowerCase() || "",
43
+ },
44
+
45
+ totalSources: child?.sources || 0,
46
+ tooltipLabel: t("Holding"),
47
+ onClick: () => {
48
+ if (child?.type === "operator") {
49
+ goTo(`/app/operator-summary/${child.datastakeId}`);
50
+ return;
51
+ }
52
+
53
+ goTo(`/app/view/stakeholders/${child.datastakeId}`);
54
+ },
55
+ value: child?.holding || 0,
56
+ };
57
+ }),
58
+ };
59
+ }),
60
+ };
61
+ }
@@ -0,0 +1,55 @@
1
+ import React, { useMemo } from 'react'
2
+ import { useWidgetFetch } from '../../../../../hooks/useWidgetFetch.js';
3
+ import { getGovernanceData } from './helper.js';
4
+ import Widget from '../../../../../core/components/Dashboard/Widget/index.jsx';
5
+ import StakeholderMappings from '../../../../../core/components/Graphs/StakeholderMappings/index.jsx';
6
+
7
+ const Governance = ({
8
+ selectedPartners = {},
9
+ operatorData = {},
10
+ t = () => {},
11
+ id,
12
+ options = {},
13
+ goTo = () => {},
14
+
15
+ }) => {
16
+ const defaultFetchConfig = useMemo(() => {
17
+ return {
18
+ basepath: "analytics",
19
+ url: "/widgets/information-map-graph",
20
+ filters: {
21
+ datastakeId: id,
22
+ sources: selectedPartners?.partners || [],
23
+ coreSubject: "stakeholder"
24
+ },
25
+ defaultData: {},
26
+ stop: selectedPartners?.loading,
27
+ };
28
+ }, [selectedPartners]);
29
+
30
+ const { data, loading } = useWidgetFetch({config: defaultFetchConfig});
31
+
32
+ const graphData = useMemo(() => {
33
+ return getGovernanceData({data, operatorData, id, options, t, goTo, selectedPartners});
34
+ }, [data, operatorData, options, t]);
35
+
36
+ return (
37
+ <Widget
38
+ loading={loading}
39
+ title={t("Governance")}
40
+ className={"with-border-header no-p-body"}
41
+ >
42
+ <div style={{ height: 600 }}>
43
+ <StakeholderMappings
44
+ data={graphData}
45
+ maxZoom={1.1}
46
+ t={t}
47
+ isSelectable={true}
48
+ isAllOpenDefault={true}
49
+ />
50
+ </div>
51
+ </Widget>
52
+ )
53
+ }
54
+
55
+ export default Governance
@@ -0,0 +1,84 @@
1
+ import React from "react";
2
+ import { Tag, Tooltip } from "antd";
3
+ import CountryFlag from "../../../../../core/components/UI/CountryFlag/index.jsx";
4
+ import {findOptions } from "../../../../../../helpers/StringHelper.js";
5
+
6
+ export const getKeyIndicatorConfig = ({ t, data = {}, options = {} }) => [
7
+ {
8
+ label: t("Country"),
9
+ render: () => {
10
+ if (!data?.country) {
11
+ return "-";
12
+ }
13
+
14
+ const country = findOptions(data?.country, options?.countries);
15
+ const code = data?.country;
16
+
17
+ return (
18
+ <Tooltip title={country}>
19
+ <img
20
+ alt={code}
21
+ style={{ width: 24, borderRadius: 100, height: 24 }}
22
+ src={`https://flagcdn.com/w80/${code.toLowerCase()}.png`}
23
+ />
24
+ </Tooltip>
25
+ );
26
+ },
27
+ },
28
+ {
29
+ label: t("Supply Chain Position"),
30
+ render: () => {
31
+ const position = findOptions(data?.positionSupplyChain, options?.positionSupplyChainOptions);
32
+ return <div>{position|| "-"}</div>;
33
+ },
34
+ },
35
+ {
36
+ label: t("Legal Form"),
37
+ render: () => {
38
+ const subCategory = findOptions(data?.subCategory, options?.subCategoriesOptions);
39
+ return <div>{subCategory || "-"}</div>;
40
+ },
41
+ },
42
+ {
43
+ label: t("Products"),
44
+ render: () => {
45
+ if ((data?.products || []).length === 0) {
46
+ return "-";
47
+ }
48
+
49
+ return (
50
+ <div style={{ display: "flex", flexWrap: "wrap" }}>
51
+ {data?.products?.map((product) => {
52
+ return (
53
+ <Tag
54
+ color="processing"
55
+ style={{ color: "#1677FF", marginBottom: 8 }}
56
+ key={product}
57
+ >
58
+ {t(product)}
59
+ </Tag>
60
+ );
61
+ })}
62
+ </div>
63
+ );
64
+ },
65
+ },
66
+ {
67
+ label: t("Associated Mine Sites"),
68
+ render: () => {
69
+ return <div>{data?.associatedMineSites || 0}</div>;
70
+ },
71
+ },
72
+ {
73
+ label: t("Identified Suppliers"),
74
+ render: () => {
75
+ return <div>{data?.identifiedSuppliers || 0}</div>;
76
+ },
77
+ },
78
+ {
79
+ label: t("Identified Customers"),
80
+ render: () => {
81
+ return <div>{data?.identifiedCustomers || 0}</div>;
82
+ },
83
+ },
84
+ ];
@@ -0,0 +1,46 @@
1
+ import React from 'react'
2
+ import KeyIndicatorsWidget from '../../../../../core/components/Dashboard/Widget/KeyIndicators/index.jsx';
3
+ import { useMemo } from 'react';
4
+ import { useWidgetFetch } from '../../../../../hooks/useWidgetFetch.js';
5
+ import { getKeyIndicatorConfig } from './config.js';
6
+
7
+
8
+ const KeyInformation = ({options = {}, selectedPartners = {}, t = () => {}, id = {}, data = {}, loading = false}) => {
9
+ // const defaultFetchConfig = useMemo(() => {
10
+ // return {
11
+ // basepath: "analytics",
12
+ // url: '/widgets/key-informations',
13
+ // defaultData: [],
14
+ // stop: selectedPartners?.loading,
15
+ // filters: {
16
+ // datastakeId: id,
17
+ // sources: selectedPartners?.partners || [],
18
+ // },
19
+ // };
20
+ // }, [selectedPartners, id]);
21
+
22
+ // const { data, loading } = useWidgetFetch({config: defaultFetchConfig});
23
+
24
+ const config = useMemo(
25
+ () =>
26
+ getKeyIndicatorConfig({
27
+ t,
28
+ data,
29
+ options,
30
+ }),
31
+ [t, data, options],
32
+ );
33
+
34
+ return (
35
+ <KeyIndicatorsWidget
36
+ t={t}
37
+ config={config}
38
+ className="small-content"
39
+ loading={loading}
40
+ withTooltip
41
+ noMinWidth
42
+ />
43
+ )
44
+ }
45
+
46
+ export default KeyInformation
@@ -0,0 +1,40 @@
1
+ import React from "react";
2
+ import CustomIcon from "../../../../../core/components/Icon/CustomIcon.jsx";
3
+
4
+ export const topIconColor = "#6C737F";
5
+ export const iconColorStakeholder = "#08979C";
6
+ export const leftBackgroundColorStakeholder = "#B5F5EC";
7
+ export const iconColorLocation = "#C41D7F";
8
+ export const leftBackgroundColorLocation = "#FFD6E7";
9
+
10
+ export const topIcons = {
11
+ building: <CustomIcon name="Building" color={topIconColor} width={16} height={16} />,
12
+ factory: <CustomIcon name="Factory" color={topIconColor} width={16} height={16} />,
13
+ smelter: <CustomIcon name="Smelter" color={topIconColor} width={16} height={16} />,
14
+ internationalTrader: <CustomIcon name="Globe04" color={topIconColor} width={16} height={16} />,
15
+ exporter: <CustomIcon name="Truck01" color={topIconColor} width={16} height={16} />,
16
+ miningOperator: <CustomIcon name="MineOperators" color={topIconColor} width={16} height={16} />,
17
+ mineSite: <CustomIcon name="MineSite" color={topIconColor} width={16} height={16} />,
18
+ location: <CustomIcon name="PMESmallLogo" color={topIconColor} width={16} height={16} />,
19
+ inCountryTrader: <CustomIcon name="Handshake" color={topIconColor} width={16} height={16} />,
20
+ localTradingHouse: <CustomIcon name="Building" color={topIconColor} width={16} height={16} />,
21
+ mineralProcessor: <CustomIcon name="Building" color={topIconColor} width={16} height={16} />,
22
+ inCountryTransporter: <CustomIcon name="Truck01" color={topIconColor} width={16} height={16} />,
23
+ internationalTransporter: (
24
+ <CustomIcon name="Truck01" color={topIconColor} width={16} height={16} />
25
+ ),
26
+ };
27
+
28
+ export const leftIcons = {
29
+ stakeholder: (
30
+ <CustomIcon
31
+ name="DashboardStakeholder"
32
+ color={iconColorStakeholder}
33
+ width={16}
34
+ height={16}
35
+ />
36
+ ),
37
+ location: (
38
+ <CustomIcon name="DashboardLocations" color={iconColorLocation} width={16} height={16} />
39
+ ),
40
+ };
@@ -0,0 +1,98 @@
1
+ import { leftIcons, leftBackgroundColorLocation, leftBackgroundColorStakeholder, topIcons } from './config.js';
2
+ import { findOptions } from '../../../../../../helpers/StringHelper.js';
3
+
4
+ export const getFilterConfig = ({operatorData = {}, options = {}, filters = {}, t = () => {}}) => {
5
+ const productSet = new Set();
6
+ const allTradeMineralOptions = [
7
+ ...(operatorData?.suppliers || []),
8
+ ...(operatorData?.clients || []),
9
+ ...(operatorData?.locationSuppliers || []),
10
+ ].flatMap((trade) =>
11
+ (trade?.products || [])
12
+ .filter(
13
+ (product) => !!product?.typeOfProduct && !productSet.has(product.typeOfProduct),
14
+ )
15
+ .map((product) => {
16
+ productSet.add(product.typeOfProduct);
17
+
18
+ const label = options?.minerals?.find(
19
+ (mineral) => mineral.value === product.typeOfProduct,
20
+ )?.label;
21
+
22
+ return {
23
+ value: product.typeOfProduct,
24
+ label: label ?? product.typeOfProduct,
25
+ };
26
+ }),
27
+ );
28
+
29
+ const combinedMineralOptions = [...allTradeMineralOptions].filter((option, index, self) => {
30
+ return option && index === self.findIndex((o) => o.value === option.value);
31
+ });
32
+
33
+ const value = filters.products ? { value: filters.products } : {};
34
+ return [
35
+ {
36
+ label: t("Products"),
37
+ placeholder: t("Select"),
38
+ key: "products",
39
+ type: "select",
40
+ ...value,
41
+ options: combinedMineralOptions,
42
+ },
43
+ ];
44
+ }
45
+
46
+ export const getLeft = (data = {}, mapChildren = () => {}, supplierLocations = []) => {
47
+ if (data?.suppliers?.length > 0) {
48
+ return mapChildren(data.suppliers, data.datastakeId, "left").filter(
49
+ (d) => !!d,
50
+ );
51
+ }
52
+
53
+ const storeLocation = supplierLocations;
54
+ supplierLocations = [];
55
+
56
+ return storeLocation
57
+ .map((location) => {
58
+ return mapChildren([location], location.connect, "left");
59
+ })
60
+ .flat()
61
+ .filter((d) => !!d);
62
+ }
63
+
64
+ export const mapItem = (data, options, goTo, getRedirectLink) => {
65
+ const { positionSupplyChainOptions, locationCategories } = options || {};
66
+ return {
67
+ id: data.datastakeId || "-",
68
+ datastakeId: data.datastakeId || "-",
69
+ leftIcon: leftIcons[data.type === "mineSite" ? "location" : "stakeholder"],
70
+ name: data.name || "-",
71
+ subTitle: findOptions(data.type, [
72
+ ...(positionSupplyChainOptions || []),
73
+ ...(locationCategories || []),
74
+ ]),
75
+ leftBackground:
76
+ data.type === "mineSite"
77
+ ? leftBackgroundColorLocation
78
+ : leftBackgroundColorStakeholder,
79
+ topIcon: topIcons[data.type],
80
+ country: {
81
+ label: findOptions(data.country, options?.countries || []),
82
+ value: data.country,
83
+ },
84
+ totalSources: data.sources ?? 0,
85
+ volume: data?.volume || "",
86
+ onClick: function () {
87
+ if (data.type === "mineSite") {
88
+ return goTo(
89
+ getRedirectLink(`/app/summary/scl/${data.datastakeId}`),
90
+ );
91
+ }
92
+ return goTo(
93
+ getRedirectLink(`/app/summary/operators/${data.datastakeId}`),
94
+ );
95
+ },
96
+ }
97
+ }
98
+