@visns-studio/visns-components 5.0.23 → 5.0.25
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/package.json
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
78
78
|
},
|
|
79
79
|
"name": "@visns-studio/visns-components",
|
|
80
|
-
"version": "5.0.
|
|
80
|
+
"version": "5.0.25",
|
|
81
81
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
82
82
|
"main": "src/index.js",
|
|
83
83
|
"files": [
|
|
@@ -391,6 +391,7 @@ const DataGrid = forwardRef(
|
|
|
391
391
|
case 'envelope':
|
|
392
392
|
case 'file':
|
|
393
393
|
case 'image':
|
|
394
|
+
case 'undo':
|
|
394
395
|
CustomFetch(s.url, 'POST', { id: d[s.key] }, (result) => {
|
|
395
396
|
toast.success(result.message);
|
|
396
397
|
});
|
|
@@ -1144,6 +1145,8 @@ const DataGrid = forwardRef(
|
|
|
1144
1145
|
return getIconComponent(SoundOn);
|
|
1145
1146
|
case 'ssa':
|
|
1146
1147
|
return getIconComponent(Clock);
|
|
1148
|
+
case 'undo':
|
|
1149
|
+
return getIconComponent(ArrowCounterClockwise);
|
|
1147
1150
|
case 'update':
|
|
1148
1151
|
return getIconComponent(Edit);
|
|
1149
1152
|
default:
|
|
@@ -6,13 +6,13 @@ import { ResponsiveBar } from '@nivo/bar';
|
|
|
6
6
|
import { ResponsiveLine } from '@nivo/line';
|
|
7
7
|
import { ResponsivePie } from '@nivo/pie';
|
|
8
8
|
import Popup from 'reactjs-popup';
|
|
9
|
+
import dayjs from 'dayjs';
|
|
9
10
|
import { CircleX } from 'akar-icons';
|
|
10
11
|
|
|
11
12
|
import CustomFetch from '../../crm/Fetch';
|
|
12
13
|
import MultiSelect from '../../crm/MultiSelect';
|
|
13
14
|
|
|
14
15
|
import styles from './styles/GenericDashboard.module.scss';
|
|
15
|
-
import { drop } from 'lodash';
|
|
16
16
|
|
|
17
17
|
const toSnakeCase = (str) => str.replace(/[\s-]+/g, '_').toLowerCase();
|
|
18
18
|
|
|
@@ -71,7 +71,7 @@ function GenericDashboard({ setting }) {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
useEffect(() => {
|
|
74
|
-
fetchData(); // Fetch initial data
|
|
74
|
+
fetchData(filters); // Fetch initial data
|
|
75
75
|
}, [setting]);
|
|
76
76
|
|
|
77
77
|
const openModal = (widgetId) => {
|
|
@@ -124,6 +124,51 @@ function GenericDashboard({ setting }) {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
const getDefaultDate = (defaultValue) => {
|
|
128
|
+
switch (defaultValue) {
|
|
129
|
+
case 'startOfMonth':
|
|
130
|
+
return dayjs().startOf('month').format('YYYY-MM-DD');
|
|
131
|
+
case 'endOfMonth':
|
|
132
|
+
return dayjs().endOf('month').format('YYYY-MM-DD');
|
|
133
|
+
default:
|
|
134
|
+
return '';
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
// Initialize filters with default values when settings change
|
|
140
|
+
const initializeFilters = () => {
|
|
141
|
+
const initialFilters = {};
|
|
142
|
+
|
|
143
|
+
setting.widgets.forEach((widget) => {
|
|
144
|
+
if (widget.filters) {
|
|
145
|
+
initialFilters[widget.id] = widget.filters.reduce(
|
|
146
|
+
(acc, filter) => {
|
|
147
|
+
if (filter.type === 'date' && filter.default) {
|
|
148
|
+
acc[filter.id] = getDefaultDate(filter.default);
|
|
149
|
+
} else if (filter.type === 'multi-dropdown-ajax') {
|
|
150
|
+
acc[filter.id] = [];
|
|
151
|
+
}
|
|
152
|
+
return acc;
|
|
153
|
+
},
|
|
154
|
+
{}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
setFilters(initialFilters);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
initializeFilters();
|
|
163
|
+
}, [setting]);
|
|
164
|
+
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
// Fetch data whenever filters are updated
|
|
167
|
+
if (Object.keys(filters).length > 0) {
|
|
168
|
+
fetchData(filters);
|
|
169
|
+
}
|
|
170
|
+
}, [filters]);
|
|
171
|
+
|
|
127
172
|
const renderFilters = (widget) => {
|
|
128
173
|
if (!widget.filters || widget.filters.length === 0) return null;
|
|
129
174
|
|
|
@@ -152,13 +197,14 @@ function GenericDashboard({ setting }) {
|
|
|
152
197
|
filter.id
|
|
153
198
|
] || ''
|
|
154
199
|
}
|
|
155
|
-
onChange={(e) =>
|
|
200
|
+
onChange={(e) => {
|
|
156
201
|
handleFilterChange(
|
|
157
202
|
widget.id,
|
|
158
203
|
filter.id,
|
|
159
204
|
e.target.value
|
|
160
|
-
)
|
|
161
|
-
|
|
205
|
+
);
|
|
206
|
+
e.target.blur(); // Closes the picker
|
|
207
|
+
}}
|
|
162
208
|
/>
|
|
163
209
|
</div>
|
|
164
210
|
);
|
|
@@ -198,14 +244,14 @@ function GenericDashboard({ setting }) {
|
|
|
198
244
|
}
|
|
199
245
|
})}
|
|
200
246
|
<div className={styles['filter-actions']}>
|
|
201
|
-
<button
|
|
247
|
+
{/* <button
|
|
202
248
|
className={`${styles.btn} ${styles['btn-primary']}`}
|
|
203
249
|
onClick={() => {
|
|
204
250
|
fetchData(filters); // Trigger fetchData with the current filters
|
|
205
251
|
}}
|
|
206
252
|
>
|
|
207
253
|
Apply Filters
|
|
208
|
-
</button>
|
|
254
|
+
</button> */}
|
|
209
255
|
<button
|
|
210
256
|
className={`${styles.btn} ${styles['btn-secondary']}`}
|
|
211
257
|
onClick={() => {
|