datastake-daf 0.6.762 → 0.6.764
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 +205 -165
- package/dist/hooks/index.js +1 -5
- package/dist/layouts/index.js +36 -11
- package/dist/pages/index.js +1922 -1021
- package/dist/services/index.js +1 -21
- package/dist/utils/index.js +0 -6
- package/package.json +1 -1
- package/src/@daf/core/components/Graphs/StakeholderMappings/index.jsx +2 -0
- package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +2 -1
- package/src/@daf/core/components/Screens/TableScreen/TablePageWithTabs/index.jsx +9 -4
- package/src/@daf/core/components/Screens/Users/config.js +0 -1
- package/src/@daf/core/components/Table/index.jsx +2 -2
- package/src/@daf/core/components/UI/KeyIndicatorNavigateLabel/index.jsx +29 -0
- package/src/@daf/hooks/useFilters.js +1 -3
- package/src/@daf/layouts/AppLayout/components/MobileDrawer/index.js +4 -2
- package/src/@daf/layouts/AppLayout/components/UserDropdown/index.js +23 -2
- package/src/@daf/layouts/AppLayout/index.jsx +2 -0
- package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/GenderDistribution/config.js +7 -6
- package/src/@daf/pages/Dashboards/SupplyChain/components/ChartsContainer/components/GenderDistribution/index.js +2 -1
- package/src/@daf/pages/Dashboards/SupplyChain/components/KeyIndicators/config.js +29 -53
- package/src/@daf/pages/Dashboards/SupplyChain/index.jsx +2 -2
- package/src/@daf/pages/Dashboards/UserDashboard/components/DataCompilation/index.jsx +1 -0
- package/src/@daf/pages/Dashboards/UserDashboard/components/DataConsilidation/index.jsx +0 -1
- package/src/@daf/pages/Dashboards/UserDashboard/components/KeyIndicators/config.js +36 -70
- package/src/@daf/pages/Documents/index.jsx +9 -13
- package/src/@daf/pages/Events/Activities/index.jsx +8 -21
- package/src/@daf/pages/Events/Incidents/index.jsx +8 -21
- package/src/@daf/pages/Events/config.js +0 -1
- package/src/@daf/pages/Events/index.jsx +8 -20
- package/src/@daf/pages/Locations/MineSite/columns.js +3 -3
- package/src/@daf/pages/Locations/MineSite/config.js +0 -1
- package/src/@daf/pages/Locations/MineSite/index.jsx +8 -21
- package/src/@daf/pages/Locations/index.jsx +9 -12
- package/src/@daf/pages/Partners/columns.js +421 -0
- package/src/@daf/pages/Partners/config.js +32 -0
- package/src/@daf/pages/Partners/create.jsx +145 -0
- package/src/@daf/pages/Partners/edit.jsx +98 -0
- package/src/@daf/pages/Partners/hook.js +153 -0
- package/src/@daf/pages/Partners/index.jsx +233 -8
- package/src/@daf/pages/Stakeholders/Operators/index.jsx +8 -22
- package/src/@daf/pages/Stakeholders/Workers/index.jsx +8 -21
- package/src/@daf/pages/Stakeholders/index.jsx +9 -10
- package/src/@daf/pages/hook.js +34 -0
- package/src/@daf/services/PartnerService.js +1 -16
- package/src/helpers/breadCrumbs.js +0 -2
- package/src/index.js +1 -1
- package/src/pages.js +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const filtersConfig = {
|
|
2
|
+
name: "",
|
|
3
|
+
datastakeId: "",
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const selectFiltersConfig = {
|
|
7
|
+
category: {
|
|
8
|
+
type: "select",
|
|
9
|
+
label: "Category",
|
|
10
|
+
placeholder: (t) => `${t("Filter by")} ${t("Category").toLowerCase()}`,
|
|
11
|
+
style: { flex: 1 },
|
|
12
|
+
labelStyle: { flex: 1 },
|
|
13
|
+
getLabel: (option) => option.label,
|
|
14
|
+
getValue: (option) => option.value,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const checkboxConfig = {
|
|
19
|
+
name: "Name",
|
|
20
|
+
datastakeId: "ID",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const partnerTypes = [
|
|
24
|
+
{ label: "Individual", value: "individual" },
|
|
25
|
+
{ label: "Organisation", value: "organisation" },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export const partnershipTypes = [
|
|
29
|
+
{ label: "Source", value: "source" },
|
|
30
|
+
{ label: "Client", value: "client" },
|
|
31
|
+
{ label: "Exchange", value: "exchange" },
|
|
32
|
+
];
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
import PartnerService from '../../services/PartnerService.js';
|
|
4
|
+
import DynamicForm from '../../core/components/DynamicForm/index.jsx';
|
|
5
|
+
import { partnershipTypes, partnerTypes } from './config.js';
|
|
6
|
+
|
|
7
|
+
const data = {};
|
|
8
|
+
|
|
9
|
+
const Create = ({
|
|
10
|
+
query,
|
|
11
|
+
goTo = () => {},
|
|
12
|
+
user,
|
|
13
|
+
t = () => {},
|
|
14
|
+
ajaxForms,
|
|
15
|
+
changeAjaxForms = () => {},
|
|
16
|
+
ajaxOptions,
|
|
17
|
+
changeAjaxOptions = () => {},
|
|
18
|
+
onClose = () => {},
|
|
19
|
+
fetchData = () => {},
|
|
20
|
+
APP,
|
|
21
|
+
getAppHeader = () => {},
|
|
22
|
+
getApiBaseUrl = () => {},
|
|
23
|
+
}) => {
|
|
24
|
+
|
|
25
|
+
const form = useMemo(
|
|
26
|
+
() => ({
|
|
27
|
+
identification: {
|
|
28
|
+
partnershipType: {
|
|
29
|
+
label: t("Type of partnership"),
|
|
30
|
+
type: "select",
|
|
31
|
+
position: 1,
|
|
32
|
+
dataId: "partnershipType",
|
|
33
|
+
tooltip: (
|
|
34
|
+
<div style={{ maxWidth: 296 }}>
|
|
35
|
+
{t("Source: This partner will share information with you.")}
|
|
36
|
+
<br />
|
|
37
|
+
{t("Client: You will share information with this partner.")}
|
|
38
|
+
<br />
|
|
39
|
+
{t("Exchange: You will both share information with each other.")}
|
|
40
|
+
</div>
|
|
41
|
+
),
|
|
42
|
+
options: partnershipTypes.map((o) => ({ ...o, label: t(o.label) })),
|
|
43
|
+
rules: [{ required: true, message: "errors::field is required" }],
|
|
44
|
+
},
|
|
45
|
+
partnerType: {
|
|
46
|
+
label: t("Type of partner"),
|
|
47
|
+
type: "select",
|
|
48
|
+
position: 2,
|
|
49
|
+
dataId: "partnerType",
|
|
50
|
+
options: partnerTypes.map((o) => ({ ...o, label: t(o.label) })),
|
|
51
|
+
rules: [{ required: true, message: "errors::field is required" }],
|
|
52
|
+
},
|
|
53
|
+
nickName: {
|
|
54
|
+
label: {
|
|
55
|
+
"partnerType is individual": t("Person name"),
|
|
56
|
+
"partnerType is organisation": t("Organisation name"),
|
|
57
|
+
},
|
|
58
|
+
type: "text",
|
|
59
|
+
position: 3,
|
|
60
|
+
showIf: "partnerType notEmpty true",
|
|
61
|
+
dataId: "nickName",
|
|
62
|
+
rules: [{ required: true, message: "errors::field is required" }],
|
|
63
|
+
},
|
|
64
|
+
invitationType: {
|
|
65
|
+
label: t("Invitation type"),
|
|
66
|
+
type: "select",
|
|
67
|
+
position: 3,
|
|
68
|
+
dataId: "invitationType",
|
|
69
|
+
options: [
|
|
70
|
+
{ label: "Email", value: "email" },
|
|
71
|
+
{ label: "Application ID", value: "id" },
|
|
72
|
+
],
|
|
73
|
+
rules: [{ required: true, message: "errors::field is required" }],
|
|
74
|
+
},
|
|
75
|
+
email: {
|
|
76
|
+
label: t("Email"),
|
|
77
|
+
type: "text",
|
|
78
|
+
position: 4,
|
|
79
|
+
showIf: "invitationType is email",
|
|
80
|
+
dataId: "email",
|
|
81
|
+
rules: [
|
|
82
|
+
{ required: true, message: "errors::field is required" },
|
|
83
|
+
{ type: "email", message: "errors::field must be email" },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
datastakeId: {
|
|
87
|
+
label: t("Application ID"),
|
|
88
|
+
type: "text",
|
|
89
|
+
position: 4,
|
|
90
|
+
showIf: "invitationType is id",
|
|
91
|
+
dataId: "datastakeId",
|
|
92
|
+
rules: [{ required: true, message: "errors::field is required" }],
|
|
93
|
+
},
|
|
94
|
+
partnerMessage: {
|
|
95
|
+
type: "message",
|
|
96
|
+
position: 4,
|
|
97
|
+
label: t(
|
|
98
|
+
"If the user you are inviting is part of an existing organisation, the invitation will be shared with the account administrator of that organisation.",
|
|
99
|
+
),
|
|
100
|
+
showIf: "partnerType is individual",
|
|
101
|
+
dataId: "partnerMessage",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
[t],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const submit = async (data) => {
|
|
109
|
+
try {
|
|
110
|
+
const { form, ...rest } = data;
|
|
111
|
+
await PartnerService.create(rest);
|
|
112
|
+
fetchData();
|
|
113
|
+
onClose();
|
|
114
|
+
} catch (err) {
|
|
115
|
+
onClose();
|
|
116
|
+
message.error(t(err?.response?.data?.message || "Error occured"));
|
|
117
|
+
console.log(err);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<DynamicForm
|
|
123
|
+
form={form}
|
|
124
|
+
data={data}
|
|
125
|
+
showSaveAndNext={false}
|
|
126
|
+
module={APP}
|
|
127
|
+
t={t}
|
|
128
|
+
isCreate
|
|
129
|
+
user={user}
|
|
130
|
+
ajaxForms={ajaxForms}
|
|
131
|
+
ajaxOptions={ajaxOptions}
|
|
132
|
+
getAppHeader={getAppHeader}
|
|
133
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
134
|
+
changeAjaxOptions={changeAjaxOptions}
|
|
135
|
+
app={APP}
|
|
136
|
+
query={query}
|
|
137
|
+
goTo={() => {}}
|
|
138
|
+
changeAjaxForms={changeAjaxForms}
|
|
139
|
+
onCancel={onClose}
|
|
140
|
+
submit={submit}
|
|
141
|
+
/>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default Create
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { Form, Input, Select } from "antd";
|
|
3
|
+
import PartnerService from '../../services/PartnerService.js';
|
|
4
|
+
import Loading from '../../core/components/Loading/index.jsx';
|
|
5
|
+
import ProjectVisualisationFooter from '../../core/components/ProjectVisualisation/Footer.js';
|
|
6
|
+
import { partnershipTypes } from './config.js';
|
|
7
|
+
import { licensingOptions } from '../../core/components/DataStore/components/Settings/config.js';
|
|
8
|
+
|
|
9
|
+
const Edit = ({
|
|
10
|
+
partner,
|
|
11
|
+
onClose = () => { },
|
|
12
|
+
fetchData = () => { },
|
|
13
|
+
t = () => { },
|
|
14
|
+
}) => {
|
|
15
|
+
const [MainForm] = Form.useForm();
|
|
16
|
+
const [loading, setLoading] = useState(false);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
MainForm.setFieldsValue({ ...partner, licensing: 'no_citation' });
|
|
20
|
+
}, [partner]);
|
|
21
|
+
|
|
22
|
+
const onSubmit = async () => {
|
|
23
|
+
setLoading(true);
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const val = await MainForm.validateFields();
|
|
27
|
+
await PartnerService.update(partner.id, val);
|
|
28
|
+
onClose();
|
|
29
|
+
fetchData();
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.log(err);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setLoading(false);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div>
|
|
39
|
+
{loading ? <Loading /> : null}
|
|
40
|
+
<Form form={MainForm} layout="vertical">
|
|
41
|
+
<Form.Item
|
|
42
|
+
required
|
|
43
|
+
name="nickName"
|
|
44
|
+
rules={[{ required: true }]}
|
|
45
|
+
label={t('Name')}
|
|
46
|
+
>
|
|
47
|
+
<Input name="name" />
|
|
48
|
+
</Form.Item>
|
|
49
|
+
|
|
50
|
+
<Form.Item
|
|
51
|
+
required
|
|
52
|
+
name="partnershipType"
|
|
53
|
+
label={t('Partner Type')}
|
|
54
|
+
>
|
|
55
|
+
<Select>
|
|
56
|
+
{partnershipTypes.map((type) => (
|
|
57
|
+
<Select.Option key={type.value} value={type.value}>
|
|
58
|
+
{type.label}
|
|
59
|
+
</Select.Option>
|
|
60
|
+
))}
|
|
61
|
+
</Select>
|
|
62
|
+
</Form.Item>
|
|
63
|
+
|
|
64
|
+
<Form.Item
|
|
65
|
+
required
|
|
66
|
+
name="email"
|
|
67
|
+
label={t('Email address')}
|
|
68
|
+
rules={[{ type: 'email', required: true }]}
|
|
69
|
+
>
|
|
70
|
+
<Input disabled />
|
|
71
|
+
</Form.Item>
|
|
72
|
+
|
|
73
|
+
<Form.Item
|
|
74
|
+
required
|
|
75
|
+
name="licensing"
|
|
76
|
+
label={t('Licensing')}
|
|
77
|
+
>
|
|
78
|
+
<Select disabled>
|
|
79
|
+
{licensingOptions.map((option) => (
|
|
80
|
+
<Select.Option key={option.value} value={option.value}>
|
|
81
|
+
{t(option.label)}
|
|
82
|
+
</Select.Option>
|
|
83
|
+
))}
|
|
84
|
+
</Select>
|
|
85
|
+
</Form.Item>
|
|
86
|
+
</Form>
|
|
87
|
+
|
|
88
|
+
<ProjectVisualisationFooter
|
|
89
|
+
t={t}
|
|
90
|
+
loading={loading}
|
|
91
|
+
onClose={onClose}
|
|
92
|
+
onSubmit={onSubmit}
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default Edit
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import PartnerService from "../../services/PartnerService.js";
|
|
3
|
+
import { message } from "antd";
|
|
4
|
+
|
|
5
|
+
export const usePartnersActions = ({
|
|
6
|
+
activeTab,
|
|
7
|
+
filters,
|
|
8
|
+
setTotalRequests,
|
|
9
|
+
t = () => {},
|
|
10
|
+
}) => {
|
|
11
|
+
const [loading, setLoading] = useState(false);
|
|
12
|
+
const [data, setData] = useState([]);
|
|
13
|
+
const [requestDataFetch, setRequestDataFetch] = useState(false);
|
|
14
|
+
const [initFetchDone, setInitFetchDone] = useState(false);
|
|
15
|
+
|
|
16
|
+
const fetchData = useCallback(async () => {
|
|
17
|
+
setLoading(true);
|
|
18
|
+
setData([]);
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const { data } = await PartnerService.get(activeTab, {
|
|
22
|
+
...filters,
|
|
23
|
+
type: activeTab,
|
|
24
|
+
});
|
|
25
|
+
setData(data);
|
|
26
|
+
setTotalRequests(data?.meta?.total || 0);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.log(err);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setLoading(false);
|
|
32
|
+
|
|
33
|
+
if (!initFetchDone) {
|
|
34
|
+
setInitFetchDone(true);
|
|
35
|
+
}
|
|
36
|
+
}, [activeTab, filters, initFetchDone, setLoading, setTotalRequests, setData, setInitFetchDone]);
|
|
37
|
+
|
|
38
|
+
const accept = useCallback(
|
|
39
|
+
async (id) => {
|
|
40
|
+
setLoading(true);
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
await PartnerService.accept(id);
|
|
44
|
+
setRequestDataFetch(true);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.log(err);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setLoading(false);
|
|
50
|
+
},
|
|
51
|
+
[setLoading],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const decline = useCallback(
|
|
55
|
+
async (id) => {
|
|
56
|
+
setLoading(true);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
await PartnerService.decline(id);
|
|
60
|
+
setRequestDataFetch(true);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
console.log(err);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setLoading(false);
|
|
66
|
+
},
|
|
67
|
+
[setLoading],
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const activate = useCallback(
|
|
71
|
+
async (id) => {
|
|
72
|
+
setLoading(true);
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
await PartnerService.activate(id);
|
|
76
|
+
setRequestDataFetch(true);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.log(err);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setLoading(false);
|
|
82
|
+
},
|
|
83
|
+
[setLoading],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const suspend = useCallback(
|
|
87
|
+
async (id) => {
|
|
88
|
+
setLoading(true);
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
await PartnerService.suspend(id);
|
|
92
|
+
message.success(t("Partner suspended successfully"));
|
|
93
|
+
setRequestDataFetch(true);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.log(err);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
setLoading(false);
|
|
99
|
+
},
|
|
100
|
+
[setLoading],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const resendInvite = useCallback(
|
|
104
|
+
async (id) => {
|
|
105
|
+
setLoading(true);
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
await PartnerService.resendInvite(id);
|
|
109
|
+
await fetchData();
|
|
110
|
+
} catch (err) {
|
|
111
|
+
console.log(err);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
setLoading(false);
|
|
115
|
+
},
|
|
116
|
+
[fetchData, setLoading],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const block = useCallback(
|
|
120
|
+
async (id) => {
|
|
121
|
+
setLoading(true);
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
await PartnerService.block(id);
|
|
125
|
+
await fetchData();
|
|
126
|
+
} catch (err) {
|
|
127
|
+
console.log(err);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
setLoading(false);
|
|
131
|
+
},
|
|
132
|
+
[fetchData, setLoading],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
loading,
|
|
137
|
+
setLoading,
|
|
138
|
+
data,
|
|
139
|
+
setData,
|
|
140
|
+
requestDataFetch,
|
|
141
|
+
setRequestDataFetch,
|
|
142
|
+
fetchData,
|
|
143
|
+
accept,
|
|
144
|
+
decline,
|
|
145
|
+
activate,
|
|
146
|
+
suspend,
|
|
147
|
+
resendInvite,
|
|
148
|
+
block,
|
|
149
|
+
setTotalRequests,
|
|
150
|
+
initFetchDone,
|
|
151
|
+
setInitFetchDone,
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -1,11 +1,236 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState, useMemo, useEffect, useCallback } from 'react'
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { usePartnersActions } from './hook.js';
|
|
4
|
+
import { getColumns } from './columns.js';
|
|
5
|
+
import TablePageWithTabs from '../../core/components/Screens/TableScreen/TablePageWithTabs/index.jsx';
|
|
6
|
+
import { checkboxConfig, selectFiltersConfig, filtersConfig } from './config.js';
|
|
7
|
+
import Create from './create.jsx';
|
|
8
|
+
import { useGetQueryParams } from '../../hooks/useGetQueryParams.js';
|
|
9
|
+
import ModalHeader from '../../core/components/Header/ModalHeader/index.jsx';
|
|
10
|
+
import Edit from './edit.jsx';
|
|
2
11
|
|
|
3
|
-
const
|
|
12
|
+
const PartnersTable = ({
|
|
13
|
+
t = () => {},
|
|
14
|
+
goTo = () => {},
|
|
15
|
+
user = {},
|
|
16
|
+
options = {},
|
|
17
|
+
getRedirectLink = () => {},
|
|
18
|
+
theme = {},
|
|
19
|
+
isMobile,
|
|
20
|
+
APP,
|
|
21
|
+
location,
|
|
22
|
+
breadcrumbs = [],
|
|
23
|
+
getApiBaseUrl = () => {},
|
|
24
|
+
getAppHeader = () => {},
|
|
25
|
+
query = {},
|
|
26
|
+
ajaxForms = {},
|
|
27
|
+
changeAjaxForms = () => {},
|
|
28
|
+
ajaxOptions = {},
|
|
29
|
+
changeAjaxOptions = () => {},
|
|
30
|
+
applications = [],
|
|
31
|
+
extendingFilters = {},
|
|
32
|
+
searchLocationParams,
|
|
33
|
+
}) => {
|
|
34
|
+
const [totalRequests, setTotalRequests] = useState(0);
|
|
35
|
+
const [selectOptions, setSelectOptions] = useState();
|
|
36
|
+
const [activeTab, setActiveTab] = useState();
|
|
37
|
+
const [pendingEditId, setPendingEditId] = useState(null);
|
|
38
|
+
const [openModal, setOpenModal] = useState(false);
|
|
39
|
+
|
|
40
|
+
const tabs = useMemo(() => [
|
|
41
|
+
{ label: t("List"), key: "partners" },
|
|
42
|
+
{ label: (
|
|
43
|
+
<div className="tab-cont">
|
|
44
|
+
<div className="flex flex-column justify-content-center">
|
|
45
|
+
{t('Requests')}
|
|
46
|
+
</div>
|
|
47
|
+
{typeof totalRequests === 'number' ? (
|
|
48
|
+
<div className="flex flex-column justify-content-center">
|
|
49
|
+
<div className="bubble">
|
|
50
|
+
<div className="flex flex-column justify-content-center">
|
|
51
|
+
{totalRequests}
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
) : null}
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
key: "requests"
|
|
59
|
+
},
|
|
60
|
+
], [t, totalRequests]);
|
|
61
|
+
|
|
62
|
+
const { paginationQuery, searchParams, otherParams, sortBy, sortDir, } = useGetQueryParams({location});
|
|
63
|
+
|
|
64
|
+
const filters = useMemo(() => {
|
|
65
|
+
const cleanSearchParams = Object.fromEntries(
|
|
66
|
+
Object.entries(searchParams).filter(([_, value]) => value != null && value !== '')
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
pagination: paginationQuery,
|
|
71
|
+
...(Object.keys(otherParams).length > 0 && otherParams ),
|
|
72
|
+
...(Object.keys(cleanSearchParams).length > 0 && { search: cleanSearchParams }),
|
|
73
|
+
tab: activeTab,
|
|
74
|
+
sortBy: {
|
|
75
|
+
[sortBy || "updatedAt"]: sortDir ? (sortDir === "ascend" ? 1 : -1) : -1,
|
|
76
|
+
},
|
|
77
|
+
...extendingFilters,
|
|
78
|
+
}
|
|
79
|
+
}, [location.search, activeTab, JSON.stringify(extendingFilters)]);
|
|
80
|
+
|
|
81
|
+
const {
|
|
82
|
+
loading,
|
|
83
|
+
data,
|
|
84
|
+
requestDataFetch,
|
|
85
|
+
fetchData,
|
|
86
|
+
accept,
|
|
87
|
+
decline,
|
|
88
|
+
activate,
|
|
89
|
+
suspend,
|
|
90
|
+
resendInvite,
|
|
91
|
+
block,
|
|
92
|
+
setRequestDataFetch,
|
|
93
|
+
initFetchDone,
|
|
94
|
+
setInitFetchDone,
|
|
95
|
+
} = usePartnersActions({
|
|
96
|
+
activeTab,
|
|
97
|
+
filters,
|
|
98
|
+
setTotalRequests,
|
|
99
|
+
t,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const columns = useMemo(() => getColumns({
|
|
103
|
+
t,
|
|
104
|
+
accept,
|
|
105
|
+
decline,
|
|
106
|
+
suspend,
|
|
107
|
+
resendInvite,
|
|
108
|
+
activate,
|
|
109
|
+
activeTab,
|
|
110
|
+
selectOptions,
|
|
111
|
+
block,
|
|
112
|
+
setOpen: setOpenModal,
|
|
113
|
+
}), [t, accept, decline, suspend, resendInvite, activate, activeTab, selectOptions, block, setOpenModal]);
|
|
114
|
+
|
|
115
|
+
const handleActiveTabChange = useCallback((value) => {
|
|
116
|
+
setActiveTab(value);
|
|
117
|
+
}, []);
|
|
118
|
+
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (requestDataFetch) {
|
|
121
|
+
fetchData();
|
|
122
|
+
setRequestDataFetch(false);
|
|
123
|
+
}
|
|
124
|
+
}, [requestDataFetch, fetchData, setRequestDataFetch]);
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
if (searchLocationParams.has("datastakeId") && !pendingEditId) {
|
|
128
|
+
setPendingEditId(searchLocationParams.get("datastakeId"));
|
|
129
|
+
}
|
|
130
|
+
}, [searchLocationParams, pendingEditId]);
|
|
131
|
+
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
if (pendingEditId) {
|
|
134
|
+
const partner = data.find((partner) => partner.datastakeId === pendingEditId);
|
|
135
|
+
if (partner) {
|
|
136
|
+
setOpenModal(partner);
|
|
137
|
+
setPendingEditId(null);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, [data, pendingEditId]);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
fetchData();
|
|
144
|
+
}, [filters]);
|
|
145
|
+
|
|
146
|
+
const headerTooltip = useMemo(() => ({
|
|
147
|
+
title: t("Partners"),
|
|
148
|
+
content: (
|
|
149
|
+
<div className="max-w-250">
|
|
150
|
+
{t(
|
|
151
|
+
"Partners are organisations sharing their information with you, or receiving your information.",
|
|
152
|
+
)}
|
|
153
|
+
<br />
|
|
154
|
+
{t("Only authorised users can create partnerships.")}
|
|
155
|
+
</div>
|
|
156
|
+
),
|
|
157
|
+
}), [t]);
|
|
158
|
+
|
|
159
|
+
const drawerTooltip = useMemo(() => ({
|
|
160
|
+
content: (
|
|
161
|
+
<div className="max-w-250">
|
|
162
|
+
{t("Source: This partner will share information with you.")},
|
|
163
|
+
<br />
|
|
164
|
+
{t("Client: You will share information with this partner.")},
|
|
165
|
+
<br />
|
|
166
|
+
{t("Exchange: You will both share information with each other.")}
|
|
167
|
+
</div>
|
|
168
|
+
),
|
|
169
|
+
}), [t]);
|
|
170
|
+
|
|
4
171
|
return (
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
172
|
+
<>
|
|
173
|
+
<TablePageWithTabs
|
|
174
|
+
t={t}
|
|
175
|
+
tabs={tabs}
|
|
176
|
+
title={t("Partners")}
|
|
177
|
+
breadCrumbs={breadcrumbs}
|
|
178
|
+
location={location}
|
|
179
|
+
loading={loading}
|
|
180
|
+
goTo={goTo}
|
|
181
|
+
defaultActiveTab={"partners"}
|
|
182
|
+
columns={columns}
|
|
183
|
+
data={data}
|
|
184
|
+
checkboxConfig={checkboxConfig}
|
|
185
|
+
APP={APP}
|
|
186
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
187
|
+
selectOptions={selectOptions}
|
|
188
|
+
selectFiltersConfig={selectFiltersConfig}
|
|
189
|
+
getRedirectLink={getRedirectLink}
|
|
190
|
+
filtersConfig={filtersConfig}
|
|
191
|
+
isMobile={isMobile}
|
|
192
|
+
view="partners"
|
|
193
|
+
getActiveTab={handleActiveTabChange}
|
|
194
|
+
headerTooltip={headerTooltip}
|
|
195
|
+
drawerTitle={t("Create Partner")}
|
|
196
|
+
drawerTooltip={drawerTooltip}
|
|
197
|
+
>
|
|
198
|
+
{({onDrawerClose}) => (
|
|
199
|
+
<Create
|
|
200
|
+
query={query}
|
|
201
|
+
goTo={goTo}
|
|
202
|
+
user={user}
|
|
203
|
+
t={t}
|
|
204
|
+
ajaxForms={ajaxForms}
|
|
205
|
+
changeAjaxForms={changeAjaxForms}
|
|
206
|
+
ajaxOptions={ajaxOptions}
|
|
207
|
+
changeAjaxOptions={changeAjaxOptions}
|
|
208
|
+
onClose={onDrawerClose}
|
|
209
|
+
fetchData={() => setRequestDataFetch(true)}
|
|
210
|
+
APP={APP}
|
|
211
|
+
getAppHeader={getAppHeader}
|
|
212
|
+
getApiBaseUrl={getApiBaseUrl}
|
|
213
|
+
/>
|
|
214
|
+
)}
|
|
215
|
+
</TablePageWithTabs>
|
|
216
|
+
<Modal
|
|
217
|
+
open={!!openModal}
|
|
218
|
+
onCancel={() => setOpenModal(false)}
|
|
219
|
+
footer={null}
|
|
220
|
+
title={<ModalHeader title={t("Edit Settings")} />}
|
|
221
|
+
>
|
|
222
|
+
{openModal ? (
|
|
223
|
+
<Edit
|
|
224
|
+
partner={openModal}
|
|
225
|
+
fetchData={() => setRequestDataFetch(true)}
|
|
226
|
+
onClose={() => setOpenModal(false)}
|
|
227
|
+
t={t}
|
|
228
|
+
/>
|
|
229
|
+
) : null}
|
|
230
|
+
</Modal>
|
|
231
|
+
<input id="myInput" hidden />
|
|
232
|
+
</>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
10
235
|
|
|
11
|
-
export default
|
|
236
|
+
export default PartnersTable
|