@buerokratt-ria/common-gui-components 0.0.52 → 0.0.53
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/templates/history-page/src/History.scss +0 -4
- package/templates/history-page/src/index.tsx +113 -112
- package/translations/en/common.json +4 -2
- package/translations/et/common.json +4 -2
- package/ui-components/Card/index.tsx +3 -1
- package/ui-components/ClearFiltersButton/index.tsx +24 -0
- package/ui-components/FormElements/FormSelect/FormMultiselect.tsx +4 -1
- package/ui-components/index.tsx +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## Template [MajorVersion.MediterraneanVersion.MinorVersion] - DD-MM-YYYY
|
|
6
6
|
|
|
7
|
+
## [0.0.53] - 06.05.2026
|
|
8
|
+
|
|
9
|
+
- Removed the Chosen CSA filter from chat history.
|
|
10
|
+
- Added Clear filters action for chat history filters.
|
|
11
|
+
- Added Choose all / Vali kõik option to the chosen columns filter.
|
|
12
|
+
- Persisted selected chat history columns in user preferences.
|
|
13
|
+
|
|
7
14
|
## [0.0.52] - 05.05.2026
|
|
8
15
|
|
|
9
16
|
- Updated loading logic
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {FC, PropsWithChildren, useEffect, useMemo, useRef, useState} from 'react';
|
|
2
2
|
import {useTranslation} from 'react-i18next';
|
|
3
3
|
import {useMutation} from '@tanstack/react-query';
|
|
4
4
|
import {ColumnPinningState, createColumnHelper, PaginationState, SortingState,} from '@tanstack/react-table';
|
|
5
5
|
import {endOfDay, format, formatISO, startOfDay} from "date-fns";
|
|
6
6
|
import {AxiosError} from 'axios';
|
|
7
7
|
import './History.scss';
|
|
8
|
-
import {MdOutlineRemoveRedEye} from 'react-icons/md';
|
|
8
|
+
import {MdOutlineRemoveRedEye } from 'react-icons/md';
|
|
9
9
|
import {CgSpinner} from 'react-icons/cg';
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
Button,
|
|
13
13
|
Card,
|
|
14
|
+
ClearFiltersButton,
|
|
14
15
|
DataTable,
|
|
15
16
|
Dialog,
|
|
16
17
|
Drawer,
|
|
@@ -61,6 +62,8 @@ type ExportResult = {
|
|
|
61
62
|
chatIds: string[];
|
|
62
63
|
};
|
|
63
64
|
|
|
65
|
+
const ALL_COLUMNS_VALUE = '__all__';
|
|
66
|
+
|
|
64
67
|
const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
65
68
|
user,
|
|
66
69
|
userDomains,
|
|
@@ -86,8 +89,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
86
89
|
const passedStartDate = delegatedStartDate ?? params.get("start");
|
|
87
90
|
const passedEndDate = delegatedEndDate ?? params.get("end");
|
|
88
91
|
const skipNextSelectedColumnsEffect = useRef(false);
|
|
89
|
-
const passedCustomerSupportIds = params.getAll('customerSupportIds');
|
|
90
|
-
const [search, setSearch] = useState('');
|
|
91
92
|
const [selectedChat, setSelectedChat] = useState<ChatType | null>(null);
|
|
92
93
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
93
94
|
const [statusChangeModal, setStatusChangeModal] = useState<string | null>(
|
|
@@ -114,7 +115,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
114
115
|
|
|
115
116
|
const [messagesTrigger, setMessagesTrigger] = useState(false);
|
|
116
117
|
const [selectedColumns, setSelectedColumns] = useState<string[]>([]);
|
|
117
|
-
const [customerSupportAgents, setCustomerSupportAgents] = useState<any[]>([]);
|
|
118
118
|
const [counterKey, setCounterKey] = useState<number>(0)
|
|
119
119
|
|
|
120
120
|
const useStore = userDomains;
|
|
@@ -137,13 +137,16 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
137
137
|
const { control, setValue, watch } = useForm<{
|
|
138
138
|
startDate: Date | string;
|
|
139
139
|
endDate: Date | string;
|
|
140
|
+
search: string;
|
|
140
141
|
}>({
|
|
141
142
|
defaultValues: {
|
|
142
143
|
startDate: passedStartDate ? parseDateParam(passedStartDate) : startOfDay(new Date()),
|
|
143
144
|
endDate: passedEndDate ? parseDateParam(passedEndDate) : endOfDay(new Date()),
|
|
145
|
+
search: '',
|
|
144
146
|
},
|
|
145
147
|
});
|
|
146
148
|
|
|
149
|
+
const search = watch('search');
|
|
147
150
|
const startDate = watch('startDate');
|
|
148
151
|
const endDate = watch('endDate');
|
|
149
152
|
|
|
@@ -151,7 +154,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
151
154
|
getAllEndedChats.mutate({
|
|
152
155
|
startDate: formatISO(startOfDay(new Date(startDate))),
|
|
153
156
|
endDate: formatISO(endOfDay(new Date(endDate))),
|
|
154
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
155
157
|
pagination,
|
|
156
158
|
sorting,
|
|
157
159
|
search,
|
|
@@ -198,7 +200,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
198
200
|
getAllEndedChats.mutate({
|
|
199
201
|
startDate: hasStart ? unifyDateFromat(delegatedStartDate) : formatISO(startOfDay(new Date(startDate))),
|
|
200
202
|
endDate: hasEnd ? unifyDateFromat(delegatedEndDate) : formatISO(endOfDay(new Date(endDate))),
|
|
201
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
202
203
|
pagination,
|
|
203
204
|
sorting,
|
|
204
205
|
search,
|
|
@@ -229,13 +230,12 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
skipNextSelectedColumnsEffect.current = true;
|
|
232
|
-
setSelectedColumns(newSelectedColumns);
|
|
233
|
+
setSelectedColumns(getUiSelectedColumns(newSelectedColumns));
|
|
233
234
|
setCounterKey(prev => prev + 1);
|
|
234
235
|
|
|
235
236
|
getAllEndedChats.mutate({
|
|
236
237
|
startDate: formatISO(startOfDay(new Date(startDate))),
|
|
237
238
|
endDate: formatISO(endOfDay(new Date(endDate))),
|
|
238
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
239
239
|
pagination: updatedPagination,
|
|
240
240
|
sorting,
|
|
241
241
|
search,
|
|
@@ -264,7 +264,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
264
264
|
getAllEndedChats.mutate({
|
|
265
265
|
startDate: formatISO(startOfDay(new Date(startDate))),
|
|
266
266
|
endDate: formatISO(endOfDay(new Date(endDate))),
|
|
267
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
268
267
|
pagination,
|
|
269
268
|
sorting,
|
|
270
269
|
search,
|
|
@@ -272,10 +271,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
272
271
|
}
|
|
273
272
|
}, [selectedColumns, currentDomains]);
|
|
274
273
|
|
|
275
|
-
useEffect(() => {
|
|
276
|
-
listCustomerSupportAgents.mutate();
|
|
277
|
-
}, []);
|
|
278
|
-
|
|
279
274
|
const updatePagePreferences = useMutation({
|
|
280
275
|
mutationFn: (data: {
|
|
281
276
|
page_results: number;
|
|
@@ -294,7 +289,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
294
289
|
mutationFn: (data: {
|
|
295
290
|
startDate: string;
|
|
296
291
|
endDate: string;
|
|
297
|
-
customerSupportIds: string[];
|
|
298
292
|
pagination: PaginationState;
|
|
299
293
|
sorting: SortingState;
|
|
300
294
|
search: string;
|
|
@@ -309,7 +303,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
309
303
|
}
|
|
310
304
|
|
|
311
305
|
return apiDevEnded.post('agents/chats/ended', {
|
|
312
|
-
customerSupportIds: data.customerSupportIds,
|
|
313
306
|
startDate: formatISO(startOfDay(new Date(data.startDate))),
|
|
314
307
|
endDate: formatISO(endOfDay(new Date(data.endDate))),
|
|
315
308
|
urls: getDomainsArray(currentDomains),
|
|
@@ -373,27 +366,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
373
366
|
},
|
|
374
367
|
});
|
|
375
368
|
|
|
376
|
-
const
|
|
377
|
-
mutationFn: () =>
|
|
378
|
-
apiDev.post('accounts/customer-support-agents', {
|
|
379
|
-
page: 0,
|
|
380
|
-
page_size: 99999,
|
|
381
|
-
sorting: 'name asc',
|
|
382
|
-
show_active_only: false,
|
|
383
|
-
roles: ['ROLE_CUSTOMER_SUPPORT_AGENT'],
|
|
384
|
-
}),
|
|
385
|
-
onSuccess: (res: any) => {
|
|
386
|
-
setCustomerSupportAgents([
|
|
387
|
-
{label: 'Bürokratt', value: 'chatbot'},
|
|
388
|
-
...res.data.response.map((item) => ({
|
|
389
|
-
label: [item.firstName, item.lastName].join(' ').trim(),
|
|
390
|
-
value: item.idCode,
|
|
391
|
-
})),
|
|
392
|
-
]);
|
|
393
|
-
},
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
const visibleColumnOptions = useMemo(() => {
|
|
369
|
+
const realColumnOptions: {readonly label: string; readonly value: string}[] = useMemo(() => {
|
|
397
370
|
const columns = [
|
|
398
371
|
{label: t('chat.history.startTime'), value: 'created'},
|
|
399
372
|
{label: t('chat.history.endTime'), value: 'ended'},
|
|
@@ -422,6 +395,49 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
422
395
|
return columns;
|
|
423
396
|
}, [t, showEmail, testMessageEnabled])
|
|
424
397
|
|
|
398
|
+
const visibleColumnOptions = useMemo(() => [
|
|
399
|
+
{label: t('chat.history.chooseAll'), value: ALL_COLUMNS_VALUE},
|
|
400
|
+
...realColumnOptions,
|
|
401
|
+
], [t, realColumnOptions]);
|
|
402
|
+
|
|
403
|
+
const getRealSelectedColumns = (columns: string[]) =>
|
|
404
|
+
columns.filter((column) => column !== ALL_COLUMNS_VALUE);
|
|
405
|
+
|
|
406
|
+
const getAllColumnValues = () => realColumnOptions.map((option) => option.value);
|
|
407
|
+
|
|
408
|
+
const areAllColumnsSelected = (columns: string[]) => {
|
|
409
|
+
const realSelectedColumns = getRealSelectedColumns(columns);
|
|
410
|
+
const allColumnValues = getAllColumnValues();
|
|
411
|
+
|
|
412
|
+
return allColumnValues.length > 0 &&
|
|
413
|
+
allColumnValues.every((column) => realSelectedColumns.includes(column));
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
const getUiSelectedColumns = (columns: string[]) => {
|
|
417
|
+
const realSelectedColumns = getRealSelectedColumns(columns);
|
|
418
|
+
|
|
419
|
+
if (areAllColumnsSelected(realSelectedColumns)) {
|
|
420
|
+
return [ALL_COLUMNS_VALUE, ...getAllColumnValues()];
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return realSelectedColumns;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const normalizeSelectedColumns = (selection: string[]) => {
|
|
427
|
+
const currentAllSelected = selectedColumns.includes(ALL_COLUMNS_VALUE) || areAllColumnsSelected(selectedColumns);
|
|
428
|
+
const nextAllSelected = selection.includes(ALL_COLUMNS_VALUE);
|
|
429
|
+
|
|
430
|
+
if (nextAllSelected && !currentAllSelected) {
|
|
431
|
+
return [ALL_COLUMNS_VALUE, ...getAllColumnValues()];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (!nextAllSelected && currentAllSelected) {
|
|
435
|
+
return [];
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return getUiSelectedColumns(selection);
|
|
439
|
+
};
|
|
440
|
+
|
|
425
441
|
const chatStatusChangeMutation = useMutation({
|
|
426
442
|
mutationFn: async (data: { chatId: string | number; event: string }) => {
|
|
427
443
|
const changeableTo = [
|
|
@@ -456,7 +472,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
456
472
|
getAllEndedChats.mutate({
|
|
457
473
|
startDate: formatISO(startOfDay(new Date(startDate))),
|
|
458
474
|
endDate: formatISO(endOfDay(new Date(endDate))),
|
|
459
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
460
475
|
pagination,
|
|
461
476
|
sorting,
|
|
462
477
|
search,
|
|
@@ -924,9 +939,11 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
924
939
|
};
|
|
925
940
|
|
|
926
941
|
const getFilteredColumns = () => {
|
|
927
|
-
|
|
942
|
+
const realSelectedColumns = getRealSelectedColumns(selectedColumns);
|
|
943
|
+
|
|
944
|
+
if (realSelectedColumns.length === 0) return endedChatsColumns;
|
|
928
945
|
return endedChatsColumns.filter((c) =>
|
|
929
|
-
['detail', 'forward', ...
|
|
946
|
+
['detail', 'forward', ...realSelectedColumns].includes(c.id ?? '')
|
|
930
947
|
);
|
|
931
948
|
};
|
|
932
949
|
|
|
@@ -953,10 +970,11 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
953
970
|
selectedColumns: string[],
|
|
954
971
|
t: (key: string) => string
|
|
955
972
|
): ExportResult => {
|
|
973
|
+
const realSelectedColumns = getRealSelectedColumns(selectedColumns);
|
|
956
974
|
const activeColumns =
|
|
957
|
-
|
|
975
|
+
realSelectedColumns.length > 0
|
|
958
976
|
? allColumns.filter(
|
|
959
|
-
(col) => col.id && col.id !== 'detail' &&
|
|
977
|
+
(col) => col.id && col.id !== 'detail' && realSelectedColumns.includes(col.id)
|
|
960
978
|
)
|
|
961
979
|
: allColumns.filter((col) => col.id && col.id !== 'detail');
|
|
962
980
|
|
|
@@ -1026,9 +1044,10 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1026
1044
|
sortBy = `${sorting[0].id} ${sortType}`;
|
|
1027
1045
|
}
|
|
1028
1046
|
|
|
1029
|
-
const
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1047
|
+
const realSelectedColumns = getRealSelectedColumns(selectedColumns);
|
|
1048
|
+
const { headers } = mapChatsToExportRows([], endedChatsColumns, realSelectedColumns, t);
|
|
1049
|
+
const activeColumns = realSelectedColumns.length > 0
|
|
1050
|
+
? endedChatsColumns.filter((col) => col.id && col.id !== 'detail' && realSelectedColumns.includes(col.id))
|
|
1032
1051
|
: endedChatsColumns.filter((col) => col.id && col.id !== 'detail');
|
|
1033
1052
|
const columnIds = activeColumns.map((col) => col.id!);
|
|
1034
1053
|
|
|
@@ -1041,7 +1060,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1041
1060
|
urls: getDomainsArray(currentDomains),
|
|
1042
1061
|
sorting: sortBy,
|
|
1043
1062
|
search,
|
|
1044
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
1045
1063
|
});
|
|
1046
1064
|
|
|
1047
1065
|
const downloadData = response.data.data ?? response.data;
|
|
@@ -1060,6 +1078,21 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1060
1078
|
|
|
1061
1079
|
const endUserFullName = getUserName();
|
|
1062
1080
|
|
|
1081
|
+
const isClearFiltersVisible = useMemo(()=> {
|
|
1082
|
+
return search.length > 0 || selectedColumns.length > 0;
|
|
1083
|
+
}, [search, selectedColumns]);
|
|
1084
|
+
|
|
1085
|
+
const onClearFilersClick = () => {
|
|
1086
|
+
const clearedColumns: string[] = [];
|
|
1087
|
+
setSelectedColumns(clearedColumns);
|
|
1088
|
+
setCounterKey(0);
|
|
1089
|
+
setValue('search', '');
|
|
1090
|
+
updatePagePreferences.mutate({
|
|
1091
|
+
page_results: pagination.pageSize,
|
|
1092
|
+
selected_columns: clearedColumns
|
|
1093
|
+
});
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1063
1096
|
if (!filteredEndedChatsList) return <>Loading... {{filteredEndedChatsList}} something is wrong </>;
|
|
1064
1097
|
|
|
1065
1098
|
return (
|
|
@@ -1086,27 +1119,29 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1086
1119
|
</div>
|
|
1087
1120
|
|
|
1088
1121
|
<div className={`history-content${getAllEndedChats.isPending ? ' history-content--loading' : ''}`}>
|
|
1089
|
-
<Card>
|
|
1122
|
+
<Card style={{marginBottom: '16px'}}>
|
|
1090
1123
|
<Track gap={16}>
|
|
1091
1124
|
{displaySearchBar && (
|
|
1092
|
-
<
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1125
|
+
<Controller name="search" control={control} render={({ field }) => {
|
|
1126
|
+
return <FormInput
|
|
1127
|
+
label={t('chat.history.searchChats')}
|
|
1128
|
+
hideLabel
|
|
1129
|
+
name="searchChats"
|
|
1130
|
+
value={field.value}
|
|
1131
|
+
placeholder={t('chat.history.searchChats') + '...'}
|
|
1132
|
+
onChange={(e) => {
|
|
1133
|
+
setPagination({ pageIndex: 0, pageSize: pagination.pageSize });
|
|
1134
|
+
setSearchParams((params) => {
|
|
1135
|
+
params.set("page", "1");
|
|
1136
|
+
return params;
|
|
1137
|
+
});
|
|
1138
|
+
field.onChange(e.target.value);
|
|
1139
|
+
debouncedGetAllEnded(e.target.value);
|
|
1140
|
+
}}
|
|
1141
|
+
/>
|
|
1142
|
+
}} />
|
|
1143
|
+
)}
|
|
1144
|
+
<Track gap={16}>
|
|
1110
1145
|
{displayDateFilter && (
|
|
1111
1146
|
<>
|
|
1112
1147
|
<Track gap={10}>
|
|
@@ -1133,7 +1168,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1133
1168
|
getAllEndedChats.mutate({
|
|
1134
1169
|
startDate: start,
|
|
1135
1170
|
endDate: formatISO(endOfDay(new Date(endDate))),
|
|
1136
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
1137
1171
|
pagination: resetPagination,
|
|
1138
1172
|
sorting,
|
|
1139
1173
|
search,
|
|
@@ -1168,7 +1202,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1168
1202
|
getAllEndedChats.mutate({
|
|
1169
1203
|
startDate: formatISO(startOfDay(new Date(startDate))),
|
|
1170
1204
|
endDate: end,
|
|
1171
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
1172
1205
|
pagination: resetPagination,
|
|
1173
1206
|
sorting,
|
|
1174
1207
|
search,
|
|
@@ -1181,6 +1214,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1181
1214
|
</Track>
|
|
1182
1215
|
</>
|
|
1183
1216
|
)}
|
|
1217
|
+
<Track style={{width: '240px'}}>
|
|
1184
1218
|
<FormMultiselect
|
|
1185
1219
|
key={counterKey}
|
|
1186
1220
|
name="visibleColumns"
|
|
@@ -1190,54 +1224,18 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1190
1224
|
selectedOptions={visibleColumnOptions.filter((o) =>
|
|
1191
1225
|
selectedColumns.includes(o.value)
|
|
1192
1226
|
)}
|
|
1227
|
+
selectedOptionsCount={getRealSelectedColumns(selectedColumns).length}
|
|
1193
1228
|
onSelectionChange={(selection) => {
|
|
1194
|
-
const columns = selection?.map((s) => s.value) ?? [];
|
|
1229
|
+
const columns = normalizeSelectedColumns(selection?.map((s) => s.value) ?? []);
|
|
1195
1230
|
setSelectedColumns(columns);
|
|
1231
|
+
setCounterKey(prev => prev + 1);
|
|
1196
1232
|
updatePagePreferences.mutate({
|
|
1197
1233
|
page_results: pagination.pageSize,
|
|
1198
|
-
selected_columns: columns
|
|
1234
|
+
selected_columns: getRealSelectedColumns(columns)
|
|
1199
1235
|
})
|
|
1200
1236
|
}}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
name="agent"
|
|
1204
|
-
label={t('')}
|
|
1205
|
-
placeholder={t('chat.history.chosenCsa')}
|
|
1206
|
-
options={customerSupportAgents}
|
|
1207
|
-
selectedOptions={customerSupportAgents.filter((item) =>
|
|
1208
|
-
passedCustomerSupportIds.includes(item.value)
|
|
1209
|
-
)}
|
|
1210
|
-
onSelectionChange={(selection) => {
|
|
1211
|
-
setSearchParams((params) => {
|
|
1212
|
-
params.delete('customerSupportIds');
|
|
1213
|
-
params.set('page', '1');
|
|
1214
|
-
selection?.forEach((s) => {
|
|
1215
|
-
params.append("customerSupportIds", s.value);
|
|
1216
|
-
if (s.value === "chatbot") params.append("customerSupportIds", "-");
|
|
1217
|
-
return params;
|
|
1218
|
-
});
|
|
1219
|
-
return params;
|
|
1220
|
-
});
|
|
1221
|
-
|
|
1222
|
-
setPagination({pageIndex: 0, pageSize: pagination.pageSize});
|
|
1223
|
-
|
|
1224
|
-
const customerSupportIds =
|
|
1225
|
-
selection?.reduce((acc, s) => {
|
|
1226
|
-
acc.push(s.value);
|
|
1227
|
-
if (s.value === "chatbot") acc.push("-");
|
|
1228
|
-
return acc;
|
|
1229
|
-
}, []) || [];
|
|
1230
|
-
|
|
1231
|
-
getAllEndedChats.mutate({
|
|
1232
|
-
startDate,
|
|
1233
|
-
endDate,
|
|
1234
|
-
customerSupportIds: customerSupportIds,
|
|
1235
|
-
pagination: {pageIndex: 0, pageSize: pagination.pageSize},
|
|
1236
|
-
sorting,
|
|
1237
|
-
search,
|
|
1238
|
-
});
|
|
1239
|
-
}}
|
|
1240
|
-
/>
|
|
1237
|
+
/>
|
|
1238
|
+
</Track>
|
|
1241
1239
|
</Track>
|
|
1242
1240
|
</Track>
|
|
1243
1241
|
</Card>
|
|
@@ -1249,6 +1247,11 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1249
1247
|
</Button>
|
|
1250
1248
|
</div>)
|
|
1251
1249
|
}
|
|
1250
|
+
{isClearFiltersVisible && (
|
|
1251
|
+
<Track justify="between" style={{ marginBottom: '16px' }}>
|
|
1252
|
+
<ClearFiltersButton style={{ marginLeft: 'auto' }} onClick={onClearFilersClick} />
|
|
1253
|
+
</Track>
|
|
1254
|
+
)}
|
|
1252
1255
|
<div className="card-drawer-container" style={{height: '100%', overflow: 'auto'}}>
|
|
1253
1256
|
<div className="card-wrapper">
|
|
1254
1257
|
<Card>
|
|
@@ -1269,12 +1272,11 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1269
1272
|
setPagination(state);
|
|
1270
1273
|
updatePagePreferences.mutate({
|
|
1271
1274
|
page_results: state.pageSize,
|
|
1272
|
-
selected_columns: selectedColumns
|
|
1275
|
+
selected_columns: getRealSelectedColumns(selectedColumns)
|
|
1273
1276
|
});
|
|
1274
1277
|
getAllEndedChats.mutate({
|
|
1275
1278
|
startDate: formatISO(startOfDay(new Date(startDate))),
|
|
1276
1279
|
endDate: formatISO(endOfDay(new Date(endDate))),
|
|
1277
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
1278
1280
|
pagination: state,
|
|
1279
1281
|
sorting,
|
|
1280
1282
|
search,
|
|
@@ -1285,7 +1287,6 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
|
|
|
1285
1287
|
getAllEndedChats.mutate({
|
|
1286
1288
|
startDate: formatISO(startOfDay(new Date(startDate))),
|
|
1287
1289
|
endDate: formatISO(endOfDay(new Date(endDate))),
|
|
1288
|
-
customerSupportIds: passedCustomerSupportIds,
|
|
1289
1290
|
pagination,
|
|
1290
1291
|
sorting: state,
|
|
1291
1292
|
search,
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"today": "Today",
|
|
46
46
|
"forward": "Forward",
|
|
47
47
|
"chosen": "Chosen",
|
|
48
|
-
"read": "Read"
|
|
48
|
+
"read": "Read",
|
|
49
|
+
"clearFilters": "Clear filters"
|
|
49
50
|
},
|
|
50
51
|
"sorting": {
|
|
51
52
|
"des": "descending",
|
|
@@ -175,7 +176,8 @@
|
|
|
175
176
|
"statusAdder": "Status adder",
|
|
176
177
|
"statusAddedDate": "Status added date",
|
|
177
178
|
"chosenCsa": "Chosen csa(s)",
|
|
178
|
-
"chosenColumn": "Chosen column(s)"
|
|
179
|
+
"chosenColumn": "Chosen column(s)",
|
|
180
|
+
"chooseAll": "Choose all"
|
|
179
181
|
},
|
|
180
182
|
"plainEvents": {
|
|
181
183
|
"answered": "Answered",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"today": "Täna",
|
|
46
46
|
"forward": "Suuna",
|
|
47
47
|
"chosen": "Valitud",
|
|
48
|
-
"read": "Loetud"
|
|
48
|
+
"read": "Loetud",
|
|
49
|
+
"clearFilters": "Tühjenda filtrid"
|
|
49
50
|
},
|
|
50
51
|
"sorting": {
|
|
51
52
|
"des": "kahanevalt",
|
|
@@ -175,7 +176,8 @@
|
|
|
175
176
|
"statusAdder": "Staatuse lisaja",
|
|
176
177
|
"statusAddedDate": "Staatuse lisamise kuupäev",
|
|
177
178
|
"chosenCsa": "Valitud nõustaja(d)",
|
|
178
|
-
"chosenColumn": "Valitud tulba(d)"
|
|
179
|
+
"chosenColumn": "Valitud tulba(d)",
|
|
180
|
+
"chooseAll": "Vali kõik"
|
|
179
181
|
},
|
|
180
182
|
"plainEvents": {
|
|
181
183
|
"answered": "Vastatud",
|
|
@@ -10,6 +10,7 @@ type CardProps = {
|
|
|
10
10
|
isHeaderLight?: boolean;
|
|
11
11
|
isBodyDivided?: boolean;
|
|
12
12
|
isScrollable?: boolean;
|
|
13
|
+
style?: React.CSSProperties;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
const Card: FC<PropsWithChildren<CardProps>> = ({
|
|
@@ -19,10 +20,11 @@ const Card: FC<PropsWithChildren<CardProps>> = ({
|
|
|
19
20
|
isHeaderLight,
|
|
20
21
|
isBodyDivided,
|
|
21
22
|
isScrollable = false,
|
|
23
|
+
style,
|
|
22
24
|
children,
|
|
23
25
|
}) => {
|
|
24
26
|
return (
|
|
25
|
-
<div className={clsx('card', { 'card--borderless': borderless, 'card--scrollable': isScrollable })}>
|
|
27
|
+
<div className={clsx('card', { 'card--borderless': borderless, 'card--scrollable': isScrollable })} style={style}>
|
|
26
28
|
{header && (
|
|
27
29
|
<div className={`card__header ${isHeaderLight ? 'white' : ''}`}>
|
|
28
30
|
{header}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Button } from "@buerokratt-ria/header/src/components";
|
|
2
|
+
import { ComponentProps, FC } from "react";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { MdFilterListOff } from "react-icons/md";
|
|
5
|
+
|
|
6
|
+
type ClearFiltersButtonProps = {
|
|
7
|
+
readonly onClick: () => void;
|
|
8
|
+
readonly style?: Pick<ComponentProps<typeof Button>, 'style'>['style'];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const ClearFiltersButton: FC<ClearFiltersButtonProps> = ({ onClick, style }) => {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
|
|
14
|
+
return <Button
|
|
15
|
+
appearance="primary"
|
|
16
|
+
size="s"
|
|
17
|
+
style={style}
|
|
18
|
+
onClick={onClick}>
|
|
19
|
+
{t('global.clearFilters')}
|
|
20
|
+
<MdFilterListOff style={{ height: '24px', width: '24px' }} />
|
|
21
|
+
</Button>
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default ClearFiltersButton;
|
|
@@ -16,6 +16,7 @@ type FormMultiselectProps = SelectHTMLAttributes<HTMLSelectElement> & {
|
|
|
16
16
|
hideLabel?: boolean;
|
|
17
17
|
options: SelectOption[];
|
|
18
18
|
selectedOptions?: SelectOption[];
|
|
19
|
+
selectedOptionsCount?: number;
|
|
19
20
|
onSelectionChange?: (selection: SelectOption[] | null) => void;
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -28,6 +29,7 @@ const FormMultiselect: FC<FormMultiselectProps> = (
|
|
|
28
29
|
placeholder,
|
|
29
30
|
defaultValue,
|
|
30
31
|
selectedOptions,
|
|
32
|
+
selectedOptionsCount,
|
|
31
33
|
onSelectionChange,
|
|
32
34
|
...rest
|
|
33
35
|
},
|
|
@@ -84,13 +86,14 @@ const FormMultiselect: FC<FormMultiselectProps> = (
|
|
|
84
86
|
);
|
|
85
87
|
|
|
86
88
|
const placeholderValue = placeholder || t('global.choose');
|
|
89
|
+
const displaySelectedCount = selectedOptionsCount ?? selectedItems.length;
|
|
87
90
|
|
|
88
91
|
return (
|
|
89
92
|
<div className={selectClasses} style={rest.style}>
|
|
90
93
|
{label && !hideLabel && <label htmlFor={id} className='select__label' {...getLabelProps()}>{label}</label>}
|
|
91
94
|
<div className='select__wrapper'>
|
|
92
95
|
<div className='select__trigger' {...getToggleButtonProps()}>
|
|
93
|
-
{selectedItems.length > 0 ? `${placeholder ?? t('global.chosen')} (${
|
|
96
|
+
{selectedItems.length > 0 ? `${placeholder ?? t('global.chosen')} (${displaySelectedCount})` : placeholderValue}
|
|
94
97
|
<Icon label='Dropdown icon' size='medium' icon={<MdArrowDropDown color='#5D6071' />} />
|
|
95
98
|
</div>
|
|
96
99
|
|
package/ui-components/index.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import Drawer from './Drawer';
|
|
|
24
24
|
import HistoricalChat from './HistoricalChat';
|
|
25
25
|
import Dialog from './Dialog';
|
|
26
26
|
import Label from './Label';
|
|
27
|
+
import ClearFiltersButton from './ClearFiltersButton';
|
|
27
28
|
|
|
28
29
|
export {
|
|
29
30
|
Button,
|
|
@@ -49,5 +50,6 @@ export {
|
|
|
49
50
|
HistoricalChat,
|
|
50
51
|
Dialog,
|
|
51
52
|
Toast,
|
|
52
|
-
Label
|
|
53
|
+
Label,
|
|
54
|
+
ClearFiltersButton,
|
|
53
55
|
};
|