datastake-daf 0.6.842 → 0.6.844

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 (30) hide show
  1. package/dist/components/index.js +800 -774
  2. package/dist/hooks/index.js +4 -6
  3. package/dist/layouts/index.js +6 -0
  4. package/dist/pages/index.js +172 -115
  5. package/package.json +1 -1
  6. package/src/@daf/core/components/DynamicForm/hook.js +2 -2
  7. package/src/@daf/core/components/DynamicForm/index.jsx +1 -1
  8. package/src/@daf/core/components/Filters/selectFilters/index.jsx +7 -1
  9. package/src/@daf/core/components/Graphs/TradeRelationship/index.jsx +1 -27
  10. package/src/@daf/core/components/Graphs/components/BaseGraph.jsx +22 -18
  11. package/src/@daf/core/components/Screens/Admin/AdminModals/NewAccount/index.jsx +19 -6
  12. package/src/@daf/core/components/Screens/Admin/AdminScreens/Accounts.jsx +4 -1
  13. package/src/@daf/core/components/Screens/Admin/AdminTables/AccountTable/index.jsx +2 -0
  14. package/src/@daf/core/components/Select/MultiSelect/style.js +1 -1
  15. package/src/@daf/core/components/ViewForm/components/DataLink/flat.js +7 -3
  16. package/src/@daf/core/components/ViewForm/components/DataLink/index.js +6 -2
  17. package/src/@daf/core/components/ViewForm/components/input.js +7 -7
  18. package/src/@daf/hooks/useWidgetFetch.js +26 -35
  19. package/src/@daf/pages/Dashboards/ConflictManagement/components/RisksWidget/components/IncidentsTime/index.js +1 -0
  20. package/src/@daf/pages/ResetPassword/index.jsx +228 -228
  21. package/src/@daf/pages/Summary/Operator/components/KeyInformation/config.js +0 -1
  22. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/helper.js +7 -5
  23. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/hook.js +29 -14
  24. package/src/@daf/pages/Summary/Operator/components/TradeRelationships/index.js +69 -20
  25. package/src/@daf/pages/Summary/Operator/index.jsx +1 -0
  26. package/src/@daf/pages/Template/components/LinkingTemplate/config.js +1 -0
  27. package/src/@daf/pages/Template/components/LinkingTemplate/index.jsx +3 -1
  28. package/src/@daf/pages/View/index.jsx +1 -1
  29. package/src/@daf/services/LinkedSubjects.js +1 -0
  30. package/src/helpers/Forms.js +7 -5
