@selfcommunity/react-ui 0.10.5-payments.185 → 0.10.5-payments.186
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.
|
@@ -9,13 +9,16 @@ const system_1 = require("@mui/system");
|
|
|
9
9
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
10
10
|
const react_intl_1 = require("react-intl");
|
|
11
11
|
const react_pdf_1 = require("react-pdf");
|
|
12
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
12
13
|
const Button_1 = tslib_1.__importDefault(require("@mui/material/Button"));
|
|
13
14
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
15
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
14
16
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
17
|
+
const Errors_1 = require("../../constants/Errors");
|
|
15
18
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
19
|
// @ts-ignore
|
|
17
20
|
react_pdf_1.pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.js', import.meta.url).toString();
|
|
18
|
-
const PREFIX = '
|
|
21
|
+
const PREFIX = 'SCPdfPreview';
|
|
19
22
|
const classes = {
|
|
20
23
|
root: `${PREFIX}-root`,
|
|
21
24
|
documentPdfWrapper: `${PREFIX}-document-pdf-wrapper`,
|
|
@@ -27,23 +30,7 @@ const Root = (0, material_1.styled)(material_1.Box, {
|
|
|
27
30
|
name: PREFIX,
|
|
28
31
|
slot: 'Root',
|
|
29
32
|
overridesResolver: (props, styles) => styles.root
|
|
30
|
-
})(({ theme }) => ({
|
|
31
|
-
display: 'flex',
|
|
32
|
-
flexDirection: 'column',
|
|
33
|
-
[`& .${classes.documentPdfWrapper}`]: {
|
|
34
|
-
filter: 'drop-shadow(0 0 5px #00000040)'
|
|
35
|
-
},
|
|
36
|
-
[`& .${classes.documentPdfLink}`]: {
|
|
37
|
-
padding: 10,
|
|
38
|
-
'&:hover': {
|
|
39
|
-
opacity: 0.5
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
[`& .${classes.documentPdfPage}`]: {
|
|
43
|
-
display: 'flex',
|
|
44
|
-
justifyContent: 'center'
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
33
|
+
})(({ theme }) => ({}));
|
|
47
34
|
// Default options conf PDFViewer
|
|
48
35
|
const options = {
|
|
49
36
|
cMapUrl: '/cmaps/',
|
|
@@ -80,10 +67,8 @@ function PdfPreview(inProps) {
|
|
|
80
67
|
setIsLoading(false);
|
|
81
68
|
}
|
|
82
69
|
const fetchBlob = (0, react_1.useCallback)((url) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
return yield request.blob();
|
|
70
|
+
const response = yield api_services_1.http.request({ url, responseType: 'blob' });
|
|
71
|
+
return response.data;
|
|
87
72
|
}), [scUserContext.user, scUserContext.session]);
|
|
88
73
|
(0, react_1.useEffect)(() => {
|
|
89
74
|
if (pdfUrl) {
|
|
@@ -94,7 +79,9 @@ function PdfPreview(inProps) {
|
|
|
94
79
|
setUrl(_url);
|
|
95
80
|
setIsLoading(false);
|
|
96
81
|
})
|
|
97
|
-
.catch(
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
84
|
+
});
|
|
98
85
|
}
|
|
99
86
|
}, [scUserContext.user, scUserContext.session]);
|
|
100
87
|
function renderDocument() {
|
|
@@ -6,13 +6,16 @@ import { useThemeProps } from '@mui/system';
|
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { FormattedMessage } from 'react-intl';
|
|
8
8
|
import { Document, Page, pdfjs } from 'react-pdf';
|
|
9
|
+
import { Logger } from '@selfcommunity/utils';
|
|
9
10
|
import Button from '@mui/material/Button';
|
|
10
11
|
import Skeleton from './Skeleton';
|
|
12
|
+
import { http } from '@selfcommunity/api-services';
|
|
11
13
|
import { useResizeObserver, useSCUser } from '@selfcommunity/react-core';
|
|
14
|
+
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
12
15
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
13
16
|
// @ts-ignore
|
|
14
17
|
pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.js', import.meta.url).toString();
|
|
15
|
-
const PREFIX = '
|
|
18
|
+
const PREFIX = 'SCPdfPreview';
|
|
16
19
|
const classes = {
|
|
17
20
|
root: `${PREFIX}-root`,
|
|
18
21
|
documentPdfWrapper: `${PREFIX}-document-pdf-wrapper`,
|
|
@@ -24,23 +27,7 @@ const Root = styled(Box, {
|
|
|
24
27
|
name: PREFIX,
|
|
25
28
|
slot: 'Root',
|
|
26
29
|
overridesResolver: (props, styles) => styles.root
|
|
27
|
-
})(({ theme }) => ({
|
|
28
|
-
display: 'flex',
|
|
29
|
-
flexDirection: 'column',
|
|
30
|
-
[`& .${classes.documentPdfWrapper}`]: {
|
|
31
|
-
filter: 'drop-shadow(0 0 5px #00000040)'
|
|
32
|
-
},
|
|
33
|
-
[`& .${classes.documentPdfLink}`]: {
|
|
34
|
-
padding: 10,
|
|
35
|
-
'&:hover': {
|
|
36
|
-
opacity: 0.5
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
[`& .${classes.documentPdfPage}`]: {
|
|
40
|
-
display: 'flex',
|
|
41
|
-
justifyContent: 'center'
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
30
|
+
})(({ theme }) => ({}));
|
|
44
31
|
// Default options conf PDFViewer
|
|
45
32
|
const options = {
|
|
46
33
|
cMapUrl: '/cmaps/',
|
|
@@ -77,10 +64,8 @@ export default function PdfPreview(inProps) {
|
|
|
77
64
|
setIsLoading(false);
|
|
78
65
|
}
|
|
79
66
|
const fetchBlob = useCallback((url) => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
return yield request.blob();
|
|
67
|
+
const response = yield http.request({ url, responseType: 'blob' });
|
|
68
|
+
return response.data;
|
|
84
69
|
}), [scUserContext.user, scUserContext.session]);
|
|
85
70
|
useEffect(() => {
|
|
86
71
|
if (pdfUrl) {
|
|
@@ -91,7 +76,9 @@ export default function PdfPreview(inProps) {
|
|
|
91
76
|
setUrl(_url);
|
|
92
77
|
setIsLoading(false);
|
|
93
78
|
})
|
|
94
|
-
.catch(
|
|
79
|
+
.catch((error) => {
|
|
80
|
+
Logger.error(SCOPE_SC_UI, error);
|
|
81
|
+
});
|
|
95
82
|
}
|
|
96
83
|
}, [scUserContext.user, scUserContext.session]);
|
|
97
84
|
function renderDocument() {
|