@stack-spot/portal-components 2.10.4 → 2.11.0

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
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.11.0](https://github.com/stack-spot/portal-commons/compare/portal-components@v2.10.4...portal-components@v2.11.0) (2024-12-27)
4
+
5
+
6
+ ### Features
7
+
8
+ * update libs banner ([#604](https://github.com/stack-spot/portal-commons/issues/604)) ([f2bc440](https://github.com/stack-spot/portal-commons/commit/f2bc440db6c65461a2b1228d0efc08ed3d883d67))
9
+
3
10
  ## [2.10.4](https://github.com/stack-spot/portal-commons/compare/portal-components@v2.10.3...portal-components@v2.10.4) (2024-12-12)
4
11
 
5
12
 
@@ -1,10 +1,10 @@
1
1
  /**
2
- * A styled and non-dismissible alert box for showing important warnings for the user.
2
+ * A styled and dismissible alert box for showing important warnings for the user.
3
3
  *
4
4
  * This renders a yellow box with an exclamation icon. The content passed as parameter is placed on the right of the icon.
5
5
  * @param props an object containing the content (children) to show inside the alert box.
6
6
  */
7
7
  export declare const BannerWarning: ({ children }: {
8
8
  children: React.ReactNode;
9
- }) => import("react/jsx-runtime").JSX.Element;
9
+ }) => import("react/jsx-runtime").JSX.Element | null;
10
10
  //# sourceMappingURL=BannerWarning.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BannerWarning.d.ts","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,iBAAkB;IAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;CAAE,4CAgBxE,CAAA"}
1
+ {"version":3,"file":"BannerWarning.d.ts","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,iBAAkB;IAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;CAAE,mDA4FxE,CAAA"}
@@ -1,12 +1,59 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Flex, IconBox, Text } from '@citric/core';
3
- import { ExclamationTriangle } from '@citric/icons';
2
+ /* eslint-disable comma-dangle */
3
+ import { Button, Flex, IconBox, Text } from '@citric/core';
4
+ import { ExclamationTriangle, TimesCircleFill } from '@citric/icons';
4
5
  import { Alert } from '@citric/ui';
6
+ import { useState } from 'react';
5
7
  /**
6
- * A styled and non-dismissible alert box for showing important warnings for the user.
8
+ * A styled and dismissible alert box for showing important warnings for the user.
7
9
  *
8
10
  * This renders a yellow box with an exclamation icon. The content passed as parameter is placed on the right of the icon.
9
11
  * @param props an object containing the content (children) to show inside the alert box.
10
12
  */
11
- export const BannerWarning = ({ children }) => (_jsx(Flex, { sx: { position: 'fixed', top: 0, zIndex: '999', w: 12, left: 0 }, children: _jsxs(Alert, { colorScheme: "warning", sx: { p: 2, w: 12, justifyContent: 'center', height: ['60px', '100px'] }, children: [_jsx(IconBox, { size: "md", colorIcon: "light.500", sx: { display: ['block', 'none'] }, children: _jsx(ExclamationTriangle, {}) }), _jsx(Flex, { sx: { py: [5, 3] }, children: _jsx(Text, { sx: { fontSize: ['16px', '14px'], whiteSpace: 'pre-line' }, colorScheme: "warning.contrastText", children: children }) }), _jsx(IconBox, { size: "md", colorIcon: "light.500", sx: { display: ['block', 'none'] }, children: _jsx(ExclamationTriangle, {}) })] }) }));
13
+ export const BannerWarning = ({ children }) => {
14
+ const bannerKey = 'bannerClosed';
15
+ const getCookie = (key) => document.cookie
16
+ .split('; ')
17
+ .find((row) => row.startsWith(`${key}=`))
18
+ ?.split('=')[1];
19
+ const setCookie = (key, value, domain = '.stackspot.com') => {
20
+ document.cookie = `${key}=${value};path=/${location.host.endsWith(domain) ? `;domain=${domain}` : ''}`;
21
+ };
22
+ const [isVisible, setIsVisible] = useState(() => {
23
+ if (typeof window !== 'undefined') {
24
+ const isBannerValid = getCookie(bannerKey) !== 'expired';
25
+ const isBannerClosed = getCookie(bannerKey) === 'true';
26
+ return isBannerValid && !isBannerClosed;
27
+ }
28
+ return false;
29
+ });
30
+ const handleClose = () => {
31
+ setCookie(bannerKey, 'true');
32
+ setIsVisible(false);
33
+ };
34
+ if (!isVisible) {
35
+ return null;
36
+ }
37
+ return (_jsx(Flex, { id: "banner-warning", sx: { zIndex: '1', w: 12, mb: 7 }, children: _jsxs(Alert, { colorScheme: "warning", sx: {
38
+ height: '48px',
39
+ position: 'relative',
40
+ px: 3,
41
+ py: 1
42
+ }, children: [_jsxs(Flex, { sx: { display: 'flex', alignItems: 'center', flex: 1 }, children: [_jsx(IconBox, { size: "sm", colorIcon: "light.500", sx: {
43
+ display: ['flex', 'flex'],
44
+ mr: 2,
45
+ mb: 2
46
+ }, children: _jsx(ExclamationTriangle, {}) }), _jsx(Text, { sx: {
47
+ whiteSpace: 'pre-wrap'
48
+ }, appearance: "body2", colorScheme: "warning.contrastText", children: children })] }), _jsx(Button, { appearance: 'text', onClick: handleClose, sx: {
49
+ border: 'none',
50
+ outline: 'none',
51
+ ':hover': {
52
+ boxShadow: 'none'
53
+ },
54
+ ml: 2
55
+ }, children: _jsx(IconBox, { size: "lg", colorIcon: "light.500", sx: {
56
+ display: ['flex', 'flex']
57
+ }, children: _jsx(TimesCircleFill, {}) }) })] }) }));
58
+ };
12
59
  //# sourceMappingURL=BannerWarning.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BannerWarning.js","sourceRoot":"","sources":["../../src/components/BannerWarning.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CAC5E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eAAe,KAAG,GACX,GACH,IACH,GACH,CACR,CAAA;AACH,CAAC,CAAA"}