@@ -1,228 +1,228 @@
1
- // import React from "react";
2
- // import DafButton from "../../../Button/index.jsx";
3
- // import Loading from "../../../Loading/index.jsx";
4
- // import AuthForm from "../../../AuthForm/index.jsx";
5
-
6
- // const step = 1;
7
-
8
- // export default function ResetPassword({
9
- // resetRequestSuccedded,
10
- // resetRequestError,
11
- // submitting,
12
- // requestResetPassword,
13
- // resetPassword,
14
- // params: propParams = {},
15
- // Layout,
16
- // goTo,
17
- // t,
18
- // theme,
19
- // errors,
20
-
21
- // loginPath: loginPathProp,
22
- // }) {
23
- // const { app, confirmationToken } = propParams;
24
-
25
- // const getLogInLink = () => {
26
- // if (loginPathProp) return loginPathProp;
27
- // if (app) return `/${app}/login`;
28
- // return "/login";
29
- // };
30
-
31
- // const handleGoToLogin = () => {
32
- // const link = getLogInLink();
33
- // if (goTo && typeof goTo === "function") {
34
- // goTo(link);
35
- // } else {
36
- // window.location.href = link;
37
- // }
38
- // };
39
-
40
- // const title = !confirmationToken
41
- // ? resetRequestSuccedded
42
- // ? "Thank you"
43
- // : "Reset Password"
44
- // : resetRequestSuccedded
45
- // ? "Password updated"
46
- // : "Create Password";
47
-
48
- // const subTitle = !confirmationToken
49
- // ? resetRequestSuccedded
50
- // ? "A password reset link has been sent to your email address. If you can’t find the message in your inbox, please check your spam folder!"
51
- // : "Please enter your email, to get a link and request a new password."
52
- // : resetRequestSuccedded
53
- // ? "Your password has been updated, click in the button below to log in."
54
- // : "Please set up your new password.";
55
-
56
- // const requestResetFields = [
57
- // {
58
- // name: "email",
59
- // label: t("Email"),
60
- // type: "input",
61
- // required: true,
62
- // rules: [
63
- // {
64
- // required: true,
65
- // message: t("errors::email should not be empty"),
66
- // },
67
- // {
68
- // pattern:
69
- // /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,
70
- // message: t("errors::email is not valid"),
71
- // },
72
- // ],
73
- // placeholder: t("Email"),
74
- // },
75
- // ];
76
-
77
- // const resetPasswordFields = [
78
- // {
79
- // name: "password",
80
- // label: t("Enter password"),
81
- // type: "password",
82
- // required: true,
83
- // rules: [
84
- // {
85
- // required: true,
86
- // message: t("errors::password should not be empty"),
87
- // },
88
- // ],
89
- // placeholder: t("••••••••"),
90
- // },
91
- // {
92
- // name: "confirmPassword",
93
- // label: t("Confirm password"),
94
- // type: "password",
95
- // required: true,
96
- // dependencies: ["password"],
97
- // rules: [
98
- // {
99
- // required: true,
100
- // message: t("errors::password should not be empty"),
101
- // },
102
- // ({ getFieldValue }) => ({
103
- // validator(rule, value) {
104
- // if (!value || getFieldValue("password") === value) {
105
- // return Promise.resolve();
106
- // }
107
- // return Promise.reject(t("errors::passwordNotMatch"));
108
- // },
109
- // }),
110
- // ],
111
- // placeholder: t("••••••••"),
112
- // },
113
- // ];
114
-
115
- // const handleRequestResetSubmit = (values) => {
116
- // requestResetPassword(values);
117
- // };
118
-
119
- // const handleResetPasswordSubmit = (values) => {
120
-
121
- // resetPassword({
122
- // ...values,
123
- // passConfirmationToken: confirmationToken,
124
- // });
125
- // };
126
-
127
- // const currentTheme = theme || window.theme;
128
-
129
- // const Content = (
130
- // <>
131
- // {!resetRequestSuccedded && !confirmationToken && (
132
- // <>
133
- // <AuthForm
134
- // fields={requestResetFields}
135
- // onSubmit={handleRequestResetSubmit}
136
- // submitText={t("Get Link")}
137
- // errors={errors}
138
- // t={t}
139
- // executeRecaptcha={() => Promise.resolve(true)}
140
- // theme={currentTheme}
141
- // submitButtonProps={{
142
- // loading: submitting,
143
- // }}
144
- // />
145
- // <div className="mt-4">
146
- // <DafButton
147
- // type="default"
148
- // className="normal-br"
149
- // style={
150
- // currentTheme
151
- // ? {
152
- // borderColor: currentTheme.colorPrimary,
153
- // color: currentTheme.colorPrimary,
154
- // }
155
- // : {}
156
- // }
157
- // onClick={handleGoToLogin}
158
- // >
159
- // {t("Back")}
160
- // </DafButton>
161
- // </div>
162
-
163
- // {resetRequestError ? (
164
- // <div
165
- // className="ant-form-item-explain errors-cont no-pt mt-3"
166
- // style={{ color: "#ff4d4f" }}
167
- // >
168
- // {t(resetRequestError)}
169
- // </div>
170
- // ) : null}
171
- // </>
172
- // )}
173
-
174
- // {!resetRequestSuccedded && confirmationToken && (
175
- // <AuthForm
176
- // fields={resetPasswordFields}
177
- // onSubmit={handleResetPasswordSubmit}
178
- // submitText={t("Reset Password")}
179
- // errors={errors}
180
- // t={t}
181
- // executeRecaptcha={() => Promise.resolve(true)}
182
- // theme={currentTheme}
183
- // submitButtonProps={{
184
- // loading: submitting,
185
- // }}
186
- // />
187
- // )}
188
-
189
- // {resetRequestSuccedded && confirmationToken && (
190
- // <div className="buttons">
191
- // <DafButton
192
- // type="primary"
193
- // className="normal-br"
194
- // style={
195
- // currentTheme
196
- // ? {
197
- // backgroundColor: currentTheme.colorPrimary,
198
- // borderColor: currentTheme.colorPrimary,
199
- // }
200
- // : {}
201
- // }
202
- // onClick={handleGoToLogin}
203
- // >
204
- // {t("Log In")}
205
- // </DafButton>
206
- // </div>
207
- // )}
208
-
209
- // {resetRequestSuccedded && !confirmationToken && null}
210
- // </>
211
- // );
212
-
213
- // if (Layout) {
214
- // return (
215
- // <Layout app={app} step={step} title={title} subTitle={subTitle}>
216
- // {Content}
217
- // </Layout>
218
- // );
219
- // }
220
-
221
- // return (
222
- // <div style={{ padding: 20, maxWidth: 400, margin: "0 auto" }}>
223
- // <h2>{title}</h2>
224
- // <p>{subTitle}</p>
225
- // {Content}
226
- // </div>
227
- // );
228
- // }
1
+ import React from "react";
2
+ import DafButton from "../../../Button/index.jsx";
3
+ import Loading from "../../../Loading/index.jsx";
4
+ import AuthForm from "../../../AuthForm/index.jsx";
5
+
6
+ const step = 1;
7
+
8
+ export default function ResetPassword({
9
+ resetRequestSuccedded,
10
+ resetRequestError,
11
+ submitting,
12
+ requestResetPassword,
13
+ resetPassword,
14
+ params: propParams = {},
15
+ Layout,
16
+ goTo,
17
+ t,
18
+ theme,
19
+ errors,
20
+
21
+ loginPath: loginPathProp,
22
+ }) {
23
+ const { app, confirmationToken } = propParams;
24
+
25
+ const getLogInLink = () => {
26
+ if (loginPathProp) return loginPathProp;
27
+ if (app) return `/${app}/login`;
28
+ return "/login";
29
+ };
30
+
31
+ const handleGoToLogin = () => {
32
+ const link = getLogInLink();
33
+ if (goTo && typeof goTo === "function") {
34
+ goTo(link);
35
+ } else {
36
+ window.location.href = link;
37
+ }
38
+ };
39
+
40
+ const title = !confirmationToken
41
+ ? resetRequestSuccedded
42
+ ? "Thank you"
43
+ : "Reset Password"
44
+ : resetRequestSuccedded
45
+ ? "Password updated"
46
+ : "Create Password";
47
+
48
+ const subTitle = !confirmationToken
49
+ ? resetRequestSuccedded
50
+ ? "A password reset link has been sent to your email address. If you can’t find the message in your inbox, please check your spam folder!"
51
+ : "Please enter your email, to get a link and request a new password."
52
+ : resetRequestSuccedded
53
+ ? "Your password has been updated, click in the button below to log in."
54
+ : "Please set up your new password.";
55
+
56
+ const requestResetFields = [
57
+ {
58
+ name: "email",
59
+ label: t("Email"),
60
+ type: "input",
61
+ required: true,
62
+ rules: [
63
+ {
64
+ required: true,
65
+ message: t("errors::email should not be empty"),
66
+ },
67
+ {
68
+ pattern:
69
+ /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,
70
+ message: t("errors::email is not valid"),
71
+ },
72
+ ],
73
+ placeholder: t("Email"),
74
+ },
75
+ ];
76
+
77
+ const resetPasswordFields = [
78
+ {
79
+ name: "password",
80
+ label: t("Enter password"),
81
+ type: "password",
82
+ required: true,
83
+ rules: [
84
+ {
85
+ required: true,
86
+ message: t("errors::password should not be empty"),
87
+ },
88
+ ],
89
+ placeholder: t("••••••••"),
90
+ },
91
+ {
92
+ name: "confirmPassword",
93
+ label: t("Confirm password"),
94
+ type: "password",
95
+ required: true,
96
+ dependencies: ["password"],
97
+ rules: [
98
+ {
99
+ required: true,
100
+ message: t("errors::password should not be empty"),
101
+ },
102
+ ({ getFieldValue }) => ({
103
+ validator(rule, value) {
104
+ if (!value || getFieldValue("password") === value) {
105
+ return Promise.resolve();
106
+ }
107
+ return Promise.reject(t("errors::passwordNotMatch"));
108
+ },
109
+ }),
110
+ ],
111
+ placeholder: t("••••••••"),
112
+ },
113
+ ];
114
+
115
+ const handleRequestResetSubmit = (values) => {
116
+ requestResetPassword(values);
117
+ };
118
+
119
+ const handleResetPasswordSubmit = (values) => {
120
+
121
+ resetPassword({
122
+ ...values,
123
+ passConfirmationToken: confirmationToken,
124
+ });
125
+ };
126
+
127
+ const currentTheme = theme || window.theme;
128
+
129
+ const Content = (
130
+ <>
131
+ {!resetRequestSuccedded && !confirmationToken && (
132
+ <>
133
+ <AuthForm
134
+ fields={requestResetFields}
135
+ onSubmit={handleRequestResetSubmit}
136
+ submitText={t("Get Link")}
137
+ errors={errors}
138
+ t={t}
139
+ executeRecaptcha={() => Promise.resolve(true)}
140
+ theme={currentTheme}
141
+ submitButtonProps={{
142
+ loading: submitting,
143
+ }}
144
+ />
145
+ <div className="mt-4">
146
+ <DafButton
147
+ type="default"
148
+ className="normal-br"
149
+ style={
150
+ currentTheme
151
+ ? {
152
+ borderColor: currentTheme.colorPrimary,
153
+ color: currentTheme.colorPrimary,
154
+ }
155
+ : {}
156
+ }
157
+ onClick={handleGoToLogin}
158
+ >
159
+ {t("Back")}
160
+ </DafButton>
161
+ </div>
162
+
163
+ {resetRequestError ? (
164
+ <div
165
+ className="ant-form-item-explain errors-cont no-pt mt-3"
166
+ style={{ color: "#ff4d4f" }}
167
+ >
168
+ {t(resetRequestError)}
169
+ </div>
170
+ ) : null}
171
+ </>
172
+ )}
173
+
174
+ {!resetRequestSuccedded && confirmationToken && (
175
+ <AuthForm
176
+ fields={resetPasswordFields}
177
+ onSubmit={handleResetPasswordSubmit}
178
+ submitText={t("Reset Password")}
179
+ errors={errors}
180
+ t={t}
181
+ executeRecaptcha={() => Promise.resolve(true)}
182
+ theme={currentTheme}
183
+ submitButtonProps={{
184
+ loading: submitting,
185
+ }}
186
+ />
187
+ )}
188
+
189
+ {resetRequestSuccedded && confirmationToken && (
190
+ <div className="buttons">
191
+ <DafButton
192
+ type="primary"
193
+ className="normal-br"
194
+ style={
195
+ currentTheme
196
+ ? {
197
+ backgroundColor: currentTheme.colorPrimary,
198
+ borderColor: currentTheme.colorPrimary,
199
+ }
200
+ : {}
201
+ }
202
+ onClick={handleGoToLogin}
203
+ >
204
+ {t("Log In")}
205
+ </DafButton>
206
+ </div>
207
+ )}
208
+
209
+ {resetRequestSuccedded && !confirmationToken && null}
210
+ </>
211
+ );
212
+
213
+ if (Layout) {
214
+ return (
215
+ <Layout app={app} step={step} title={title} subTitle={subTitle}>
216
+ {Content}
217
+ </Layout>
218
+ );
219
+ }
220
+
221
+ return (
222
+ <div style={{ padding: 20, maxWidth: 400, margin: "0 auto" }}>
223
+ <h2>{title}</h2>
224
+ <p>{subTitle}</p>
225
+ {Content}
226
+ </div>
227
+ );
228
+ }
@@ -43,7 +43,6 @@ export const getKeyIndicatorConfig = ({ t, data = {}, options = {} }) => [
43
43
  label: t("Legal Form"),
44
44
  render: () => {
45
45
  const subCategory = findOptions(data?.subCategory, options?.subCategoriesOptions || options?.subCategory);
46
- console.log({subCategory, initialSub: data?.subCategory, options: options?.subCategoriesOptions || options?.subCategory})
47
46
  if(subCategory?.length > 22) {
48
47
  const _subCategory = truncateString(subCategory, 22);
49
48
  return <Tooltip title={subCategory}>
@@ -2,6 +2,7 @@ import { leftIcons, leftBackgroundColorLocation, leftBackgroundColorStakeholder,
2
2
  import { findOptions } from '../../../../../../helpers/StringHelper.js';
3
3
 
4
4
  export const getFilterConfig = ({operatorData = {}, options = {}, filters = {}, t = () => {}, APP}) => {
5
+ console.log({operatorData})
5
6
  const productSet = new Set();
6
7
  const allTradeMineralOptions = [
7
8
  ...(operatorData?.suppliers || []),
@@ -33,17 +34,18 @@ const label = options?.[
33
34
  return option && index === self.findIndex((o) => o.value === option.value);
34
35
  });
35
36
 
36
- const value = filters.products ? { value: filters.products } : {};
37
- return [
38
- {
37
+ const value = filters?.products ? { value: filters?.products } : {};
38
+ return {
39
+ products: {
39
40
  label: t("Products"),
40
41
  placeholder: t("Select"),
41
42
  key: "products",
42
43
  type: "select",
43
- ...value,
44
+ // ...value,
45
+ style: { flex: 1 },
44
46
  options: combinedMineralOptions,
45
47
  },
46
- ];
48
+ };
47
49
  }
48
50
 
49
51
  export const getLeft = (data = {}, mapChildren = () => {}, supplierLocations = []) => {
@@ -1,4 +1,4 @@
1
- import { useEffect, useState, useMemo } from "react";
1
+ import { useEffect, useState, useMemo, useRef } from "react";
2
2
  import { useWidgetFetch } from "../../../../../hooks/useWidgetFetch.js";
3
3
  import { leftIcons, leftBackgroundColorLocation, leftBackgroundColorStakeholder, topIcons } from './config.js';
4
4
  import { findOptions } from '../../../../../../helpers/StringHelper.js';
@@ -8,6 +8,8 @@ import { getLeft, mapItem as _mapItem } from './helper.js';
8
8
  export const useTradeRelationship = ({
9
9
  id,
10
10
  selectedPartners,
11
+ isProductsFilterReady,
12
+ hasProducts,
11
13
  options,
12
14
  goTo,
13
15
  getRedirectLink,
@@ -19,26 +21,38 @@ export const useTradeRelationship = ({
19
21
  const [graphData, setGraphData] = useState({});
20
22
  const [loading, setLoading] = useState(false);
21
23
  const [fetchedProducts, setFetchedProducts] = useState(false);
22
-
23
- const config = useMemo(() => ({
24
- basepath: "analytics",
25
- url: `/widgets/trade-relationship-map`,
26
- filters: {
24
+ const initFetchDoneRef = useRef(false);
25
+
26
+ const product = useMemo(() => {
27
+ return filters?.products
28
+ }, [filters?.products]);
29
+
30
+ console.log({hasProducts, product, isProductsFilterReady, stop: !selectedPartners?.partners?.length
31
+ || selectedPartners?.loading || !isProductsFilterReady || (isProductsFilterReady && hasProducts && !product)},
32
+ !selectedPartners?.partners?.length,
33
+ selectedPartners?.loading,
34
+ !isProductsFilterReady,
35
+ (isProductsFilterReady && hasProducts && !product))
36
+ const config = useMemo(() => ({
37
+ basepath: "analytics",
38
+ url: `/widgets/trade-relationship-map`,
39
+ filters: {
27
40
  datastakeId: id,
28
- product: filters?.products,
29
- sources: selectedPartners?.partners || [],
30
- },
31
- stop: !selectedPartners?.partners?.length || selectedPartners?.loading,
32
- }), [id, filters?.products, selectedPartners?.partners, selectedPartners?.loading]);
33
-
34
- const { data } = useWidgetFetch({config: config});
41
+ ...(product && {product: product}),
42
+ sources: selectedPartners?.partners || [],
43
+ },
44
+ stop: !selectedPartners?.partners?.length
45
+ || selectedPartners?.loading || !isProductsFilterReady || (isProductsFilterReady && hasProducts && !product)
46
+ }), [id, product, selectedPartners?.partners, selectedPartners?.loading, isProductsFilterReady, hasProducts]);
47
+
48
+ const { data, loading: dataLoading } = useWidgetFetch({config: config});
35
49
 
36
50
  const mapItem = (data) => {
37
51
  return _mapItem(data, options, goTo, getRedirectLink, operatorData, APP);
38
52
  }
39
53
 
40
54
  useEffect(() => {
41
- if (id && selectedPartners?.partners?.length > 0 && fetchedProducts) {
55
+ if (id && selectedPartners?.partners?.length > 0) {
42
56
  const _fetch = async () => {
43
57
  setLoading(true);
44
58
 
@@ -156,5 +170,6 @@ export const useTradeRelationship = ({
156
170
  setGraphData,
157
171
  setLoading,
158
172
  data,
173
+ dataLoading
159
174
  }
160
175
  }