datastake-daf 0.6.746 → 0.6.747

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 (34) hide show
  1. package/dist/hooks/index.js +2 -2
  2. package/dist/pages/index.js +2478 -176
  3. package/dist/services/index.js +23 -1
  4. package/package.json +1 -1
  5. package/src/@daf/hooks/useSources.js +1 -1
  6. package/src/@daf/pages/Summary/Minesite/components/LocationMap/index.js +61 -0
  7. package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/config.js +77 -0
  8. package/src/@daf/pages/Summary/Minesite/components/MineSiteDetails/index.js +47 -0
  9. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/config.js +26 -0
  10. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/helper.js +64 -0
  11. package/src/@daf/pages/Summary/Minesite/components/StakeholderMapping/index.js +56 -0
  12. package/src/@daf/pages/Summary/Minesite/index.jsx +162 -0
  13. package/src/@daf/pages/Summary/Operator/components/Governance/config.js +26 -0
  14. package/src/@daf/pages/Summary/Operator/components/Governance/helper.js +61 -0
  15. package/src/@daf/pages/Summary/Operator/components/Governance/index.js +55 -0
  16. package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +84 -0
  17. package/src/@daf/pages/Summary/Operator/components/KeyInformation/index.js +46 -0
  18. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/config.js +40 -0
  19. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +98 -0
  20. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +160 -0
  21. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +83 -0
  22. package/src/@daf/pages/Summary/Operator/hook.js +176 -0
  23. package/src/@daf/pages/Summary/Operator/index.jsx +170 -0
  24. package/src/@daf/pages/Summary/components/InformationAvailability/components/Contributions/index.js +36 -0
  25. package/src/@daf/pages/Summary/components/InformationAvailability/components/InformationCompleteness/index.js +58 -0
  26. package/src/@daf/pages/Summary/components/InformationAvailability/index.js +42 -0
  27. package/src/@daf/pages/Summary/hook.js +188 -0
  28. package/src/@daf/services/OperatorService.js +16 -0
  29. package/src/@daf/services/SourceService.js +1 -1
  30. package/src/helpers/StringHelper.js +7 -0
  31. package/src/pages.js +2 -2
  32. package/dist/style/datastake/mapbox-gl.css +0 -330
  33. package/src/@daf/pages/Summary/minesite/index.js +0 -0
  34. package/src/@daf/pages/Summary/operator/index.jsx +0 -76
@@ -5841,7 +5841,7 @@ const useHeader = ({
5841
5841
  };
5842
5842
 
5843
5843
  const {
5844
- useToken: useToken$7
5844
+ useToken: useToken$8
5845
5845
  } = antd.theme;
5846
5846
  function BreadCrumbs({
5847
5847
  breadcrumbs = [],
@@ -5850,7 +5850,7 @@ function BreadCrumbs({
5850
5850
  const [splitIndex, setSplitIndex] = React.useState(0);
5851
5851
  const {
5852
5852
  token
5853
- } = useToken$7();
5853
+ } = useToken$8();
5854
5854
  const _renderBreadcrumb = (b, i, isLast, noOnClickLast = false) => {
5855
5855
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
5856
5856
  className: "flex breadcrumb-item",
@@ -6004,7 +6004,7 @@ DAFHeader.propTypes = {
6004
6004
  };
6005
6005
 
6006
6006
  const {
6007
- useToken: useToken$6
6007
+ useToken: useToken$7
6008
6008
  } = antd.theme;
6009
6009
 
6010
6010
  /**
@@ -6097,7 +6097,7 @@ function Multiselect({
6097
6097
  }) {
6098
6098
  const {
6099
6099
  token
6100
- } = useToken$6();
6100
+ } = useToken$7();
6101
6101
  const [selectValue, setSelectValue] = React.useState(Array.isArray(defaultSelected) ? defaultSelected.length > 0 ? defaultSelected : [] : [defaultSelected]);
6102
6102
  function onSelectChange(value) {
6103
6103
  if (!canUnselectLast && value.length === 0) {
@@ -10525,6 +10525,9 @@ PrimaryNode.propTypes = {
10525
10525
  })
10526
10526
  };
10527
10527
 
10528
+ // import { ICON_NODES } from "../../config.js";
10529
+ const ICON_NODE_WIDTH = 40;
10530
+ const ICON_NODE_HEIGHT = 40;
10528
10531
  function IconNode({
10529
10532
  id,
10530
10533
  data
@@ -10642,14 +10645,14 @@ const Style$6 = styled__default["default"].div`
10642
10645
  // components/Nodes/NameNode.jsx
10643
10646
  const NAME_CARD_WIDTH = 315;
10644
10647
  const {
10645
- useToken: useToken$5
10648
+ useToken: useToken$6
10646
10649
  } = antd.theme;
10647
10650
  function NameNode({
10648
10651
  data
10649
10652
  }) {
10650
10653
  const {
10651
10654
  token
10652
- } = useToken$5();
10655
+ } = useToken$6();
10653
10656
  const translateFN = typeof data?.t === "function" ? data.t : key => key;
10654
10657
  const isPdf = data?.isPdf;
10655
10658
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -10873,6 +10876,9 @@ const Style$4 = styled__default["default"].div`
10873
10876
  }
10874
10877
  }
10875
10878
  `;
10879
+ const EXPANDED_NODE_WIDTH = 535;
10880
+ const EXPANDED_NODE_HEIGHT = 120;
10881
+ const EXPANDED_NODE_ACTIVE_HEIGHT = 50;
10876
10882
  function ExpandedNode({
10877
10883
  data
10878
10884
  }) {
@@ -11724,7 +11730,7 @@ const defaultFetchConfig$6 = {
11724
11730
  filters: {},
11725
11731
  defaultData: []
11726
11732
  };
11727
- function TradeRelationships({
11733
+ function TradeRelationships$1({
11728
11734
  goTo,
11729
11735
  t = () => {},
11730
11736
  options = {},
@@ -11756,7 +11762,7 @@ function TradeRelationships({
11756
11762
  })
11757
11763
  });
11758
11764
  }
11759
- TradeRelationships.propTypes = {
11765
+ TradeRelationships$1.propTypes = {
11760
11766
  goTo: PropTypes__default["default"].func,
11761
11767
  t: PropTypes__default["default"].func,
11762
11768
  options: PropTypes__default["default"].object,
@@ -11863,7 +11869,7 @@ const CustomLegend = ({
11863
11869
  };
11864
11870
 
11865
11871
  const {
11866
- useToken: useToken$4
11872
+ useToken: useToken$5
11867
11873
  } = antd.theme;
11868
11874
 
11869
11875
  /**
@@ -11952,7 +11958,7 @@ function LineChart({
11952
11958
  const chartRef = React__default["default"].useRef(null);
11953
11959
  const {
11954
11960
  token
11955
- } = useToken$4();
11961
+ } = useToken$5();
11956
11962
  const {
11957
11963
  legendEnabled,
11958
11964
  legendItems,
@@ -12954,7 +12960,7 @@ function SupplyChain({
12954
12960
  getRedirectLink: getRedirectLink
12955
12961
  })
12956
12962
  }), /*#__PURE__*/jsxRuntime.jsx("section", {
12957
- children: /*#__PURE__*/jsxRuntime.jsx(TradeRelationships, {
12963
+ children: /*#__PURE__*/jsxRuntime.jsx(TradeRelationships$1, {
12958
12964
  selectedSources: selectedPartners,
12959
12965
  t: t,
12960
12966
  options: options,
@@ -13832,7 +13838,7 @@ function AccumulationGraph({
13832
13838
  }
13833
13839
 
13834
13840
  const {
13835
- useToken: useToken$3
13841
+ useToken: useToken$4
13836
13842
  } = antd.theme;
13837
13843
 
13838
13844
  /**
@@ -13923,7 +13929,7 @@ function BarChart({
13923
13929
  const chartRef = React__default["default"].useRef(null);
13924
13930
  const {
13925
13931
  token
13926
- } = useToken$3();
13932
+ } = useToken$4();
13927
13933
  const {
13928
13934
  legendEnabled,
13929
13935
  legendItems,
@@ -15605,7 +15611,7 @@ const TablePageWithTabs = ({
15605
15611
  };
15606
15612
 
15607
15613
  const {
15608
- useToken: useToken$2
15614
+ useToken: useToken$3
15609
15615
  } = antd.theme;
15610
15616
  const MAX_LENGTH = 3;
15611
15617
  function AvatarGroup({
@@ -15616,7 +15622,7 @@ function AvatarGroup({
15616
15622
  const count = items.length === maxLength + 1 ? items.length : maxLength;
15617
15623
  const {
15618
15624
  token
15619
- } = useToken$2();
15625
+ } = useToken$3();
15620
15626
  return /*#__PURE__*/jsxRuntime.jsx(antd.Avatar.Group, {
15621
15627
  max: {
15622
15628
  count: count,
@@ -19478,12 +19484,12 @@ function Geolocation$1({
19478
19484
  }
19479
19485
 
19480
19486
  const {
19481
- useToken: useToken$1
19487
+ useToken: useToken$2
19482
19488
  } = antd.theme;
19483
19489
  function Smart() {
19484
19490
  const {
19485
19491
  token
19486
- } = useToken$1();
19492
+ } = useToken$2();
19487
19493
  const [isOpen, setIsOpen] = React.useState(false);
19488
19494
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
19489
19495
  style: {
@@ -19567,7 +19573,7 @@ function SmartWidget({
19567
19573
  }) {
19568
19574
  const {
19569
19575
  token
19570
- } = useToken$1();
19576
+ } = useToken$2();
19571
19577
  return /*#__PURE__*/jsxRuntime.jsx(Widget, {
19572
19578
  noTitle: true,
19573
19579
  className: "no-p-body p-xs",
@@ -20615,7 +20621,7 @@ FormPopover.propTypes = {
20615
20621
  };
20616
20622
 
20617
20623
  const {
20618
- useToken
20624
+ useToken: useToken$1
20619
20625
  } = antd.theme;
20620
20626
  const disabledTypes = ["dataLink"];
20621
20627
  function Versions({
@@ -20628,7 +20634,7 @@ function Versions({
20628
20634
  }) {
20629
20635
  const {
20630
20636
  token
20631
- } = useToken();
20637
+ } = useToken$1();
20632
20638
  const dataSource = React.useMemo(() => {
20633
20639
  if (!versionsDatapoints) {
20634
20640
  return [];
@@ -34878,188 +34884,2066 @@ const ProductionSitesTable = ({
34878
34884
  });
34879
34885
  };
34880
34886
 
34881
- function OperatorSummary({
34882
- t = () => {},
34883
- goTo = () => {},
34884
- getRedirectLink = () => {},
34885
- theme = {},
34886
- user = {},
34887
- options = {},
34887
+ const useSummary = ({
34888
+ getOne,
34889
+ getMultiple,
34890
+ id,
34891
+ hasSelect = false,
34892
+ storageKey,
34893
+ data,
34894
+ isPdf,
34895
+ params,
34888
34896
  partners,
34889
34897
  selectedPartners,
34890
- setSelectedPartners,
34891
- informationSources,
34892
- hardcodedData,
34893
- breadCrumbs = []
34894
- }) {
34898
+ user,
34899
+ t,
34900
+ theme = {},
34901
+ service,
34902
+ onIdChange = () => {}
34903
+ }) => {
34904
+ const [search, setSearch] = React.useState("");
34905
+ const [debouncedSearch, setDebouncedSearch] = React.useState("");
34906
+ const [hasInitialized, setHasInitialized] = React.useState(false);
34907
+ const [singleItemData, setSingleItemData] = React.useState();
34908
+ const [loading, setLoading] = React.useState(false);
34909
+ const [_partners, _setPartners] = React.useState();
34910
+ const [selectedItem, setSelectedItem] = React.useState(undefined);
34911
+ const dataOptions = React.useMemo(() => {
34912
+ if (hasSelect) {
34913
+ const mappedData = Array.isArray(data) ? data.map(item => ({
34914
+ label: item?.name,
34915
+ value: item?.datastakeId
34916
+ })) : [];
34917
+ const storedData = StorageManager$1.get(storageKey);
34918
+ if (storedData) {
34919
+ try {
34920
+ const parsedStoredData = JSON.parse(storedData);
34921
+ const existsInData = mappedData?.find(item => item.value === parsedStoredData.value);
34922
+ if (!existsInData) {
34923
+ return [...mappedData, parsedStoredData];
34924
+ }
34925
+ } catch (error) {
34926
+ console.log('Error parsing stored data:', error);
34927
+ }
34928
+ }
34929
+ return mappedData;
34930
+ }
34931
+ }, [data, hasSelect, storageKey]);
34932
+ React.useEffect(() => {
34933
+ if (hasSelect && dataOptions && dataOptions.length > 0 && !debouncedSearch && !hasInitialized) {
34934
+ let selectedValue;
34935
+ if (isPdf) {
34936
+ selectedValue = id;
34937
+ } else {
34938
+ const storedData = StorageManager$1.get(storageKey);
34939
+ if (storedData) {
34940
+ try {
34941
+ const parsedData = JSON.parse(storedData);
34942
+ const existsInOptions = dataOptions?.find(item => item?.value === parsedData?.value);
34943
+ selectedValue = existsInOptions ? parsedData?.value : Array.isArray(dataOptions) ? dataOptions[0]?.value : undefined;
34944
+ } catch (error) {
34945
+ console.log('Error parsing stored data:', error);
34946
+ selectedValue = Array.isArray(dataOptions) ? dataOptions[0]?.value : undefined;
34947
+ }
34948
+ } else {
34949
+ selectedValue = Array.isArray(dataOptions) ? dataOptions[0]?.value : undefined;
34950
+ }
34951
+ }
34952
+ setSelectedItem(selectedValue);
34953
+ setHasInitialized(true);
34954
+ }
34955
+ }, [hasSelect, storageKey, isPdf, id, debouncedSearch, hasInitialized, dataOptions]);
34956
+ React.useEffect(() => {
34957
+ if (selectedItem && Array.isArray(data)) {
34958
+ const selectedData = data.find(item => item?.datastakeId === selectedItem);
34959
+ if (selectedData) {
34960
+ const saved = {
34961
+ label: selectedData.name,
34962
+ value: selectedData.datastakeId
34963
+ };
34964
+ StorageManager$1.set(storageKey, JSON.stringify(saved));
34965
+ }
34966
+ }
34967
+ }, [selectedItem, storageKey, data]);
34968
+ const debouncedSetSearch = React.useMemo(() => _.debounce(value => setDebouncedSearch(value), 300), []);
34969
+ const onSearch = React.useCallback(value => {
34970
+ setSearch(value);
34971
+ debouncedSetSearch(value);
34972
+ }, [debouncedSetSearch]);
34973
+ React.useEffect(() => {
34974
+ setDebouncedSearch("");
34975
+ }, [selectedItem]);
34976
+ const filters = React.useMemo(() => {
34977
+ return {
34978
+ pagination: {
34979
+ size: 20,
34980
+ page: 1
34981
+ },
34982
+ ...(debouncedSearch ? {
34983
+ search: {
34984
+ qs: debouncedSearch,
34985
+ fields: ["name", "datastakeId", "orgShortName"]
34986
+ }
34987
+ } : {})
34988
+ };
34989
+ }, [debouncedSearch]);
34990
+ React.useEffect(() => {
34991
+ if (_partners !== undefined) {
34992
+ if ((params?.id !== null || isPdf && id !== null) && !hasSelect) {
34993
+ getOne({
34994
+ datastakeId: params?.id || id,
34995
+ sources: _partners
34996
+ });
34997
+ }
34998
+ }
34999
+ if (hasSelect && !params?.id) {
35000
+ getMultiple(filters);
35001
+ }
35002
+ }, [params?.id, hasSelect, getOne, getMultiple, _partners, isPdf, id, filters]);
35003
+ React.useEffect(() => {
35004
+ if (selectedItem && _partners !== undefined) {
35005
+ const fetchSingleItem = async () => {
35006
+ setLoading(true);
35007
+ try {
35008
+ const {
35009
+ data
35010
+ } = await service.getOne(selectedItem, {
35011
+ sources: _partners
35012
+ });
35013
+ setSingleItemData(data);
35014
+ } catch (error) {
35015
+ console.log(error);
35016
+ } finally {
35017
+ setLoading(false);
35018
+ }
35019
+ };
35020
+ fetchSingleItem();
35021
+ }
35022
+ }, [selectedItem, service, _partners]);
35023
+ React.useEffect(() => {
35024
+ _setPartners(selectedPartners?.partners);
35025
+ }, [selectedPartners]);
35026
+ React.useEffect(() => {
35027
+ const currentId = params?.id || selectedItem;
35028
+ if (typeof onIdChange === 'function') {
35029
+ if (currentId) {
35030
+ onIdChange(currentId);
35031
+ }
35032
+ }
35033
+ }, [params?.id, selectedItem, onIdChange]);
34895
35034
  const sourceOptions = React.useMemo(() => {
34896
- if (!partners?.length) return [];
34897
- return partners?.map(partner => {
35035
+ return (partners || [])?.map(partner => {
34898
35036
  const isOwnData = partner.id === user?.company?.id;
34899
35037
  return {
34900
- label: partner.nickName,
35038
+ label: isOwnData ? t("Own Data") : partner.nickName,
34901
35039
  value: partner.id,
34902
35040
  avatar: isOwnData ? /*#__PURE__*/jsxRuntime.jsx("span", {
34903
35041
  children: "OWN"
34904
- }) : /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
34905
- name: "Search02",
34906
- size: 14
34907
- }),
35042
+ }) : undefined,
34908
35043
  background: isOwnData ? theme.colorPrimary7 : undefined,
34909
35044
  color: isOwnData ? "white" : undefined
34910
35045
  };
34911
35046
  });
34912
- }, [partners, user]);
34913
- React.useEffect(() => {
34914
- window.theme = theme;
34915
- }, [theme]);
34916
- return /*#__PURE__*/jsxRuntime.jsx(DashboardLayout, {
34917
- header: /*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
34918
- title: t('Operator Summary'),
34919
- addedHeader: /*#__PURE__*/jsxRuntime.jsx("div", {
34920
- children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
34921
- options: [...sourceOptions],
34922
- isAvatarGroup: true,
34923
- selectionType: "checkbox",
34924
- canUnselectLast: false,
34925
- onChange: selected => {
34926
- setSelectedPartners(prev => ({
34927
- ...prev,
34928
- partners: selected,
34929
- loading: false
34930
- }));
34931
- },
34932
- dropDownWidth: 200,
34933
- defaultSelected: partners?.map(p => p.id) || []
34934
- }, partners?.length)
34935
- }),
34936
- breadcrumbs: breadCrumbs
34937
- })
34938
- });
34939
- }
34940
-
34941
- styled__default["default"].div`
34942
- max-width: calc(100% - 48px);
34943
- margin-left: var(--size-lg);
34944
- overflow: hidden;
34945
-
34946
- .daf-table {
34947
- padding: 0px;
34948
- margin-top: 0px;
34949
-
34950
- .ant-tag {
34951
- text-align: center;
34952
- }
34953
- }
34954
-
34955
- .daf-select-filters .filters {
34956
- padding-top: 16px;
34957
- padding-left: 0;
34958
- padding-right: 0;
34959
- }
34960
-
34961
- .daf-table {
34962
- padding-top: 16px;
34963
- }
34964
- `;
34965
- ({
34966
- size: PropTypes__default["default"].any,
34967
- maxHeight: PropTypes__default["default"].number,
34968
- dataSource: PropTypes__default["default"].array,
34969
- columns: PropTypes__default["default"].object,
34970
- pagination: PropTypes__default["default"].any
34971
- });
35047
+ }, [partners, user, hasSelect]);
35048
+ return {
35049
+ selectedItem,
35050
+ setSelectedItem,
35051
+ dataOptions,
35052
+ search,
35053
+ debouncedSearch,
35054
+ onSearch,
35055
+ setSearch,
35056
+ setDebouncedSearch,
35057
+ sourceOptions,
35058
+ singleItemData,
35059
+ loading
35060
+ };
35061
+ };
34972
35062
 
34973
35063
  ({
34974
- data: PropTypes__default["default"].array.isRequired,
34975
- limit: PropTypes__default["default"].number
35064
+ countryName: PropTypes__default["default"].string.isRequired,
35065
+ code: PropTypes__default["default"].string.isRequired,
35066
+ hasTooltip: PropTypes__default["default"].bool
34976
35067
  });
34977
35068
 
34978
- ({
34979
- content: PropTypes__default["default"].string,
34980
- size: PropTypes__default["default"].oneOf(['large', 'middle', 'small']),
34981
- type: PropTypes__default["default"].oneOf(['dashed', 'default', 'ghost', 'link', 'primary', 'text']),
34982
- icon: PropTypes__default["default"].node,
34983
- onClick: PropTypes__default["default"].func,
34984
- disabled: PropTypes__default["default"].bool,
34985
- loading: PropTypes__default["default"].bool,
34986
- title: PropTypes__default["default"].string,
34987
- style: PropTypes__default["default"].object,
34988
- className: PropTypes__default["default"].string
34989
- });
35069
+ const getKeyIndicatorConfig = ({
35070
+ t,
35071
+ data = {},
35072
+ options = {}
35073
+ }) => [{
35074
+ label: t("Country"),
35075
+ render: () => {
35076
+ if (!data?.country) {
35077
+ return "-";
35078
+ }
35079
+ const country = findOptions(data?.country, options?.countries);
35080
+ const code = data?.country;
35081
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
35082
+ title: country,
35083
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
35084
+ alt: code,
35085
+ style: {
35086
+ width: 24,
35087
+ borderRadius: 100,
35088
+ height: 24
35089
+ },
35090
+ src: `https://flagcdn.com/w80/${code.toLowerCase()}.png`
35091
+ })
35092
+ });
35093
+ }
35094
+ }, {
35095
+ label: t("Supply Chain Position"),
35096
+ render: () => {
35097
+ const position = findOptions(data?.positionSupplyChain, options?.positionSupplyChainOptions);
35098
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
35099
+ children: position || "-"
35100
+ });
35101
+ }
35102
+ }, {
35103
+ label: t("Legal Form"),
35104
+ render: () => {
35105
+ const subCategory = findOptions(data?.subCategory, options?.subCategoriesOptions);
35106
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
35107
+ children: subCategory || "-"
35108
+ });
35109
+ }
35110
+ }, {
35111
+ label: t("Products"),
35112
+ render: () => {
35113
+ if ((data?.products || []).length === 0) {
35114
+ return "-";
35115
+ }
35116
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
35117
+ style: {
35118
+ display: "flex",
35119
+ flexWrap: "wrap"
35120
+ },
35121
+ children: data?.products?.map(product => {
35122
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
35123
+ color: "processing",
35124
+ style: {
35125
+ color: "#1677FF",
35126
+ marginBottom: 8
35127
+ },
35128
+ children: t(product)
35129
+ }, product);
35130
+ })
35131
+ });
35132
+ }
35133
+ }, {
35134
+ label: t("Associated Mine Sites"),
35135
+ render: () => {
35136
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
35137
+ children: data?.associatedMineSites || 0
35138
+ });
35139
+ }
35140
+ }, {
35141
+ label: t("Identified Suppliers"),
35142
+ render: () => {
35143
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
35144
+ children: data?.identifiedSuppliers || 0
35145
+ });
35146
+ }
35147
+ }, {
35148
+ label: t("Identified Customers"),
35149
+ render: () => {
35150
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
35151
+ children: data?.identifiedCustomers || 0
35152
+ });
35153
+ }
35154
+ }];
34990
35155
 
