datastake-daf 0.6.830 → 0.6.832
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.js +1538 -1478
- package/dist/hooks/index.js +40 -1
- package/dist/layouts/index.js +2 -2
- package/dist/pages/index.js +1890 -171
- package/dist/services/index.js +121 -0
- package/dist/utils/index.js +15 -1
- package/package.json +1 -1
- package/src/@daf/core/components/EditForm/storyConfig2.js +1176 -728
- package/src/@daf/core/components/Screens/ConflictManagement/components/KeyIndicators/config.js +106 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/KeyIndicators/index.js +47 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/MineSite/helper.js +3 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/MineSite/index.js +218 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/IncidentsTime/hook.js +32 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +73 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/ProblemSolver/hook.js +86 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/ProblemSolver/index.js +102 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/config.js +34 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/components/TerritorialDistribution/index.js +107 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/config.js +5 -0
- package/src/@daf/core/components/Screens/ConflictManagement/components/RisksWidget/index.js +77 -0
- package/src/@daf/core/components/Screens/ConflictManagement/index.js +136 -0
- package/src/@daf/hooks/useWidgetFetch.js +7 -0
- package/src/@daf/layouts/AppLayout/components/MobileDrawer/index.js +1 -1
- package/src/@daf/pages/Events/Testimonials/columns.js +1 -1
- package/src/@daf/pages/Events/columns.js +2 -3
- package/src/@daf/pages/Locations/columns.js +1 -1
- package/src/@daf/pages/Summary/hook.js +52 -19
- package/src/@daf/services/DashboardService.js +9 -0
- package/src/@daf/services/MineSiteService.js +104 -0
- package/src/constants/locales/en/translation.js +1 -0
- package/src/helpers/user.js +16 -1
- package/src/pages.js +4 -1
- package/src/services.js +2 -1
- package/src/utils.js +1 -1
- package/build/favicon.ico +0 -0
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React, { useMemo, useCallback } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { renderTooltipJsx } from '../../../../../../../../utils/tooltip.js';
|
|
4
|
+
import Widget from '../../../../../../../../core/components/Dashboard/Widget/index.jsx';
|
|
5
|
+
import Chart from '../../../../../../../../core/components/Charts/PieChart/chart.jsx';
|
|
6
|
+
import {useWidgetFetch} from '../../../../../../../../hooks/useWidgetFetch.js';
|
|
7
|
+
import { getColors } from './config.js';
|
|
8
|
+
import useTerritorialDistribution from './config.js';
|
|
9
|
+
|
|
10
|
+
function TerritorialDistribution({ selectedPartners = {}, loading: parentLoading = false, t = (s) => s, theme = {}, category = "conflict", selectedRange ,goTo = () => {}, getRedirectLink = () => {}}) {
|
|
11
|
+
const { filters, filtersConfig } = useTerritorialDistribution({ t });
|
|
12
|
+
const colors = getColors(theme);
|
|
13
|
+
|
|
14
|
+
const defaultFetchConfig = useMemo(
|
|
15
|
+
() => ({
|
|
16
|
+
url: "/territorial-distribution",
|
|
17
|
+
filters: {
|
|
18
|
+
...filters,
|
|
19
|
+
category,
|
|
20
|
+
period: selectedRange,
|
|
21
|
+
sources: selectedPartners?.partners || [],
|
|
22
|
+
},
|
|
23
|
+
defaultData: [],
|
|
24
|
+
stop: selectedPartners?.loading,
|
|
25
|
+
}),
|
|
26
|
+
[filters, category, selectedRange, selectedPartners],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const { data, loading } = useWidgetFetch({ config: defaultFetchConfig });
|
|
30
|
+
|
|
31
|
+
const pieData = useMemo(() => {
|
|
32
|
+
if (!data || Array.isArray(data)) return [];
|
|
33
|
+
const all = Object.keys(data);
|
|
34
|
+
const totalEvents = all.reduce((acc, key) => acc + (data[key]?.events?.length || 0), 0);
|
|
35
|
+
|
|
36
|
+
return all
|
|
37
|
+
.sort((a, b) => (data[b]?.events?.length || 0) - (data[a]?.events?.length || 0))
|
|
38
|
+
.map((key, index) => {
|
|
39
|
+
const item = data[key];
|
|
40
|
+
return {
|
|
41
|
+
value: item?.events?.length,
|
|
42
|
+
label: item?.locationData?.name,
|
|
43
|
+
locationData: item?.locationData,
|
|
44
|
+
color: colors[index % colors.length],
|
|
45
|
+
percent: totalEvents ? (item?.events?.length / totalEvents) : 0,
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}, [data, colors]);
|
|
49
|
+
|
|
50
|
+
const isEmpty = !pieData.length;
|
|
51
|
+
|
|
52
|
+
const getTooltipChildren = useCallback((items) => {
|
|
53
|
+
const item = items[0];
|
|
54
|
+
|
|
55
|
+
return renderTooltipJsx({
|
|
56
|
+
title: item?.label || t("Undetermined"),
|
|
57
|
+
link: true,
|
|
58
|
+
onClickLink: () => {
|
|
59
|
+
if (item?.label) {
|
|
60
|
+
goTo(
|
|
61
|
+
`/app/incident?administrativeLevel1=${item?.locationData?.administrativeLevel1}&administrativeLevel2=${item?.locationData?.administrativeLevel2}&country=${item?.locationData?.country}`,
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
goTo("/app/incident");
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
items: [
|
|
68
|
+
{
|
|
69
|
+
label: t("Number of incidents"),
|
|
70
|
+
value: item?.value,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
}, [t, goTo]);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Widget
|
|
78
|
+
loading={loading || parentLoading}
|
|
79
|
+
title={t("Territorial Distribution")}
|
|
80
|
+
className="with-border-header"
|
|
81
|
+
filtersConfig={filtersConfig}
|
|
82
|
+
>
|
|
83
|
+
<Chart
|
|
84
|
+
mouseXOffset={10}
|
|
85
|
+
mouseYOffset={10}
|
|
86
|
+
changeOpacityOnHover={false}
|
|
87
|
+
data={pieData}
|
|
88
|
+
doConstraints={false}
|
|
89
|
+
isPie
|
|
90
|
+
t={t}
|
|
91
|
+
isEmpty={isEmpty}
|
|
92
|
+
getTooltipChildren={getTooltipChildren}
|
|
93
|
+
/>
|
|
94
|
+
</Widget>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
TerritorialDistribution.propTypes = {
|
|
99
|
+
selectedPartners: PropTypes.object,
|
|
100
|
+
loading: PropTypes.bool,
|
|
101
|
+
t: PropTypes.func,
|
|
102
|
+
theme: PropTypes.object,
|
|
103
|
+
category: PropTypes.string,
|
|
104
|
+
selectedRange: PropTypes.string,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default TerritorialDistribution;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Select } from "antd";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import Widget from "../../../../Dashboard/Widget/index.jsx";
|
|
4
|
+
import IncidentsTime from "./components/IncidentsTime/index.js";
|
|
5
|
+
import TerritorialDistribution from "./components/TerritorialDistribution/index.js";
|
|
6
|
+
import ProblemSolver from "./components/ProblemSolver/index.js";
|
|
7
|
+
import { filterOptions } from "./config.js";
|
|
8
|
+
|
|
9
|
+
export default function RisksWidget({
|
|
10
|
+
title = "Analytics",
|
|
11
|
+
selectedPartners = {},
|
|
12
|
+
t = (s) => s,
|
|
13
|
+
goTo = () => {},
|
|
14
|
+
getRedirectLink = (s) => s,
|
|
15
|
+
theme = {},
|
|
16
|
+
APP,
|
|
17
|
+
options = {},
|
|
18
|
+
category = "conflict",
|
|
19
|
+
user = {},
|
|
20
|
+
}) {
|
|
21
|
+
const [range, setRange] = useState(filterOptions[0].value);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Widget
|
|
25
|
+
title={t(title)}
|
|
26
|
+
className="with-border-header month-select-header"
|
|
27
|
+
addedHeader={
|
|
28
|
+
<>
|
|
29
|
+
<div className="flex-1" />
|
|
30
|
+
<div>
|
|
31
|
+
<Select
|
|
32
|
+
value={range}
|
|
33
|
+
className="custom-select white month-select"
|
|
34
|
+
onChange={(val) => setRange(val)}
|
|
35
|
+
>
|
|
36
|
+
{filterOptions.map((o) => (
|
|
37
|
+
<Select.Option value={o.value} key={o.value}>
|
|
38
|
+
{t(o.label)}
|
|
39
|
+
</Select.Option>
|
|
40
|
+
))}
|
|
41
|
+
</Select>
|
|
42
|
+
</div>
|
|
43
|
+
</>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
<div className="flex flex-row flex-col-mobile gap-6">
|
|
47
|
+
<IncidentsTime
|
|
48
|
+
selectedRange={range}
|
|
49
|
+
selectedPartners={selectedPartners}
|
|
50
|
+
t={t}
|
|
51
|
+
theme={theme}
|
|
52
|
+
goTo={goTo}
|
|
53
|
+
getRedirectLink={getRedirectLink}
|
|
54
|
+
options={options}
|
|
55
|
+
user={user}
|
|
56
|
+
/>
|
|
57
|
+
<TerritorialDistribution
|
|
58
|
+
category={category}
|
|
59
|
+
selectedRange={range}
|
|
60
|
+
selectedPartners={selectedPartners}
|
|
61
|
+
t={t}
|
|
62
|
+
theme={theme}
|
|
63
|
+
goTo={goTo}
|
|
64
|
+
getRedirectLink={getRedirectLink}
|
|
65
|
+
/>
|
|
66
|
+
<ProblemSolver
|
|
67
|
+
selectedRange={range}
|
|
68
|
+
selectedPartners={selectedPartners}
|
|
69
|
+
t={t}
|
|
70
|
+
theme={theme}
|
|
71
|
+
goTo={goTo}
|
|
72
|
+
getRedirectLink={getRedirectLink}
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
</Widget>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React, { useMemo, useEffect } from "react";
|
|
2
|
+
import Header from "../../Header/index.jsx";
|
|
3
|
+
import KeyIndicators from "./components/KeyIndicators/index.js";
|
|
4
|
+
import Multiselect from "../../Select/MultiSelect/index.jsx";
|
|
5
|
+
import MineSites from "./components/MineSite/index.js";
|
|
6
|
+
import RisksWidget from "./components/RisksWidget/index.js";
|
|
7
|
+
import { useSources } from "../../../../hooks/useSources.js";
|
|
8
|
+
import { renderBreadCrumbs } from "../../../../../helpers/breadCrumbs.js";
|
|
9
|
+
import CustomIcon from "../../Icon/CustomIcon.jsx";
|
|
10
|
+
|
|
11
|
+
export default function ConflictManagement({
|
|
12
|
+
t=()=>{},
|
|
13
|
+
user = {},
|
|
14
|
+
APP,
|
|
15
|
+
goTo = () => {},
|
|
16
|
+
getRedirectLink = (s) => s,
|
|
17
|
+
theme = {},
|
|
18
|
+
options = {}
|
|
19
|
+
}) {
|
|
20
|
+
const { partners, selectedPartners, setSelectedPartners, informationSources } =
|
|
21
|
+
useSources({ user, t });
|
|
22
|
+
|
|
23
|
+
// const { pushPath } = useHistory();
|
|
24
|
+
|
|
25
|
+
// useEffect(() => {
|
|
26
|
+
// pushPath(`/app/conflict-management`);
|
|
27
|
+
// }, []);
|
|
28
|
+
|
|
29
|
+
const breadCrumbs = useMemo(() => {
|
|
30
|
+
return renderBreadCrumbs({ t, view: "conflict-management", mod: APP, goTo });
|
|
31
|
+
}, [t, APP, goTo]);
|
|
32
|
+
|
|
33
|
+
const sourceOptions = useMemo(() => {
|
|
34
|
+
return partners.map((partner) => {
|
|
35
|
+
const isOwnData = partner.id === user?.company?.id;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
label: partner.nickName,
|
|
39
|
+
value: partner.id,
|
|
40
|
+
avatar: isOwnData ? <span>OWN</span> : <CustomIcon name={"Search02"} width={14} height={14} />,
|
|
41
|
+
background: isOwnData ? theme.colorPrimary7 : undefined,
|
|
42
|
+
color: isOwnData ? "white" : undefined,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}, [partners, user, theme]);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="daf-analysis">
|
|
49
|
+
<Header
|
|
50
|
+
title={t("conflict-management")}
|
|
51
|
+
breadcrumbs={breadCrumbs}
|
|
52
|
+
supportText={
|
|
53
|
+
<>
|
|
54
|
+
{t("Supported by")}{" "}
|
|
55
|
+
<a
|
|
56
|
+
href="https://www.eeas.europa.eu/delegations/dr-congo-kinshasa_en?s=94"
|
|
57
|
+
target="_blank"
|
|
58
|
+
rel="noreferrer"
|
|
59
|
+
>
|
|
60
|
+
{t("European Union")}
|
|
61
|
+
</a>
|
|
62
|
+
</>
|
|
63
|
+
}
|
|
64
|
+
addedHeader={
|
|
65
|
+
<div>
|
|
66
|
+
<div className="flex-1" />
|
|
67
|
+
<Multiselect
|
|
68
|
+
options={[...sourceOptions]}
|
|
69
|
+
isAvatarGroup
|
|
70
|
+
canUnselectLast={false}
|
|
71
|
+
key={partners?.length}
|
|
72
|
+
onChange={(selected) => {
|
|
73
|
+
setSelectedPartners((prev) => ({
|
|
74
|
+
...prev,
|
|
75
|
+
partners: selected,
|
|
76
|
+
loading: false,
|
|
77
|
+
}));
|
|
78
|
+
}}
|
|
79
|
+
dropDownWidth={200}
|
|
80
|
+
selectionType="checkbox"
|
|
81
|
+
defaultSelected={partners.map((p) => p.id) || []}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
}
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<div className="content">
|
|
88
|
+
<div className="view-content">
|
|
89
|
+
<div className="daf-analysis-layout">
|
|
90
|
+
<div className="sections-cont w-pt">
|
|
91
|
+
<section>
|
|
92
|
+
<KeyIndicators
|
|
93
|
+
selectedPartners={selectedPartners}
|
|
94
|
+
partners={
|
|
95
|
+
informationSources > 0
|
|
96
|
+
? informationSources
|
|
97
|
+
: selectedPartners?.partners?.length > 0
|
|
98
|
+
? selectedPartners?.partners?.length
|
|
99
|
+
: 0
|
|
100
|
+
}
|
|
101
|
+
t={t}
|
|
102
|
+
goTo={goTo}
|
|
103
|
+
getRedirectLink={getRedirectLink}
|
|
104
|
+
theme={theme}
|
|
105
|
+
/>
|
|
106
|
+
</section>
|
|
107
|
+
<section>
|
|
108
|
+
<MineSites
|
|
109
|
+
selectedPartners={selectedPartners}
|
|
110
|
+
t={t}
|
|
111
|
+
goTo={goTo}
|
|
112
|
+
getRedirectLink={getRedirectLink}
|
|
113
|
+
theme={theme}
|
|
114
|
+
APP={APP}
|
|
115
|
+
options={options}
|
|
116
|
+
/>
|
|
117
|
+
</section>
|
|
118
|
+
<section>
|
|
119
|
+
<RisksWidget
|
|
120
|
+
selectedPartners={selectedPartners}
|
|
121
|
+
t={t}
|
|
122
|
+
goTo={goTo}
|
|
123
|
+
getRedirectLink={getRedirectLink}
|
|
124
|
+
theme={theme}
|
|
125
|
+
APP={APP}
|
|
126
|
+
options={options}
|
|
127
|
+
/>
|
|
128
|
+
</section>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
2
|
import DashboardService from "../services/DashboardService.js";
|
|
3
|
+
import { isErrorResponse, getErrorMessage } from "../../helpers/errorHandling.js";
|
|
4
|
+
import { message } from "antd";
|
|
3
5
|
|
|
4
6
|
// config: {
|
|
5
7
|
// stop: boolean,
|
|
@@ -25,6 +27,11 @@ export const useWidgetFetch = ({config, getData = DashboardService.getWidget, on
|
|
|
25
27
|
try {
|
|
26
28
|
const { data } = await getData(rest);
|
|
27
29
|
setData(data || defaultData);
|
|
30
|
+
if (isErrorResponse(data)) {
|
|
31
|
+
const errorMessage = getErrorMessage(data);
|
|
32
|
+
message.error(errorMessage);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
28
35
|
onFetch()
|
|
29
36
|
} catch (err) {
|
|
30
37
|
console.log(err);
|
|
@@ -50,7 +50,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
50
50
|
return <div className="daf-default-cell" />;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const type = findOptions(title,
|
|
53
|
+
const type = findOptions(title, options?.testimonialsType);
|
|
54
54
|
|
|
55
55
|
return type ? <Tooltip title={type}>{type}</Tooltip> : '-';
|
|
56
56
|
},
|
|
@@ -51,9 +51,8 @@ export const getColumns = ({ t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
51
51
|
return <div className="daf-default-cell" />
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const type = findOptions(v,
|
|
55
|
-
|
|
56
|
-
return type ? <Tooltip title={type}>{type}</Tooltip> : '-';
|
|
54
|
+
const type = findOptions(v, options?.eventType || options?.eventsType);
|
|
55
|
+
return <Tooltip title={type}>{type}</Tooltip>;
|
|
57
56
|
},
|
|
58
57
|
},
|
|
59
58
|
{
|
|
@@ -43,7 +43,7 @@ export const getColumns = ({t, goTo, user, options, activeTab, getRedirectLink,
|
|
|
43
43
|
return <div className="daf-default-cell" />
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const locationCategories = [...(
|
|
46
|
+
const locationCategories = [...(options?.locationCategories || []), ...(options?.productionSiteCategories || [])]
|
|
47
47
|
|
|
48
48
|
const category = findOptions(v, locationCategories);
|
|
49
49
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useState, useMemo, useCallback, useEffect } from "react"
|
|
2
2
|
import { debounce } from "lodash";
|
|
3
3
|
import { StorageManager } from "../../../helpers/StorageManager.js";
|
|
4
|
+
import { isErrorResponse, getErrorMessage } from "../../../helpers/errorHandling.js";
|
|
5
|
+
import { message } from "antd";
|
|
4
6
|
|
|
5
7
|
export const useSummary = ({
|
|
6
8
|
getOne,
|
|
@@ -131,32 +133,63 @@ export const useSummary = ({
|
|
|
131
133
|
}, [debouncedSearch]);
|
|
132
134
|
|
|
133
135
|
useEffect(() => {
|
|
134
|
-
if (_partners !== undefined) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
136
|
+
// if (_partners !== undefined) {
|
|
137
|
+
// if ((params?.id !== null || (isPdf && id !== null)) && !hasSelect) {
|
|
138
|
+
// getOne({ datastakeId: params?.id || id, sources: _partners });
|
|
139
|
+
// }
|
|
140
|
+
// }
|
|
139
141
|
if (hasSelect && !params?.id) {
|
|
140
142
|
getMultiple(filters);
|
|
141
143
|
}
|
|
142
|
-
}, [
|
|
144
|
+
}, [hasSelect, params?.id, filters]);
|
|
143
145
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
const activeId = useMemo(() => {
|
|
147
|
+
return selectedItem || params?.id;
|
|
148
|
+
}, [selectedItem, params?.id]);
|
|
149
|
+
|
|
150
|
+
const memoizedPartners = useMemo(() => {
|
|
151
|
+
return _partners;
|
|
152
|
+
}, [_partners]);
|
|
153
|
+
|
|
154
|
+
const memoizedService = useMemo(() => {
|
|
155
|
+
return service;
|
|
156
|
+
}, [service]);
|
|
157
|
+
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (!activeId || memoizedPartners === undefined) return;
|
|
160
|
+
|
|
161
|
+
let cancelled = false;
|
|
162
|
+
|
|
163
|
+
const fetchSingleItem = async () => {
|
|
164
|
+
setLoading(true);
|
|
165
|
+
try {
|
|
166
|
+
const { data } = await memoizedService.getOne(activeId, { sources: memoizedPartners });
|
|
167
|
+
|
|
168
|
+
if (cancelled) return;
|
|
169
|
+
|
|
170
|
+
setSingleItemData(data);
|
|
171
|
+
if (isErrorResponse(data)) {
|
|
172
|
+
const errorMessage = getErrorMessage(data);
|
|
173
|
+
message.error(errorMessage);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
} catch (error) {
|
|
177
|
+
if (!cancelled) {
|
|
152
178
|
console.log(error);
|
|
153
|
-
}
|
|
179
|
+
}
|
|
180
|
+
} finally {
|
|
181
|
+
if (!cancelled) {
|
|
154
182
|
setLoading(false);
|
|
155
183
|
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
fetchSingleItem();
|
|
188
|
+
|
|
189
|
+
return () => {
|
|
190
|
+
cancelled = true;
|
|
191
|
+
};
|
|
192
|
+
}, [activeId, memoizedPartners, memoizedService]);
|
|
160
193
|
|
|
161
194
|
useEffect(() => {
|
|
162
195
|
_setPartners(selectedPartners?.partners);
|
|
@@ -24,6 +24,15 @@ class DashboardService extends BaseService {
|
|
|
24
24
|
isUserManager: true,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
// getWidgetConflictManagement({ url, params = {}, filters = {} }) {
|
|
29
|
+
// return this.apiGet({
|
|
30
|
+
// url: `/dashboard/conflict-management${url}`,
|
|
31
|
+
// params: { ...params, ...filters },
|
|
32
|
+
// isApp: true,
|
|
33
|
+
// });
|
|
34
|
+
// }
|
|
35
|
+
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
export default createLazyService(DashboardService);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { BaseService } from "./BaseService.js";
|
|
2
|
+
import { createLazyService } from "./helpers/LazyService.js";
|
|
3
|
+
import { filterCreateData } from "../../helpers/Forms.js";
|
|
4
|
+
|
|
5
|
+
class MineSiteService extends BaseService {
|
|
6
|
+
get(params) {
|
|
7
|
+
const { datastakeId, ...rest } = params;
|
|
8
|
+
if(datastakeId) {
|
|
9
|
+
return this.apiGet({
|
|
10
|
+
url: `/location/${datastakeId}`,
|
|
11
|
+
params: {...rest},
|
|
12
|
+
isApp: true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return this.apiGet({
|
|
16
|
+
url: "/location",
|
|
17
|
+
params: {...rest},
|
|
18
|
+
isApp: true,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getOne(id, params) {
|
|
23
|
+
return this.apiGet({
|
|
24
|
+
url: `/location/${id}`,
|
|
25
|
+
params,
|
|
26
|
+
isApp: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getForm(scope = "create", language = "en") {
|
|
31
|
+
return this.apiGet({
|
|
32
|
+
url: `/forms/location`,
|
|
33
|
+
params: { scope, language },
|
|
34
|
+
isApp: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getAll(params, signal) {
|
|
39
|
+
return this.apiGet({
|
|
40
|
+
url: "/location",
|
|
41
|
+
params,
|
|
42
|
+
signal,
|
|
43
|
+
isApp: true,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
getData(id, sourceId, source, version) {
|
|
48
|
+
return this.apiGet({
|
|
49
|
+
url: `/location/${id}`,
|
|
50
|
+
isApp: true,
|
|
51
|
+
params: { authorId: sourceId, source, version },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
submit(payload) {
|
|
56
|
+
if (payload.id) {
|
|
57
|
+
// eslint-disable-next-line no-unused-vars
|
|
58
|
+
const { namespace, ...data } = payload;
|
|
59
|
+
return this.apiPut({
|
|
60
|
+
url: `/location/${payload.id}`,
|
|
61
|
+
data: filterCreateData(data),
|
|
62
|
+
isApp: true,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (payload?.form) {
|
|
66
|
+
delete payload.form;
|
|
67
|
+
return this.apiPost({
|
|
68
|
+
url: "/location",
|
|
69
|
+
data: filterCreateData(payload),
|
|
70
|
+
isApp: true,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return this.apiPost({
|
|
74
|
+
url: "/location",
|
|
75
|
+
data: filterCreateData(payload),
|
|
76
|
+
isApp: true,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
submitStep(data, id) {
|
|
81
|
+
return this.apiPut({
|
|
82
|
+
isApp: true,
|
|
83
|
+
url: `/location/submit/${id}`,
|
|
84
|
+
data: filterCreateData(data),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
remove(id, data) {
|
|
89
|
+
return this.apiDelete({
|
|
90
|
+
url: `/location/${id}/remove`,
|
|
91
|
+
data: data,
|
|
92
|
+
isApp: true,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getOptions(id = "countries,minerals") {
|
|
97
|
+
return this.apiGet({
|
|
98
|
+
isApp: true,
|
|
99
|
+
url: `/forms/options`,
|
|
100
|
+
params: { id },
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export default createLazyService(MineSiteService);
|
package/src/helpers/user.js
CHANGED
|
@@ -146,7 +146,7 @@ export const userHasInterface = (user, app, intf) => {
|
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
export const userIsAdmin = (user) => {
|
|
149
|
-
return user?.role?.id === 'APP_ADMIN';
|
|
149
|
+
return user?.role?.id === 'APP_ADMIN' || user?.role?.id === 'SUPER_ADMIN';
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
export const createModule = (selectedModule, role = "user") => {
|
|
@@ -193,3 +193,18 @@ export function getRedirectPath(user, fallback = '', app, isDatastake) {
|
|
|
193
193
|
|
|
194
194
|
return isDatastake ? `/${app}/app` : '/app';
|
|
195
195
|
}
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
export function mapUser(user) {
|
|
199
|
+
return {
|
|
200
|
+
...user,
|
|
201
|
+
company: user.company,
|
|
202
|
+
verified: user.emailVerified,
|
|
203
|
+
companyId: user?.company?.id,
|
|
204
|
+
modules: Array.isArray(user.company?.modules) ?
|
|
205
|
+
user.company?.modules.reduce((all, item) => {
|
|
206
|
+
all[item.id] = item;
|
|
207
|
+
return all;
|
|
208
|
+
}, {}) : user.company?.modules || {},
|
|
209
|
+
};
|
|
210
|
+
}
|
package/src/pages.js
CHANGED
|
@@ -20,4 +20,7 @@ export { default as UsersTable } from './@daf/core/components/Screens/Users/inde
|
|
|
20
20
|
export { default as View } from './@daf/pages/View/index.jsx';
|
|
21
21
|
|
|
22
22
|
// Edit
|
|
23
|
-
export { default as Edit } from './@daf/pages/Edit/index.jsx';
|
|
23
|
+
export { default as Edit } from './@daf/pages/Edit/index.jsx';
|
|
24
|
+
|
|
25
|
+
// Conflict Management
|
|
26
|
+
export { default as ConflictManagement } from './@daf/core/components/Screens/ConflictManagement/index.js';
|
package/src/services.js
CHANGED
|
@@ -20,4 +20,5 @@ export { default as LinkedSubjectsService } from './@daf/services/LinkedSubjects
|
|
|
20
20
|
export { default as OperatorService } from './@daf/services/OperatorService.js';
|
|
21
21
|
export { default as PartnerService } from './@daf/services/PartnerService.js';
|
|
22
22
|
export { default as EventsService } from './@daf/services/EventsService.js';
|
|
23
|
-
export { default as WorkersService } from './@daf/services/WorkersService.js';
|
|
23
|
+
export { default as WorkersService } from './@daf/services/WorkersService.js';
|
|
24
|
+
export { default as MineSiteService } from './@daf/services/MineSiteService.js';
|
package/src/utils.js
CHANGED
|
@@ -21,7 +21,7 @@ export { getOptionConfig, getOptionLabel } from './@daf/core/components/DynamicV
|
|
|
21
21
|
|
|
22
22
|
export { defaultMapConfig } from './@daf/hooks/useMapHelper.js';
|
|
23
23
|
|
|
24
|
-
export { getInterface, modules, isSuperAdmin, isModuleApproved, userHasInterface, userIsAdmin, createModule, mapModulesFromApps, getRedirectPath } from './helpers/user.js'
|
|
24
|
+
export { getInterface, modules, isSuperAdmin, isModuleApproved, userHasInterface, userIsAdmin, createModule, mapModulesFromApps, getRedirectPath, mapUser } from './helpers/user.js'
|
|
25
25
|
|
|
26
26
|
export { default as locales } from './constants/locales/index.js';
|
|
27
27
|
|
package/build/favicon.ico
DELETED
|
Binary file
|
package/build/logo192.png
DELETED
|
Binary file
|
package/build/logo512.png
DELETED
|
Binary file
|