@pagopa/selfcare-common-frontend 1.4.1 → 1.5.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 +9 -0
- package/README.md +25 -5
- package/build.info +2 -2
- package/components/ErrorBoundary/ErrorBoundary.js +3 -0
- package/components/ErrorBoundary/ErrorBoundary.js.map +1 -1
- package/components/UserNotifyHandle.js +7 -4
- package/components/UserNotifyHandle.js.map +1 -1
- package/decorators/withRetrievedValue.d.ts +4 -0
- package/decorators/withRetrievedValue.js +38 -0
- package/decorators/withRetrievedValue.js.map +1 -0
- package/hooks/useFakePagination.d.ts +9 -0
- package/hooks/useFakePagination.js +66 -0
- package/hooks/useFakePagination.js.map +1 -0
- package/hooks/useReduxCachedValue.d.ts +4 -0
- package/hooks/useReduxCachedValue.js +29 -0
- package/hooks/useReduxCachedValue.js.map +1 -0
- package/model/AppError.d.ts +31 -0
- package/model/AppError.js +3 -0
- package/model/AppError.js.map +1 -0
- package/model/UserNotify.d.ts +7 -0
- package/package.json +2 -3
- package/redux/slices/appStateSlice.d.ts +2 -25
- package/redux/slices/appStateSlice.js +18 -0
- package/redux/slices/appStateSlice.js.map +1 -1
- package/utils/api-utils.d.ts +1 -1
- package/utils/constants.d.ts +1 -0
- package/utils/constants.js +12 -3
- package/utils/constants.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v1.5.0](https://github.com/pagopa/selfcare-common-frontend/compare/v1.4.1...v1.5.0)
|
|
8
|
+
|
|
9
|
+
- Toast autoclosable in UserNotifyHandle and ErrorBoundaryfeatures [`#24`](https://github.com/pagopa/selfcare-common-frontend/pull/24)
|
|
10
|
+
- Customhook cached redux [`#23`](https://github.com/pagopa/selfcare-common-frontend/pull/23)
|
|
11
|
+
- fixed readme [`#22`](https://github.com/pagopa/selfcare-common-frontend/pull/22)
|
|
12
|
+
- fake-pagination custom hook [`#21`](https://github.com/pagopa/selfcare-common-frontend/pull/21)
|
|
13
|
+
|
|
7
14
|
#### [v1.4.1](https://github.com/pagopa/selfcare-common-frontend/compare/v1.4.0...v1.4.1)
|
|
8
15
|
|
|
16
|
+
> 9 February 2022
|
|
17
|
+
|
|
9
18
|
- edit-rolelabel - added description in roleLabels [`#20`](https://github.com/pagopa/selfcare-common-frontend/pull/20)
|
|
10
19
|
|
|
11
20
|
#### [v1.4.0](https://github.com/pagopa/selfcare-common-frontend/compare/v1.3.1...v1.4.0)
|
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# SelfCare's common components & features
|
|
2
|
-
This library contains
|
|
2
|
+
This library contains [utilities](#utilities), [components](#components), [decorators](#decorators), [custom hooks](#custom-hooks) and [features](#features) built for the selfcare project.
|
|
3
3
|
|
|
4
4
|
# Configuration
|
|
5
5
|
In order to use these components it's necessary to set the following keys of the CONFIG object imported from /config/env as first things inside the application:
|
|
6
6
|
|
|
7
7
|
| Key | Type | Description | DefaultValue |
|
|
8
|
+
|-----|------|-------------|--------------|
|
|
8
9
|
| URL_FE.LOGIN | string | The url of the login page | /auth/login |
|
|
9
10
|
| URL_FE.LOGOUT | string | The url of the logout page | /auth/logout |
|
|
10
11
|
| URL_FE.ASSISTANCE | string | The url of the assistance page | /assistenza |
|
|
@@ -12,7 +13,7 @@ In order to use these components it's necessary to set the following keys of the
|
|
|
12
13
|
| ANALYTICS.* | | See [analitics feature](#analytics) | |
|
|
13
14
|
| CONSENT.* | | See [consent management feature](#consent-management) | |
|
|
14
15
|
|
|
15
|
-
#
|
|
16
|
+
# Components
|
|
16
17
|
## Header
|
|
17
18
|
SelfCare Header component
|
|
18
19
|
|
|
@@ -123,7 +124,7 @@ Selfcare's ending page
|
|
|
123
124
|
| buttonLabel | string | N | The ending page button label if any |
|
|
124
125
|
| onButtonClick | () => void | N | if defined it will show a button that will performe this action on click |
|
|
125
126
|
|
|
126
|
-
#
|
|
127
|
+
# Utilities
|
|
127
128
|
## api-utils
|
|
128
129
|
### onRedirectToLogin: (store: EnhancedStore) => void
|
|
129
130
|
To show an error popup to inform of the not valid session
|
|
@@ -169,14 +170,29 @@ It will return a string representing the provided date in the italian format gg
|
|
|
169
170
|
## fixSwagger20ArraySchemaDef.js
|
|
170
171
|
An utility script to use when generating the stub through @pagopa/openapi-codegen-ts in order to handle the REST api whose operations returns an array of objects
|
|
171
172
|
|
|
172
|
-
#
|
|
173
|
+
# Decorators
|
|
173
174
|
## withLogin
|
|
174
175
|
This feature is based on react-redux library and require to register the reducer build in userSlice into the application's redux store.
|
|
175
176
|
This decorator has to be applied to components whose acces require an active session.
|
|
176
177
|
Accessing to the components decorated with it without a session will brought to the login page.
|
|
177
178
|
It's possible to modify the login path changing the value in [CONFIG.URL_FE.LOGIN](#Configuration) inside the index.tsx file
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
## withRetrievedValue
|
|
181
|
+
Decorator to retrieve a value and serve it once ready to the decorated component.
|
|
182
|
+
It's recommended to use it together with [useReduxCachedValue](#usereduxcachedvalue)
|
|
183
|
+
See withRetrievedValue.test.tsx file for an axample.
|
|
184
|
+
|
|
185
|
+
# Custom Hooks
|
|
186
|
+
## useFakePagination
|
|
187
|
+
Custom hook used to simulate paginated resources when the external service doesn't implement it, caching values when filter doesn't change and serving them a page at time.
|
|
188
|
+
Cached values are stored using useRef, so they are local to the component using this hook.
|
|
189
|
+
The sorting actually is applied using string representation
|
|
190
|
+
|
|
191
|
+
## useReduxCachedValue
|
|
192
|
+
It will return a method that only at the very first invocation it will call the retrieverService only the first time, storing the obtained values, and returning always cached values.
|
|
193
|
+
See useReduxCachedValue.test.tsx file for an example
|
|
194
|
+
|
|
195
|
+
# Features
|
|
180
196
|
## LoadingOverlay
|
|
181
197
|
This feature is based on react-redux library and require to register the reducer build in appStateSlice into the application's redux store.
|
|
182
198
|
It allows to draw a loader when an async task to wait is running.
|
|
@@ -207,6 +223,8 @@ The error to be submitted has type AppError which has the following fields:
|
|
|
207
223
|
| onClose | () => void | N | If defined, in case of not blocking error, it will be executed when closing the popup |
|
|
208
224
|
| toNotify | boolean | Y | If true, it will notify the error |
|
|
209
225
|
| component | string | N | Can render a SessionModal or Toast component |
|
|
226
|
+
| autoclosable | string | N | If component === 'Toast'. The notify will be autoclosed using this configuration, as default timer. If none, it will not be closed automatically. If timer, it will be closed after autocloseMilliseconds milliseconds |
|
|
227
|
+
| autocloseMilliseconds | boolean | N | If component === 'Toast' and autoclosable === 'timer'. The millisecond after which close the notify. As default 2000 |
|
|
210
228
|
|
|
211
229
|
The error will be notified as a GENERIC_ERROR through the [analytcs feature](#analytics)
|
|
212
230
|
|
|
@@ -231,6 +249,8 @@ The user notify to be submitted has type UserNotify which has the following fiel
|
|
|
231
249
|
| onClose | () => void | N | If defined, it will be executed when closing the popup |
|
|
232
250
|
| closeLabel | string | N | If component === 'SessionModal'. The close button label |
|
|
233
251
|
| component | string | N | Can render a SessionModal or Toast component |
|
|
252
|
+
| autoclosable | string | N | If component === 'Toast'. The notify will be autoclosed using this configuration, as default timer. If none, it will not be closed automatically. If timer, it will be closed after autocloseMilliseconds milliseconds |
|
|
253
|
+
| autocloseMilliseconds | boolean | N | If component === 'Toast' and autoclosable === 'timer'. The millisecond after which close the notify. As default 2000 |
|
|
234
254
|
|
|
235
255
|
## UnloadEventHandler
|
|
236
256
|
This feature is based on react-redux library and require to register the reducer build in appStateSlice into the application's redux store.
|
package/build.info
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
tags/v1.
|
|
1
|
+
20220211.1 - selfcare-common-frontend.deploy(20159)
|
|
2
|
+
tags/v1.5.0^0 9cb310deb17715c689c21d21c46d8fe79593c30c
|
|
@@ -59,6 +59,9 @@ class ErrorBoundary extends react_1.Component {
|
|
|
59
59
|
}
|
|
60
60
|
buildErrorToast(error) {
|
|
61
61
|
var _a, _b;
|
|
62
|
+
if (error.autoclosable === 'timer') {
|
|
63
|
+
setTimeout(() => this.handleClose(error), error.autocloseMilliseconds);
|
|
64
|
+
}
|
|
62
65
|
return ((0, jsx_runtime_1.jsx)(Toast_1.default, { open: true, title: (_a = error.displayableTitle) !== null && _a !== void 0 ? _a : 'ERRORE', message: (_b = error.displayableDescription) !== null && _b !== void 0 ? _b : 'Spiacenti, qualcosa è andato storto.', logo: FaultIcon_1.default, leftBorderColor: "#C02927", onCloseToast: () => this.handleClose(error) }, void 0));
|
|
63
66
|
}
|
|
64
67
|
buildErrorModal(error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../src/lib/components/ErrorBoundary/ErrorBoundary.tsx"],"names":[],"mappings":";;;;AACA,mCAAkC;AAClC,iCAAgF;AAChF,6CAAsC;AACtC,uCAA0C;AAC1C,oEAAgG;AAChG,8DAA2D;AAC3D,gFAA2C;AAC3C,kEAA6B;AAC7B,gFAA2C;AAC3C,oGAA+D;AAa/D;;;;;iJAKiJ;AACjJ,MAAM,aAAc,SAAQ,iBAAiC;IAC3D,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAEM,iBAAiB,CAAC,KAAY,EAAE,SAAoB;QACzD,IAAI,CAAC,KAAK,CAAC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E,eAAe,EACf,kBAAkB,CACnB,CAAC,aAAa,CAAC,CAAC;AACjB,kBAAe,sBAAsB,CAAC"}
|
|
@@ -16,9 +16,6 @@ function UserNotifyHandle() {
|
|
|
16
16
|
const notifies = (0, react_redux_1.useSelector)(appStateSlice_1.appStateSelectors.selectNotifies);
|
|
17
17
|
const lastNotifyToast = (0, react_1.useRef)();
|
|
18
18
|
const lastNotifyModal = (0, react_1.useRef)();
|
|
19
|
-
const { openModal, openToast } = updateCurrents(lastNotifyModal, lastNotifyToast, notifies);
|
|
20
|
-
const notifyModal = lastNotifyModal.current;
|
|
21
|
-
const notifyToast = lastNotifyToast.current;
|
|
22
19
|
const onClose = (notify) => {
|
|
23
20
|
dispatch(appStateSlice_1.appStateActions.removeNotify(notify));
|
|
24
21
|
if (notify === null || notify === void 0 ? void 0 : notify.onClose) {
|
|
@@ -31,10 +28,13 @@ function UserNotifyHandle() {
|
|
|
31
28
|
notify.onConfirm();
|
|
32
29
|
}
|
|
33
30
|
};
|
|
31
|
+
const { openModal, openToast } = updateCurrents(lastNotifyModal, lastNotifyToast, notifies, onClose);
|
|
32
|
+
const notifyModal = lastNotifyModal.current;
|
|
33
|
+
const notifyToast = lastNotifyToast.current;
|
|
34
34
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(__1.Toast, { open: openToast, title: (_a = notifyToast === null || notifyToast === void 0 ? void 0 : notifyToast.title) !== null && _a !== void 0 ? _a : 'Notify Title', message: notifyToast === null || notifyToast === void 0 ? void 0 : notifyToast.message, logo: notifyToast === null || notifyToast === void 0 ? void 0 : notifyToast.logo, leftBorderColor: notifyToast === null || notifyToast === void 0 ? void 0 : notifyToast.leftBorderColor, onCloseToast: () => onClose(notifyToast) }, void 0), (0, jsx_runtime_1.jsx)(__1.SessionModal, { open: openModal, title: (_b = notifyModal === null || notifyModal === void 0 ? void 0 : notifyModal.title) !== null && _b !== void 0 ? _b : 'Notify Title', message: notifyModal === null || notifyModal === void 0 ? void 0 : notifyModal.message, onConfirm: () => onConfirm(notifyModal), onConfirmLabel: notifyModal === null || notifyModal === void 0 ? void 0 : notifyModal.confirmLabel, handleClose: () => onClose(notifyModal), onCloseLabel: notifyModal === null || notifyModal === void 0 ? void 0 : notifyModal.closeLabel }, void 0)] }, void 0));
|
|
35
35
|
}
|
|
36
36
|
exports.default = UserNotifyHandle;
|
|
37
|
-
function updateCurrents(lastNotifyModalRef, lastNotifyToastRef, notifies) {
|
|
37
|
+
function updateCurrents(lastNotifyModalRef, lastNotifyToastRef, notifies, onClose) {
|
|
38
38
|
const lastNotifyToast = notifies.find((e) => e.component === 'Toast');
|
|
39
39
|
const lastNotifySessionModal = notifies.find((e) => e.component === 'SessionModal');
|
|
40
40
|
const openToast = !!lastNotifyToast;
|
|
@@ -46,6 +46,9 @@ function updateCurrents(lastNotifyModalRef, lastNotifyToastRef, notifies) {
|
|
|
46
46
|
if (lastNotifyToast && lastNotifyToast !== (lastNotifyToastRef === null || lastNotifyToastRef === void 0 ? void 0 : lastNotifyToastRef.current)) {
|
|
47
47
|
// eslint-disable-next-line functional/immutable-data
|
|
48
48
|
lastNotifyToastRef.current = lastNotifyToast;
|
|
49
|
+
if (lastNotifyToast.autoclosable === 'timer') {
|
|
50
|
+
setTimeout(() => onClose(lastNotifyToast), lastNotifyToast.autocloseMilliseconds);
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
return {
|
|
51
54
|
openToast,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserNotifyHandle.js","sourceRoot":"","sources":["../../src/lib/components/UserNotifyHandle.tsx"],"names":[],"mappings":";;;AAAA,iCAAiD;AACjD,6CAAuD;AACvD,0BAAyC;AAEzC,iEAAmF;AAEnF;;;;wJAIwJ;AACxJ,SAAS,gBAAgB;;IACvB,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC,iCA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C,CAAC;IAEpF,MAAM,SAAS,GAAY,CAAC,CAAC,eAAe,CAAC;IAC7C,MAAM,SAAS,GAAY,CAAC,CAAC,sBAAsB,CAAC;IAEpD,IAAI,sBAAsB,IAAI,sBAAsB,MAAK,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,OAAO,CAAA,EAAE;QACpF,qDAAqD;QACrD,kBAAkB,CAAC,OAAO,GAAG,sBAAsB,CAAC;KACrD;IACD,IAAI,eAAe,IAAI,eAAe,MAAK,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,OAAO,CAAA,EAAE;QACtE,qDAAqD;QACrD,kBAAkB,CAAC,OAAO,GAAG,eAAe,CAAC;QAE7C,IAAI,eAAe,CAAC,YAAY,KAAK,OAAO,EAAE;YAC5C,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC,CAAC;SACnF;KACF;IACD,OAAO;QACL,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AppError } from '../redux/slices/appStateSlice';
|
|
3
|
+
/** Decorator to retrieve a value and serve it once ready to the decorated component */
|
|
4
|
+
export default function withRetrievedValue<ENTITY_TYPE extends Record<string, any>, PROP_NAME extends string, PROPS extends Record<PROP_NAME, ENTITY_TYPE>>(propEntityName: PROP_NAME, getRetrieverService: () => () => Promise<ENTITY_TYPE>, WrappedComponent: React.ComponentType<PROPS>, onError?: (appError: AppError) => void): import("react").ComponentType<Omit<PROPS, PROP_NAME>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const useErrorDispatcher_1 = (0, tslib_1.__importDefault)(require("../hooks/useErrorDispatcher"));
|
|
7
|
+
/** Decorator to retrieve a value and serve it once ready to the decorated component */
|
|
8
|
+
function withRetrievedValue(propEntityName, getRetrieverService, WrappedComponent, onError) {
|
|
9
|
+
const displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
10
|
+
const ComponentWithParties = (props) => {
|
|
11
|
+
const [value, setValue] = (0, react_1.useState)();
|
|
12
|
+
const cachedRetrieve = getRetrieverService();
|
|
13
|
+
const addError = (0, useErrorDispatcher_1.default)();
|
|
14
|
+
const doRetrieve = () => {
|
|
15
|
+
cachedRetrieve()
|
|
16
|
+
.then((v) => setValue(v))
|
|
17
|
+
.catch((reason) => (onError !== null && onError !== void 0 ? onError : addError)({
|
|
18
|
+
id: `RETRIEVE_VALUE_${propEntityName}`,
|
|
19
|
+
blocking: false,
|
|
20
|
+
techDescription: `Something gone wrong while retrieving ${propEntityName}`,
|
|
21
|
+
toNotify: true,
|
|
22
|
+
error: reason,
|
|
23
|
+
onRetry: doRetrieve,
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
if (!value) {
|
|
28
|
+
doRetrieve();
|
|
29
|
+
}
|
|
30
|
+
}, []);
|
|
31
|
+
return (value !== undefined && ((0, jsx_runtime_1.jsx)(WrappedComponent, Object.assign({}, props, { [propEntityName]: value }), void 0)));
|
|
32
|
+
};
|
|
33
|
+
// eslint-disable-next-line functional/immutable-data
|
|
34
|
+
ComponentWithParties.displayName = `withRetrieve${propEntityName}(${displayName})`;
|
|
35
|
+
return ComponentWithParties;
|
|
36
|
+
}
|
|
37
|
+
exports.default = withRetrievedValue;
|
|
38
|
+
//# sourceMappingURL=withRetrievedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withRetrievedValue.js","sourceRoot":"","sources":["../../src/lib/decorators/withRetrievedValue.tsx"],"names":[],"mappings":";;;;AAAA,i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WAAW,GAAG,eAAe,cAAc,IAAI,WAAW,GAAG,CAAC;IAEnF,OAAO,oBAAmE,CAAC;AAC7E,CAAC;AAlDD,qCAkDC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PageRequest } from '../model/PageRequest';
|
|
2
|
+
import { PageResource } from '../model/PageResource';
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook used to simulate paginated resources when the external service doesn't implement it, caching values when filter doesn't change and serving them a page at time.
|
|
5
|
+
* Cached values are stored using useRef, so they are local to the component using this hook.
|
|
6
|
+
* The sorting actually is applied using string representation
|
|
7
|
+
*/
|
|
8
|
+
declare const useFakePagination: <T extends Record<string, any>>(fetch: () => Promise<T[]>) => (pageRequest: PageRequest, filterChanged: boolean) => Promise<PageResource<T>>;
|
|
9
|
+
export default useFakePagination;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const toPageResource = (content, page, size, totalElements) => ({
|
|
5
|
+
content,
|
|
6
|
+
page: {
|
|
7
|
+
number: page,
|
|
8
|
+
size,
|
|
9
|
+
totalElements,
|
|
10
|
+
totalPages: size > 0 ? Math.ceil(totalElements / size) : 0,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const extractPageRequest = (data, pageRequest) => {
|
|
14
|
+
const firstIndex = pageRequest.page * pageRequest.size;
|
|
15
|
+
return toPageResource(firstIndex < data.length && pageRequest.size > 0
|
|
16
|
+
? data.slice(firstIndex, firstIndex + pageRequest.size)
|
|
17
|
+
: [], pageRequest.page, pageRequest.size, data.length);
|
|
18
|
+
};
|
|
19
|
+
const applySort = (data, sort) => {
|
|
20
|
+
const sortConfiguration = sort.split(' ').map((order) => {
|
|
21
|
+
const [key, direction] = order.split(',');
|
|
22
|
+
return { key, asc: direction === 'asc' };
|
|
23
|
+
});
|
|
24
|
+
// eslint-disable-next-line functional/immutable-data
|
|
25
|
+
data.sort((a, b) => {
|
|
26
|
+
for (const order of sortConfiguration) {
|
|
27
|
+
const compare = `${a[order.key]}`.localeCompare(`${b[order.key]}`);
|
|
28
|
+
if (compare !== 0) {
|
|
29
|
+
return compare * (order.asc ? 1 : -1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return 0;
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Custom hook used to simulate paginated resources when the external service doesn't implement it, caching values when filter doesn't change and serving them a page at time.
|
|
37
|
+
* Cached values are stored using useRef, so they are local to the component using this hook.
|
|
38
|
+
* The sorting actually is applied using string representation
|
|
39
|
+
*/
|
|
40
|
+
const useFakePagination = (fetch) => {
|
|
41
|
+
const cachedData = (0, react_1.useRef)();
|
|
42
|
+
const cachedDataSort = (0, react_1.useRef)();
|
|
43
|
+
const checkAndApplySort = (sort) => {
|
|
44
|
+
if (sort && cachedDataSort.current !== sort) {
|
|
45
|
+
applySort(cachedData.current, sort);
|
|
46
|
+
// eslint-disable-next-line functional/immutable-data
|
|
47
|
+
cachedDataSort.current = sort;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return (pageRequest, filterChanged) => {
|
|
51
|
+
if (!filterChanged && cachedData.current) {
|
|
52
|
+
checkAndApplySort(pageRequest.sort);
|
|
53
|
+
return new Promise((resolve) => resolve(extractPageRequest(cachedData.current, pageRequest)));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return fetch().then((results) => {
|
|
57
|
+
// eslint-disable-next-line functional/immutable-data
|
|
58
|
+
cachedData.current = results;
|
|
59
|
+
checkAndApplySort(pageRequest.sort);
|
|
60
|
+
return extractPageRequest(cachedData.current, pageRequest);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
exports.default = useFakePagination;
|
|
66
|
+
//# sourceMappingURL=useFakePagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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AAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC9B,qDAAqD;gBACrD,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;gBAC7B,iBAAiB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBACpC,OAAO,kBAAkB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PayloadActionCreator } from '@reduxjs/toolkit';
|
|
2
|
+
/** It will return a method that only at the very first invocation it will call the retrieverService only the first time, storing the obtained values, and returning always cached values */
|
|
3
|
+
declare const useReduxCachedValue: <T extends any[] | Record<string, any>>(entity: string, retrieverService: () => Promise<T>, reduxSelector: (state: any) => T, reduxSetterAction: import("@reduxjs/toolkit/dist/tsHelpers").IsAny<T, import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, import("@reduxjs/toolkit/dist/tsHelpers").IsUnknown<T, import("@reduxjs/toolkit").ActionCreatorWithNonInferrablePayload<string>, import("@reduxjs/toolkit/dist/tsHelpers").IfVoid<T, import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, import("@reduxjs/toolkit/dist/tsHelpers").IfMaybeUndefined<T, import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<T, string>, import("@reduxjs/toolkit").ActionCreatorWithPayload<T, string>>>>>, alwaysRetrieve?: boolean | undefined) => () => Promise<T>;
|
|
4
|
+
export default useReduxCachedValue;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_redux_1 = require("react-redux");
|
|
5
|
+
const constants_1 = require("../utils/constants");
|
|
6
|
+
const useLoading_1 = (0, tslib_1.__importDefault)(require("./useLoading"));
|
|
7
|
+
/** It will return a method that only at the very first invocation it will call the retrieverService only the first time, storing the obtained values, and returning always cached values */
|
|
8
|
+
const useReduxCachedValue = (entity, retrieverService, reduxSelector, reduxSetterAction, alwaysRetrieve) => {
|
|
9
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
10
|
+
const entities = (0, react_redux_1.useSelector)(reduxSelector);
|
|
11
|
+
const setEntities = (value) => dispatch(reduxSetterAction(value));
|
|
12
|
+
const setLoading = (0, useLoading_1.default)(`${constants_1.LOADING_TASK_RETRIEVE_CACHED_VALUES}_${entity}`);
|
|
13
|
+
return () => {
|
|
14
|
+
if (alwaysRetrieve || !entities) {
|
|
15
|
+
setLoading(true);
|
|
16
|
+
return retrieverService()
|
|
17
|
+
.then((e) => {
|
|
18
|
+
setEntities(e);
|
|
19
|
+
return e;
|
|
20
|
+
})
|
|
21
|
+
.finally(() => setLoading(false));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return new Promise((resolve) => resolve(entities));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.default = useReduxCachedValue;
|
|
29
|
+
//# sourceMappingURL=useReduxCachedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReduxCachedValue.js","sourceRoot":"","sources":["../../src/lib/hooks/useReduxCachedValue.tsx"],"names":[],"mappings":";;;AACA,6CAAuD;AACvD,kDAAyE;AACzE,2EAAsC;AAEtC,4LAA4L;AAC5L,MAAM,mBAAmB,GAAG,CAC1B,MAAc,EACd,gBAAkC,EAClC,aAAgC,EAChC,iBAA0C,EAC1C,cAAwB,EACJ,EAAE;IACtB,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC,aAAa,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,CAAC,KAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IAErE,MAAM,UAAU,GAAG,IAAA,oBAAU,EAAC,GAAG,+CAAmC,IAAI,MAAM,EAAE,CAAC,CAAC;IAElF,OAAO,GAAe,EAAE;QACtB,IAAI,cAAc,IAAI,CAAC,QAAQ,EAAE;YAC/B,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,OAAO,gBAAgB,EAAE;iBACtB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;gBACV,WAAW,CAAC,CAAC,CAAC,CAAC;gBACf,OAAO,CAAC,CAAC;YACX,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;SACrC;aAAM;YACL,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;SACpD;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ErrorInfo } from 'react';
|
|
2
|
+
export declare type AppError = {
|
|
3
|
+
/** The identifier used to recognize the error: it cannot be possible to have the same error id at the same time */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The Error thrown */
|
|
6
|
+
error: Error;
|
|
7
|
+
errorInfo?: ErrorInfo;
|
|
8
|
+
/** If true, this error will show the error page, not allowing the user to do anything, otherwise it will show a closable popup */
|
|
9
|
+
blocking: boolean;
|
|
10
|
+
/** A description of the error to send when notifying the error */
|
|
11
|
+
techDescription: string;
|
|
12
|
+
/** A text to show as title of the popup when a not blocking error occurs */
|
|
13
|
+
displayableTitle?: string;
|
|
14
|
+
/** A text to show as body of the popup when a not blocking error occurs */
|
|
15
|
+
displayableDescription?: string;
|
|
16
|
+
/** If defined, in case of not blocking error, it will render a retry button which will execute this function */
|
|
17
|
+
onRetry?: () => void;
|
|
18
|
+
/** If defined, in case of not blocking error, it will be executed when closing the popup */
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
/** If true, it will notify the error */
|
|
21
|
+
toNotify: boolean;
|
|
22
|
+
/** Can render a SessionModal or Toast component */
|
|
23
|
+
component?: 'SessionModal' | 'Toast';
|
|
24
|
+
/** If component === 'Toast'. The notify will be autoclosed using this configuration, as default timer.
|
|
25
|
+
* If none, it will not be closed automatically.
|
|
26
|
+
* If timer, it will be closed after autocloseMilliseconds milliseconds
|
|
27
|
+
*/
|
|
28
|
+
autoclosable?: 'none' | 'timer';
|
|
29
|
+
/** If component === 'Toast' and autoclosable === 'timer'. The millisecond after which close the notify. As default 2000 */
|
|
30
|
+
autocloseMilliseconds?: number;
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppError.js","sourceRoot":"","sources":["../../src/lib/model/AppError.ts"],"names":[],"mappings":""}
|
package/model/UserNotify.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ export declare type UserNotify = {
|
|
|
8
8
|
message: React.ReactNode;
|
|
9
9
|
/** If component === 'Toast'. The logo to be rendered. As default a confirm logo will be used */
|
|
10
10
|
logo?: React.ElementType;
|
|
11
|
+
/** If component === 'Toast'. The notify will be autoclosed using this configuration, as default timer.
|
|
12
|
+
* If none, it will not be closed automatically.
|
|
13
|
+
* If timer, it will be closed after autocloseMilliseconds milliseconds
|
|
14
|
+
*/
|
|
15
|
+
autoclosable?: 'none' | 'timer';
|
|
16
|
+
/** If component === 'Toast' and autoclosable === 'timer'. The millisecond after which close the notify. As default 2000 */
|
|
17
|
+
autocloseMilliseconds?: number;
|
|
11
18
|
/** If component === 'Toast'. The color used for the left border */
|
|
12
19
|
leftBorderColor?: string;
|
|
13
20
|
/** If component === 'SessionModal'. If defined, it will render a confirm button which will execute this function */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/selfcare-common-frontend",
|
|
3
3
|
"description": "Shared React components for the pagopa selfcare project",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/pagopa/selfcare-common-frontend",
|
|
7
7
|
"author": "https://www.pagopa.gov.it",
|
|
@@ -121,8 +121,7 @@
|
|
|
121
121
|
"src/lib/common-polyfill.ts",
|
|
122
122
|
"src/lib/index.ts",
|
|
123
123
|
"src/lib/components/icons/*",
|
|
124
|
-
"src/lib/model/*"
|
|
125
|
-
"src/store.ts"
|
|
124
|
+
"src/lib/model/*"
|
|
126
125
|
]
|
|
127
126
|
}
|
|
128
127
|
}
|
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
2
|
-
import {
|
|
2
|
+
import { AppError } from '../../model/AppError';
|
|
3
3
|
import { UserNotify } from '../../model/UserNotify';
|
|
4
|
-
export
|
|
5
|
-
/** The identifier used to recognize the error: it cannot be possible to have the same error id at the same time */
|
|
6
|
-
id: string;
|
|
7
|
-
/** The Error thrown */
|
|
8
|
-
error: Error;
|
|
9
|
-
errorInfo?: ErrorInfo;
|
|
10
|
-
/** If true, this error will show the error page, not allowing the user to do anything, otherwise it will show a closable popup */
|
|
11
|
-
blocking: boolean;
|
|
12
|
-
/** A description of the error to send when notifying the error */
|
|
13
|
-
techDescription: string;
|
|
14
|
-
/** A text to show as title of the popup when a not blocking error occurs */
|
|
15
|
-
displayableTitle?: string;
|
|
16
|
-
/** A text to show as body of the popup when a not blocking error occurs */
|
|
17
|
-
displayableDescription?: string;
|
|
18
|
-
/** If defined, in case of not blocking error, it will render a retry button which will execute this function */
|
|
19
|
-
onRetry?: () => void;
|
|
20
|
-
/** If defined, in case of not blocking error, it will be executed when closing the popup */
|
|
21
|
-
onClose?: () => void;
|
|
22
|
-
/** If true, it will notify the error */
|
|
23
|
-
toNotify: boolean;
|
|
24
|
-
/** Can render a SessionModal or Toast component */
|
|
25
|
-
component?: 'SessionModal' | 'Toast';
|
|
26
|
-
};
|
|
4
|
+
export type { AppError } from '../../model/AppError';
|
|
27
5
|
interface AppStateState {
|
|
28
6
|
loading: {
|
|
29
7
|
result: boolean;
|
|
@@ -96,4 +74,3 @@ export declare const appStateSelectors: {
|
|
|
96
74
|
exitAction?: (() => void) | undefined;
|
|
97
75
|
};
|
|
98
76
|
};
|
|
99
|
-
export {};
|
|
@@ -40,12 +40,30 @@ exports.appStateSlice = (0, toolkit_1.createSlice)({
|
|
|
40
40
|
if (!action.payload.component) {
|
|
41
41
|
action.payload.component = 'SessionModal';
|
|
42
42
|
}
|
|
43
|
+
if (action.payload.component === 'Toast') {
|
|
44
|
+
if (action.payload.autoclosable === undefined) {
|
|
45
|
+
action.payload.autoclosable = 'timer';
|
|
46
|
+
}
|
|
47
|
+
if (action.payload.autoclosable === 'timer' &&
|
|
48
|
+
(!action.payload.autocloseMilliseconds || action.payload.autocloseMilliseconds < 0)) {
|
|
49
|
+
action.payload.autocloseMilliseconds = 2000;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
43
52
|
state.errors.push(action.payload);
|
|
44
53
|
},
|
|
45
54
|
removeError: (state, action) => {
|
|
46
55
|
state.errors = state.errors.filter((e) => e.id !== action.payload.id);
|
|
47
56
|
},
|
|
48
57
|
addNotify: (state, action) => {
|
|
58
|
+
if (action.payload.component === 'Toast') {
|
|
59
|
+
if (action.payload.autoclosable === undefined) {
|
|
60
|
+
action.payload.autoclosable = 'timer';
|
|
61
|
+
}
|
|
62
|
+
if (action.payload.autoclosable === 'timer' &&
|
|
63
|
+
(!action.payload.autocloseMilliseconds || action.payload.autocloseMilliseconds < 0)) {
|
|
64
|
+
action.payload.autocloseMilliseconds = 2000;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
49
67
|
state.userNotifies.push(action.payload);
|
|
50
68
|
},
|
|
51
69
|
removeNotify: (state, action) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appStateSlice.js","sourceRoot":"","sources":["../../../src/lib/redux/slices/appStateSlice.ts"],"names":[],"mappings":";;;AAAA,8CAA8D;
|
|
1
|
+
{"version":3,"file":"appStateSlice.js","sourceRoot":"","sources":["../../../src/lib/redux/slices/appStateSlice.ts"],"names":[],"mappings":";;;AAAA,8CAA8D;AAuB9D,MAAM,YAAY,GAAkB;IAClC,OAAO,EAAE;QACP,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,EAAE;KACV;IACD,MAAM,EAAE,EAAE;IACV,YAAY,EAAE,EAAE;IAChB,wBAAwB,EAAE;QACxB,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,KAAK;KACZ;CACF,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,CAAoB,EAAE,EAAE;IAC1C,MAAM,OAAO,GACX,mGAAmG,CAAC;IACtG,CAAC,CAAC,cAAc,EAAE,CAAC;IACnB,qDAAqD;IACrD,CAAC,CAAC,WAAW,GAAG,OAAO,CAAC;IACxB,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,8CAA8C;AACjC,QAAA,aAAa,GAAG,IAAA,qBAAW,EAAC;IACvC,IAAI,EAAE,UAAU;IAChB,YAAY;IACZ,QAAQ,EAAE;QACR,UAAU,EAAE,CAAC,KAAK,EAAE,MAAyD,EAAE,EAAE;YAC/E,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;gBAC1B,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;gBAC5B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;aACjD;iBAAM;gBACL,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChD,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;aACpE;QACH,CAAC;QAED,QAAQ,EAAE,CAA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,GAAG,MAAM,CAAC,OAAO,CAAC;QAC7D,CAAC;QACD,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE;YAChC,KAAK,CAAC,wBAAwB,CAAC,IAAI,GAAG,KAAK,CAAC;YAC5C,KAAK,CAAC,wBAAwB,CAAC,UAAU,GAAG,SAAS,CAAC;QACxD,CAAC;KACF;CACF,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,qBAAa,CAAC,OAAO,CAAC;AACxC,QAAA,eAAe,GAAG,qBAAa,CAAC,OAAO,CAAC;AAExC,QAAA,iBAAiB,GAAG;IAC/B,aAAa,EAAE,CAAC,KAAkC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM;IACpF,YAAY,EAAE,CAAC,KAAkC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM;IAC3E,cAAc,EAAE,CAAC,KAAkC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY;IACnF,8BAA8B,EAAE,CAAC,KAAkC,EAAE,EAAE,CACrE,KAAK,CAAC,QAAQ,CAAC,wBAAwB;CAC1C,CAAC"}
|
package/utils/api-utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as t from 'io-ts';
|
|
|
3
3
|
import { EnhancedStore } from '@reduxjs/toolkit';
|
|
4
4
|
/** To show an error popup to inform of the not valid session */
|
|
5
5
|
export declare const onRedirectToLogin: (store: EnhancedStore) => {
|
|
6
|
-
payload: import("../
|
|
6
|
+
payload: import("../model/AppError").AppError;
|
|
7
7
|
type: string;
|
|
8
8
|
};
|
|
9
9
|
/** Return the implementation of fetch configured with a timeout */
|
package/utils/constants.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const STORAGE_KEY_USER = "user";
|
|
|
4
4
|
/** The key used to store in the session storage the logged user token in selfcare projects */
|
|
5
5
|
export declare const STORAGE_KEY_TOKEN = "token";
|
|
6
6
|
export declare const LOADING_TASK_LOGIN_CHECK = "LOGIN_CHECK";
|
|
7
|
+
export declare const LOADING_TASK_RETRIEVE_CACHED_VALUES = "RETRIEVE_CACHED_VALUES";
|
|
7
8
|
/** The short and long labels used for the roles of selfcare's projects */
|
|
8
9
|
export declare const roleLabels: {
|
|
9
10
|
[key in UserRole]: {
|
package/utils/constants.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roleLabels = exports.LOADING_TASK_LOGIN_CHECK = exports.STORAGE_KEY_TOKEN = exports.STORAGE_KEY_USER = void 0;
|
|
3
|
+
exports.roleLabels = exports.LOADING_TASK_RETRIEVE_CACHED_VALUES = exports.LOADING_TASK_LOGIN_CHECK = exports.STORAGE_KEY_TOKEN = exports.STORAGE_KEY_USER = void 0;
|
|
4
4
|
/** The key used to store in the session storage the loggedUser in selfcare projects */
|
|
5
5
|
exports.STORAGE_KEY_USER = 'user';
|
|
6
6
|
/** The key used to store in the session storage the logged user token in selfcare projects */
|
|
7
7
|
exports.STORAGE_KEY_TOKEN = 'token';
|
|
8
8
|
exports.LOADING_TASK_LOGIN_CHECK = 'LOGIN_CHECK';
|
|
9
|
+
exports.LOADING_TASK_RETRIEVE_CACHED_VALUES = 'RETRIEVE_CACHED_VALUES';
|
|
9
10
|
/** The short and long labels used for the roles of selfcare's projects */
|
|
10
11
|
exports.roleLabels = {
|
|
11
|
-
ADMIN: {
|
|
12
|
-
|
|
12
|
+
ADMIN: {
|
|
13
|
+
shortLabel: 'Ref. Amministrativo',
|
|
14
|
+
longLabel: 'Referente Amministrativo',
|
|
15
|
+
description: 'Gestisce i prodotti e gli utenti attivi',
|
|
16
|
+
},
|
|
17
|
+
LIMITED: {
|
|
18
|
+
shortLabel: 'Ref. Operativo',
|
|
19
|
+
longLabel: 'Referente Operativo',
|
|
20
|
+
description: 'Operatore prodotto',
|
|
21
|
+
},
|
|
13
22
|
};
|
|
14
23
|
//# sourceMappingURL=constants.js.map
|
package/utils/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/utils/constants.ts"],"names":[],"mappings":";;;AAEA,uFAAuF;AAC1E,QAAA,gBAAgB,GAAG,MAAM,CAAC;AACvC,8FAA8F;AACjF,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAE5B,QAAA,wBAAwB,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/utils/constants.ts"],"names":[],"mappings":";;;AAEA,uFAAuF;AAC1E,QAAA,gBAAgB,GAAG,MAAM,CAAC;AACvC,8FAA8F;AACjF,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAE5B,QAAA,wBAAwB,GAAG,aAAa,CAAC;AACzC,QAAA,mCAAmC,GAAG,wBAAwB,CAAC;AAE5E,0EAA0E;AAC7D,QAAA,UAAU,GAEnB;IACF,KAAK,EAAE;QACL,UAAU,EAAE,qBAAqB;QACjC,SAAS,EAAE,0BAA0B;QACrC,WAAW,EAAE,yCAAyC;KACvD;IACD,OAAO,EAAE;QACP,UAAU,EAAE,gBAAgB;QAC5B,SAAS,EAAE,qBAAqB;QAChC,WAAW,EAAE,oBAAoB;KAClC;CACF,CAAC"}
|