@@ -19,6 +19,7 @@ export type GetTenantNotificationsResponse = {
19
19
  last_until?: string;
20
20
  trigger_at: string;
21
21
  created_at?: string;
22
+ isBanner?: boolean;
22
23
  };
23
24
  export type ResponseModelGetTenantNotificationsResponse = {
24
25
  items: GetTenantNotificationsResponse[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/notification/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;AAExD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAA;AAI3E,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAAC;KAC5C,CAAC;IACF,eAAe,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;IACpE,OAAO,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,MAAM,MAAM,2CAA2C,GAAG;IACxD,KAAK,EAAE,8BAA8B,EAAE,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,GAAG,UAAU,CAAA;AAEnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;CACpB;AAID,oBAAY,UAAU;IACpB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;CAChD"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/notification/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;AAExD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAA;AAI3E,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAAC;KAC5C,CAAC;IACF,eAAe,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;IACpE,OAAO,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAA;AAED,MAAM,MAAM,2CAA2C,GAAG;IACxD,KAAK,EAAE,8BAA8B,EAAE,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,gBAAgB,GAAG,UAAU,CAAA;AAEnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;CACpB;AAID,oBAAY,UAAU;IACpB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;CAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/notification/types.ts"],"names":[],"mappings":"AAiDA,iIAAiI;AACjI,gDAAgD;AAChD,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IACpB,+BAAiB,CAAA;AACnB,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/notification/types.ts"],"names":[],"mappings":"AAkDA,iIAAiI;AACjI,gDAAgD;AAChD,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IACpB,+BAAiB,CAAA;AACnB,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB"}
@@ -7,9 +7,11 @@ export interface LoadNotificationsFilters {
7
7
  search?: string;
8
8
  context?: NotificationContext;
9
9
  size?: number;
10
+ isBanner?: boolean;
10
11
  }
11
12
  export interface LoadNotificationsOptions extends LoadNotificationsFilters {
12
13
  page: number;
14
+ isBanner?: boolean;
13
15
  }
14
16
  export type LazyNotificationListener = (notifications: GetTenantNotificationsResponse[], hasMore: boolean) => void;
15
17
  export interface NotificationConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/context/notification/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,2CAA2C,EAAE,MAAM,qBAAqB,CAAA;AAEjH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;AAE5D,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEpE,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,oBAAoB,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAyB,SAAQ,wBAAwB;IACxE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM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AAQ,wBAAwB;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,8BAA8B,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;AAElH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,2CAA2C,CAAC,CAAC;IAC9F;;;;OAIG;IACH,gCAAgC,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChE;;;OAGG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,MAAM,0BAA0B,GAAG,CAAC,qBAAqB,EAAE,OAAO,KAAK,IAAI,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stack-spot/portal-components",
3
- "version": "2.10.4",
3
+ "version": "2.11.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,27 +1,105 @@
1
- import { Flex, IconBox, Text } from '@citric/core'
2
- import { ExclamationTriangle } from '@citric/icons'
1
+ /* eslint-disable comma-dangle */
2
+ import { Button, Flex, IconBox, Text } from '@citric/core'
3
+ import { ExclamationTriangle, TimesCircleFill } from '@citric/icons'
3
4
  import { Alert } from '@citric/ui'
5
+ import { useState } from 'react'
4
6
 
5
7
  /**
6
- * A styled and non-dismissible alert box for showing important warnings for the user.
7
- *
8
- * This renders a yellow box with an exclamation icon. The content passed as parameter is placed on the right of the icon.
8
+ * A styled and dismissible alert box for showing important warnings for the user.
9
+ *
10
+ * This renders a yellow box with an exclamation icon. The content passed as parameter is placed on the right of the icon.
9
11
  * @param props an object containing the content (children) to show inside the alert box.
10
12
  */
