@buerokratt-ria/common-gui-components 0.0.18 → 0.0.20

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.20] - 21-05-2025
8
+
9
+ - Making chat view go take all vertical space.
10
+
11
+ ## [0.0.19] - 19-05-2025
12
+
13
+ - Reduced extra calling of mutation on init.
14
+
7
15
  ## [0.0.18] - 16-05-2025
8
16
 
9
17
  - Made title configurable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -1,4 +1,4 @@
1
- import React, {FC, PropsWithChildren, useEffect, useMemo, useState} from 'react';
1
+ import React, {FC, PropsWithChildren, useEffect, useRef, useMemo, 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';
@@ -68,7 +68,8 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
68
68
  const params = new URLSearchParams(routerLocation.search);
69
69
  let passedChatId = new URLSearchParams(routerLocation.search).get('chat');
70
70
  const passedStartDate = delegatedStartDate ?? params.get('start');
71
- const passedEndDate = delegatedEndDate ?? params.get('end');
71
+ const passedEndDate = delegatedStartDate ?? params.get('end');
72
+ const skipNextSelectedColumnsEffect = useRef(false);
72
73
  const passedCustomerSupportIds = params.getAll('customerSupportIds');
73
74
  const [search, setSearch] = useState('');
74
75
  const [selectedChat, setSelectedChat] = useState<ChatType | null>(null);
@@ -143,18 +144,31 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
143
144
  }, [passedChatId]);
144
145
 
145
146
  useEffect(() => {
146
- if (delegatedStartDate) {
147
- setValue('startDate', unifyDateFromat(delegatedStartDate));
148
- fetchData()
149
- }
150
- }, [delegatedStartDate]);
147
+ const hasStart = delegatedStartDate !== null && delegatedStartDate !== undefined;
148
+ const hasEnd = delegatedEndDate !== null && delegatedEndDate !== undefined;
151
149
 
152
- useEffect(() => {
153
- if (delegatedEndDate) {
154
- setValue('endDate', unifyDateFromat(delegatedEndDate));
155
- fetchData()
150
+ if (hasStart || hasEnd) {
151
+ if (hasStart) {
152
+ setValue('startDate', unifyDateFromat(delegatedStartDate));
153
+ }
154
+ if (hasEnd) {
155
+ setValue('endDate', unifyDateFromat(delegatedEndDate));
156
+ }
157
+
158
+ if(initialLoad) {
159
+ fetchData()
160
+ } else {
161
+ getAllEndedChats.mutate({
162
+ startDate: hasStart ? unifyDateFromat(delegatedStartDate) : format(new Date(startDate), 'yyyy-MM-dd'),
163
+ endDate: hasEnd ? unifyDateFromat(delegatedEndDate) : format(new Date(endDate), 'yyyy-MM-dd'),
164
+ customerSupportIds: passedCustomerSupportIds,
165
+ pagination,
166
+ sorting,
167
+ search,
168
+ });
169
+ }
156
170
  }
157
- }, [delegatedEndDate]);
171
+ }, [delegatedStartDate, delegatedEndDate]);
158
172
 
159
173
 
160
174
  const fetchData = async () => {
@@ -166,18 +180,21 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
166
180
  page_name: window.location.pathname,
167
181
  },
168
182
  });
183
+
169
184
  if (response.data) {
170
185
  const currentColumns = response.data.selectedColumns;
171
186
  const newPageResults = response.data.pageResults !== undefined ? response.data.pageResults : 10;
172
187
  const updatedPagination = updatePagePreference(newPageResults);
173
188
 
174
189
  let newSelectedColumns = [];
175
- if (currentColumns != null && currentColumns.length > 0 && currentColumns[0] !== "") {
190
+ if (currentColumns?.length > 0 && currentColumns[0] !== "") {
176
191
  newSelectedColumns = currentColumns;
177
192
  }
178
- setSelectedColumns(newSelectedColumns)
179
193
 
180
- setCounterKey(counterKey + 1)
194
+ skipNextSelectedColumnsEffect.current = true;
195
+ setSelectedColumns(newSelectedColumns);
196
+ setCounterKey(prev => prev + 1);
197
+
181
198
  getAllEndedChats.mutate({
182
199
  startDate: format(new Date(startDate), 'yyyy-MM-dd'),
183
200
  endDate: format(new Date(endDate), 'yyyy-MM-dd'),
@@ -204,6 +221,8 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
204
221
  useEffect(() => {
205
222
  if (initialLoad) {
206
223
  fetchData();
224
+ } else if (skipNextSelectedColumnsEffect.current) {
225
+ skipNextSelectedColumnsEffect.current = false;
207
226
  } else {
208
227
  getAllEndedChats.mutate({
209
228
  startDate: format(new Date(startDate), 'yyyy-MM-dd'),
@@ -867,7 +886,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
867
886
  </Button>
868
887
  </div>)
869
888
  }
870
- <div className="card-drawer-container" style={{ height: 'auto', overflow: 'auto' }}>
889
+ <div className="card-drawer-container" style={{ height: '100%', overflow: 'auto' }}>
871
890
  <div className="card-wrapper">
872
891
  <Card>
873
892
  <DataTable