@buerokratt-ria/common-gui-components 0.0.51 → 0.0.52

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,10 @@ 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.52] - 05.05.2026
8
+
9
+ - Updated loading logic
10
+
7
11
  ## [0.0.51] - 05.05.2026
8
12
 
9
13
  - History page header alignment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -89,3 +89,11 @@
89
89
  .spinner {
90
90
  height: 24px;
91
91
  }
92
+
93
+ .history-content {
94
+ &--loading {
95
+ opacity: 0.5;
96
+ pointer-events: none;
97
+ user-select: none;
98
+ }
99
+ }
@@ -126,6 +126,8 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
126
126
  const showTest = envVal === undefined ? true : envVal.toLowerCase() === 'true';
127
127
  const [loading, setLoading] = useState(false);
128
128
  const abortRef = useRef<AbortController | null>(null);
129
+ const loadingTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
130
+ const timeoutAbortRef = useRef(false);
129
131
 
130
132
  const parseDateParam = (dateString: string | null) => {
131
133
  if (!dateString) return new Date();
@@ -334,8 +336,32 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
334
336
  setTotalPages(res?.data?.response[0]?.totalPages ?? 1);
335
337
  setTotalCount(res?.data?.response[0]?.totalCount ?? null);
336
338
  },
339
+ onError: (error: AxiosError) => {
340
+ if (error.code === 'ERR_CANCELED' && !timeoutAbortRef.current) return;
341
+ timeoutAbortRef.current = false;
342
+ toast?.open({
343
+ type: 'error',
344
+ title: t('global.notificationError'),
345
+ message: 'Veateade',
346
+ });
347
+ },
337
348
  });
338
349
 
350
+ useEffect(() => {
351
+ if (getAllEndedChats.isPending) {
352
+ loadingTimeoutRef.current = setTimeout(() => {
353
+ timeoutAbortRef.current = true;
354
+ abortRef.current?.abort();
355
+ }, 10000);
356
+ } else if (loadingTimeoutRef.current) {
357
+ clearTimeout(loadingTimeoutRef.current);
358
+ loadingTimeoutRef.current = null;
359
+ }
360
+ return () => {
361
+ if (loadingTimeoutRef.current) clearTimeout(loadingTimeoutRef.current);
362
+ };
363
+ }, [getAllEndedChats.isPending]);
364
+
339
365
  const getChatById = useMutation({
340
366
  mutationFn: () =>
341
367
  apiDev.post('chats/get', {
@@ -1059,6 +1085,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
1059
1085
  )}
1060
1086
  </div>
1061
1087
 
1088
+ <div className={`history-content${getAllEndedChats.isPending ? ' history-content--loading' : ''}`}>
1062
1089
  <Card>
1063
1090
  <Track gap={16}>
1064
1091
  {displaySearchBar && (
@@ -1433,6 +1460,7 @@ const ChatHistory: FC<PropsWithChildren<HistoryProps>> = ({
1433
1460
  </>
1434
1461
  )}
1435
1462
  </div>
1463
+ </div>
1436
1464
 
1437
1465
  {statusChangeModal && (
1438
1466
  <Dialog