34991
- ({
34992
- onClick: PropTypes__default["default"].func,
34993
- isActive: PropTypes__default["default"].bool,
34994
- children: PropTypes__default["default"].any,
34995
- className: PropTypes__default["default"].string
34996
- });
35156
+ const KeyInformation = ({
35157
+ options = {},
35158
+ selectedPartners = {},
35159
+ t = () => {},
35160
+ id = {},
35161
+ data = {},
35162
+ loading = false
35163
+ }) => {
35164
+ // const defaultFetchConfig = useMemo(() => {
35165
+ // return {
35166
+ // basepath: "analytics",
35167
+ // url: '/widgets/key-informations',
35168
+ // defaultData: [],
35169
+ // stop: selectedPartners?.loading,
35170
+ // filters: {
35171
+ // datastakeId: id,
35172
+ // sources: selectedPartners?.partners || [],
35173
+ // },
35174
+ // };
35175
+ // }, [selectedPartners, id]);
35176
+
35177
+ // const { data, loading } = useWidgetFetch({config: defaultFetchConfig});
35178
+
35179
+ const config = React.useMemo(() => getKeyIndicatorConfig({
35180
+ t,
35181
+ data,
35182
+ options
35183
+ }), [t, data, options]);
35184
+ return /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorsWidget, {
35185
+ t: t,
35186
+ config: config,
35187
+ className: "small-content",
35188
+ loading: loading,
35189
+ withTooltip: true,
35190
+ noMinWidth: true
35191
+ });
35192
+ };
34997
35193
 
