@buerokratt-ria/common-gui-components 0.0.14 → 0.0.17

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 CHANGED
@@ -4,10 +4,19 @@ 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.14] - 05-05-2025
7
+ ## [0.0.17] - 13-05-2025
8
+
9
+ - Display feedback rating consistently in history page.
10
+
11
+ ## [0.0.15] - 05-05-2025
8
12
 
9
13
  - Updated popup duration to be 5 seconds.
10
14
 
15
+ ## [0.0.14] - 30-04-2025
16
+
17
+ - Added sorting configurable (disabled by default)
18
+ - Added Email display configurable (disabled by default)
19
+
11
20
  ## [0.0.13] - 25-04-2025
12
21
 
13
22
  - Adding double scrollbar to history page when size is small.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -37,10 +37,12 @@ type HistoryProps = {
37
37
  toastContext: ToastContextType | null;
38
38
  onMessageClick?: (message: any) => void;
39
39
  showComment?: boolean;
40
+ showEmail?: boolean;
41
+ showSortingLabel?: boolean;
40
42
  showStatus?: boolean;
41
43
  }
42
44
 
43
- const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, onMessageClick, showComment = true, showStatus = true}) => {
45
+ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, onMessageClick, showComment = true, showEmail = false, showSortingLabel = false,showStatus = true}) => {
44
46
  const {t, i18n} = useTranslation();
45
47
  const toast = toastContext;
46
48
  const userInfo = user;
@@ -259,7 +261,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
259
261
  }),
