datastake-daf 0.6.382 → 0.6.384
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 +222 -345
- package/dist/style/datastake/mapbox-gl.css +330 -0
- package/dist/utils/index.js +0 -24
- package/package.json +2 -2
- package/src/@daf/core/components/Charts/AreaChart/AreaChart.stories.jsx +1 -444
- package/src/@daf/core/components/Charts/AreaChart/index.jsx +12 -27
- package/src/@daf/core/components/Charts/BarChart/BarChart.stories.jsx +0 -88
- package/src/@daf/core/components/Charts/BarChart/index.jsx +12 -27
- package/src/@daf/core/components/Charts/ColumnChart/ColumnChart.stories.jsx +28 -23
- package/src/@daf/core/components/Charts/ColumnChart/index.jsx +20 -42
- package/src/@daf/core/components/Charts/DonutPie/DonutPie.stories.jsx +0 -55
- package/src/@daf/core/components/Charts/DonutPie/index.js +11 -21
- package/src/@daf/core/components/Charts/DualAxes/DualAxes.stories.js +0 -33
- package/src/@daf/core/components/Charts/DualAxes/index.js +0 -21
- package/src/@daf/core/components/Charts/LineChart/LineChart.stories.jsx +0 -81
- package/src/@daf/core/components/Charts/LineChart/index.jsx +12 -21
- package/src/@daf/core/components/Charts/PieChart/PieChart.stories.js +0 -52
- package/src/@daf/core/components/Charts/PieChart/chart.jsx +90 -20
- package/src/@daf/core/components/Charts/RadarChart/RadarChart.stories.jsx +0 -52
- package/src/@daf/core/components/Charts/RadarChart/index.jsx +0 -21
- package/src/@daf/core/components/Charts/RadialBarChart/RadialBarChart.stories.jsx +0 -56
- package/src/@daf/core/components/Charts/RadialBarChart/index.jsx +0 -22
- package/src/@daf/core/components/Charts/StackChart/StackChart.stories.jsx +0 -22
- package/src/@daf/core/components/Charts/StackChart/index.jsx +14 -22
- package/src/@daf/core/components/Screens/Admin/AdminModals/AddUser/index.jsx +4 -2
- package/src/@daf/core/components/Screens/Admin/AdminModals/NewUser/index.jsx +23 -5
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Edit/index.jsx +12 -1
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/helper.js +2 -0
- package/src/@daf/core/components/Screens/Admin/AdminViews/components/Users/index.jsx +2 -0
- package/src/helpers/StringHelper.js +0 -29
- package/src/utils.js +1 -1
- package/src/@daf/core/components/Charts/components/CustomLegend/index.js +0 -80
- package/src/@daf/core/components/Charts/helper.js +0 -25
|
@@ -2,8 +2,6 @@ import PropTypes from 'prop-types'
|
|
|
2
2
|
import React, { useCallback, useMemo, useRef, useState, Fragment } from 'react';
|
|
3
3
|
import Tooltip from './tooltip.jsx';
|
|
4
4
|
import { ChartStyle, LegendStyle } from './style.js';
|
|
5
|
-
import { useLegendConfig } from '../helper.js';
|
|
6
|
-
import CustomLegend from '../components/CustomLegend/index.js';
|
|
7
5
|
|
|
8
6
|
const Chart = ({
|
|
9
7
|
data = [],
|
|
@@ -20,7 +18,6 @@ const Chart = ({
|
|
|
20
18
|
children = null,
|
|
21
19
|
legend,
|
|
22
20
|
isPdf = false,
|
|
23
|
-
legendConfig = {},
|
|
24
21
|
isPercentage = false,
|
|
25
22
|
}) => {
|
|
26
23
|
const [hoveredGroup, setHoveredGroup] = useState(null);
|
|
@@ -30,15 +27,6 @@ const Chart = ({
|
|
|
30
27
|
const [mouseX, setMouseX] = useState(0);
|
|
31
28
|
const [mouseLocked, setMouseLocked] = useState(false);
|
|
32
29
|
|
|
33
|
-
const {
|
|
34
|
-
legendEnabled,
|
|
35
|
-
legendItems,
|
|
36
|
-
legendPosition,
|
|
37
|
-
legendLayout,
|
|
38
|
-
legendInteractive,
|
|
39
|
-
legendStyle
|
|
40
|
-
} = useLegendConfig({legendConfig, isPdf});
|
|
41
|
-
|
|
42
30
|
const getCoordinatesForPercent = useCallback((percent) => [
|
|
43
31
|
Math.cos(2 * Math.PI * percent),
|
|
44
32
|
Math.sin(2 * Math.PI * percent),
|
|
@@ -69,6 +57,41 @@ const Chart = ({
|
|
|
69
57
|
}
|
|
70
58
|
}, [svgRef, containerRef, hoveredGroup, mouseLocked]);
|
|
71
59
|
|
|
60
|
+
const legendConfig = useMemo(() => {
|
|
61
|
+
if (legend === false || legend === null) {
|
|
62
|
+
return isPdf ? {} : null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (typeof legend === 'object') {
|
|
66
|
+
return legend;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (legend === true || isPdf) {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return null;
|
|
74
|
+
}, [legend, isPdf]);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const legendItems = useMemo(() => {
|
|
78
|
+
const items = Array.isArray(data) ? data : [];
|
|
79
|
+
|
|
80
|
+
if (!legendConfig) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const { itemName } = legendConfig;
|
|
85
|
+
const getName = typeof itemName?.formatter === 'function'
|
|
86
|
+
? (item, index) => itemName.formatter(item.name || item.label || `Item ${index + 1}`, item, index)
|
|
87
|
+
: (item, index) => item.name || item.label || `Item ${index + 1}`;
|
|
88
|
+
|
|
89
|
+
return items.map((item, index) => ({
|
|
90
|
+
...item,
|
|
91
|
+
label: getName(item, index),
|
|
92
|
+
}));
|
|
93
|
+
}, [data, legendConfig]);
|
|
94
|
+
|
|
72
95
|
const dataToShow = useMemo(() => {
|
|
73
96
|
let cumulativePercent = 0;
|
|
74
97
|
function getRotationAngle(percent) {
|
|
@@ -196,14 +219,61 @@ const Chart = ({
|
|
|
196
219
|
{dataToShow}
|
|
197
220
|
</svg>
|
|
198
221
|
{tooltip}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
222
|
+
{!!legendConfig && legendItems.length > 0 && (
|
|
223
|
+
<LegendStyle className={legendConfig?.className} data-position={legendConfig?.position || 'bottom'}>
|
|
224
|
+
{legendItems.map((item, index) => {
|
|
225
|
+
const markerStyle = legendConfig?.marker || {};
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<li
|
|
229
|
+
key={item.id ?? index}
|
|
230
|
+
className={item.className}
|
|
231
|
+
onMouseEnter={() => {
|
|
232
|
+
if (mouseLocked) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
setHoveredGroup({ ...item, id: index, fromLegend: true });
|
|
237
|
+
}}
|
|
238
|
+
onMouseLeave={() => {
|
|
239
|
+
if (mouseLocked) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
setHoveredGroup(null);
|
|
244
|
+
}}
|
|
245
|
+
onClick={() => {
|
|
246
|
+
if (!changeOpacityOnHover) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (hoveredGroup?.id === index && hoveredGroup?.fromLegend) {
|
|
251
|
+
setHoveredGroup(null);
|
|
252
|
+
setMouseLocked(false);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
setHoveredGroup({ ...item, id: index, fromLegend: true });
|
|
257
|
+
setMouseLocked((prev) => !prev);
|
|
258
|
+
}}
|
|
259
|
+
>
|
|
260
|
+
<span
|
|
261
|
+
className="legend-marker"
|
|
262
|
+
style={{
|
|
263
|
+
backgroundColor: item.color,
|
|
264
|
+
width: markerStyle?.size || 12,
|
|
265
|
+
height: markerStyle?.size || 12,
|
|
266
|
+
borderRadius: markerStyle?.shape === 'square' ? 2 : '50%',
|
|
267
|
+
border: markerStyle?.style === 'line' ? `2px solid ${item.color}` : undefined,
|
|
268
|
+
background: markerStyle?.style === 'line' ? 'transparent' : item.color,
|
|
269
|
+
}}
|
|
270
|
+
/>
|
|
271
|
+
<span>{item.label}</span>
|
|
272
|
+
</li>
|
|
273
|
+
);
|
|
274
|
+
})}
|
|
275
|
+
</LegendStyle>
|
|
276
|
+
)}
|
|
207
277
|
{children}
|
|
208
278
|
</ChartStyle>
|
|
209
279
|
);
|
|
@@ -77,55 +77,3 @@ export const WithMultipleSeries = {
|
|
|
77
77
|
</Widget>
|
|
78
78
|
),
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
export const Pdf = {
|
|
82
|
-
args: {
|
|
83
|
-
data: [
|
|
84
|
-
{ item: "Category 1", score: 70, type: "Series 1" },
|
|
85
|
-
{ item: "Category 2", score: 30, type: "Series 1" },
|
|
86
|
-
{ item: "Category 3", score: 60, type: "Series 1" },
|
|
87
|
-
{ item: "Category 4", score: 90, type: "Series 1" },
|
|
88
|
-
{ item: "Category 5", score: 50, type: "Series 1" },
|
|
89
|
-
{ item: "Category 6", score: 80, type: "Series 1" },
|
|
90
|
-
{ item: "Category 1", score: 40, type: "Series 2" },
|
|
91
|
-
{ item: "Category 2", score: 80, type: "Series 2" },
|
|
92
|
-
{ item: "Category 3", score: 35, type: "Series 2" },
|
|
93
|
-
{ item: "Category 4", score: 55, type: "Series 2" },
|
|
94
|
-
{ item: "Category 5", score: 75, type: "Series 2" },
|
|
95
|
-
{ item: "Category 6", score: 0, type: "Series 2" },
|
|
96
|
-
],
|
|
97
|
-
seriesField: "type",
|
|
98
|
-
color: ["#1890FF", "#2FC25B"], // Added two distinct colors for the series
|
|
99
|
-
height: 300,
|
|
100
|
-
legendConfig: {
|
|
101
|
-
enabled: false,
|
|
102
|
-
position: 'bottom',
|
|
103
|
-
layout: 'horizontal',
|
|
104
|
-
items: [
|
|
105
|
-
{
|
|
106
|
-
id: 'baseline',
|
|
107
|
-
label: 'Baseline',
|
|
108
|
-
color: '#96b1ff',
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
id: 'improvement',
|
|
112
|
-
label: 'Improvement',
|
|
113
|
-
color: '#4b6ae7',
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
id: 'profit',
|
|
117
|
-
label: 'Net Profit',
|
|
118
|
-
color: '#52c41a',
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
isPdf: true,
|
|
123
|
-
},
|
|
124
|
-
render: (args) => (
|
|
125
|
-
<Widget title="Pdf">
|
|
126
|
-
<div style={{ height: "800px", width: "100%" }}>
|
|
127
|
-
<RadarChart {...args} />
|
|
128
|
-
</div>
|
|
129
|
-
</Widget>
|
|
130
|
-
),
|
|
131
|
-
};
|
|
@@ -3,8 +3,6 @@ import { Radar } from "@antv/g2plot";
|
|
|
3
3
|
import { theme } from "antd";
|
|
4
4
|
import { renderTooltip } from "../../../../utils/tooltip";
|
|
5
5
|
import Container from "../style";
|
|
6
|
-
import { useLegendConfig } from "../helper";
|
|
7
|
-
import CustomLegend from "../components/CustomLegend/index.js";
|
|
8
6
|
|
|
9
7
|
const { useToken } = theme;
|
|
10
8
|
|
|
@@ -22,23 +20,12 @@ const RadarChart = ({
|
|
|
22
20
|
// fillOpacity = 0.5,
|
|
23
21
|
score = { min: 0, max: 100 },
|
|
24
22
|
height,
|
|
25
|
-
isPdf = false,
|
|
26
|
-
legendConfig = {},
|
|
27
23
|
...rest
|
|
28
24
|
}) => {
|
|
29
25
|
const containerRef = useRef(null);
|
|
30
26
|
const chartRef = useRef(null);
|
|
31
27
|
const { token } = useToken();
|
|
32
28
|
|
|
33
|
-
const {
|
|
34
|
-
legendEnabled,
|
|
35
|
-
legendItems,
|
|
36
|
-
legendPosition,
|
|
37
|
-
legendLayout,
|
|
38
|
-
legendInteractive,
|
|
39
|
-
legendStyle
|
|
40
|
-
} = useLegendConfig({legendConfig, isPdf});
|
|
41
|
-
|
|
42
29
|
useEffect(() => {
|
|
43
30
|
if (!containerRef.current) {
|
|
44
31
|
return;
|
|
@@ -146,14 +133,6 @@ const RadarChart = ({
|
|
|
146
133
|
<div className="flex justify-content-center">
|
|
147
134
|
<Container ref={containerRef} height={height}></Container>
|
|
148
135
|
</div>
|
|
149
|
-
{legendEnabled && legendPosition === 'bottom' && (
|
|
150
|
-
<CustomLegend
|
|
151
|
-
items={legendItems}
|
|
152
|
-
layout={legendLayout}
|
|
153
|
-
interactive={legendInteractive}
|
|
154
|
-
style={legendStyle}
|
|
155
|
-
/>
|
|
156
|
-
)}
|
|
157
136
|
</div>
|
|
158
137
|
);
|
|
159
138
|
};
|
|
@@ -47,8 +47,6 @@ export const Primary = {
|
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
50
|
export const Empty = {
|
|
53
51
|
name: "Empty",
|
|
54
52
|
args: {
|
|
@@ -116,57 +114,3 @@ export const WithColor = {
|
|
|
116
114
|
);
|
|
117
115
|
},
|
|
118
116
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
export const Pdf = {
|
|
122
|
-
name: "Pdf",
|
|
123
|
-
args: {
|
|
124
|
-
data: [
|
|
125
|
-
{ label: "X6", value: 57 },
|
|
126
|
-
{ label: "G", value: 0 },
|
|
127
|
-
{ label: "AVA", value: 5 },
|
|
128
|
-
{ label: "G2Plot", value: 78 },
|
|
129
|
-
],
|
|
130
|
-
|
|
131
|
-
renderTooltipContent: (title, data) => {
|
|
132
|
-
console.log("title", title, data);
|
|
133
|
-
return {
|
|
134
|
-
title,
|
|
135
|
-
items: data.map((item) => ({
|
|
136
|
-
label: "TEXT",
|
|
137
|
-
value: item.value,
|
|
138
|
-
})),
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
isPdf: true,
|
|
142
|
-
legendConfig: {
|
|
143
|
-
enabled: false,
|
|
144
|
-
position: 'bottom',
|
|
145
|
-
layout: 'horizontal',
|
|
146
|
-
items: [
|
|
147
|
-
{
|
|
148
|
-
id: 'baseline',
|
|
149
|
-
label: 'Baseline',
|
|
150
|
-
color: '#96b1ff',
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
id: 'improvement',
|
|
154
|
-
label: 'Improvement',
|
|
155
|
-
color: '#4b6ae7',
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
id: 'profit',
|
|
159
|
-
label: 'Net Profit',
|
|
160
|
-
color: '#52c41a',
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
render: (args) => {
|
|
166
|
-
return (
|
|
167
|
-
<Widget title="Radial Bar Chart" className={"with-border-header"}>
|
|
168
|
-
<RadialBarChart {...args} />
|
|
169
|
-
</Widget>
|
|
170
|
-
);
|
|
171
|
-
},
|
|
172
|
-
};
|
|
@@ -3,9 +3,6 @@ import { RadialBar } from "@antv/g2plot";
|
|
|
3
3
|
import React, { useMemo, useRef, useEffect } from "react";
|
|
4
4
|
import { renderTooltip } from "../../../../utils/tooltip";
|
|
5
5
|
import { theme } from "antd";
|
|
6
|
-
import { useLegendConfig } from "../helper";
|
|
7
|
-
import CustomLegend from "../components/CustomLegend/index.js";
|
|
8
|
-
|
|
9
6
|
//Just renders a chart with 2 bars with 0 value as empty state.
|
|
10
7
|
const EMPTY_STATE_ARRAY = [
|
|
11
8
|
{ label: "1", value: 0 },
|
|
@@ -65,22 +62,11 @@ export default function RadialBarChart({
|
|
|
65
62
|
animation = false,
|
|
66
63
|
isPercentage = true,
|
|
67
64
|
color,
|
|
68
|
-
isPdf = false,
|
|
69
|
-
legendConfig = {},
|
|
70
65
|
}) {
|
|
71
66
|
const containerRef = React.useRef(null);
|
|
72
67
|
const chartRef = React.useRef(null);
|
|
73
68
|
const { token } = useToken();
|
|
74
69
|
|
|
75
|
-
const {
|
|
76
|
-
legendEnabled,
|
|
77
|
-
legendItems,
|
|
78
|
-
legendPosition,
|
|
79
|
-
legendLayout,
|
|
80
|
-
legendInteractive,
|
|
81
|
-
legendStyle
|
|
82
|
-
} = useLegendConfig({legendConfig, isPdf});
|
|
83
|
-
|
|
84
70
|
const formattedData = useMemo(() => {
|
|
85
71
|
return data.map((item) => ({
|
|
86
72
|
...item,
|
|
@@ -194,14 +180,6 @@ export default function RadialBarChart({
|
|
|
194
180
|
<div className="flex justify-content-center">
|
|
195
181
|
<Container ref={containerRef}></Container>
|
|
196
182
|
</div>
|
|
197
|
-
{legendEnabled && legendPosition === 'bottom' && (
|
|
198
|
-
<CustomLegend
|
|
199
|
-
items={legendItems}
|
|
200
|
-
layout={legendLayout}
|
|
201
|
-
interactive={legendInteractive}
|
|
202
|
-
style={legendStyle}
|
|
203
|
-
/>
|
|
204
|
-
)}
|
|
205
183
|
</div>
|
|
206
184
|
);
|
|
207
185
|
}
|
|
@@ -418,28 +418,6 @@ export const WithCustomObject = {
|
|
|
418
418
|
environmental: "#f9b836",
|
|
419
419
|
},
|
|
420
420
|
isPdf: true,
|
|
421
|
-
legendConfig: {
|
|
422
|
-
enabled: false,
|
|
423
|
-
position: 'bottom',
|
|
424
|
-
layout: 'horizontal',
|
|
425
|
-
items: [
|
|
426
|
-
{
|
|
427
|
-
id: 'baseline',
|
|
428
|
-
label: 'Baseline',
|
|
429
|
-
color: '#96b1ff',
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
id: 'improvement',
|
|
433
|
-
label: 'Improvement',
|
|
434
|
-
color: '#4b6ae7',
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
id: 'profit',
|
|
438
|
-
label: 'Net Profit',
|
|
439
|
-
color: '#52c41a',
|
|
440
|
-
}
|
|
441
|
-
]
|
|
442
|
-
},
|
|
443
421
|
},
|
|
444
422
|
render: (args) => {
|
|
445
423
|
return <StackChart {...args} />;
|
|
@@ -3,9 +3,6 @@ import { Style, StyleWrapper } from "./classes.js";
|
|
|
3
3
|
import { formatClassname } from "../../../../../helpers/ClassesHelper";
|
|
4
4
|
import { Popover, theme } from "antd";
|
|
5
5
|
import { renderTooltipJsx as renderDafTooltip } from "../../../../utils/tooltip.js";
|
|
6
|
-
import { useLegendConfig } from "../helper.js";
|
|
7
|
-
import CustomLegend from "../components/CustomLegend/index.js";
|
|
8
|
-
|
|
9
6
|
const { useToken } = theme;
|
|
10
7
|
/**
|
|
11
8
|
* StackChart Component
|
|
@@ -88,7 +85,6 @@ export default function StackChart({
|
|
|
88
85
|
height = 300,
|
|
89
86
|
isPdf = false,
|
|
90
87
|
t = (s) => s,
|
|
91
|
-
legendConfig = {},
|
|
92
88
|
}) {
|
|
93
89
|
const ref = React.useRef();
|
|
94
90
|
const { token } = useToken();
|
|
@@ -106,15 +102,6 @@ export default function StackChart({
|
|
|
106
102
|
return Array.from(uniqueLabels);
|
|
107
103
|
}, [data, xFieldKey]);
|
|
108
104
|
|
|
109
|
-
const {
|
|
110
|
-
legendEnabled,
|
|
111
|
-
legendItems,
|
|
112
|
-
legendPosition,
|
|
113
|
-
legendLayout,
|
|
114
|
-
legendInteractive,
|
|
115
|
-
legendStyle
|
|
116
|
-
} = useLegendConfig({legendConfig, isPdf});
|
|
117
|
-
|
|
118
105
|
const groupedByLabel = React.useMemo(() => {
|
|
119
106
|
return data.reduce((acc, item) => {
|
|
120
107
|
const label = item[xFieldKey];
|
|
@@ -243,7 +230,7 @@ export default function StackChart({
|
|
|
243
230
|
);
|
|
244
231
|
|
|
245
232
|
return (
|
|
246
|
-
|
|
233
|
+
<StyleWrapper>
|
|
247
234
|
<Style
|
|
248
235
|
{...(isEmpty
|
|
249
236
|
? {
|
|
@@ -271,14 +258,19 @@ export default function StackChart({
|
|
|
271
258
|
{content()}
|
|
272
259
|
</div>
|
|
273
260
|
</Style>
|
|
274
|
-
|
|
275
|
-
<
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
261
|
+
{isPdf && (
|
|
262
|
+
<div className="legend">
|
|
263
|
+
{Object.entries(seriesColors).map(([series, color]) => (
|
|
264
|
+
<div key={series} className="legend-item">
|
|
265
|
+
<span
|
|
266
|
+
className="legend-color"
|
|
267
|
+
style={{ backgroundColor: color || token.colorPrimary7 }}
|
|
268
|
+
/>
|
|
269
|
+
<span className="legend-label">{t(series)}</span>
|
|
270
|
+
</div>
|
|
271
|
+
))}
|
|
272
|
+
</div>
|
|
281
273
|
)}
|
|
282
|
-
|
|
274
|
+
</StyleWrapper>
|
|
283
275
|
);
|
|
284
276
|
}
|
|
@@ -24,6 +24,8 @@ export default function AddUserModal({ isOpen, defaultData = {}, userRoles = [],
|
|
|
24
24
|
.catch(() => {});
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
console.log("hellooooooooooooooooooooooooo");
|
|
28
|
+
|
|
27
29
|
return (
|
|
28
30
|
<Modal
|
|
29
31
|
open={isOpen}
|
|
@@ -55,7 +57,7 @@ export default function AddUserModal({ isOpen, defaultData = {}, userRoles = [],
|
|
|
55
57
|
}}
|
|
56
58
|
/>
|
|
57
59
|
</Form.Item>
|
|
58
|
-
{accountUsed && (
|
|
60
|
+
{/* {accountUsed && (
|
|
59
61
|
<Alert
|
|
60
62
|
message={t("FB00001")}
|
|
61
63
|
type="error"
|
|
@@ -64,7 +66,7 @@ export default function AddUserModal({ isOpen, defaultData = {}, userRoles = [],
|
|
|
64
66
|
closable
|
|
65
67
|
onClose={() => setAccountUsed(false)}
|
|
66
68
|
/>
|
|
67
|
-
)}
|
|
69
|
+
)} */}
|
|
68
70
|
|
|
69
71
|
<Form.Item name="role" label={t("Role")} rules={[{ required: true }]}>
|
|
70
72
|
<Select
|
|
@@ -2,7 +2,7 @@ import Modal from "../../../../Modal/index.jsx";
|
|
|
2
2
|
import { Form, Select, Alert, Input } from "antd";
|
|
3
3
|
import { useState, useEffect } from "react";
|
|
4
4
|
|
|
5
|
-
export default function NewUser({ t, isOpen, onClose, defaultData, userRoles = [] }) {
|
|
5
|
+
export default function NewUser({ t, isOpen, onClose, defaultData, userRoles = [], addUser = () => {} }) {
|
|
6
6
|
const [MainForm] = Form.useForm();
|
|
7
7
|
const [accountUsed, setAccountUsed] = useState(false);
|
|
8
8
|
|
|
@@ -18,8 +18,26 @@ export default function NewUser({ t, isOpen, onClose, defaultData, userRoles = [
|
|
|
18
18
|
const onSubmit = () => {
|
|
19
19
|
MainForm.validateFields()
|
|
20
20
|
.then((val) => {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Create user object with the form data
|
|
22
|
+
const userData = {
|
|
23
|
+
firstName: val.firstName,
|
|
24
|
+
lastName: val.lastName,
|
|
25
|
+
email: val.email,
|
|
26
|
+
role: val.role,
|
|
27
|
+
apps: {
|
|
28
|
+
straatos: {
|
|
29
|
+
role: val.role,
|
|
30
|
+
access: true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Add user to local state
|
|
36
|
+
addUser(userData);
|
|
37
|
+
|
|
38
|
+
// Close modal and reset form
|
|
39
|
+
onClose();
|
|
40
|
+
MainForm.resetFields();
|
|
23
41
|
})
|
|
24
42
|
.catch(() => {});
|
|
25
43
|
};
|
|
@@ -45,7 +63,7 @@ export default function NewUser({ t, isOpen, onClose, defaultData, userRoles = [
|
|
|
45
63
|
}}
|
|
46
64
|
/>
|
|
47
65
|
</Form.Item>
|
|
48
|
-
{accountUsed && (
|
|
66
|
+
{/* {accountUsed && (
|
|
49
67
|
<Alert
|
|
50
68
|
message={t("FB00001")}
|
|
51
69
|
type="error"
|
|
@@ -54,7 +72,7 @@ export default function NewUser({ t, isOpen, onClose, defaultData, userRoles = [
|
|
|
54
72
|
closable
|
|
55
73
|
onClose={() => setAccountUsed(false)}
|
|
56
74
|
/>
|
|
57
|
-
)}
|
|
75
|
+
)} */}
|
|
58
76
|
|
|
59
77
|
<Form.Item name="role" label={t("Role")} rules={[{ required: true }]}>
|
|
60
78
|
<Select
|
|
@@ -58,6 +58,16 @@ export default function Edit({
|
|
|
58
58
|
}));
|
|
59
59
|
}, []);
|
|
60
60
|
|
|
61
|
+
const addUser = useCallback((userData) => {
|
|
62
|
+
setIsChanged(true);
|
|
63
|
+
setData((prev) => ({
|
|
64
|
+
...prev,
|
|
65
|
+
users: [...(prev.users || []), {
|
|
66
|
+
...userData,
|
|
67
|
+
}]
|
|
68
|
+
}));
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
61
71
|
const onSuspend = () => {
|
|
62
72
|
Modal.confirm({
|
|
63
73
|
title: t("sbg-admin::suspend-title"),
|
|
@@ -105,7 +115,7 @@ export default function Edit({
|
|
|
105
115
|
onCancel: () => {},
|
|
106
116
|
});
|
|
107
117
|
};
|
|
108
|
-
|
|
118
|
+
console.log("good morning",module);
|
|
109
119
|
const renderItem = (item) => {
|
|
110
120
|
if (item.type === "users") {
|
|
111
121
|
return (
|
|
@@ -118,6 +128,7 @@ export default function Edit({
|
|
|
118
128
|
userRoles={userRoles}
|
|
119
129
|
deleteUser={deleteUser}
|
|
120
130
|
updateUser={updateUser}
|
|
131
|
+
addUser={addUser}
|
|
121
132
|
goTo={goTo}
|
|
122
133
|
accountStatuses={accountStatuses}
|
|
123
134
|
transferAdmin={transferAdmin}
|
|
@@ -29,6 +29,7 @@ export default function Users({
|
|
|
29
29
|
accountStatuses,
|
|
30
30
|
deleteUser = () => {},
|
|
31
31
|
updateUser = () => {},
|
|
32
|
+
addUser = () => {},
|
|
32
33
|
transferAdmin = () => {},
|
|
33
34
|
}) {
|
|
34
35
|
const [hasError, setHasError] = useState(false);
|
|
@@ -177,6 +178,7 @@ export default function Users({
|
|
|
177
178
|
isOpen={newUserModalVisible}
|
|
178
179
|
onClose={() => setNewUserModalVisible(false)}
|
|
179
180
|
userRoles={userRoles}
|
|
181
|
+
addUser={addUser}
|
|
180
182
|
/>
|
|
181
183
|
</div>
|
|
182
184
|
);
|
|
@@ -164,32 +164,3 @@ export const renderTemplateStringInObject = (obj, variables) => {
|
|
|
164
164
|
export const truncateString = (str, n) => {
|
|
165
165
|
return str?.length > n ? `${str.slice(0, n)}...` : str || "";
|
|
166
166
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
export const splitStringInMultipleLines = (s, limit = 20) => {
|
|
170
|
-
if (!s) return "";
|
|
171
|
-
|
|
172
|
-
let result = "";
|
|
173
|
-
let line = "";
|
|
174
|
-
|
|
175
|
-
for (let word of s.split(" ")) {
|
|
176
|
-
if ((line + word).length <= limit) {
|
|
177
|
-
line += (line ? " " : "") + word;
|
|
178
|
-
} else if (word.length > limit) {
|
|
179
|
-
// break long word with hyphen
|
|
180
|
-
while (word.length > limit) {
|
|
181
|
-
result += word.slice(0, limit - 1) + "-\n";
|
|
182
|
-
word = word.slice(limit - 1);
|
|
183
|
-
}
|
|
184
|
-
line = word;
|
|
185
|
-
} else {
|
|
186
|
-
// move current line into result
|
|
187
|
-
if (line) result += line + "\n";
|
|
188
|
-
line = word;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (line) result += line;
|
|
193
|
-
|
|
194
|
-
return result;
|
|
195
|
-
}
|
package/src/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ export { renderTooltip, renderTooltipJsx } from './@daf/utils/tooltip'
|
|
|
9
9
|
export { getRangeOfTicks } from './helpers/chart'
|
|
10
10
|
|
|
11
11
|
export { propHasValue } from './helpers/deepFind'
|
|
12
|
-
export { isEmptyOrSpaces, capitalizeAll, capitalize, camelCaseToTitle, snakeCaseToTitleCase, titleToCamelCase, findOptions, getOptionAsObject, nowToIso, renderTemplateString, renderTemplateStringInObject, truncateString
|
|
12
|
+
export { isEmptyOrSpaces, capitalizeAll, capitalize, camelCaseToTitle, snakeCaseToTitleCase, titleToCamelCase, findOptions, getOptionAsObject, nowToIso, renderTemplateString, renderTemplateStringInObject, truncateString } from './helpers/StringHelper'
|
|
13
13
|
export { getNkey, groupSubsections, getImageUploadViewValue } from './@daf/core/components/ViewForm/helper'
|
|
14
14
|
export { renderRows } from './@daf/core/components/Table/helper'
|
|
15
15
|
export { filterOptions, filterString, hasNotChanged, filterSelectOptions, mapSubGroupsInSubmit, mapSubGroupsInGet, filterCreateData, changeInputMeta, renderDateFormatted } from './helpers/Forms'
|