34998
- styled__default["default"].div`
34999
- .ant-btn {
35000
- border-radius: 100px 100px 100px 0;
35001
- padding: 10px;
35002
- height: fit-content;
35003
- font-size: var(--size);
35004
- line-height: var(--size-lg);
35005
- font-weight: 400;
35006
- width: 100%;
35194
+ const {
35195
+ useToken
35196
+ } = antd.theme;
35197
+ /**
35198
+ * RadialBarChart Component
35199
+ *
35200
+ * A reusable and customizable radial bar chart built on top of AntV's G2Plot `RadialBar` component.
35201
+ * This chart supports percentage-based or absolute values and allows detailed tooltip customization.
35202
+ *
35203
+ * Props:
35204
+ * - data (Array):
35205
+ * Array of data points to be visualized. Each object should contain fields matching `xFieldKey` and `yFieldKey`.
35206
+ * Example: [{ label: 'Item A', value: 40 }]
35207
+ *
35208
+ * - xFieldKey (string):
35209
+ * The key in the data objects used for the X-axis (typically the label).
35210
+ * Default: "label"
35211
+ *
35212
+ * - yFieldKey (string):
35213
+ * The key in the data objects used for the Y-axis (typically the value to plot).
35214
+ * Default: "value"
35215
+ *
35216
+ * - renderTooltipContent (function):
35217
+ * Optional custom tooltip render function. It receives `(title, data)` and should return a React node or HTML content.
35218
+ *
35219
+ * - tooltipConfig (object):
35220
+ * Additional configuration passed to the AntV `tooltip` config.
35221
+ * Can include fields like `showMarkers`, `showTitle`, etc.
35222
+ *
35223
+ * - colorKey (string):
35224
+ * Optional key in data to map unique colors for each bar (via AntV's `colorField`).
35225
+ * If not provided, a single color is used.
35226
+ *
35227
+ * - animation (boolean):
35228
+ * Whether to animate the initial chart render.
35229
+ * Default: false
35230
+ *
35231
+ * - isPercentage (boolean):
35232
+ * If true, calculates the chart's maximum angle based on percentage value (0–100).
35233
+ * Default: true
35234
+ *
35235
+ * - color (string):
35236
+ * Custom hex color string or token for chart bars. Overrides the default theme color.
35237
+ */
35007
35238
 
35008
- @media (${MOBILE_WIDTH}) {
35009
- padding: 0.8rem 2.625rem;
35239
+ function RadialBarChart({
35240
+ data = [],
35241
+ xFieldKey = "label",
35242
+ yFieldKey = "value",
35243
+ renderTooltipContent,
35244
+ tooltipConfig = {},
35245
+ colorKey,
35246
+ animation = false,
35247
+ isPercentage = true,
35248
+ color,
35249
+ isPdf = false,
35250
+ legendConfig = {}
35251
+ }) {
35252
+ const containerRef = React__default["default"].useRef(null);
35253
+ const chartRef = React__default["default"].useRef(null);
35254
+ const {
35255
+ token
35256
+ } = useToken();
35257
+ const {
35258
+ legendEnabled,
35259
+ legendItems,
35260
+ legendPosition,
35261
+ legendLayout,
35262
+ legendInteractive,
35263
+ legendStyle
35264
+ } = useLegendConfig({
35265
+ legendConfig,
35266
+ isPdf
35267
+ });
35268
+ const formattedData = React.useMemo(() => {
35269
+ return data.map(item => ({
35270
+ ...item,
35271
+ originalValue: item[yFieldKey],
35272
+ [yFieldKey]: item[yFieldKey] || 100,
35273
+ isEmptyBar: item[yFieldKey] === 0
35274
+ }));
35275
+ }, [data, yFieldKey]);
35276
+ const maxAngle = React.useMemo(() => {
35277
+ const maxValue = Math.max(...formattedData.map(item => item[yFieldKey]));
35278
+ if (isPercentage) {
35279
+ if (maxValue >= 0 && maxValue <= 100) {
35280
+ return maxValue / 100 * 360;
35281
+ }
35010
35282
  }
35011
-
35012
- &.normal-br {
35013
- border-radius: 8px;
35283
+ if (maxValue >= 10 && maxValue <= 90 && maxValue % 10 === 0) {
35284
+ return maxValue / 100 * 360;
35285
+ }
35286
+ return 360;
35287
+ }, [formattedData, isPercentage, yFieldKey]);
35288
+ React.useEffect(() => {
35289
+ if (!containerRef.current) {
35290
+ return;
35291
+ }
35292
+ const config = {
35293
+ data: formattedData,
35294
+ xField: xFieldKey,
35295
+ yField: yFieldKey,
35296
+ color: color || token.colorPrimary7,
35297
+ colorField: colorKey || undefined,
35298
+ innerRadius: data.length === 1 ? 0.8 : 0.3,
35299
+ maxAngle,
35300
+ tooltip: renderTooltipContent ? {
35301
+ customContent: (title, data) => {
35302
+ // Replace the displayed value with originalValue
35303
+ const updatedData = data.map(d => {
35304
+ const matchedItem = formattedData.find(item => item[xFieldKey] === d.data.label);
35305
+ return {
35306
+ ...d,
35307
+ [yFieldKey]: matchedItem?.originalValue ?? d.data.value,
35308
+ data: {
35309
+ ...d.data,
35310
+ value: matchedItem?.originalValue ?? d.data.value
35311
+ }
35312
+ };
35313
+ });
35314
+ return renderTooltip(renderTooltipContent(title, updatedData));
35315
+ },
35316
+ ...tooltipConfig
35317
+ } : tooltipConfig,
35318
+ label: false,
35319
+ xAxis: false,
35320
+ barBackground: {
35321
+ style: {
35322
+ fill: "#EEEFF0",
35323
+ fillOpacity: 1
35324
+ }
35325
+ },
35326
+ barStyle: item => {
35327
+ const dataItem = formattedData.find(d => d[xFieldKey] === item[xFieldKey]);
35328
+ if (dataItem.isEmptyBar) {
35329
+ return {
35330
+ fill: "#EEEFF0",
35331
+ strokeOpacity: 0
35332
+ };
35333
+ }
35334
+ return undefined;
35335
+ },
35336
+ animation: animation
35337
+ };
35338
+ if (!chartRef.current) {
35339
+ chartRef.current = new g2plot.RadialBar(containerRef.current, config);
35340
+ chartRef.current.render();
35341
+ } else {
35342
+ chartRef.current.update(config);
35014
35343
  }
35344
+ }, [formattedData, xFieldKey, yFieldKey, maxAngle, renderTooltipContent, tooltipConfig, colorKey, animation, color, token.colorPrimary7]);
35345
+ React.useEffect(() => {
35346
+ return () => {
35347
+ if (chartRef.current) {
35348
+ chartRef.current.destroy();
35349
+ chartRef.current = null;
35350
+ }
35351
+ };
35352
+ }, []);
35353
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
35354
+ className: "flex flex-1 flex-column justify-content-center",
35355
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
35356
+ className: "flex justify-content-center",
35357
+ children: /*#__PURE__*/jsxRuntime.jsx(Container, {
35358
+ ref: containerRef,
35359
+ isPdf: isPdf
35360
+ })
35361
+ }), legendEnabled && legendPosition === 'bottom' && /*#__PURE__*/jsxRuntime.jsx(CustomLegend, {
35362
+ items: legendItems,
35363
+ layout: legendLayout,
35364
+ interactive: legendInteractive,
35365
+ style: legendStyle
35366
+ })]
35367
+ });
35368
+ }
35015
35369
 
35016
- &.ant-btn-primary {
35017
- background: var(--color-primary-70);
35370
+ const InformationCompleteness = ({
35371
+ data = {},
35372
+ loading = false,
35373
+ t = () => {}
35374
+ }) => {
35375
+ const graphData = React.useMemo(() => {
35376
+ const keys = {
35377
+ ownDataCompletion: data?.ownDataCompletion || 0,
35378
+ consolidatedCompletion: data?.consolidatedCompletion || 0
35379
+ };
35380
+ const _data = Object.keys(keys).map(key => {
35381
+ const item = keys[key];
35382
+ if (!Array.isArray(item)) {
35383
+ return {
35384
+ label: key?.includes("own") ? t("Own Data") : t("Consolidated"),
35385
+ value: item
35386
+ };
35387
+ }
35388
+ });
35389
+ return _data.filter(item => item !== undefined);
35390
+ }, [data]);
35391
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
35392
+ title: t("Information Completeness"),
35393
+ loading: loading,
35394
+ className: "with-border-header h-w-btn-header",
35395
+ children: /*#__PURE__*/jsxRuntime.jsx(RadialBarChart, {
35396
+ data: graphData,
35397
+ renderTooltipContent: (title, item) => {
35398
+ const value = item?.[0]?.data?.value > 100 ? 100 : item?.[0]?.data?.value || 0;
35399
+ return {
35400
+ title: title,
35401
+ items: [{
35402
+ label: t("Completion"),
35403
+ value: `${value}%`
35404
+ }]
35405
+ };
35406
+ }
35407
+ })
35408
+ });
35409
+ };
35018
35410
 
35019
- &[disabled] {
35020
- opacity: 0.6;
35021
- color: white;
35411
+ const Contributions = ({
35412
+ data = {},
35413
+ loading = false,
35414
+ t = () => {}
35415
+ }) => {
35416
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
35417
+ title: t("Contributions"),
35418
+ className: "with-border-header h-w-btn-header",
35419
+ loading: loading,
35420
+ children: /*#__PURE__*/jsxRuntime.jsx(BarChart, {
35421
+ data: data?.stakeholders || [],
35422
+ xFieldKey: "completedDatapoints",
35423
+ yFieldKey: "author",
35424
+ renderTooltipContent: (title, item) => {
35425
+ return {
35426
+ title: title,
35427
+ items: [{
35428
+ label: t("Datapoints"),
35429
+ value: item?.[0]?.data?.completedDatapoints || 0
35430
+ }]
35431
+ };
35022
35432
  }
35023
- }
35433
+ })
35434
+ });
35435
+ };
35024
35436
 
35025
- &.ant-btn-dark-primary {
35026
- background: #193E61;
35027
- color: white;
35437
+ const InformationAvailability = ({
35438
+ selectedPartners = {},
35439
+ t = () => {},
35440
+ id
35441
+ }) => {
35442
+ const defaultFetchConfig = React.useMemo(() => ({
35443
+ basepath: "analytics",
35444
+ url: "/widgets/completeness",
35445
+ defaultData: [],
35446
+ stop: selectedPartners?.loading,
35447
+ filters: {
35448
+ datastakeId: id,
35449
+ sources: selectedPartners?.partners || []
35028
35450
  }
35451
+ }), [id, selectedPartners]);
35452
+ const {
35453
+ data,
35454
+ loading
35455
+ } = useWidgetFetch({
35456
+ config: defaultFetchConfig
35457
+ });
35458
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
35459
+ title: t("Information Availability"),
35460
+ loading: loading,
35461
+ className: "with-border-header h-w-btn-header",
35462
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
35463
+ className: "flex flex-row flex-col-mobile gap-6",
35464
+ children: [/*#__PURE__*/jsxRuntime.jsx(InformationCompleteness, {
35465
+ data: data,
35466
+ loading: loading,
35467
+ t: t
35468
+ }), /*#__PURE__*/jsxRuntime.jsx(Contributions, {
35469
+ data: data,
35470
+ loading: loading,
35471
+ t: t
35472
+ })]
35473
+ })
35474
+ });
35475
+ };
35029
35476
 
35030
- &.ant-btn-default {
35031
- color: var(--color-primary-70);
35032
- border: 1.5px solid var(--color-primary-70);
35477
+ const topIconColor = "#6C737F";
35478
+ const iconColorStakeholder = "#08979C";
35479
+ const leftBackgroundColorStakeholder = "#B5F5EC";
35480
+ const iconColorLocation = "#C41D7F";
35481
+ const leftBackgroundColorLocation = "#FFD6E7";
35482
+ const topIcons = {
35483
+ building: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35484
+ name: "Building",
35485
+ color: topIconColor,
35486
+ width: 16,
35487
+ height: 16
35488
+ }),
35489
+ factory: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35490
+ name: "Factory",
35491
+ color: topIconColor,
35492
+ width: 16,
35493
+ height: 16
35494
+ }),
35495
+ smelter: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35496
+ name: "Smelter",
35497
+ color: topIconColor,
35498
+ width: 16,
35499
+ height: 16
35500
+ }),
35501
+ internationalTrader: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35502
+ name: "Globe04",
35503
+ color: topIconColor,
35504
+ width: 16,
35505
+ height: 16
35506
+ }),
35507
+ exporter: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35508
+ name: "Truck01",
35509
+ color: topIconColor,
35510
+ width: 16,
35511
+ height: 16
35512
+ }),
35513
+ miningOperator: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35514
+ name: "MineOperators",
35515
+ color: topIconColor,
35516
+ width: 16,
35517
+ height: 16
35518
+ }),
35519
+ mineSite: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35520
+ name: "MineSite",
35521
+ color: topIconColor,
35522
+ width: 16,
35523
+ height: 16
35524
+ }),
35525
+ location: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35526
+ name: "PMESmallLogo",
35527
+ color: topIconColor,
35528
+ width: 16,
35529
+ height: 16
35530
+ }),
35531
+ inCountryTrader: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35532
+ name: "Handshake",
35533
+ color: topIconColor,
35534
+ width: 16,
35535
+ height: 16
35536
+ }),
35537
+ localTradingHouse: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35538
+ name: "Building",
35539
+ color: topIconColor,
35540
+ width: 16,
35541
+ height: 16
35542
+ }),
35543
+ mineralProcessor: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35544
+ name: "Building",
35545
+ color: topIconColor,
35546
+ width: 16,
35547
+ height: 16
35548
+ }),
35549
+ inCountryTransporter: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35550
+ name: "Truck01",
35551
+ color: topIconColor,
35552
+ width: 16,
35553
+ height: 16
35554
+ }),
35555
+ internationalTransporter: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35556
+ name: "Truck01",
35557
+ color: topIconColor,
35558
+ width: 16,
35559
+ height: 16
35560
+ })
35561
+ };
35562
+ const leftIcons = {
35563
+ stakeholder: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35564
+ name: "DashboardStakeholder",
35565
+ color: iconColorStakeholder,
35566
+ width: 16,
35567
+ height: 16
35568
+ }),
35569
+ location: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
35570
+ name: "DashboardLocations",
35571
+ color: iconColorLocation,
35572
+ width: 16,
35573
+ height: 16
35574
+ })
35575
+ };
35033
35576
 
35034
- &.default {
35035
- color: #1F2A37;
35036
- border: 1.5px solid #E5E7EB;
35577
+ const getFilterConfig = ({
35578
+ operatorData = {},
35579
+ options = {},
35580
+ filters = {},
35581
+ t = () => {}
35582
+ }) => {
35583
+ const productSet = new Set();
35584
+ const allTradeMineralOptions = [...(operatorData?.suppliers || []), ...(operatorData?.clients || []), ...(operatorData?.locationSuppliers || [])].flatMap(trade => (trade?.products || []).filter(product => !!product?.typeOfProduct && !productSet.has(product.typeOfProduct)).map(product => {
35585
+ productSet.add(product.typeOfProduct);
35586
+ const label = options?.minerals?.find(mineral => mineral.value === product.typeOfProduct)?.label;
35587
+ return {
35588
+ value: product.typeOfProduct,
35589
+ label: label ?? product.typeOfProduct
35590
+ };
35591
+ }));
35592
+ const combinedMineralOptions = [...allTradeMineralOptions].filter((option, index, self) => {
35593
+ return option && index === self.findIndex(o => o.value === option.value);
35594
+ });
35595
+ const value = filters.products ? {
35596
+ value: filters.products
35597
+ } : {};
35598
+ return [{
35599
+ label: t("Products"),
35600
+ placeholder: t("Select"),
35601
+ key: "products",
35602
+ type: "select",
35603
+ ...value,
35604
+ options: combinedMineralOptions
35605
+ }];
35606
+ };
35607
+ const getLeft = (data = {}, mapChildren = () => {}, supplierLocations = []) => {
35608
+ if (data?.suppliers?.length > 0) {
35609
+ return mapChildren(data.suppliers, data.datastakeId, "left").filter(d => !!d);
35610
+ }
35611
+ const storeLocation = supplierLocations;
35612
+ supplierLocations = [];
35613
+ return storeLocation.map(location => {
35614
+ return mapChildren([location], location.connect, "left");
35615
+ }).flat().filter(d => !!d);
35616
+ };
35617
+ const mapItem = (data, options, goTo, getRedirectLink) => {
35618
+ const {
35619
+ positionSupplyChainOptions,
35620
+ locationCategories
35621
+ } = options || {};
35622
+ return {
35623
+ id: data.datastakeId || "-",
35624
+ datastakeId: data.datastakeId || "-",
35625
+ leftIcon: leftIcons[data.type === "mineSite" ? "location" : "stakeholder"],
35626
+ name: data.name || "-",
35627
+ subTitle: findOptions(data.type, [...(positionSupplyChainOptions || []), ...(locationCategories || [])]),
35628
+ leftBackground: data.type === "mineSite" ? leftBackgroundColorLocation : leftBackgroundColorStakeholder,
35629
+ topIcon: topIcons[data.type],
35630
+ country: {
35631
+ label: findOptions(data.country, options?.countries || []),
35632
+ value: data.country
35633
+ },
35634
+ totalSources: data.sources ?? 0,
35635
+ volume: data?.volume || "",
35636
+ onClick: function () {
35637
+ if (data.type === "mineSite") {
35638
+ return goTo(getRedirectLink(`/app/summary/scl/${data.datastakeId}`));
35037
35639
  }
35640
+ return goTo(getRedirectLink(`/app/summary/operators/${data.datastakeId}`));
35038
35641
  }
35642
+ };
35643
+ };
35039
35644
 
35040
- &.cancel {
35041
- background: #1F4A72;
35042
- color: white;
35043
- border-color: transparent;
35044
- }
35045
-
35046
- &.blue-color {
35047
- color: var(--color-primary-70);
35048
- border-color: var(--color-primary-70);
35645
+ const useTradeRelationship = ({
35646
+ id,
35647
+ selectedPartners,
35648
+ options,
35649
+ goTo,
35650
+ getRedirectLink,
35651
+ filters
35652
+ }) => {
35653
+ const [graphData, setGraphData] = React.useState({});
35654
+ const [loading, setLoading] = React.useState(false);
35655
+ const [fetchedProducts, setFetchedProducts] = React.useState(false);
35656
+ const config = React.useMemo(() => ({
35657
+ basepath: "analytics",
35658
+ url: "/widgets/trade-connection-map",
35659
+ filters: {
35660
+ product: filters?.products,
35661
+ sources: selectedPartners?.partners || []
35049
35662
  }
35050
- }
35051
- `;
35052
-
35053
- styled__default["default"].div`
35054
- display: inline-flex;
35055
- align-items: center;
35056
- justify-content: center;
35057
- gap: 4px;
35058
- padding: 4px;
35059
- max-width: 100%;
35060
-
35061
- overflow: hidden;
35062
- white-space: nowrap;
35663
+ }), [id, filters?.products, selectedPartners?.partners]);
35664
+ const {
35665
+ data
35666
+ } = useWidgetFetch({
35667
+ config: config
35668
+ });
35669
+ const mapItem$1 = data => {
35670
+ return mapItem(data, options, goTo, getRedirectLink);
35671
+ };
35672
+ React.useEffect(() => {
35673
+ if (id && selectedPartners?.partners?.length > 0 && fetchedProducts) {
35674
+ const _fetch = async () => {
35675
+ setLoading(true);
35676
+ try {
35677
+ let supplierLocations = [];
35678
+ const sources = {};
35679
+ const dataSources = [];
35680
+ const mapChildren = (children, parentId, type = "left") => {
35681
+ return children?.map(child => {
35682
+ const childData = mapItem$1(child);
35683
+ if (type === "left") {
35684
+ supplierLocations.push(...(child?.locations || []).map(location => {
35685
+ return {
35686
+ ...location,
35687
+ type: "mineSite",
35688
+ sources: child.sources || 1,
35689
+ suppliers: [],
35690
+ clients: [],
35691
+ connect: child.datastakeId
35692
+ };
35693
+ }));
35694
+ }
35695
+ const children = type === "left" ? [...child.suppliers] : [...child.clients];
35696
+ if (child.datastakeId === data.datastakeId) {
35697
+ dataSources.push(parentId);
35698
+ return null;
35699
+ }
35700
+ if (sources[child.datastakeId]) {
35701
+ if (!sources[child.datastakeId].includes(parentId)) {
35702
+ sources[child.datastakeId].push(parentId);
35703
+ }
35704
+ return null;
35705
+ } else {
35706
+ sources[child.datastakeId] = [parentId];
35707
+ }
35708
+ if (type === "left" && children?.length === 0 && supplierLocations?.length > 0) {
35709
+ const storeLocation = supplierLocations;
35710
+ supplierLocations = [];
35711
+ const children = storeLocation?.map(location => {
35712
+ return mapChildren([location], location.connect, "left");
35713
+ });
35714
+ return {
35715
+ ...childData,
35716
+ sources: sources[child.datastakeId] || [],
35717
+ children: children.flat()?.filter(d => !!d)
35718
+ };
35719
+ }
35720
+ return {
35721
+ ...childData,
35722
+ sources: sources[child.datastakeId] || [],
35723
+ children: children.length > 0 ? mapChildren(children, child.datastakeId, type)?.filter(d => !!d) : []
35724
+ };
35725
+ });
35726
+ };
35727
+ supplierLocations.push(...(data?.locations || []).map(location => {
35728
+ return {
35729
+ ...location,
35730
+ type: "mineSite",
35731
+ suppliers: [],
35732
+ clients: [],
35733
+ connect: data?.datastakeId
35734
+ };
35735
+ }));
35736
+ const graphData = {
35737
+ ...mapItem$1(data),
35738
+ onClick: undefined,
35739
+ sources: dataSources,
35740
+ right: mapChildren(data.clients, data.datastakeId, "right")?.filter(d => !!d),
35741
+ left: getLeft(data, mapChildren, supplierLocations)
35742
+ };
35743
+ console.log({
35744
+ graphData
35745
+ });
35746
+ setGraphData(graphData);
35747
+ } catch (err) {
35748
+ setGraphData({});
35749
+ console.log(err);
35750
+ }
35751
+ setLoading(false);
35752
+ };
35753
+ _fetch();
35754
+ }
35755
+ }, [filters?.products, id, selectedPartners, fetchedProducts]);
35756
+ return {
35757
+ graphData,
35758
+ loading,
35759
+ fetchedProducts,
35760
+ setFetchedProducts,
35761
+ setGraphData,
35762
+ setLoading,
35763
+ data
35764
+ };
35765
+ };
35766
+
35767
+ const NODE_GAP_X = 100;
35768
+ const NODE_GAP_Y = 50;
35769
+ function TradeRelationship({
35770
+ data,
35771
+ maxZoom = 1,
35772
+ minZoom = 0.2,
35773
+ t = s => s,
35774
+ tooltipTitle = "Trade",
35775
+ filtersConfig,
35776
+ onFilterChange = () => {},
35777
+ renderTooltipItems = () => [],
35778
+ getTotal = () => 0
35779
+ }) {
35780
+ const reactFlowWrapper = React.useRef(null);
35781
+ const [nodes, setNodes] = react.useNodesState([]);
35782
+ const [edges, setEdges] = react.useEdgesState([]);
35783
+ const {
35784
+ setViewport,
35785
+ getViewport,
35786
+ fitView
35787
+ } = react.useReactFlow();
35788
+ const [activeNode, setActiveNode] = React.useState(null);
35789
+ // const [initCenter, setInitCenter] = useState(true);
35790
+ const [associatedNodes, setAssociatedNodes] = React.useState(null);
35791
+ React.useEffect(() => {
35792
+ setActiveNode(null);
35793
+ }, [data]);
35794
+ const mappedNodes = React.useMemo(() => nodes.map(n => ({
35795
+ ...n,
35796
+ id: (n?.id || "").toString(),
35797
+ width: 405,
35798
+ height: activeNode === n.id ? 190 : 140,
35799
+ data: {
35800
+ ...n.data,
35801
+ activeNode,
35802
+ setActiveNode,
35803
+ associatedNodes,
35804
+ t
35805
+ }
35806
+ })), [activeNode, setActiveNode, nodes, associatedNodes, t]);
35807
+ const mappedEdges = React.useMemo(() => edges.map(n => ({
35808
+ ...n,
35809
+ id: (n?.id || "").toString(),
35810
+ width: 224,
35811
+ height: 1,
35812
+ data: {
35813
+ ...n.data,
35814
+ activeNode,
35815
+ associatedNodes
35816
+ }
35817
+ })), [edges, activeNode, associatedNodes]);
35818
+ React.useEffect(() => {
35819
+ let yInit = 0;
35820
+ let xInit = 0;
35821
+ const isBilateral = data?.sources?.length >= 1;
35822
+ let customIndex = 0;
35823
+ const isActive = activeNode === data.id;
35824
+ if (Object.keys(data).length === 0) {
35825
+ setNodes([]);
35826
+ setEdges([]);
35827
+ return;
35828
+ }
35829
+ const _nodes = [{
35830
+ id: data.id,
35831
+ type: "expandedNode",
35832
+ position: {
35833
+ x: xInit,
35834
+ y: isActive ? yInit - EXPANDED_NODE_ACTIVE_HEIGHT / 2 : yInit
35835
+ },
35836
+ data
35837
+ }];
35838
+ const _edges = [];
35839
+ if (isBilateral) {
35840
+ (data.sources || []).forEach(source => {
35841
+ const hasPrev = false;
35842
+ _edges.push({
35843
+ id: `e-${data.id}-${source}`,
35844
+ source: source,
35845
+ type: "default",
35846
+ target: data?.id?.toString(),
35847
+ sourceHandle: "left",
35848
+ targetHandle: "right",
35849
+ data: {
35850
+ maxHeight: 0,
35851
+ isBilateral: !hasPrev,
35852
+ type: "left",
35853
+ ...data,
35854
+ getTotal,
35855
+ renderTooltipItems,
35856
+ tooltipTitle,
35857
+ moreLeft: false
35858
+ }
35859
+ });
35860
+ });
35861
+ }
35862
+ const mapChildren = ({
35863
+ children = [],
35864
+ x = 0,
35865
+ sourceHandle,
35866
+ targetHandle,
35867
+ type = "right",
35868
+ prevChildren = [],
35869
+ maxHeight = 0
35870
+ }) => {
35871
+ let _maxHeight = maxHeight;
35872
+ let y = children.length === 1 ? yInit : yInit - children.length / 2 * (EXPANDED_NODE_HEIGHT + NODE_GAP_Y) + NODE_GAP_Y;
35873
+ let addedHeight = 0;
35874
+ const _children = [];
35875
+ let hasActive = children.find(ch => ch.id === activeNode);
35876
+ if (hasActive) {
35877
+ y = y - EXPANDED_NODE_ACTIVE_HEIGHT / 2;
35878
+ }
35879
+ children.forEach((ch, i) => {
35880
+ const _prevNodes = [..._nodes];
35881
+ const _y = Math.round(y + (EXPANDED_NODE_HEIGHT + NODE_GAP_Y) * i + addedHeight);
35882
+ if (activeNode === ch.id) {
35883
+ addedHeight += EXPANDED_NODE_ACTIVE_HEIGHT;
35884
+ }
35885
+ _nodes.push({
35886
+ id: ch?.id?.toString(),
35887
+ type: "expandedNode",
35888
+ position: {
35889
+ x,
35890
+ y: _y
35891
+ },
35892
+ data: ch
35893
+ });
35894
+ if (_y > _maxHeight) {
35895
+ _maxHeight = _y;
35896
+ }
35897
+ (ch.sources || []).forEach(source => {
35898
+ const hasPrev = _prevNodes.find(p => p.id === source);
35899
+ const isCustom = !hasPrev ? true : prevChildren.includes(source) ? false : true;
35900
+ _edges.push({
35901
+ id: `e-${ch.id}-${source}`,
35902
+ source: hasPrev ? source : ch?.id?.toString(),
35903
+ type: isCustom ? "verticalPath" : "defaultEdge",
35904
+ target: hasPrev ? ch?.id?.toString() : source,
35905
+ sourceHandle: sourceHandle,
35906
+ targetHandle: targetHandle,
35907
+ data: {
35908
+ maxHeight: _maxHeight,
35909
+ isBilateral: !hasPrev,
35910
+ type,
35911
+ ...ch,
35912
+ getTotal,
35913
+ customIndex,
35914
+ renderTooltipItems,
35915
+ tooltipTitle,
35916
+ moreLeft: prevChildren.length > children.length
35917
+ }
35918
+ });
35919
+ if (isCustom) {
35920
+ customIndex += 1;
35921
+ }
35922
+ });
35923
+ if (Array.isArray(ch.children)) {
35924
+ _children.push(...ch.children);
35925
+ }
35926
+ });
35927
+ if (_children.length) {
35928
+ mapChildren({
35929
+ children: _children,
35930
+ x: type === "right" ? x + (EXPANDED_NODE_WIDTH + NODE_GAP_X) : x - (EXPANDED_NODE_WIDTH + NODE_GAP_X),
35931
+ sourceHandle,
35932
+ targetHandle,
35933
+ type,
35934
+ maxHeight: _maxHeight,
35935
+ prevChildren: children.map(ch => ch.id)
35936
+ });
35937
+ }
35938
+ };
35939
+ mapChildren({
35940
+ children: data.left,
35941
+ x: xInit - (EXPANDED_NODE_WIDTH + NODE_GAP_X),
35942
+ sourceHandle: "left",
35943
+ targetHandle: "right",
35944
+ type: "left",
35945
+ prevChildren: !isBilateral ? [data.id] : [],
35946
+ maxHeight: 0
35947
+ });
35948
+ mapChildren({
35949
+ children: data.right,
35950
+ x: xInit + (EXPANDED_NODE_WIDTH + NODE_GAP_X),
35951
+ sourceHandle: "right",
35952
+ targetHandle: "left",
35953
+ type: "right",
35954
+ prevChildren: !isBilateral ? [data.id] : [],
35955
+ maxHeight: 0
35956
+ });
35957
+ setNodes(_nodes);
35958
+ setEdges(_edges);
35959
+ }, [data, activeNode]);
35960
+
35961
+ // Used to find associated nodes, when a node is selected
35962
+ React.useEffect(() => {
35963
+ if (activeNode) {
35964
+ let _associatedNodesRight = [activeNode];
35965
+ let _prevAssocatedNodesRight = [];
35966
+ let _associatedNodesLeft = [activeNode];
35967
+ let _prevAssocatedNodesLeft = [];
35968
+ let check = false;
35969
+ const checkSide = ({
35970
+ type = "target",
35971
+ associatedNodes = [],
35972
+ prevAssocatedNodes = []
35973
+ }) => {
35974
+ while (prevAssocatedNodes.length !== associatedNodes.length) {
35975
+ prevAssocatedNodes = [...associatedNodes];
35976
+ const _edges = edges.filter(e => associatedNodes.includes(e[type]));
35977
+ const _allEdges = _edges.reduce((a, e) => [...a, e.source, e.target], []);
35978
+ _allEdges.forEach(e => {
35979
+ if (!associatedNodes.includes(e)) {
35980
+ associatedNodes.push(e);
35981
+ }
35982
+ if (e === data.id && !check) {
35983
+ check = true;
35984
+ checkSide({
35985
+ prevAssocatedNodes: _prevAssocatedNodesRight,
35986
+ associatedNodes: _associatedNodesRight,
35987
+ type: "source"
35988
+ });
35989
+ }
35990
+ });
35991
+ }
35992
+ };
35993
+
35994
+ // Find Targets
35995
+ checkSide({
35996
+ prevAssocatedNodes: _prevAssocatedNodesRight,
35997
+ associatedNodes: _associatedNodesRight
35998
+ });
35999
+ // Find Sources
36000
+ checkSide({
36001
+ prevAssocatedNodes: _prevAssocatedNodesLeft,
36002
+ associatedNodes: _associatedNodesLeft,
36003
+ type: "source"
36004
+ });
36005
+ setAssociatedNodes([..._associatedNodesLeft, ..._associatedNodesRight]);
36006
+ } else {
36007
+ setAssociatedNodes(null);
36008
+ }
36009
+ }, [edges.length, activeNode]);
36010
+ return /*#__PURE__*/jsxRuntime.jsx(BaseGraph, {
36011
+ nodes: mappedNodes,
36012
+ edges: mappedEdges,
36013
+ maxZoom: maxZoom,
36014
+ minZoom: minZoom,
36015
+ setViewport: setViewport,
36016
+ getViewport: getViewport,
36017
+ filtersConfig: filtersConfig,
36018
+ t: t,
36019
+ onFilterChange: onFilterChange,
36020
+ centerFlow: () => {
36021
+ fitView({
36022
+ padding: 0.1,
36023
+ nodes
36024
+ });
36025
+ },
36026
+ ref: reactFlowWrapper
36027
+ });
36028
+ }
36029
+ var TradeRelationship$1 = withProvider(TradeRelationship);
36030
+
36031
+ const TradeRelationships = ({
36032
+ t = () => {},
36033
+ goTo = () => {},
36034
+ operatorData = {},
36035
+ selectedPartners = {},
36036
+ id,
36037
+ options = {},
36038
+ getRedirectLink = () => {}
36039
+ }) => {
36040
+ const [filters, setFilters] = React.useState({});
36041
+ const onFilterChange = filters => {
36042
+ setFilters(p => ({
36043
+ ...p,
36044
+ ...filters
36045
+ }));
36046
+ };
36047
+ const filterConfig = React.useMemo(() => {
36048
+ return getFilterConfig({
36049
+ operatorData,
36050
+ options,
36051
+ filters,
36052
+ t
36053
+ });
36054
+ }, [filters.products, t, options?.minerals, operatorData]);
36055
+ const {
36056
+ graphData,
36057
+ loading,
36058
+ fetchedProducts,
36059
+ setFetchedProducts
36060
+ } = useTradeRelationship({
36061
+ id,
36062
+ selectedPartners,
36063
+ options,
36064
+ goTo,
36065
+ getRedirectLink,
36066
+ filters
36067
+ });
36068
+ React.useEffect(() => {
36069
+ const defaultProduct = filterConfig?.[0]?.options?.[0]?.value;
36070
+ if (!filters.products && defaultProduct) {
36071
+ setFilters(prev => {
36072
+ const data = {
36073
+ ...prev,
36074
+ products: defaultProduct
36075
+ };
36076
+ return data;
36077
+ });
36078
+ }
36079
+ if (!fetchedProducts) {
36080
+ setFetchedProducts(true);
36081
+ }
36082
+ }, [filterConfig]);
36083
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
36084
+ title: t("Trade Relationships"),
36085
+ className: "flex flex-1 with-border-header no-p-body",
36086
+ loading: loading,
36087
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
36088
+ className: "flex flex-1 flex-column justify-content-center",
36089
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
36090
+ style: {
36091
+ height: 600
36092
+ },
36093
+ className: "flex flex-column",
36094
+ children: /*#__PURE__*/jsxRuntime.jsx(TradeRelationship$1, {
36095
+ data: graphData,
36096
+ goTo: goTo,
36097
+ t: t,
36098
+ getTotal: c => {
36099
+ return c.totalSources || 0;
36100
+ },
36101
+ renderTooltipItems: data => [{
36102
+ label: "Volume",
36103
+ value: data?.volume || "--"
36104
+ }],
36105
+ maxZoom: 1.2,
36106
+ minZoom: 0.4,
36107
+ tooltipTitle: "Trade",
36108
+ filtersConfig: filterConfig,
36109
+ onFilterChange: onFilterChange
36110
+ })
36111
+ })
36112
+ })
36113
+ });
36114
+ };
36115
+
36116
+ const IconNodesConfig$1 = {
36117
+ beneficiaries: {
36118
+ name: "nashiriki::beneficiaries",
36119
+ icon: "CoinsHand",
36120
+ order: 3,
36121
+ emptyName: "no-beneficiaries"
36122
+ },
36123
+ boardMembers: {
36124
+ name: "nashiriki::board-members",
36125
+ icon: "Users",
36126
+ order: 1,
36127
+ emptyName: "no-board-members"
36128
+ },
36129
+ management: {
36130
+ name: "nashiriki::management",
36131
+ icon: "Filters",
36132
+ order: 2,
36133
+ emptyName: "no-management"
36134
+ },
36135
+ shareholders: {
36136
+ name: "nashiriki::stakeholders",
36137
+ icon: "PercentCircle",
36138
+ order: 4,
36139
+ emptyName: "no-stakeholders"
36140
+ }
36141
+ };
36142
+
36143
+ const getGovernanceData = ({
36144
+ data,
36145
+ operatorData,
36146
+ id,
36147
+ options,
36148
+ t,
36149
+ goTo,
36150
+ selectedPartners
36151
+ }) => {
36152
+ const {
36153
+ sources,
36154
+ ...rest
36155
+ } = data;
36156
+ const _data = rest;
36157
+ return {
36158
+ id: operatorData?.datastakeId || id,
36159
+ name: t(operatorData?.name || ""),
36160
+ country: {
36161
+ label: options?.countries?.find(country => country.value === operatorData?.country)?.label || "",
36162
+ value: (operatorData?.country || "").toLowerCase() || ""
36163
+ },
36164
+ onClick: () => {
36165
+ goTo(`/app/view/operators/${operatorData?.datastakeId || id}`);
36166
+ },
36167
+ totalSources: selectedPartners?.partners?.length || 0,
36168
+ children: Object.keys(_data)?.map((key, index) => {
36169
+ return {
36170
+ id: key,
36171
+ name: t(IconNodesConfig$1[key]?.name),
36172
+ icon: IconNodesConfig$1[key]?.icon,
36173
+ order: IconNodesConfig$1[key]?.order || index + 1,
36174
+ emptyName: t(`${IconNodesConfig$1[key]?.emptyName}`),
36175
+ activeColour: "#b6f5ec",
36176
+ iconHoverColor: "#fff",
36177
+ hoverColor: "#36cfca",
36178
+ content: _data[key].length,
36179
+ children: _data[key]?.map(child => {
36180
+ return {
36181
+ id: child?.datastakeId || "",
36182
+ name: child?.name || "",
36183
+ country: {
36184
+ label: options?.countries?.find(country => country.value === child?.country)?.label || "",
36185
+ value: (child?.country || "").toLowerCase() || ""
36186
+ },
36187
+ totalSources: child?.sources || 0,
36188
+ tooltipLabel: t("Holding"),
36189
+ onClick: () => {
36190
+ if (child?.type === "operator") {
36191
+ goTo(`/app/operator-summary/${child.datastakeId}`);
36192
+ return;
36193
+ }
36194
+ goTo(`/app/view/stakeholders/${child.datastakeId}`);
36195
+ },
36196
+ value: child?.holding || 0
36197
+ };
36198
+ })
36199
+ };
36200
+ })
36201
+ };
36202
+ };
36203
+
36204
+ const DEFAULT_SIBLING_SPACE = 49;
36205
+ const NO_CHILDREN_SIBLING_SPACE = 46;
36206
+ const DEFAULT_PRIMARY_NODE_SPACE = 33;
36207
+ const SINGLE_CHILDREN_PRIMARY_WITH_CONTENT_SPACE = 36;
36208
+
36209
+ const DATA_NODE_SIZE = {
36210
+ primaryNode: {
36211
+ width: MAIN_NODE_WIDTH,
36212
+ height: MAIN_NODE_HEIGHT
36213
+ },
36214
+ iconNode: {
36215
+ width: ICON_NODE_WIDTH,
36216
+ height: ICON_NODE_HEIGHT
36217
+ },
36218
+ nameNode: {
36219
+ width: NAME_CARD_WIDTH,
36220
+ height: ICON_NODE_HEIGHT
36221
+ }
36222
+ };
36223
+ function positionIconNodes({
36224
+ order,
36225
+ mainNode,
36226
+ offsetY = 250
36227
+ }) {
36228
+ const offsetX = 270;
36229
+ const centerX = mainNode.position.x + MAIN_NODE_WIDTH / 2;
36230
+ const centerY = mainNode.position.y + MAIN_NODE_HEIGHT / 2;
36231
+ switch (order) {
36232
+ case 1:
36233
+ return {
36234
+ x: centerX - offsetX,
36235
+ y: centerY - offsetY
36236
+ };
36237
+ case 2:
36238
+ return {
36239
+ x: centerX + offsetX,
36240
+ y: centerY - offsetY
36241
+ };
36242
+ case 3:
36243
+ return {
36244
+ x: centerX - offsetX,
36245
+ y: centerY + offsetY - ICON_NODE_HEIGHT
36246
+ };
36247
+ case 4:
36248
+ return {
36249
+ x: centerX + offsetX,
36250
+ y: centerY + offsetY - ICON_NODE_HEIGHT
36251
+ };
36252
+ default:
36253
+ return null;
36254
+ }
36255
+ }
36256
+ function positionDataNodes({
36257
+ isLeftSide,
36258
+ isAboveMainNode,
36259
+ iconNode,
36260
+ index,
36261
+ total,
36262
+ mainNode,
36263
+ type,
36264
+ hasContent,
36265
+ isPdf
36266
+ }) {
36267
+ const DATA_NODE_WIDTH = DATA_NODE_SIZE[type].width;
36268
+ const DATA_NODE_HEIGHT = DATA_NODE_SIZE[type].height;
36269
+
36270
+ // const siblingSpace = () => {
36271
+ // if (type === "primaryNode") {
36272
+ // if (iconNode?.data.children?.length === 1 && hasContent) {
36273
+ // return SINGLE_CHILDREN_PRIMARY_WITH_CONTENT_SPACE;
36274
+ // }
36275
+ // return DEFAULT_PRIMARY_NODE_SPACE;
36276
+ // }
36277
+ // if (iconNode?.data?.children?.length === 0) {
36278
+ // return NO_CHILDREN_SIBLING_SPACE;
36279
+ // }
36280
+ // return DEFAULT_SIBLING_SPACE;
36281
+ // };
36282
+
36283
+ // const Y_SPACE_FROM_SIBLINGS = siblingSpace();
36284
+ const X_SPACE_FROM_ICON_NODE = 130;
36285
+ // const MIN_SPACE_REQUIRED = Y_SPACE_FROM_SIBLINGS + DATA_NODE_HEIGHT;
36286
+
36287
+ // const totalHeight = total * MIN_SPACE_REQUIRED;
36288
+
36289
+ iconNode.position.y + ICON_NODE_HEIGHT / 2 + (hasContent ? 26.5 : type === "primaryNode" ? 15 : 16.5);
36290
+ // const startY = iconNodeCenterY - totalHeight / 2;
36291
+ // const END_Y = startY + totalHeight;
36292
+
36293
+ // const yOffset = index * MIN_SPACE_REQUIRED;
36294
+ let yPosition;
36295
+ const iconNodeHandleCenterY = iconNode.position.y + ICON_NODE_HEIGHT / 2 + (hasContent ? 10 : 0);
36296
+ if (type === "nameNode" && total === 1 || isPdf) {
36297
+ yPosition = iconNodeHandleCenterY - DATA_NODE_HEIGHT / 2 - 7;
36298
+ } else {
36299
+ const siblingSpace = () => {
36300
+ if (type === "primaryNode") {
36301
+ if (iconNode?.data.children?.length === 1 && hasContent) {
36302
+ return SINGLE_CHILDREN_PRIMARY_WITH_CONTENT_SPACE;
36303
+ }
36304
+ return DEFAULT_PRIMARY_NODE_SPACE;
36305
+ }
36306
+ if (iconNode?.data?.children?.length === 0) {
36307
+ return NO_CHILDREN_SIBLING_SPACE;
36308
+ }
36309
+ return DEFAULT_SIBLING_SPACE;
36310
+ };
36311
+ const Y_SPACE_FROM_SIBLINGS = siblingSpace();
36312
+ const MIN_SPACE_REQUIRED = Y_SPACE_FROM_SIBLINGS + DATA_NODE_HEIGHT;
36313
+ const totalHeight = total * MIN_SPACE_REQUIRED;
36314
+ const startY = iconNodeHandleCenterY - totalHeight / 2;
36315
+ const END_Y = startY + totalHeight;
36316
+ const yOffset = index * MIN_SPACE_REQUIRED;
36317
+ yPosition = startY + yOffset;
36318
+ if (isAboveMainNode && END_Y >= mainNode.position.y + DATA_NODE_HEIGHT / 2) {
36319
+ yPosition = mainNode.position.y + DATA_NODE_HEIGHT / 2 - totalHeight + yOffset;
36320
+ } else if (!isAboveMainNode && startY < mainNode.position.y + DATA_NODE_HEIGHT / 2) {
36321
+ yPosition = mainNode.position.y + DATA_NODE_HEIGHT / 2 + yOffset;
36322
+ }
36323
+ }
36324
+ return {
36325
+ x: isLeftSide ? iconNode.position.x - (DATA_NODE_WIDTH + X_SPACE_FROM_ICON_NODE) : iconNode.position.x + (X_SPACE_FROM_ICON_NODE + ICON_NODE_WIDTH),
36326
+ y: yPosition
36327
+ };
36328
+ }
36329
+ function StakeholderMappings({
36330
+ data,
36331
+ maxZoom = 1,
36332
+ minZoom = 0.4,
36333
+ isAllOpenDefault = true,
36334
+ isSelectable = true,
36335
+ iconOffsetY = 250,
36336
+ t = s => s,
36337
+ emptyString = undefined,
36338
+ isPdf = false
36339
+ }) {
36340
+ const reactFlowWrapper = React.useRef(null);
36341
+ const [nodes, setNodes] = react.useNodesState([]);
36342
+ const [edges, setEdges] = react.useEdgesState([]);
36343
+ const {
36344
+ setViewport,
36345
+ getViewport,
36346
+ fitView
36347
+ } = react.useReactFlow();
36348
+ const [selectedIconNodes, setSelectedIconNodes] = React.useState([]);
36349
+ const [isChanged, setIsChanged] = React.useState(false);
36350
+ const [mandatoryNodesToFit, setMandatoryNodesToFit] = React.useState([]);
36351
+ React.useEffect(() => {
36352
+ if (!reactFlowWrapper.current) return;
36353
+ const clientHeight = reactFlowWrapper.current.clientHeight;
36354
+ const clientWidth = reactFlowWrapper.current.clientWidth;
36355
+ const centerX = Math.floor(clientWidth / 2);
36356
+ const centerY = Math.floor(clientHeight / 2);
36357
+ const children = data?.children || [];
36358
+ const mandatoryNodes = [];
36359
+ if (emptyString) {
36360
+ const emptyNode = {
36361
+ type: "nameNode",
36362
+ id: "empty-node",
36363
+ data: {
36364
+ isEmpty: true,
36365
+ name: emptyString,
36366
+ icon: data?.icon || "DashboardStakeholder",
36367
+ t: t,
36368
+ isPdf: isPdf
36369
+ },
36370
+ position: {
36371
+ x: centerX - MAIN_NODE_WIDTH / 2,
36372
+ y: centerY - MAIN_NODE_HEIGHT / 2
36373
+ }
36374
+ };
36375
+ setNodes([emptyNode]);
36376
+ mandatoryNodes.push(emptyNode.id);
36377
+ return;
36378
+ }
36379
+ const mainNode = {
36380
+ type: "primaryNode",
36381
+ id: data?.id,
36382
+ data: {
36383
+ name: data?.name,
36384
+ id: data?.id,
36385
+ country: data?.country,
36386
+ icon: data?.icon || "KYC",
36387
+ onClick: data?.onClick || undefined,
36388
+ totalSources: data?.totalSources,
36389
+ backgroundColor: data?.backgroundColor || "#ade9e1",
36390
+ iconColor: data?.iconColor || "#08949a",
36391
+ isPdf: isPdf
36392
+ },
36393
+ position: {
36394
+ x: centerX - MAIN_NODE_WIDTH / 2,
36395
+ y: centerY - MAIN_NODE_HEIGHT / 2
36396
+ }
36397
+ };
36398
+ mandatoryNodes.push(mainNode.id);
36399
+ const iconNodes = children?.map(child => {
36400
+ return {
36401
+ id: child.id,
36402
+ type: "iconNode",
36403
+ data: {
36404
+ name: child.name,
36405
+ type: child.icon,
36406
+ hoverColor: child.hoverColor,
36407
+ iconHoverColor: child.iconHoverColor,
36408
+ content: child.content,
36409
+ children: child?.children || [],
36410
+ order: child.order,
36411
+ isLeftSide: child.order % 2 !== 0,
36412
+ emptyName: child.emptyName,
36413
+ onSelect: !isSelectable ? undefined : nodeId => {
36414
+ if (selectedIconNodes.includes(nodeId)) {
36415
+ setSelectedIconNodes(prev => prev.filter(id => id !== nodeId));
36416
+ } else {
36417
+ setSelectedIconNodes(prev => [...prev, nodeId]);
36418
+ }
36419
+ setIsChanged(true);
36420
+ },
36421
+ isSelected: selectedIconNodes.includes(child.id),
36422
+ activeColour: child.activeColour
36423
+ },
36424
+ position: positionIconNodes({
36425
+ order: child.order,
36426
+ mainNode,
36427
+ offsetY: iconOffsetY
36428
+ })
36429
+ };
36430
+ });
36431
+ mandatoryNodes.push(...iconNodes.map(node => node.id));
36432
+ const iconEdges = [];
36433
+ const openIconNOdes = iconNodes.filter(node => {
36434
+ if (isAllOpenDefault && !isChanged) return true;
36435
+ return selectedIconNodes.includes(node.id);
36436
+ });
36437
+ if (isAllOpenDefault && !isChanged) {
36438
+ setSelectedIconNodes(openIconNOdes.map(node => node.id));
36439
+ }
36440
+ const dataNodes = openIconNOdes.flatMap(node => {
36441
+ const children = node.data.children || [];
36442
+ const total = children?.length || 0;
36443
+ const iconNodeId = node.id;
36444
+ node?.data?.content !== undefined && node?.data?.content !== null;
36445
+ if (children.length === 0) {
36446
+ iconEdges.push({
36447
+ id: `${node.id}-empty`,
36448
+ source: node.id,
36449
+ target: node.data.name + "-name-node",
36450
+ type: "tooltipEdge",
36451
+ data: {
36452
+ isEmpty: true,
36453
+ isOnlyOne: true,
36454
+ isPdf: isPdf
36455
+ },
36456
+ targetHandle: node.data.order % 2 === 0 ? "left-handle-target" : "right-handle-target"
36457
+ });
36458
+ mandatoryNodes.push(`${node.data.name}-name-node`);
36459
+ return [{
36460
+ id: node.data.name + "-name-node",
36461
+ type: "nameNode",
36462
+ data: {
36463
+ isEmpty: true,
36464
+ name: node.data?.emptyName || `No${node.data?.name} identified`,
36465
+ icon: node.data?.type,
36466
+ t: t,
36467
+ isPdf: isPdf
36468
+ },
36469
+ position: positionDataNodes({
36470
+ isLeftSide: node.data.order % 2 !== 0,
36471
+ isAboveMainNode: node.data.order <= 2,
36472
+ iconNode: node,
36473
+ index: 0,
36474
+ total: 1,
36475
+ mainNode,
36476
+ type: "nameNode",
36477
+ hasContent: node?.data?.content !== undefined && node?.data?.content !== null ? true : false
36478
+ })
36479
+ }];
36480
+ }
36481
+ if (isPdf) {
36482
+ iconEdges.push({
36483
+ id: `${node.id}-empty`,
36484
+ source: node.id,
36485
+ target: node.data.name + "-name-node",
36486
+ type: "tooltipEdge",
36487
+ data: {
36488
+ name: node?.data?.name,
36489
+ content: node?.data?.content,
36490
+ isOnlyOne: true,
36491
+ isPdf: true
36492
+ },
36493
+ targetHandle: node.data.order % 2 === 0 ? "left-handle-target" : "right-handle-target"
36494
+ });
36495
+ mandatoryNodes.push(`${node.data.name}-name-node`);
36496
+ return [{
36497
+ id: node.data.name + "-name-node",
36498
+ type: "nameNode",
36499
+ data: {
36500
+ name: node?.data?.name,
36501
+ content: node?.data?.content,
36502
+ icon: node.data?.type,
36503
+ backgroundColor: node?.data?.activeColour,
36504
+ iconColor: node?.data?.hoverColor,
36505
+ isPdf: true,
36506
+ t: t
36507
+ },
36508
+ position: positionDataNodes({
36509
+ isLeftSide: node.data.order % 2 !== 0,
36510
+ isAboveMainNode: node.data.order <= 2,
36511
+ iconNode: node,
36512
+ isPdf: true,
36513
+ index: 0,
36514
+ total: 1,
36515
+ mainNode,
36516
+ type: "nameNode",
36517
+ hasContent: node?.data?.content !== undefined && node?.data?.content !== null ? true : false
36518
+ })
36519
+ }];
36520
+ }
36521
+ return children.map((child, index) => {
36522
+ iconEdges.push({
36523
+ id: `${node.id}-${child.id}`,
36524
+ source: node.id,
36525
+ target: `${child.id}-${iconNodeId}`,
36526
+ type: "tooltipEdge",
36527
+ data: {
36528
+ title: child.name,
36529
+ isOnlyOne: children.length === 1,
36530
+ value: child.value,
36531
+ tooltipHeader: child.tooltipHeader,
36532
+ tooltipLabel: child?.tooltipLabel || "Holding",
36533
+ totalSources: child.totalSources || 0,
36534
+ isPdf: isPdf
36535
+ },
36536
+ targetHandle: node.data.order % 2 === 0 ? "left-handle-target" : "right-handle-target"
36537
+ });
36538
+ const isLeftSide = node.data.order % 2 !== 0;
36539
+ const isAboveMainNode = node.data.order <= 2;
36540
+ if (isAboveMainNode) {
36541
+ if (index >= children.length - 5) {
36542
+ mandatoryNodes.push(`${child.id}-${iconNodeId}`);
36543
+ }
36544
+ } else {
36545
+ if (index <= 5) {
36546
+ mandatoryNodes.push(`${child.id}-${iconNodeId}`);
36547
+ }
36548
+ }
36549
+ return {
36550
+ id: `${child.id}-${iconNodeId}`,
36551
+ type: child.type || "primaryNode",
36552
+ data: {
36553
+ name: child.name,
36554
+ id: child.id,
36555
+ country: child?.country,
36556
+ totalSources: child.totalSources || 0,
36557
+ onClick: child.onClick,
36558
+ backgroundColor: child.backgroundColor || "#ade9e1",
36559
+ iconColor: child.iconColor || "#08949a",
36560
+ icon: child.icon || "UserCircle",
36561
+ content: children.length,
36562
+ isPdf: isPdf
36563
+ },
36564
+ position: positionDataNodes({
36565
+ isLeftSide,
36566
+ isAboveMainNode,
36567
+ iconNode: node,
36568
+ index,
36569
+ total,
36570
+ mainNode,
36571
+ type: child.type || "primaryNode",
36572
+ hasContent: node?.data?.content ? true : false,
36573
+ isPdf: isPdf
36574
+ })
36575
+ };
36576
+ });
36577
+ });
36578
+ const mainNodeEdges = (data?.children || []).map(child => {
36579
+ return {
36580
+ id: `${mainNode.id}-${child.id}`,
36581
+ source: mainNode.id,
36582
+ target: child.id,
36583
+ sourceHandle: child.order % 2 !== 0 ? "left-handle-source" : "right-handle-source",
36584
+ type: "default",
36585
+ data: {
36586
+ group: child.id,
36587
+ type: "mainNode",
36588
+ isPdf: isPdf
36589
+ }
36590
+ };
36591
+ });
36592
+ setMandatoryNodesToFit(() => {
36593
+ setNodes([mainNode, ...iconNodes, ...dataNodes.flat()]);
36594
+ setEdges([...mainNodeEdges, ...iconEdges]);
36595
+ return mandatoryNodes;
36596
+ });
36597
+ }, [reactFlowWrapper.current, JSON.stringify(data), JSON.stringify(selectedIconNodes), isAllOpenDefault, isSelectable, isChanged, emptyString]);
36598
+ return /*#__PURE__*/jsxRuntime.jsx(BaseGraph, {
36599
+ nodes: nodes,
36600
+ mandatoryNodesToFit: mandatoryNodesToFit,
36601
+ edges: edges,
36602
+ maxZoom: maxZoom,
36603
+ withDuration: true,
36604
+ minZoom: minZoom,
36605
+ setViewport: setViewport,
36606
+ getViewport: getViewport,
36607
+ centerFlow: () => {
36608
+ fitView({
36609
+ padding: 0.1,
36610
+ nodes: mandatoryNodesToFit,
36611
+ duration: 300
36612
+ });
36613
+ },
36614
+ ref: reactFlowWrapper,
36615
+ isPdf: isPdf
36616
+ });
36617
+ }
36618
+ var StakeholderMappings$1 = withProvider(StakeholderMappings);
36619
+
36620
+ const Governance = ({
36621
+ selectedPartners = {},
36622
+ operatorData = {},
36623
+ t = () => {},
36624
+ id,
36625
+ options = {},
36626
+ goTo = () => {}
36627
+ }) => {
36628
+ const defaultFetchConfig = React.useMemo(() => {
36629
+ return {
36630
+ basepath: "analytics",
36631
+ url: "/widgets/information-map-graph",
36632
+ filters: {
36633
+ datastakeId: id,
36634
+ sources: selectedPartners?.partners || [],
36635
+ coreSubject: "stakeholder"
36636
+ },
36637
+ defaultData: {},
36638
+ stop: selectedPartners?.loading
36639
+ };
36640
+ }, [selectedPartners]);
36641
+ const {
36642
+ data,
36643
+ loading
36644
+ } = useWidgetFetch({
36645
+ config: defaultFetchConfig
36646
+ });
36647
+ const graphData = React.useMemo(() => {
36648
+ return getGovernanceData({
36649
+ data,
36650
+ operatorData,
36651
+ id,
36652
+ options,
36653
+ t,
36654
+ goTo,
36655
+ selectedPartners
36656
+ });
36657
+ }, [data, operatorData, options, t]);
36658
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
36659
+ loading: loading,
36660
+ title: t("Governance"),
36661
+ className: "with-border-header no-p-body",
36662
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
36663
+ style: {
36664
+ height: 600
36665
+ },
36666
+ children: /*#__PURE__*/jsxRuntime.jsx(StakeholderMappings$1, {
36667
+ data: graphData,
36668
+ maxZoom: 1.1,
36669
+ t: t,
36670
+ isSelectable: true,
36671
+ isAllOpenDefault: true
36672
+ })
36673
+ })
36674
+ });
36675
+ };
36676
+
36677
+ const OperatorSummary = ({
36678
+ hasSelect = false,
36679
+ loading = false,
36680
+ getSingleData = () => {},
36681
+ getMultipleData = () => {},
36682
+ data = [],
36683
+ id = '',
36684
+ storageKey = '',
36685
+ isPdf = false,
36686
+ params = {},
36687
+ partners = [],
36688
+ selectedPartners = {},
36689
+ user = {},
36690
+ t = () => {},
36691
+ theme = {},
36692
+ service,
36693
+ options = {},
36694
+ goTo = () => {},
36695
+ getRedirectLink = () => {},
36696
+ goBack = () => {},
36697
+ onIdChange = () => {}
36698
+ }) => {
36699
+ const {
36700
+ selectedItem,
36701
+ setSelectedItem,
36702
+ dataOptions,
36703
+ search,
36704
+ debouncedSearch,
36705
+ onSearch,
36706
+ setSearch,
36707
+ setDebouncedSearch,
36708
+ sourceOptions,
36709
+ setSelectedPartners,
36710
+ singleItemData,
36711
+ loading: loadingData
36712
+ } = useSummary({
36713
+ getOne: getSingleData,
36714
+ getMultiple: getMultipleData,
36715
+ id,
36716
+ hasSelect,
36717
+ storageKey,
36718
+ data,
36719
+ isPdf: false,
36720
+ params,
36721
+ partners,
36722
+ selectedPartners,
36723
+ user,
36724
+ t,
36725
+ theme,
36726
+ service,
36727
+ onIdChange
36728
+ });
36729
+ return /*#__PURE__*/jsxRuntime.jsxs(DashboardLayout, {
36730
+ header: /*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
36731
+ title: t('Operator Summary'),
36732
+ className: "with-border-header h-w-btn-header no-px-body",
36733
+ goBackTo: !hasSelect && goBack,
36734
+ addedHeaderFirst: true,
36735
+ actionButtons: [{
36736
+ tooltip: t("Details"),
36737
+ icon: "FileEdit",
36738
+ onClick: () => {
36739
+ goTo(getRedirectLink(`/app/view/operators/${params?.id ? params?.id : selectedItem}`));
36740
+ }
36741
+ }, {
36742
+ tooltip: t("Find Data"),
36743
+ icon: "Search",
36744
+ onClick: () => {},
36745
+ disabled: true
36746
+ }],
36747
+ addedHeader: /*#__PURE__*/jsxRuntime.jsx("div", {
36748
+ className: "flex flex-row gap-4",
36749
+ style: {
36750
+ marginRight: 8
36751
+ },
36752
+ children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
36753
+ options: [...sourceOptions],
36754
+ isAvatarGroup: true,
36755
+ selectionType: "checkbox",
36756
+ canUnselectLast: false,
36757
+ onChange: selected => {
36758
+ setSelectedPartners(prev => ({
36759
+ ...prev,
36760
+ partners: selected,
36761
+ loading: false
36762
+ }));
36763
+ },
36764
+ dropDownWidth: 200,
36765
+ defaultSelected: (partners || []).map(p => p.id) || []
36766
+ }, partners?.length)
36767
+ })
36768
+ }),
36769
+ children: [hasSelect && /*#__PURE__*/jsxRuntime.jsx("section", {
36770
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
36771
+ showSearch: true,
36772
+ debounceTimeout: 300,
36773
+ onSearch: onSearch,
36774
+ isSingle: true,
36775
+ style: {
36776
+ height: "40px",
36777
+ width: "100%"
36778
+ },
36779
+ value: selectedItem,
36780
+ onChange: setSelectedItem,
36781
+ options: dataOptions,
36782
+ filterOption: false,
36783
+ loading: loading,
36784
+ notFoundContent: loading ? /*#__PURE__*/jsxRuntime.jsx(antd.Spin, {
36785
+ size: "small"
36786
+ }) : null
36787
+ })
36788
+ }), /*#__PURE__*/jsxRuntime.jsx(KeyInformation, {
36789
+ options: options,
36790
+ selectedPartners: selectedPartners,
36791
+ t: t,
36792
+ id: params?.id || selectedItem,
36793
+ data: hasSelect ? singleItemData : data,
36794
+ loading: loading
36795
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
36796
+ children: /*#__PURE__*/jsxRuntime.jsx(InformationAvailability, {
36797
+ selectedPartners: selectedPartners,
36798
+ t: t,
36799
+ id: params?.id || selectedItem
36800
+ })
36801
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
36802
+ children: /*#__PURE__*/jsxRuntime.jsx(TradeRelationships, {
36803
+ selectedPartners: selectedPartners,
36804
+ t: t,
36805
+ id: params?.id || selectedItem,
36806
+ options: options,
36807
+ goTo: goTo,
36808
+ getRedirectLink: getRedirectLink,
36809
+ operatorData: hasSelect ? singleItemData : data
36810
+ })
36811
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
36812
+ children: /*#__PURE__*/jsxRuntime.jsx(Governance, {
36813
+ selectedPartners: selectedPartners,
36814
+ t: t,
36815
+ id: params?.id || selectedItem,
36816
+ options: options,
36817
+ goTo: goTo,
36818
+ getRedirectLink: getRedirectLink,
36819
+ operatorData: hasSelect ? singleItemData : data
36820
+ })
36821
+ })]
36822
+ });
36823
+ };
36824
+
36825
+ styled__default["default"].div`
36826
+ max-width: calc(100% - 48px);
36827
+ margin-left: var(--size-lg);
36828
+ overflow: hidden;
36829
+
36830
+ .daf-table {
36831
+ padding: 0px;
36832
+ margin-top: 0px;
36833
+
36834
+ .ant-tag {
36835
+ text-align: center;
36836
+ }
36837
+ }
36838
+
36839
+ .daf-select-filters .filters {
36840
+ padding-top: 16px;
36841
+ padding-left: 0;
36842
+ padding-right: 0;
36843
+ }
36844
+
36845
+ .daf-table {
36846
+ padding-top: 16px;
36847
+ }
36848
+ `;
36849
+ ({
36850
+ size: PropTypes__default["default"].any,
36851
+ maxHeight: PropTypes__default["default"].number,
36852
+ dataSource: PropTypes__default["default"].array,
36853
+ columns: PropTypes__default["default"].object,
36854
+ pagination: PropTypes__default["default"].any
36855
+ });
36856
+
36857
+ ({
36858
+ data: PropTypes__default["default"].array.isRequired,
36859
+ limit: PropTypes__default["default"].number
36860
+ });
36861
+
36862
+ ({
36863
+ content: PropTypes__default["default"].string,
36864
+ size: PropTypes__default["default"].oneOf(['large', 'middle', 'small']),
36865
+ type: PropTypes__default["default"].oneOf(['dashed', 'default', 'ghost', 'link', 'primary', 'text']),
36866
+ icon: PropTypes__default["default"].node,
36867
+ onClick: PropTypes__default["default"].func,
36868
+ disabled: PropTypes__default["default"].bool,
36869
+ loading: PropTypes__default["default"].bool,
36870
+ title: PropTypes__default["default"].string,
36871
+ style: PropTypes__default["default"].object,
36872
+ className: PropTypes__default["default"].string
36873
+ });
36874
+
36875
+ ({
36876
+ onClick: PropTypes__default["default"].func,
36877
+ isActive: PropTypes__default["default"].bool,
36878
+ children: PropTypes__default["default"].any,
36879
+ className: PropTypes__default["default"].string
36880
+ });
36881
+
36882
+ styled__default["default"].div`
36883
+ .ant-btn {
36884
+ border-radius: 100px 100px 100px 0;
36885
+ padding: 10px;
36886
+ height: fit-content;
36887
+ font-size: var(--size);
36888
+ line-height: var(--size-lg);
36889
+ font-weight: 400;
36890
+ width: 100%;
36891
+
36892
+ @media (${MOBILE_WIDTH}) {
36893
+ padding: 0.8rem 2.625rem;
36894
+ }
36895
+
36896
+ &.normal-br {
36897
+ border-radius: 8px;
36898
+ }
36899
+
36900
+ &.ant-btn-primary {
36901
+ background: var(--color-primary-70);
36902
+
36903
+ &[disabled] {
36904
+ opacity: 0.6;
36905
+ color: white;
36906
+ }
36907
+ }
36908
+
36909
+ &.ant-btn-dark-primary {
36910
+ background: #193E61;
36911
+ color: white;
36912
+ }
36913
+
36914
+ &.ant-btn-default {
36915
+ color: var(--color-primary-70);
36916
+ border: 1.5px solid var(--color-primary-70);
36917
+
36918
+ &.default {
36919
+ color: #1F2A37;
36920
+ border: 1.5px solid #E5E7EB;
36921
+ }
36922
+ }
36923
+
36924
+ &.cancel {
36925
+ background: #1F4A72;
36926
+ color: white;
36927
+ border-color: transparent;
36928
+ }
36929
+
36930
+ &.blue-color {
36931
+ color: var(--color-primary-70);
36932
+ border-color: var(--color-primary-70);
36933
+ }
36934
+ }
36935
+ `;
36936
+
36937
+ styled__default["default"].div`
36938
+ display: inline-flex;
36939
+ align-items: center;
36940
+ justify-content: center;
36941
+ gap: 4px;
36942
+ padding: 4px;
36943
+ max-width: 100%;
36944
+
36945
+ overflow: hidden;
36946
+ white-space: nowrap;
35063
36947
  text-overflow: ellipsis;
