@pagopa/selfcare-common-frontend 0.0.5 → 0.1.1
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/README.md +5 -3
- package/build.info +2 -2
- package/common-polyfill.d.ts +8 -0
- package/common-polyfill.js +8 -0
- package/components/CustomAvatar.d.ts +8 -1
- package/components/CustomAvatar.js +1 -0
- package/components/CustomPagination.d.ts +4 -0
- package/components/CustomPagination.js +3 -1
- package/components/ErrorBoundary/ErrorBoundary.js +6 -0
- package/components/FilterModal.d.ts +12 -1
- package/components/FilterModal.js +3 -2
- package/components/Footer/Footer.d.ts +2 -0
- package/components/Footer/Footer.js +1 -0
- package/components/Header/Header.d.ts +4 -0
- package/components/Header/Header.js +1 -0
- package/components/Loading/LoadingOverlay.d.ts +6 -1
- package/components/Loading/LoadingOverlay.js +6 -1
- package/components/SessionModal.d.ts +12 -0
- package/components/SessionModal.js +1 -0
- package/components/TitleBox.d.ts +10 -2
- package/components/TitleBox.js +3 -2
- package/components/Toast.d.ts +13 -3
- package/components/Toast.js +17 -15
- package/config/env.d.ts +1 -1
- package/config/env.js +2 -1
- package/decorators/withLogin.d.ts +4 -0
- package/decorators/withLogin.js +4 -0
- package/hooks/useErrorDispatcher.d.ts +1 -0
- package/hooks/useErrorDispatcher.js +1 -0
- package/hooks/useLoading.d.ts +1 -0
- package/hooks/useLoading.js +1 -0
- package/hooks/useLogin.js +1 -1
- package/index.d.ts +10 -0
- package/index.js +10 -0
- package/package.json +4 -1
- package/redux/slices/appStateSlice.d.ts +9 -0
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ FilterModalConfig fields:
|
|
|
53
53
|
|-------|------|-----------|-------------|
|
|
54
54
|
| data | Array<T> | Y | The list of values between to which choose |
|
|
55
55
|
| getLabel | (e: T) => string | Y | A function that will select the label to show |
|
|
56
|
-
| getValue | (e: T) =>
|
|
56
|
+
| getValue | (e: T) => string | Y | A function that will select the value to return when selecting an item |
|
|
57
57
|
| onFilterChange | (v: V) => void | Y | The function invoked when selecting a value |
|
|
58
58
|
|
|
59
59
|
## SessionModal
|
|
@@ -80,8 +80,8 @@ Selfcare's page title
|
|
|
80
80
|
|------|------|-----------|-------------|
|
|
81
81
|
| title | string | Y | The title to show |
|
|
82
82
|
| subTitle | string | N | The subtitle to show |
|
|
83
|
+
| mtTitle | number | N | The margin top of the title |
|
|
83
84
|
| mbTitle | GridSize | N | The margin bottom of the title |
|
|
84
|
-
| mtGrid | number | N | The margin top of the title |
|
|
85
85
|
| mbSubTitle | number | N | The margin bottom of the subtitle |
|
|
86
86
|
| variantTitle | Variant | N | The variant of the Typografy used for the title |
|
|
87
87
|
| variantSubTitle | Variant | N | The variant of the Typografy used for the subtitle |
|
|
@@ -91,9 +91,11 @@ Selfcare's toast
|
|
|
91
91
|
|
|
92
92
|
| Prop | Type | Mandatory | Description |
|
|
93
93
|
|------|------|-----------|-------------|
|
|
94
|
+
| open | boolean | Y | If this component should be displayed or not |
|
|
95
|
+
| logo | React.ElementType | N | The logo to be rendered. As default a confirm logo will be used |
|
|
94
96
|
| title | string | Y | The toast title |
|
|
95
97
|
| message | React.ReactNode | Y | The toast body |
|
|
96
|
-
| closeToast |
|
|
98
|
+
| closeToast | ()=>void | Y | The function to be invoked when closing the toast |
|
|
97
99
|
|
|
98
100
|
# Common decorators used in pagopa/selfcare react projects
|
|
99
101
|
## withLogin
|
package/build.info
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
tags/v0.
|
|
1
|
+
20220120.2 - selfcare-common-frontend.deploy(17331)
|
|
2
|
+
tags/v0.1.1^0 01a75c35fd9797944fbc4d330218a6a794d04cfa
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import 'react-app-polyfill/ie11';
|
|
2
|
+
import 'core-js/es/object/entries';
|
|
3
|
+
import 'core-js/es/object/values';
|
|
4
|
+
import 'core-js/es/promise';
|
|
5
|
+
import 'core-js/es/array';
|
|
6
|
+
import 'core-js/stable/string';
|
|
7
|
+
import 'core-js/stable/number';
|
|
8
|
+
import 'core-js/stable/url-search-params';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import 'react-app-polyfill/ie11';
|
|
2
|
+
import 'core-js/es/object/entries';
|
|
3
|
+
import 'core-js/es/object/values';
|
|
4
|
+
import 'core-js/es/promise';
|
|
5
|
+
import 'core-js/es/array';
|
|
6
|
+
import 'core-js/stable/string';
|
|
7
|
+
import 'core-js/stable/number';
|
|
8
|
+
import 'core-js/stable/url-search-params';
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
declare type Props = {
|
|
2
|
+
/** The id attribute added to the element */
|
|
3
|
+
id?: string;
|
|
4
|
+
/** The logo src */
|
|
2
5
|
customSrc?: string | undefined;
|
|
6
|
+
/** The alt text showed instead of the image */
|
|
3
7
|
customAlt?: string | undefined;
|
|
8
|
+
/** Logo width */
|
|
4
9
|
customWidth?: string | undefined;
|
|
10
|
+
/** Logo height */
|
|
5
11
|
customHeight?: string | undefined;
|
|
12
|
+
/** If true it will not display the component */
|
|
6
13
|
loading?: boolean;
|
|
7
|
-
id?: string;
|
|
8
14
|
};
|
|
15
|
+
/** Avatar to use to load Organization logo */
|
|
9
16
|
export default function CustomAvatar({ customAlt, customSrc, customWidth, customHeight, id, loading, }: Props): JSX.Element;
|
|
10
17
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Avatar } from '@mui/material';
|
|
4
|
+
/** Avatar to use to load Organization logo */
|
|
4
5
|
export default function CustomAvatar({ customAlt, customSrc, customWidth, customHeight, id, loading, }) {
|
|
5
6
|
return (_jsx(React.Fragment, { children: _jsx(Avatar, { id: id, alt: customAlt, src: customSrc, sx: {
|
|
6
7
|
width: customWidth,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Page } from '../model/Page';
|
|
2
2
|
import { PageRequest } from '../model/PageRequest';
|
|
3
3
|
declare type Props = {
|
|
4
|
+
/** The actual page */
|
|
4
5
|
page: Page;
|
|
6
|
+
/** The actual sort applied */
|
|
5
7
|
sort?: string;
|
|
8
|
+
/** The function to be invoked if the user change page */
|
|
6
9
|
onPageRequest: (r: PageRequest) => void;
|
|
7
10
|
};
|
|
11
|
+
/** Selfcare custom table available pages component */
|
|
8
12
|
export default function CustomPagination({ page, onPageRequest, sort }: Props): JSX.Element;
|
|
9
13
|
export {};
|
|
@@ -12,6 +12,7 @@ const getLabelDisplayedRowsTo = (count, page, size) => {
|
|
|
12
12
|
}
|
|
13
13
|
return size === -1 ? count : Math.min(count, (page + 1) * size);
|
|
14
14
|
};
|
|
15
|
+
/** Selfcare custom table available pages component */
|
|
15
16
|
export default function CustomPagination({ page, onPageRequest, sort }) {
|
|
16
17
|
const count = page.totalElements;
|
|
17
18
|
const from = count === 0 ? 0 : page.number * page.size + 1;
|
|
@@ -20,5 +21,6 @@ export default function CustomPagination({ page, onPageRequest, sort }) {
|
|
|
20
21
|
page: value - 1,
|
|
21
22
|
size: page.size,
|
|
22
23
|
sort,
|
|
23
|
-
}),
|
|
24
|
+
}),
|
|
25
|
+
window.scrollTo(0, 0)) }, void 0)) }), void 0)] }), void 0) }, void 0));
|
|
24
26
|
}
|
|
@@ -7,6 +7,12 @@ import { appStateActions, appStateSelectors } from '../../redux/slices/appStateS
|
|
|
7
7
|
import { handleErrors } from '../../services/errorService';
|
|
8
8
|
import SessionModal from '../SessionModal';
|
|
9
9
|
import BlockingErrorPage from './components/BlockingErrorPage';
|
|
10
|
+
/** This feature is based on react-redux library and require to register the reducer build in appStateSlice into the application's redux store.
|
|
11
|
+
It allows to dispatch errors in order to display a warning or the error page to the user.
|
|
12
|
+
Errors dispatched will be notified using errorService
|
|
13
|
+
|
|
14
|
+
To use this feature you have to put ErrorBOundary in your App as a child of a redux Provider component.
|
|
15
|
+
In order to dispatch an error you have to use the custom hook useErrorDispatcher which will return a fuction to be used to dispatch the error. */
|
|
10
16
|
class ErrorBoundary extends Component {
|
|
11
17
|
componentDidCatch(error, errorInfo) {
|
|
12
18
|
this.props.addError({
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
declare type Props = {
|
|
3
|
+
/** If the popup is to be displayed */
|
|
3
4
|
open: boolean;
|
|
5
|
+
/** The function to be invoked when clicking on exit button or selecting a value */
|
|
4
6
|
handleClose: React.MouseEventHandler<HTMLButtonElement>;
|
|
7
|
+
/** The popup title */
|
|
5
8
|
title: string;
|
|
9
|
+
/** @see FilterModalConfig */
|
|
6
10
|
filterModalConfig?: FilterModalConfig<any, any>;
|
|
11
|
+
/** The popup height */
|
|
7
12
|
height?: string;
|
|
13
|
+
/** The popup minHeight */
|
|
8
14
|
minHeight?: string;
|
|
9
15
|
};
|
|
10
16
|
export declare type FilterModalConfig<T, V> = {
|
|
17
|
+
/** The list of values between to which choose */
|
|
11
18
|
data: Array<T>;
|
|
19
|
+
/** A function that will select the label to show */
|
|
12
20
|
getLabel: (e: T) => string;
|
|
13
|
-
|
|
21
|
+
/** A function that will select the value to return when selecting an item */
|
|
22
|
+
getValue: (e: T) => string;
|
|
23
|
+
/** The function invoked when selecting a value */
|
|
14
24
|
onFilterChange: (v: V) => void;
|
|
15
25
|
};
|
|
26
|
+
/** Modal used to show a list of values from which to choose a single value */
|
|
16
27
|
export default function FilterModal({ open, handleClose, title, filterModalConfig, height, minHeight, }: Props): JSX.Element;
|
|
17
28
|
export {};
|
|
@@ -5,12 +5,13 @@ import Dialog from '@mui/material/Dialog';
|
|
|
5
5
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
6
6
|
import { useTheme } from '@mui/material/styles';
|
|
7
7
|
import ClearOutlinedIcon from '@mui/icons-material/ClearOutlined';
|
|
8
|
+
/** Modal used to show a list of values from which to choose a single value */
|
|
8
9
|
export default function FilterModal({ open, handleClose, title, filterModalConfig, height = '16em', minHeight = '16em', }) {
|
|
9
10
|
const theme = useTheme();
|
|
10
11
|
const fullScreen = useMediaQuery(theme.breakpoints.down('xs'));
|
|
11
12
|
const [valueRadio, setValueRadio] = React.useState('');
|
|
12
|
-
const handleChange = (
|
|
13
|
-
setValueRadio(
|
|
13
|
+
const handleChange = (_, value) => {
|
|
14
|
+
setValueRadio(value);
|
|
14
15
|
};
|
|
15
16
|
const submitFilter = (event) => {
|
|
16
17
|
const i = data.filter((value) => value.id === valueRadio).map((x) => x)[0];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Grid, Link, SvgIcon, Typography } from '@mui/material';
|
|
3
3
|
import { ReactComponent as logo } from '../../assets/logo_pago_pa.svg';
|
|
4
|
+
/** SelfCare Footer component */
|
|
4
5
|
const Footer = ({ assistanceEmail }) => (_jsxs(Box, Object.assign({ component: "footer", sx: {
|
|
5
6
|
pt: '32px',
|
|
6
7
|
height: '156px',
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare type HeaderProps = {
|
|
3
|
+
/** if true, it will render an other toolbar under the Header */
|
|
3
4
|
withSecondHeader: boolean;
|
|
5
|
+
/** The function to be invoked when pressing the rendered logout button, if not defined it will redirect to the logout page, if setted to null it will no render the logout button. It's possible to modify the logout path changing the value in CONFIG.logout inside the index.tsx file */
|
|
4
6
|
onExitAction?: (() => void) | null;
|
|
7
|
+
/** If withSecondHeader is true, this component will be rendered at the end of the secondary toolbar */
|
|
5
8
|
subHeaderChild?: React.ReactNode;
|
|
6
9
|
};
|
|
10
|
+
/** SelfCare Header component */
|
|
7
11
|
declare const Header: ({ withSecondHeader, onExitAction, subHeaderChild, }: HeaderProps) => JSX.Element;
|
|
8
12
|
export default Header;
|
|
@@ -5,6 +5,7 @@ import { Fragment } from 'react';
|
|
|
5
5
|
import { ReactComponent as logo } from '../../assets/logo_pago_pa_mini.svg';
|
|
6
6
|
import { CONFIG } from '../../config/env';
|
|
7
7
|
import SubHeader from './subHeader/SubHeader';
|
|
8
|
+
/** SelfCare Header component */
|
|
8
9
|
const Header = ({ withSecondHeader, onExitAction = () => window.location.assign(CONFIG.URL_FE.LOGOUT), subHeaderChild, }) => (_jsxs(Fragment, { children: [_jsx(AppBar, Object.assign({ position: "relative", sx: {
|
|
9
10
|
alignItems: 'center',
|
|
10
11
|
height: '48px',
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/** This feature is based on react-redux library and require to register the reducer build in appStateSlice into the application's redux store.
|
|
2
|
+
It allows to draw a loader when an async task to wait is running.
|
|
3
|
+
|
|
4
|
+
To use this feature you have to put LoadingOverlay in your App as a child of a redux Provider component.
|
|
5
|
+
In order to register the start of an async task you have to use the custom hook useLoading passing the id of the task to await, which will return a setter function used to start and end the loading behavior. */
|
|
6
|
+
export default function LoadingOverlay(): JSX.Element;
|
|
@@ -4,7 +4,12 @@ import { Box } from '@mui/system';
|
|
|
4
4
|
import MDSpinner from 'react-md-spinner';
|
|
5
5
|
import { useSelector } from 'react-redux';
|
|
6
6
|
import { appStateSelectors } from '../../redux/slices/appStateSlice';
|
|
7
|
-
|
|
7
|
+
/** This feature is based on react-redux library and require to register the reducer build in appStateSlice into the application's redux store.
|
|
8
|
+
It allows to draw a loader when an async task to wait is running.
|
|
9
|
+
|
|
10
|
+
To use this feature you have to put LoadingOverlay in your App as a child of a redux Provider component.
|
|
11
|
+
In order to register the start of an async task you have to use the custom hook useLoading passing the id of the task to await, which will return a setter function used to start and end the loading behavior. */
|
|
12
|
+
export default function LoadingOverlay() {
|
|
8
13
|
const theme = useTheme();
|
|
9
14
|
const loading = useSelector(appStateSelectors.selectLoading);
|
|
10
15
|
return (_jsx(Modal, Object.assign({ open: loading, sx: { outline: 0 } }, { children: _jsx(Box, Object.assign({ sx: {
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
declare type Props = {
|
|
3
|
+
/** If this component should be displayed or not */
|
|
3
4
|
open: boolean;
|
|
5
|
+
/** The title to show in the popup */
|
|
4
6
|
title: string;
|
|
7
|
+
/** The body to show in the popup */
|
|
5
8
|
message: React.ReactNode;
|
|
9
|
+
/** If defined, it will render a confirm button using this function as behavior */
|
|
6
10
|
onConfirm?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
11
|
+
/** The confirm label text */
|
|
7
12
|
onConfirmLabel?: string;
|
|
13
|
+
/** The function invoked when clicking on close button or in the showed X icon */
|
|
8
14
|
handleClose: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
15
|
+
/** If defined, it allow to set a different behavior when clicking on X icon */
|
|
9
16
|
handleExit?: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
|
17
|
+
/** Close button text */
|
|
10
18
|
onCloseLabel?: string;
|
|
19
|
+
/** The popup height */
|
|
11
20
|
height?: string;
|
|
21
|
+
/** The popup minHeight */
|
|
12
22
|
minHeight?: string;
|
|
23
|
+
/** The popup width */
|
|
13
24
|
width?: string;
|
|
14
25
|
};
|
|
26
|
+
/** Selfcare's popup */
|
|
15
27
|
export default function SessionModal({ open, title, message, onConfirm, onConfirmLabel, handleClose, handleExit, onCloseLabel, height, minHeight, width, }: Props): JSX.Element;
|
|
16
28
|
export {};
|
|
@@ -4,6 +4,7 @@ import Dialog from '@mui/material/Dialog';
|
|
|
4
4
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
5
5
|
import { useTheme } from '@mui/material/styles';
|
|
6
6
|
import ClearOutlinedIcon from '@mui/icons-material/ClearOutlined';
|
|
7
|
+
/** Selfcare's popup */
|
|
7
8
|
export default function SessionModal({ open, title, message, onConfirm, onConfirmLabel = 'Riprova', handleClose, handleExit = handleClose, onCloseLabel = 'Annulla', height = '16em', minHeight = '16em', width = '21.9em', }) {
|
|
8
9
|
const theme = useTheme();
|
|
9
10
|
const fullScreen = useMediaQuery(theme.breakpoints.down('xs'));
|
package/components/TitleBox.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { GridSize } from '@mui/material';
|
|
2
2
|
import { Variant } from '@mui/material/styles/createTypography';
|
|
3
3
|
declare type Props = {
|
|
4
|
+
/** The title to show */
|
|
4
5
|
title: string;
|
|
6
|
+
/** The subtitle to show */
|
|
5
7
|
subTitle?: string;
|
|
8
|
+
/** The margin top of the title */
|
|
9
|
+
mtTitle?: number;
|
|
10
|
+
/** The margin bottom of the title */
|
|
6
11
|
mbTitle?: GridSize;
|
|
7
|
-
|
|
12
|
+
/** The margin bottom of the subtitle */
|
|
8
13
|
mbSubTitle?: number;
|
|
14
|
+
/** The variant of the Typografy used for the title */
|
|
9
15
|
variantTitle?: Variant;
|
|
16
|
+
/** The variant of the Typografy used for the subtitle */
|
|
10
17
|
variantSubTitle?: Variant;
|
|
11
18
|
};
|
|
12
|
-
|
|
19
|
+
/** Selfcare's page title */
|
|
20
|
+
export default function TitleBox({ title, subTitle, mbTitle, mtTitle, mbSubTitle, variantTitle, variantSubTitle, }: Props): JSX.Element;
|
|
13
21
|
export {};
|
package/components/TitleBox.js
CHANGED
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// import { Box } from '@mui/material';
|
|
4
4
|
import { Typography } from '@mui/material';
|
|
5
5
|
import { Grid } from '@mui/material';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/** Selfcare's page title */
|
|
7
|
+
export default function TitleBox({ title, subTitle, mbTitle = 2, mtTitle, mbSubTitle, variantTitle = 'h1', variantSubTitle = 'h5', }) {
|
|
8
|
+
return (_jsxs(Grid, Object.assign({ container: true, mt: mtTitle }, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, mb: mbTitle }, { children: _jsx(Typography, Object.assign({ variant: variantTitle }, { children: title }), void 0) }), void 0), _jsx(Grid, Object.assign({ item: true, xs: 12, mb: mbSubTitle }, { children: _jsx(Typography, Object.assign({ variant: variantSubTitle, sx: { fontSize: '18px' } }, { children: subTitle }), void 0) }), void 0)] }), void 0));
|
|
8
9
|
}
|
package/components/Toast.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
declare type Props = {
|
|
3
|
+
/** If this component should be displayed or not */
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** The logo to be rendered. As default a confirm logo will be used */
|
|
6
|
+
logo?: React.ElementType;
|
|
7
|
+
/** The logo to be rendered. As default a confirm logo will be used */
|
|
8
|
+
leftBorderColor?: string;
|
|
9
|
+
/** The toast title */
|
|
3
10
|
title: string;
|
|
11
|
+
/** The toast body */
|
|
4
12
|
message: React.ReactNode;
|
|
5
|
-
|
|
13
|
+
/** The function to be invoked when closing the toast */
|
|
14
|
+
onCloseToast: () => void;
|
|
6
15
|
};
|
|
7
|
-
|
|
16
|
+
/** Selfcare's toast */
|
|
17
|
+
export default function Toast({ open, title, message, onCloseToast, logo, leftBorderColor, }: Props): JSX.Element;
|
|
8
18
|
export {};
|
package/components/Toast.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { Alert, Grid, SvgIcon, Typography, IconButton } from '@mui/material';
|
|
3
4
|
import { styled } from '@mui/system';
|
|
4
5
|
import CloseIcon from '@mui/icons-material/Close';
|
|
5
|
-
import { ReactComponent as
|
|
6
|
+
import { ReactComponent as confirmLogo } from '../assets/confirmUserUpdate.svg';
|
|
6
7
|
const CustomAlert = styled(Alert)({
|
|
7
8
|
'.MuiAlert-icon': { display: 'none' },
|
|
8
9
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
/** Selfcare's toast */
|
|
11
|
+
export default function Toast({ open, title, message, onCloseToast, logo = confirmLogo, leftBorderColor = '#00CF86', }) {
|
|
12
|
+
return (_jsx(Fragment, { children: open && (_jsx(CustomAlert, Object.assign({ className: "userToast", variant: "outlined", sx: {
|
|
13
|
+
position: 'fixed',
|
|
14
|
+
bottom: '64px',
|
|
15
|
+
right: '64px',
|
|
16
|
+
zIndex: 100,
|
|
17
|
+
width: '376px',
|
|
18
|
+
backgroundColor: 'white',
|
|
19
|
+
borderLeft: `4px solid ${leftBorderColor} !important`,
|
|
20
|
+
borderRadius: '5px',
|
|
21
|
+
boxShadow: '0px 0px 45px rgba(0, 0, 0, 0.1) ',
|
|
22
|
+
border: 'none',
|
|
23
|
+
} }, { children: _jsxs(Grid, Object.assign({ container: true }, { children: [_jsx(Grid, Object.assign({ item: true, xs: 2 }, { children: _jsx(SvgIcon, { component: logo, viewBox: "0 0 80 24", sx: { width: '80px', height: '37px', marginLeft: '13px' } }, void 0) }), void 0), _jsxs(Grid, Object.assign({ item: true, xs: 8 }, { children: [_jsx(Typography, Object.assign({ pt: 1, pb: 1, sx: { fontSize: '15px', fontWeight: '600' } }, { children: title }), void 0), _jsx(Typography, { children: message }, void 0)] }), void 0), _jsx(Grid, Object.assign({ item: true, xs: 2 }, { children: _jsx(IconButton, Object.assign({ onClick: onCloseToast }, { children: _jsx(CloseIcon, {}, void 0) }), void 0) }), void 0)] }), void 0) }), void 0)) }, void 0));
|
|
22
24
|
}
|
package/config/env.d.ts
CHANGED
package/config/env.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as env from 'env-var';
|
|
1
2
|
export const CONFIG = {
|
|
2
3
|
URL_FE: {
|
|
3
4
|
LOGIN: '/auth/login',
|
|
4
5
|
LOGOUT: '/auth/logout',
|
|
5
6
|
},
|
|
6
7
|
MOCKS: {
|
|
7
|
-
MOCK_USER:
|
|
8
|
+
MOCK_USER: env.get('REACT_APP_MOCK_USER').default('false').asBool(),
|
|
8
9
|
},
|
|
9
10
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
declare type LoginProps = {};
|
|
3
|
+
/** This feature is based on react-redux library and require to register the reducer build in userSlice into the application's redux store.
|
|
4
|
+
This decorator has to be applied to components whose acces require an active session.
|
|
5
|
+
Accessing to the components decorated with it without a session will brought to the login page.
|
|
6
|
+
It's possible to modify the login path changing the value in CONFIG.login inside the index.tsx file */
|
|
3
7
|
export default function withLogin<T extends LoginProps>(WrappedComponent: React.ComponentType<T>): React.ComponentType<T>;
|
|
4
8
|
export {};
|
package/decorators/withLogin.js
CHANGED
|
@@ -5,6 +5,10 @@ import useLoading from '../hooks/useLoading';
|
|
|
5
5
|
import { useLogin } from '../hooks/useLogin';
|
|
6
6
|
import { userSelectors } from '../redux/slices/userSlice';
|
|
7
7
|
import { LOADING_TASK_LOGIN_CHECK } from '../utils/constants';
|
|
8
|
+
/** This feature is based on react-redux library and require to register the reducer build in userSlice into the application's redux store.
|
|
9
|
+
This decorator has to be applied to components whose acces require an active session.
|
|
10
|
+
Accessing to the components decorated with it without a session will brought to the login page.
|
|
11
|
+
It's possible to modify the login path changing the value in CONFIG.login inside the index.tsx file */
|
|
8
12
|
export default function withLogin(WrappedComponent) {
|
|
9
13
|
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
10
14
|
const ComponentWithLogin = (props) => {
|
package/hooks/useLoading.d.ts
CHANGED
package/hooks/useLoading.js
CHANGED
|
@@ -2,6 +2,7 @@ import { uniqueId } from 'lodash';
|
|
|
2
2
|
import { useRef } from 'react';
|
|
3
3
|
import { useDispatch } from 'react-redux';
|
|
4
4
|
import { appStateActions } from '../redux/slices/appStateSlice';
|
|
5
|
+
/** @see LoadingOverlay */
|
|
5
6
|
export default function (task) {
|
|
6
7
|
const dispatch = useDispatch();
|
|
7
8
|
const ref = useRef(uniqueId());
|
package/hooks/useLogin.js
CHANGED
|
@@ -9,7 +9,7 @@ export const useLogin = () => {
|
|
|
9
9
|
const dispatch = useDispatch();
|
|
10
10
|
const setUser = (user) => dispatch(userActions.setLoggedUser(user));
|
|
11
11
|
const attemptSilentLogin = async () => {
|
|
12
|
-
if (CONFIG.MOCKS.MOCK_USER
|
|
12
|
+
if (CONFIG.MOCKS.MOCK_USER) {
|
|
13
13
|
setUser({
|
|
14
14
|
uid: '0',
|
|
15
15
|
taxCode: 'AAAAAA00A00A000A',
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
export { default as Header } from './components/Header/Header';
|
|
1
2
|
export * from './components/Header/Header';
|
|
3
|
+
export { default as Footer } from './components/Footer/Footer';
|
|
2
4
|
export * from './components/Footer/Footer';
|
|
5
|
+
export { default as CustomAvatar } from './components/CustomAvatar';
|
|
3
6
|
export * from './components/CustomAvatar';
|
|
7
|
+
export { default as CustomPagination } from './components/CustomPagination';
|
|
4
8
|
export * from './components/CustomPagination';
|
|
9
|
+
export { default as FilterModal } from './components/FilterModal';
|
|
5
10
|
export * from './components/FilterModal';
|
|
11
|
+
export { default as SessionModal } from './components/SessionModal';
|
|
6
12
|
export * from './components/SessionModal';
|
|
13
|
+
export { default as TitleBox } from './components/TitleBox';
|
|
7
14
|
export * from './components/TitleBox';
|
|
15
|
+
export { default as Toast } from './components/Toast';
|
|
8
16
|
export * from './components/Toast';
|
|
17
|
+
export { default as ErrorBoundary } from './components/ErrorBoundary/ErrorBoundary';
|
|
9
18
|
export * from './components/ErrorBoundary/ErrorBoundary';
|
|
19
|
+
export { default as LoadingOverlay } from './components/Loading/LoadingOverlay';
|
|
10
20
|
export * from './components/Loading/LoadingOverlay';
|
package/index.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
export { default as Header } from './components/Header/Header';
|
|
1
2
|
export * from './components/Header/Header';
|
|
3
|
+
export { default as Footer } from './components/Footer/Footer';
|
|
2
4
|
export * from './components/Footer/Footer';
|
|
5
|
+
export { default as CustomAvatar } from './components/CustomAvatar';
|
|
3
6
|
export * from './components/CustomAvatar';
|
|
7
|
+
export { default as CustomPagination } from './components/CustomPagination';
|
|
4
8
|
export * from './components/CustomPagination';
|
|
9
|
+
export { default as FilterModal } from './components/FilterModal';
|
|
5
10
|
export * from './components/FilterModal';
|
|
11
|
+
export { default as SessionModal } from './components/SessionModal';
|
|
6
12
|
export * from './components/SessionModal';
|
|
13
|
+
export { default as TitleBox } from './components/TitleBox';
|
|
7
14
|
export * from './components/TitleBox';
|
|
15
|
+
export { default as Toast } from './components/Toast';
|
|
8
16
|
export * from './components/Toast';
|
|
17
|
+
export { default as ErrorBoundary } from './components/ErrorBoundary/ErrorBoundary';
|
|
9
18
|
export * from './components/ErrorBoundary/ErrorBoundary';
|
|
19
|
+
export { default as LoadingOverlay } from './components/Loading/LoadingOverlay';
|
|
10
20
|
export * from './components/Loading/LoadingOverlay';
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/selfcare-common-frontend",
|
|
3
|
-
"
|
|
3
|
+
"description": "Shared React components for the pagopa selfcare project",
|
|
4
|
+
"version": "0.1.1",
|
|
4
5
|
"license": "MIT",
|
|
6
|
+
"repository": "https://github.com/pagopa/selfcare-common-frontend",
|
|
7
|
+
"author": "https://www.pagopa.gov.it",
|
|
5
8
|
"private": false,
|
|
6
9
|
"main": "dist/index.js",
|
|
7
10
|
"types": "dist/index.d.ts",
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
2
2
|
import { ErrorInfo } from 'react';
|
|
3
3
|
export declare type AppError = {
|
|
4
|
+
/** The identifier used to recognize the error: it cannot be possible to have the same error id at the same time */
|
|
4
5
|
id: string;
|
|
6
|
+
/** The Error thrown */
|
|
5
7
|
error: Error;
|
|
6
8
|
errorInfo?: ErrorInfo;
|
|
9
|
+
/** If true, this error will show the error page, not allowing the user to do anything, otherwise it will show a closable popup */
|
|
7
10
|
blocking: boolean;
|
|
11
|
+
/** A description of the error to send when notifying the error */
|
|
8
12
|
techDescription: string;
|
|
13
|
+
/** A text to show as title of the popup when a not blocking error occurs */
|
|
9
14
|
displayableTitle?: string;
|
|
15
|
+
/** A text to show as body of the popup when a not blocking error occurs */
|
|
10
16
|
displayableDescription?: string;
|
|
17
|
+
/** If defined, in case of not blocking error, it will render a retry button which will execute this function */
|
|
11
18
|
onRetry?: () => void;
|
|
19
|
+
/** If defined, in case of not blocking error, it will be executed when closing the popup */
|
|
12
20
|
onClose?: () => void;
|
|
21
|
+
/** If true, it will notify the error */
|
|
13
22
|
toNotify: boolean;
|
|
14
23
|
};
|
|
15
24
|
interface AppStateState {
|