@buerokratt-ria/common-gui-components 0.0.46 → 0.0.48

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,6 +4,14 @@ 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.48] - 23.04.2026
8
+
9
+ - Added chats preserve feature
10
+
11
+ ## [0.0.47] - 21.04.2026
12
+
13
+ - Added total chat counter under chat history
14
+
7
15
  ## [0.0.46] - 10.04.2026
8
16
 
9
17
  - Fixed CHAT_STATUS import
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -106,6 +106,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
106
106
  right: ['detail'],
107
107
  };
108
108
  const [totalPages, setTotalPages] = useState<number>(1);
109
+ const [totalCount, setTotalCount] = useState<number | null>(null);
109
110
  const [initialLoad, setInitialLoad] = useState<boolean>(true);
110
111
  const [filteredEndedChatsList, setFilteredEndedChatsList] = useState<
111
112
  ChatType[]
@@ -331,6 +332,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
331
332
  });
332
333
  filterChatsList(res.data.response ?? []);
333
334
  setTotalPages(res?.data?.response[0]?.totalPages ?? 1);
335
+ setTotalCount(res?.data?.response[0]?.totalCount ?? null);
334
336
  },
335
337
  });
336
338
 
@@ -389,6 +391,8 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
389
391
  columns.splice(5, 0, {label: t('global.test'), value: 'istest'});
390
392
  }
391
393
 
394
+ columns.splice(5, 0, {label: t('global.preserve'), value: 'isPreserve'});
395
+
392
396
  return columns;
393
397
  }, [t, showEmail, testMessageEnabled])
394
398
 
@@ -506,6 +510,31 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
506
510
  },
507
511
  });
508
512
 
513
+ const chatPreserveChangeMutation = useMutation({
514
+ mutationFn: (data: {
515
+ chatId: string | number;
516
+ isPreserve: boolean;
517
+ }) => apiDev.post('chats/mark-preserve', data),
518
+ onSuccess: (res, {chatId, isPreserve}) => {
519
+ const updatedChatList = filteredEndedChatsList.map((chat) =>
520
+ chat.id === chatId ? {...chat, isPreserve: isPreserve} : chat
521
+ );
522
+ filterChatsList(updatedChatList);
523
+ toast?.open({
524
+ type: 'success',
525
+ title: t('global.notification'),
526
+ message: t('toast.success.updateSuccess'),
527
+ });
528
+ },
529
+ onError: (error: AxiosError) => {
530
+ toast?.open({
531
+ type: 'error',
532
+ title: t('global.notificationError'),
533
+ message: error.message,
534
+ });
535
+ },
536
+ });
537
+
509
538
  const columnHelper = createColumnHelper<ChatType>();
510
539
 
511
540
  const copyValueToClipboard = async (value: string) => {
@@ -588,6 +617,19 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
588
617
  }
589
618
  };
590
619
 
620
+ const updateChatPreserve = function (chatId: string, isPreserve: boolean) {
621
+ setFilteredEndedChatsList((prevChats) =>
622
+ prevChats.map((chat) => (chat.id === chatId ? ({ ...chat, isPreserve: isPreserve } as ChatType) : chat))
623
+ );
624
+
625
+ if (selectedChat?.id === chatId) {
626
+ setSelectedChat({
627
+ ...selectedChat,
628
+ isPreserve: isPreserve,
629
+ } as ChatType);
630
+ }
631
+ };
632
+
591
633
  const markConversationAsTest = (props: any) => {
592
634
  const chatId = props.row.original.id;
593
635
  const newIsTestValue = props.getValue();
@@ -611,6 +653,29 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
611
653
  );
612
654
  };
613
655
 