35064
36948
 
35065
36949
  > svg {
@@ -37911,12 +39795,6 @@ styled__default["default"].div`
37911
39795
  }
37912
39796
  `;
37913
39797
 
37914
- ({
37915
- countryName: PropTypes__default["default"].string.isRequired,
37916
- code: PropTypes__default["default"].string.isRequired,
37917
- hasTooltip: PropTypes__default["default"].bool
37918
- });
37919
-
37920
39798
  const getKeyIndicatorsRowConfig = ({
37921
39799
  t,
37922
39800
  data = {}
@@ -38456,11 +40334,435 @@ const RestorationActivitySummary = ({
38456
40334
  });
38457
40335
  };
38458
40336
 
40337
+ function getKeyIndicatorsConfig({
40338
+ t,
40339
+ data
40340
+ }) {
40341
+ return [{
40342
+ label: t("Extraction Methods"),
40343
+ render: () => {
40344
+ if (!data?.extractionPoints?.length) {
40345
+ return "-";
40346
+ }
40347
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
40348
+ style: {
40349
+ display: "flex",
40350
+ flexWrap: "wrap"
40351
+ },
40352
+ children: data?.extractionPoints?.map(method => {
40353
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
40354
+ style: {
40355
+ marginBottom: 8
40356
+ },
40357
+ children: method
40358
+ }, method);
40359
+ })
40360
+ });
40361
+ }
40362
+ }, {
40363
+ label: t("Products"),
40364
+ render: () => {
40365
+ if (data?.productsOfLocation?.length === 0) {
40366
+ return "-";
40367
+ }
40368
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
40369
+ style: {
40370
+ display: "flex",
40371
+ flexWrap: "wrap"
40372
+ },
40373
+ children: data?.productsOfLocation?.map(product => {
40374
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
40375
+ style: {
40376
+ marginBottom: 8
40377
+ },
40378
+ color: getTagColor(product),
40379
+ children: product
40380
+ }, product);
40381
+ })
40382
+ });
40383
+ }
40384
+ }, {
40385
+ label: t("Number of Workers on Site"),
40386
+ render: () => {
40387
+ if (!data.workers) {
40388
+ return "-";
40389
+ }
40390
+ return data.workers;
40391
+ }
40392
+ }];
40393
+ }
40394
+
40395
+ const MineSiteDetails = ({
40396
+ locationData = {},
40397
+ loading = false,
40398
+ t = () => {},
40399
+ options = {}
40400
+ }) => {
40401
+ const data = React.useMemo(() => {
40402
+ return {
40403
+ extractionPoints: (locationData?.extractionMethod || []).map(method => {
40404
+ const _method = options?.extractionMethodsOptions?.find(option => option.value === method)?.label;
40405
+ return _method;
40406
+ }),
40407
+ products: ((locationData?.products || []).map(product => product.typeOfProduct) || []).map(product => {
40408
+ const _product = options?.minerals?.find(option => option.value === product)?.label;
40409
+ return _product;
40410
+ }),
40411
+ workers: locationData?.totalNumberOfWorkers || 0
40412
+ };
40413
+ }, [locationData, options]);
40414
+ const config = React.useMemo(() => getKeyIndicatorsConfig({
40415
+ t,
40416
+ data
40417
+ }), [t, data]);
40418
+ return /*#__PURE__*/jsxRuntime.jsx(KeyIndicatorsWidget, {
40419
+ title: t("Mine Site Details"),
40420
+ className: "value-center small-content row-content-col",
40421
+ config: config,
40422
+ loading: loading,
40423
+ widgetClassName: "custom-width-b"
40424
+ });
40425
+ };
40426
+
40427
+ const LocationMap = ({
40428
+ selectedPartners = {},
40429
+ t = () => {},
40430
+ params,
40431
+ locationData = {},
40432
+ loading = false
40433
+ }) => {
40434
+ const data = React.useMemo(() => {
40435
+ return {
40436
+ gps: locationData?.gps || {},
40437
+ name: locationData?.name || "",
40438
+ admin_level_01: locationData?.linking?.SCL?.[locationData?.administrativeLevel1]?.name || "",
40439
+ admin_level_02: locationData?.linking?.SCL?.[locationData?.administrativeLevel2]?.name || "",
40440
+ country: locationData?.country
40441
+ };
40442
+ }, [locationData]);
40443
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
40444
+ title: t("Location"),
40445
+ className: "no-px no-pb-body overflow-hidden",
40446
+ loading: loading,
40447
+ children: /*#__PURE__*/jsxRuntime.jsx(Map$1, {
40448
+ showSider: false,
40449
+ primaryLink: true,
40450
+ mapConfig: {
40451
+ maxZoom: 10
40452
+ },
40453
+ type: "location",
40454
+ data: [data],
40455
+ renderTooltip: () => {
40456
+ data?.country;
40457
+ const adminLevel1Label = t("Province");
40458
+ const adminLevel2Label = t("Territory");
40459
+ return [{
40460
+ label: t(adminLevel1Label),
40461
+ value: data?.admin_level_01 || "--"
40462
+ }, {
40463
+ label: t(adminLevel2Label),
40464
+ value: data?.admin_level_02 || "--"
40465
+ }];
40466
+ }
40467
+ })
40468
+ });
40469
+ };
40470
+
40471
+ const IconNodesConfig = {
40472
+ operators: {
40473
+ name: "nashiriki::Operators",
40474
+ icon: "Worker",
40475
+ order: 1,
40476
+ emptyName: "no-operators"
40477
+ },
40478
+ traders: {
40479
+ name: "nashiriki::Traders",
40480
+ icon: "Handshake",
40481
+ order: 2,
40482
+ emptyName: "no-traders"
40483
+ },
40484
+ government: {
40485
+ name: "nashiriki::Government",
40486
+ icon: "KYC",
40487
+ order: 3,
40488
+ emptyName: "no-government"
40489
+ },
40490
+ other: {
40491
+ name: "nashiriki::Other",
40492
+ icon: "CivilSociety",
40493
+ order: 4,
40494
+ emptyName: "no-other"
40495
+ }
40496
+ };
40497
+
40498
+ const getStakeholderMappingData = ({
40499
+ data,
40500
+ locationData,
40501
+ id,
40502
+ options,
40503
+ t,
40504
+ goTo,
40505
+ selectedPartners
40506
+ }) => {
40507
+ const _data = data;
40508
+ return {
40509
+ id: id,
40510
+ name: locationData?.name || "",
40511
+ country: {
40512
+ label: options?.countries?.find(country => country.value === locationData?.country)?.label || "",
40513
+ value: (locationData?.country || "").toLowerCase() || ""
40514
+ },
40515
+ onClick: () => goTo(`/app/view/production-sites/${id}`),
40516
+ totalSources: selectedPartners?.partners?.length || 0,
40517
+ backgroundColor: "#FFD6E7",
40518
+ iconColor: "#C41D7F",
40519
+ icon: "DashboardLocations",
40520
+ children: Object.keys(_data)?.map((key, index) => {
40521
+ return {
40522
+ id: key,
40523
+ name: t(IconNodesConfig[key]?.name),
40524
+ icon: IconNodesConfig[key]?.icon,
40525
+ order: IconNodesConfig[key]?.order || index + 1,
40526
+ activeColour: "#b6f5ec",
40527
+ iconHoverColor: "#fff",
40528
+ hoverColor: "#36cfca",
40529
+ content: _data[key].length,
40530
+ emptyName: IconNodesConfig[key]?.emptyName ? t(`nashiriki::${IconNodesConfig[key]?.emptyName}`) : undefined,
40531
+ children: (_data[key] || [])?.map(child => {
40532
+ return {
40533
+ id: child?.datastakeId || "",
40534
+ name: child?.name || "",
40535
+ country: {
40536
+ label: options?.countries?.find(country => country.value === child?.country)?.label || "",
40537
+ value: child?.country ? child?.country?.toLowerCase() : ""
40538
+ },
40539
+ icon: "DashboardStakeholder",
40540
+ onClick: () => {
40541
+ if (child?.type === "operator") {
40542
+ goTo(`/app/summary/operators/${child.datastakeId}`);
40543
+ return;
40544
+ }
40545
+ goTo(`/app/view/stakeholders/${child.datastakeId}`);
40546
+ },
40547
+ totalSources: child?.sources || 0,
40548
+ tooltipHeader: t("nashiriki::link-details"),
40549
+ tooltipLabel: t("nashiriki::sources-reporting"),
40550
+ value: child?.sources || 0
40551
+ };
40552
+ })
40553
+ };
40554
+ })
40555
+ };
40556
+ };
40557
+
40558
+ const StakeholderMapping = ({
40559
+ t = () => {},
40560
+ id,
40561
+ options = {},
40562
+ goTo = () => {},
40563
+ selectedPartners = {},
40564
+ locationData = {}
40565
+ }) => {
40566
+ const defaultFilter = React.useMemo(() => {
40567
+ return {
40568
+ basepath: "analytics",
40569
+ url: "/widgets/information-map-graph",
40570
+ defaultData: [],
40571
+ stop: selectedPartners?.loading,
40572
+ filters: {
40573
+ datastakeId: id,
40574
+ sources: selectedPartners?.partners || [],
40575
+ coreSubject: "location",
40576
+ filterBySources: false,
40577
+ metrics: {
40578
+ operator: ['operator'],
40579
+ government: ['custom', 'governance'],
40580
+ trader: ['trade'],
40581
+ other: ['civilSociety', 'international']
40582
+ }
40583
+ }
40584
+ };
40585
+ }, [selectedPartners, id]);
40586
+ const {
40587
+ data,
40588
+ loading
40589
+ } = useWidgetFetch({
40590
+ config: defaultFilter
40591
+ });
40592
+ const graphData = React.useMemo(() => {
40593
+ return getStakeholderMappingData({
40594
+ data,
40595
+ locationData,
40596
+ id,
40597
+ options,
40598
+ t,
40599
+ goTo,
40600
+ selectedPartners
40601
+ });
40602
+ }, [data, locationData, id, options, t, goTo, selectedPartners]);
40603
+ return /*#__PURE__*/jsxRuntime.jsx(Widget, {
40604
+ loading: loading,
40605
+ title: t("Stakeholder Mapping"),
40606
+ className: "with-border-header no-px no-p-body",
40607
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
40608
+ style: {
40609
+ height: 600
40610
+ },
40611
+ children: /*#__PURE__*/jsxRuntime.jsx(StakeholderMappings$1, {
40612
+ data: graphData,
40613
+ t: t
40614
+ })
40615
+ })
40616
+ });
40617
+ };
40618
+
40619
+ const MineSummary = ({
40620
+ hasSelect = false,
40621
+ loading = false,
40622
+ getSingleData = () => {},
40623
+ getMultipleData = () => {},
40624
+ data = [],
40625
+ id = '',
40626
+ storageKey = '',
40627
+ isPdf = false,
40628
+ params = {},
40629
+ partners = [],
40630
+ selectedPartners = {},
40631
+ user = {},
40632
+ t = () => {},
40633
+ theme = {},
40634
+ service,
40635
+ options = {},
40636
+ goTo = () => {},
40637
+ getRedirectLink = () => {},
40638
+ goBack = () => {},
40639
+ onIdChange = () => {}
40640
+ }) => {
40641
+ const {
40642
+ selectedItem,
40643
+ setSelectedItem,
40644
+ dataOptions,
40645
+ search,
40646
+ debouncedSearch,
40647
+ onSearch,
40648
+ setSearch,
40649
+ setDebouncedSearch,
40650
+ sourceOptions,
40651
+ setSelectedPartners,
40652
+ singleItemData,
40653
+ loading: loadingData
40654
+ } = useSummary({
40655
+ getOne: getSingleData,
40656
+ getMultiple: getMultipleData,
40657
+ id,
40658
+ hasSelect,
40659
+ storageKey,
40660
+ data,
40661
+ isPdf: false,
40662
+ params,
40663
+ partners,
40664
+ selectedPartners,
40665
+ user,
40666
+ t,
40667
+ theme,
40668
+ service,
40669
+ onIdChange
40670
+ });
40671
+ return /*#__PURE__*/jsxRuntime.jsxs(DashboardLayout, {
40672
+ header: /*#__PURE__*/jsxRuntime.jsx(DAFHeader, {
40673
+ title: t('Mine Summary'),
40674
+ className: "with-border-header h-w-btn-header no-px-body",
40675
+ goBackTo: !hasSelect && goBack,
40676
+ addedHeaderFirst: true,
40677
+ actionButtons: [{
40678
+ tooltip: t("Details"),
40679
+ icon: "FileEdit",
40680
+ onClick: () => {
40681
+ goTo(getRedirectLink(`/app/view/production-sites/${params?.id ? params?.id : selectedItem}`));
40682
+ }
40683
+ }, {
40684
+ tooltip: t("Find Data"),
40685
+ icon: "Search",
40686
+ onClick: () => {},
40687
+ disabled: true
40688
+ }],
40689
+ addedHeader: /*#__PURE__*/jsxRuntime.jsx("div", {
40690
+ className: "flex flex-row gap-4",
40691
+ style: {
40692
+ marginRight: 8
40693
+ },
40694
+ children: /*#__PURE__*/jsxRuntime.jsx(Multiselect, {
40695
+ options: [...sourceOptions],
40696
+ isAvatarGroup: true,
40697
+ selectionType: "checkbox",
40698
+ canUnselectLast: false,
40699
+ onChange: selected => {
40700
+ setSelectedPartners(prev => ({
40701
+ ...prev,
40702
+ partners: selected,
40703
+ loading: false
40704
+ }));
40705
+ },
40706
+ dropDownWidth: 200,
40707
+ defaultSelected: (partners || []).map(p => p.id) || []
40708
+ }, partners?.length)
40709
+ })
40710
+ }),
40711
+ children: [hasSelect && /*#__PURE__*/jsxRuntime.jsx("section", {
40712
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
40713
+ showSearch: true,
40714
+ debounceTimeout: 300,
40715
+ onSearch: onSearch,
40716
+ isSingle: true,
40717
+ style: {
40718
+ height: "40px",
40719
+ width: "100%"
40720
+ },
40721
+ value: selectedItem,
40722
+ onChange: setSelectedItem,
40723
+ options: dataOptions,
40724
+ filterOption: false,
40725
+ loading: loading,
40726
+ notFoundContent: loading ? /*#__PURE__*/jsxRuntime.jsx(antd.Spin, {
40727
+ size: "small"
40728
+ }) : null
40729
+ })
40730
+ }), /*#__PURE__*/jsxRuntime.jsxs("section", {
40731
+ children: [/*#__PURE__*/jsxRuntime.jsx(MineSiteDetails, {
40732
+ locationData: hasSelect ? singleItemData : data,
40733
+ loading: loadingData,
40734
+ t: t,
40735
+ options: options
40736
+ }), /*#__PURE__*/jsxRuntime.jsx(LocationMap, {
40737
+ selectedPartners: selectedPartners,
40738
+ t: t,
40739
+ params: params,
40740
+ locationData: hasSelect ? singleItemData : data,
40741
+ loading: loadingData
40742
+ })]
40743
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
40744
+ children: /*#__PURE__*/jsxRuntime.jsx(InformationAvailability, {
40745
+ selectedPartners: selectedPartners,
40746
+ t: t,
40747
+ id: params?.id || selectedItem
40748
+ })
40749
+ }), /*#__PURE__*/jsxRuntime.jsx("section", {
40750
+ children: /*#__PURE__*/jsxRuntime.jsx(StakeholderMapping, {
40751
+ selectedPartners: selectedPartners,
40752
+ t: t,
40753
+ id: params?.id || selectedItem,
40754
+ locationData: hasSelect ? singleItemData : data
40755
+ })
40756
+ })]
40757
+ });
40758
+ };
40759
+
38459
40760
  exports.ActivitiesTable = ActivitiesTable;
38460
40761
  exports.DocumentsTable = DocumentsTable;
38461
40762
  exports.EventsTable = EventsTable;
38462
40763
  exports.IncidentsTable = IncidentsTable;
38463
40764
  exports.LocationsTable = LocationsTable;
40765
+ exports.MineSummary = MineSummary;
38464
40766
  exports.OperatorSummary = OperatorSummary;
38465
40767
  exports.OperatorsTable = OperatorsTable;
38466
40768
  exports.ProductionSitesTable = ProductionSitesTable;