11
- export const BannerWarning = ({ children }: { children: React.ReactNode }) => (
12
- <Flex sx={{ position: 'fixed', top: 0, zIndex: '999', w: 12, left: 0 }}>
13
- <Alert colorScheme="warning" sx={{ p: 2, w: 12, justifyContent: 'center', height: ['60px', '100px'] }}>
14
- <IconBox size="md" colorIcon="light.500" sx={{ display: ['block', 'none'] }}>
15
- <ExclamationTriangle />
16
- </IconBox>
17
- <Flex sx={{ py: [5, 3] }}>
18
- <Text sx={{ fontSize: ['16px', '14px'], whiteSpace: 'pre-line' }} colorScheme="warning.contrastText">
19
- {children}
20
- </Text>
21
- </Flex>
22
- <IconBox size="md" colorIcon="light.500" sx={{ display: ['block', 'none'] }}>
23
- <ExclamationTriangle />
24
- </IconBox>
25
- </Alert>
26
- </Flex>
27
- )
13
+ export const BannerWarning = ({ children }: { children: React.ReactNode }) => {
14
+ const bannerKey = 'bannerClosed'
15
+
16
+ const getCookie = (key: string): string | undefined =>
17
+ document.cookie
18
+ .split('; ')
19
+ .find((row) => row.startsWith(`${key}=`))
20
+ ?.split('=')[1]
21
+
22
+ const setCookie = (key: string, value: string, domain = '.stackspot.com') => {
23
+ document.cookie = `${key}=${value};path=/${
24
+ location.host.endsWith(domain) ? `;domain=${domain}` : ''
25
+ }`
26
+ }
27
+
28
+ const [isVisible, setIsVisible] = useState(() => {
29
+ if (typeof window !== 'undefined') {
30
+ const isBannerValid = getCookie(bannerKey) !== 'expired'
31
+ const isBannerClosed = getCookie(bannerKey) === 'true'
32
+ return isBannerValid && !isBannerClosed
33
+ }
34
+ return false
35
+ })
36
+
37
+ const handleClose = () => {
38
+ setCookie(bannerKey, 'true')
39
+ setIsVisible(false)
40
+ }
41
+
42
+ if (!isVisible) {
43
+ return null
44
+ }
45
+
46
+ return (
47
+ <Flex id="banner-warning" sx={{ zIndex: '1', w: 12, mb: 7 }}>
48
+ <Alert
49
+ colorScheme="warning"
50
+ sx={{
51
+ height: '48px',
52
+ position: 'relative',
53
+ px: 3,
54
+ py: 1
55
+ }}
56
+ >
57
+ <Flex sx={{ display: 'flex', alignItems: 'center', flex: 1 }}>
58
+ <IconBox
59
+ size="sm"
60
+ colorIcon="light.500"
61
+ sx={{
62
+ display: ['flex', 'flex'],
63
+ mr: 2,
64
+ mb: 2
65
+ }}
66
+ >
67
+ <ExclamationTriangle />
68
+ </IconBox>
69
+
70
+ <Text
71
+ sx={{
72
+ whiteSpace: 'pre-wrap'
73
+ }}
74
+ appearance="body2"
75
+ colorScheme="warning.contrastText"
76
+ >
77
+ {children}
78
+ </Text>
79
+ </Flex>
80
+ <Button
81
+ appearance={'text'}
82
+ onClick={handleClose}
83
+ sx={{
84
+ border: 'none',
85
+ outline: 'none',
86
+ ':hover': {
87
+ boxShadow: 'none'
88
+ },
89
+ ml: 2
90
+ }}
91
+ >
92
+ <IconBox
93
+ size="lg"
94
+ colorIcon="light.500"
95
+ sx={{
96
+ display: ['flex', 'flex']
97
+ }}
98
+ >
99
+ <TimesCircleFill />
100
+ </IconBox>
101
+ </Button>
102
+ </Alert>
103
+ </Flex>
104
+ )
105
+ }
@@ -24,6 +24,7 @@ export type GetTenantNotificationsResponse = {
24
24
  last_until?: string,
25
25
  trigger_at: string,
26
26
  created_at?: string,
27
+ isBanner?: boolean,
27
28
  }
28
29
 
29
30
  export type ResponseModelGetTenantNotificationsResponse = {
@@ -10,10 +10,12 @@ export interface LoadNotificationsFilters {
10
10
  search?: string,
11
11
  context?: NotificationContext,
12
12
  size?: number,
13
+ isBanner?: boolean,
13
14
  }
14
15
 
15
16
  export interface LoadNotificationsOptions extends LoadNotificationsFilters {
16
17
  page: number,
18
+ isBanner?: boolean,
17
19
  }
18
20
 
19
21
  export type LazyNotificationListener = (notifications: GetTenantNotificationsResponse[], hasMore: boolean) => void