656
+ const markConversationAsPreserve = (props: any) => {
657
+ const chatId = props.row.original.id;
658
+ const newIsPreserveValue = props.getValue();
659
+ return (
660
+ <FormCheckbox
661
+ checked={newIsPreserveValue}
662
+ label={""}
663
+ hideLabel
664
+ emptyItem={true}
665
+ name="active"
666
+ item={{
667
+ label: "",
668
+ value: "active",
669
+ }}
670
+ onChange={(e) => {
671
+ const isPreserve = e.target.checked;
672
+ updateChatPreserve(chatId, isPreserve);
673
+ chatPreserveChangeMutation.mutate({ chatId, isPreserve });
674
+ }}
675
+ />
676
+ );
677
+ };
678
+
614
679
  const detailsView = (props: any) => (
615
680
  <Button
616
681
  appearance="text"
@@ -763,6 +828,12 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
763
828
  }));
764
829
  }
765
830
 
831
+ columns.splice(4, 0, columnHelper.accessor('isPreserve', {
832
+ id: 'isPreserve',
833
+ header: t('global.preserve') ?? '',
834
+ cell: markConversationAsPreserve
835
+ }));
836
+
766
837
  return columns;
767
838
  }, [t, showEmail, testMessageEnabled])
768
839
 
@@ -808,6 +879,8 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
808
879
  return 'id';
809
880
  case 'istest':
810
881
  return t('global.test') ?? ''
882
+ case 'isPreserve':
883
+ return t('global.preserve') ?? ''
811
884
  default:
812
885
  return '';
813
886
  }
@@ -972,7 +1045,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
972
1045
  return (
973
1046
  <>
974
1047
  {displayTitle && (
975
- <h1>{t('chat.history.title')}</h1>
1048
+ <h1>{t('chat.history.title')}{totalCount === null ? '' : ` (${totalCount.toLocaleString('et-EE')})`}</h1>
976
1049
  )}
977
1050
 
978
1051
  {showDownload && (
@@ -1191,6 +1264,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
1191
1264
  }}
1192
1265
  isClientSide={false}
1193
1266
  pagesCount={totalPages}
1267
+ totalCountLabel={totalCount === null ? null : `${t('chat.history.title')} ${totalCount.toLocaleString('et-EE')}`}
1194
1268
  />
1195
1269
  </Card>
1196
1270
  </div>
package/types/chat.ts CHANGED
@@ -88,9 +88,11 @@ export interface Chat {
88
88
  nps?: number;
89
89
  userDisplayName?: string;
90
90
  istest?: boolean;
91
+ isPreserve?: boolean;
91
92
  isFiveRatingScale?: string;
92
93
  allCsa?: string[];
93
94
  totalPages?: number;
95
+ totalCount?: number;
94
96
  }
95
97
  export interface GroupedChat {
96
98
  myChats: Chat[];
@@ -55,6 +55,7 @@ type DataTableProps = {
55
55
  pagesCount?: number;
56
56
  meta?: TableMeta<any>;
57
57
  selectedRow?: (row: Row<any>) => boolean;
58
+ totalCountLabel?: string | null;
58
59
  };
59
60
 
60
61
  type ColumnMeta = {
@@ -115,6 +116,7 @@ const DataTable: FC<DataTableProps> = ({
115
116
  pagesCount,
116
117
  meta,
117
118
  selectedRow,
119
+ totalCountLabel,
118
120
  }) => {
119
121
  const id = useId();
120
122
  const { t } = useTranslation();
@@ -408,6 +410,7 @@ const DataTable: FC<DataTableProps> = ({
408
410
  </div>
409
411
  )}
410
412
  <div className="data-table__page-size">
413
+ {totalCountLabel && <><span>{totalCountLabel}</span><span>|</span></>}
411
414
  <label htmlFor={id}>{t('global.resultCount')}</label>
412
415
  <select
413
416
  id={id}
@@ -416,7 +419,7 @@ const DataTable: FC<DataTableProps> = ({
416
419
  table.setPageSize(Number(e.target.value));
417
420
  }}
418
421
  >
419
- {[10, 20, 30, 40, 50].map((pageSize) => (
422
+ {[10, 20, 30, 40, 50, 100, 150, 200].map((pageSize) => (
420
423
  <option key={pageSize} value={pageSize}>
421
424
  {pageSize}
422
425
  </option>