260
262
  onSuccess: (res: any) => {
261
263
  setCustomerSupportAgents([
262
- {label: '-', value: ','},
264
+ {label: '-', value: '-'},
263
265
  {label: 'Bürokratt', value: 'chatbot'},
264
266
  ...res.data.response.map((item) => ({
265
267
  label: [item.firstName, item.lastName].join(' ').trim(),
@@ -269,8 +271,8 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
269
271
  },
270
272
  });
271
273
 
272
- const visibleColumnOptions = useMemo(
273
- () => [
274
+ const visibleColumnOptions = useMemo(() => {
275
+ const columns = [
274
276
  {label: t('chat.history.startTime'), value: 'created'},
275
277
  {label: t('chat.history.endTime'), value: 'ended'},
276
278
  {label: t('chat.history.csaName'), value: 'customerSupportFullName'},
@@ -283,9 +285,14 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
283
285
  {label: t('global.status'), value: 'status'},
284
286
  {label: 'ID', value: 'id'},
285
287
  {label: 'www', value: 'www'},
286
- ],
287
- [t]
288
- );
288
+ ];
289
+
290
+ if (showEmail) {
291
+ columns.splice(4, 0, {label: t('global.email'), value: 'endUserEmail'}); // insert after name
292
+ }
293
+
294
+ return columns;
295
+ }, [t, showEmail])
289
296
 
290
297
  const chatStatusChangeMutation = useMutation({
291
298
  mutationFn: async (data: { chatId: string | number; event: string }) => {
@@ -458,8 +465,8 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
458
465
  </Button>
459
466
  );
460
467
 
461
- const endedChatsColumns = useMemo(
462
- () => [
468
+ const endedChatsColumns = useMemo(() => {
469
+ const columns = [
463
470
  columnHelper.accessor('created', {
464
471
  id: 'created',
465
472
  header: t('chat.history.startTime') ?? '',
@@ -481,9 +488,22 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
481
488
  ),
482
489
  }),
483
490
  columnHelper.accessor(
484
- (row) => {
485
- const customerSupportIdCheck = row.customerSupportId ? `${row.customerSupportFirstName ?? ""} ${row.customerSupportLastName ?? ""}`: "-";
486
- return `${ row.customerSupportId === "chatbot" ? row.customerSupportDisplayName : customerSupportIdCheck }`;
491
+ (row) => {
492
+ if (Array.isArray(row.allCsa) && !(row.allCsa.length === 1 && (row.allCsa[0] == null || row.allCsa[0].toString().trim() === ''))) {
493
+ const cleanedNames = row.allCsa
494
+ .filter(name => !!name && typeof name === 'string')
495
+ .map(name => name.trim())
496
+ .filter(name => name !== "")
497
+ .filter((name, index, self) => self.indexOf(name) === index);
498
+
499
+ const filteredNames = cleanedNames.length > 1
500
+ ? cleanedNames.filter(name => name !== "Bürokratt")
501
+ : cleanedNames;
502
+
503
+ return filteredNames.join(", ");
504
+ } else {
505
+ return '-';
506
+ }
487
507
  },
488
508
  {
489
509
  id: `customerSupportFullName`,
@@ -514,8 +534,10 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
514
534
  columnHelper.accessor('feedbackRating', {
515
535
  id: 'feedbackRating',
516
536
  header: t('chat.history.rating') ?? '',
517
- cell: (props) =>
518
- props.getValue() && <span>{`${props.getValue()}/10`}</span>,
537
+ cell: (props) => {
538
+ const value = props.getValue();
539
+ return value !== null && value !== undefined ? <span>{`${value}/10`}</span> : null;
540
+ }
519
541
  }),
520
542
  columnHelper.accessor('feedbackText', {
521
543
  id: 'feedbackText',
@@ -561,9 +583,62 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
561
583
  sticky: 'right',
562
584
  },
563
585
  }),
564
- ],
565
- []
566
- );
586
+ ];
587
+
588
+ if (showEmail) {
589
+ columns.splice(4, 0, columnHelper.accessor('endUserEmail', {
590
+ id: 'endUserEmail',
591
+ header: t('global.email') ?? '',
592
+ }));
593
+ }
594
+
595
+ return columns;
596
+ }, [t, showEmail])
597
+
598
+ const getSortingString = () => {
599
+ if(sorting && sorting.length > 0) {
600
+ const sortingObject = sorting[0];
601
+ const sortingString = t('sorting.sorting');
602
+ const orderingString = t(`sorting.${sortingObject.desc ? 'desc' : 'asc'}`);
603
+ const column = getColumnTranslation(sortingObject.id);
604
+ return sortingString + ' ' + column + ' ' + orderingString;
605
+ } else {
606
+ return '';
607
+ }
608
+ }
609
+
610
+ const getColumnTranslation = (column: string) : string => {
611
+ switch (column) {
612
+ case 'endUserId':
613
+ return t('global.idCode') ?? ''
614
+ case 'created':
615
+ return t('chat.history.startTime') ?? ''
616
+ case 'ended':
617
+ return t('chat.history.endTime') ?? ''
618
+ case 'customerSupportFullName':
619
+ return t('chat.history.csaName') ?? ''
620
+ case 'endUserName':
621
+ return t('global.name') ?? ''
622
+ case 'endUserEmail':
623
+ return t('global.email') ?? ''
624
+ case 'contactsMessage':
625
+ return t('chat.history.contact') ?? ''
626
+ case 'comment':
627
+ return t('chat.history.comment') ?? ''
628
+ case 'feedbackRating':
629
+ return t('chat.history.rating') ?? ''
630
+ case 'feedbackText':
631
+ return t('chat.history.feedback') ?? ''
632
+ case 'status':
633
+ return t('global.status') ?? ''
634
+ case 'endUserUrl':
635
+ return 'www'
636
+ case 'id':
637
+ return 'id';
638
+ default:
639
+ return '';
640
+ }
641
+ }
567
642
 
568
643
  const handleChatStatusChange = (event: string) => {
569
644
  if (!selectedChat) return;
@@ -744,6 +819,13 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({user, toastContext, o
744
819
  </Track>
745
820
  </Card>
746
821
 
822
+ {sorting && sorting.length > 0 && showSortingLabel && (
823
+ <div>
824
+ <Button disabled={true} appearance="secondary">
825
+ {getSortingString()}
826
+ </Button>
827
+ </div>)
828
+ }
747
829
  <div className="card-drawer-container" style={{ height: 'auto', overflow: 'auto' }}>
748
830
  <div className="card-wrapper">
749
831
  <Card>
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "global": {
3
+ "email": "Email",
3
4
  "save": "Save",
4
5
  "add": "Add",
5
6
  "edit": "Edit",
@@ -46,6 +47,11 @@
46
47
  "chosen": "Chosen",
47
48
  "read": "Read"
48
49
  },
50
+ "sorting": {
51
+ "des": "descending",
52
+ "asc": "ascending",
53
+ "sorting": "Sorting"
54
+ },
49
55
  "mainMenu": {
50
56
  "menuLabel": "Main navigation",
51
57
  "closeMenu": "Close menu",
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "global": {
3
+ "email": "Email",
3
4
  "save": "Salvesta",
4
5
  "add": "Lisa",
5
6
  "edit": "Muuda",
@@ -46,6 +47,11 @@
46
47
  "chosen": "Valitud",
47
48
  "read": "Loetud"
48
49
  },
50
+ "sorting": {
51
+ "des": "kahanevalt",
52
+ "asc": "Kasvavalt",
53
+ "sorting": "Sorteerimine"
54
+ },
49
55
  "mainMenu": {
50
56
  "menuLabel": "Põhinavigatsioon",
51
57
  "closeMenu": "Kitsenda menüü",