@centreon/ui 23.10.27 → 23.10.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "23.10.27",
3
+ "version": "23.10.29",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
2
2
 
3
3
  import 'ulog';
4
4
  import axios from 'axios';
5
- import { pathOr, defaultTo, path, includes } from 'ramda';
5
+ import { pathOr, defaultTo, path, includes, or } from 'ramda';
6
6
  import anylogger from 'anylogger';
7
7
  import { JsonDecoder } from 'ts.data.json';
8
8
 
@@ -42,12 +42,15 @@ const useRequest = <TResult>({
42
42
 
43
43
  const showRequestErrorMessage = (error): void => {
44
44
  log.error(error);
45
- const message = defaultTo(
46
- pathOr(defaultFailureMessage, ['response', 'data', 'message']),
47
- getErrorMessage
48
- )(error);
49
45
 
50
- showErrorMessage(message);
46
+ const message = or(
47
+ pathOr(undefined, ['response', 'data', 'message'], error),
48
+ pathOr(defaultFailureMessage, ['response', 'data'], error)
49
+ );
50
+
51
+ const errorMessage = defaultTo(message, getErrorMessage?.(error));
52
+
53
+ showErrorMessage(errorMessage as string);
51
54
  };
52
55
 
53
56
  const sendRequest = (params): Promise<TResult> => {
@@ -2,6 +2,7 @@ import { useRef, useCallback } from 'react';
2
2
 
3
3
  interface HookParam {
4
4
  action: () => void;
5
+ intersectionObserverOptions?: IntersectionObserverInit;
5
6
  loading: boolean;
6
7
  maxPage: number;
7
8
  page: number;
@@ -11,7 +12,8 @@ export const useIntersectionObserver = ({
11
12
  maxPage,
12
13
  page,
13
14
  loading,
14
- action
15
+ action,
16
+ intersectionObserverOptions
15
17
  }: HookParam): ((node) => void) => {
16
18
  const observer = useRef<IntersectionObserver | null>(null);
17
19
  const lastElementRef = useCallback(
@@ -30,7 +32,7 @@ export const useIntersectionObserver = ({
30
32
  if (entry.isIntersecting && page < maxPage) {
31
33
  action();
32
34
  }
33
- });
35
+ }, intersectionObserverOptions);
34
36
 
35
37
  if (node && observer.current) {
36
38
  observer.current.observe(node);