@movalib/movalib-commons 1.55.6 → 1.55.8

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.
@@ -94,6 +94,7 @@ var QrCodePLVContainer = function (_a) {
94
94
  var _b = (0, react_1.useState)(null), selectedChoice = _b[0], setSelectedChoice = _b[1];
95
95
  var _c = (0, react_1.useState)(''), urlA4 = _c[0], setUrlA4 = _c[1];
96
96
  var _d = (0, react_1.useState)(''), urlA3 = _d[0], setUrlA3 = _d[1];
97
+ var _e = (0, react_1.useState)(false), isReady = _e[0], setIsReady = _e[1];
97
98
  var qrCodeRef = (0, react_1.useRef)(null);
98
99
  var theme = (0, material_1.useTheme)();
99
100
  var PLVrefA4 = (0, react_1.useRef)(null);
@@ -147,6 +148,14 @@ var QrCodePLVContainer = function (_a) {
147
148
  setUrlA3(url);
148
149
  });
149
150
  }, [data]);
151
+ (0, react_1.useEffect)(function () {
152
+ if (PLVrefA4.current || PLVrefA3.current) {
153
+ setIsReady(true);
154
+ }
155
+ else {
156
+ setIsReady(false);
157
+ }
158
+ }, [PLVrefA4.current, PLVrefA3.current]);
150
159
  function printPLV(format) {
151
160
  return __awaiter(this, void 0, void 0, function () {
152
161
  var pdfUrl, response, existingPdfBytes, pdfDoc, qrCodeBlob, qrImageBytes, qrImage, pages, firstPage, _a, width, height, optionQrcode, modifiedPdfBytes, blob, url, loadingTask, pdf, page, canvas, context, viewport, renderContext, imageUrl;
@@ -208,7 +217,7 @@ var QrCodePLVContainer = function (_a) {
208
217
  page = _b.sent();
209
218
  canvas = document.createElement('canvas');
210
219
  context = canvas.getContext('2d');
211
- viewport = page.getViewport({ scale: 1.5 });
220
+ viewport = page.getViewport({ scale: 4 });
212
221
  canvas.width = viewport.width;
213
222
  canvas.height = viewport.height;
214
223
  renderContext = {
@@ -283,7 +292,7 @@ var QrCodePLVContainer = function (_a) {
283
292
  return function () { };
284
293
  }
285
294
  }, [selectedChoice, downloadQRCodeHeadless, downloadQrCodeWithCTA, printA3PLV, printA4PLV]);
286
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '24px' }, { children: [urlA4 && (0, jsx_runtime_1.jsx)(PLVComponent_1.PLVComponentV2, { ref: PLVrefA4, url: urlA4, printSize: PLVComponent_1.PrintSize.A4 }), urlA3 && (0, jsx_runtime_1.jsx)(PLVComponent_1.PLVComponentV2, { ref: PLVrefA3, url: urlA3, printSize: PLVComponent_1.PrintSize.A3 }), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, justifyContent: 'center', alignItems: 'center' }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 7 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, size: 'small' }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, __assign({ id: 'qrcode-plv-select' }, { children: "Choisissez votre support" })), (0, jsx_runtime_1.jsxs)(material_1.Select, __assign({ labelId: 'qrcode-plv-select', label: 'Choisissez votre support', id: 'qrcode-plv-select', onChange: onChangeSelectedChoice, value: selectedChoice }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'A4' }, { children: "\uD83E\uDDFE\u00A0\u00A0PLV format A4" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'A3' }, { children: "\uD83E\uDDFE\u00A0\u00A0PLV format A3" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'QR_Google' }, { children: "QR Code format GoogleMyBusiness" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'QR_Headless' }, { children: "QR Code seul" }))] }))] })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4, marginLeft: 3 }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ startIcon: selectedChoice === 'A3' || selectedChoice === 'A4' ? (0, jsx_runtime_1.jsx)(icons_material_1.DocumentScanner, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.QrCode2, {}), onClick: onClickDownload, variant: 'outlined', disabled: !selectedChoice, sx: { color: (0, material_1.darken)(theme.palette.primary.main, 0.2), borderRadius: '10rem' } }, { children: selectedChoice === 'A3' || selectedChoice === 'A4' ? 'Imprimer' : 'Télécharger' })) }))] })), (0, jsx_runtime_1.jsx)("div", __assign({ id: 'qr-code-container', style: Tools_1.flexCenter }, { children: (0, jsx_runtime_1.jsx)("div", { ref: qrCodeRef, style: {
295
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '24px' }, { children: [urlA4 && (0, jsx_runtime_1.jsx)(PLVComponent_1.PLVComponentV2, { ref: PLVrefA4, url: urlA4, printSize: PLVComponent_1.PrintSize.A4 }), urlA3 && (0, jsx_runtime_1.jsx)(PLVComponent_1.PLVComponentV2, { ref: PLVrefA3, url: urlA3, printSize: PLVComponent_1.PrintSize.A3 }), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, justifyContent: 'center', alignItems: 'center' }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 7 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ fullWidth: true, size: 'small' }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, __assign({ id: 'qrcode-plv-select' }, { children: "Choisissez votre support" })), (0, jsx_runtime_1.jsxs)(material_1.Select, __assign({ labelId: 'qrcode-plv-select', label: 'Choisissez votre support', id: 'qrcode-plv-select', onChange: onChangeSelectedChoice, value: selectedChoice }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'A4' }, { children: "\uD83E\uDDFE\u00A0\u00A0PLV format A4" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'A3' }, { children: "\uD83E\uDDFE\u00A0\u00A0PLV format A3" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'QR_Google' }, { children: "QR Code format GoogleMyBusiness" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'QR_Headless' }, { children: "QR Code seul" }))] }))] })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4, marginLeft: 3 }, { children: (selectedChoice === 'A3' || selectedChoice === 'A4') && !isReady ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, {})) : ((0, jsx_runtime_1.jsx)(material_1.Button, __assign({ startIcon: selectedChoice === 'A3' || selectedChoice === 'A4' ? (0, jsx_runtime_1.jsx)(icons_material_1.DocumentScanner, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.QrCode2, {}), onClick: onClickDownload, variant: 'outlined', disabled: !selectedChoice || ((selectedChoice === 'A3' || selectedChoice === 'A4') && !isReady), sx: { color: (0, material_1.darken)(theme.palette.primary.main, 0.2), borderRadius: '10rem' } }, { children: selectedChoice === 'A3' || selectedChoice === 'A4' ? 'Imprimer' : 'Télécharger' }))) }))] })), (0, jsx_runtime_1.jsx)("div", __assign({ id: 'qr-code-container', style: Tools_1.flexCenter }, { children: (0, jsx_runtime_1.jsx)("div", { ref: qrCodeRef, style: {
287
296
  height: '300px',
288
297
  width: '300px',
289
298
  maxWidth: '300px !important',
@@ -25,5 +25,6 @@ export default class Prestation {
25
25
  active: boolean;
26
26
  state: PrestationState;
27
27
  multipleApplication: boolean;
28
- constructor(id: number, code: string, name: string, description: string, category: string, downtime: number, appointmentDelay: number, position: number, active: boolean, state: PrestationState, multipleApplication: boolean, operations?: Operation[]);
28
+ operationsVisible: boolean;
29
+ constructor(id: number, code: string, name: string, description: string, category: string, downtime: number, appointmentDelay: number, position: number, active: boolean, state: PrestationState, multipleApplication: boolean, operationsVisible: boolean, operations?: Operation[]);
29
30
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Prestation = /** @class */ (function () {
4
- function Prestation(id, code, name, description, category, downtime, appointmentDelay, position, active, state, multipleApplication, operations) {
4
+ function Prestation(id, code, name, description, category, downtime, appointmentDelay, position, active, state, multipleApplication, operationsVisible, operations) {
5
5
  this.id = id;
6
6
  this.code = code;
7
7
  this.name = name;
@@ -12,6 +12,7 @@ var Prestation = /** @class */ (function () {
12
12
  this.position = position;
13
13
  this.active = active;
14
14
  this.multipleApplication = multipleApplication;
15
+ this.operationsVisible = operationsVisible;
15
16
  this.operations = operations;
16
17
  this.state = state;
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.55.6",
3
+ "version": "1.55.8",
4
4
  "description": "Bibliothèque d'objets communs à l'ensemble des projets React de Movalib",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -2,6 +2,7 @@ import { DocumentScanner, QrCode2 } from '@mui/icons-material';
2
2
  import {
3
3
  Box,
4
4
  Button,
5
+ CircularProgress,
5
6
  FormControl,
6
7
  Grid,
7
8
  InputLabel,
@@ -30,6 +31,7 @@ export const QrCodePLVContainer = ({ data }: { data: string }) => {
30
31
  const [selectedChoice, setSelectedChoice] = useState<SelectChoice>(null);
31
32
  const [urlA4, setUrlA4] = useState<string>('');
32
33
  const [urlA3, setUrlA3] = useState<string>('');
34
+ const [isReady, setIsReady] = useState(false);
33
35
 
34
36
  const qrCodeRef = useRef<HTMLDivElement>(null);
35
37
  const theme = useTheme();
@@ -91,6 +93,14 @@ export const QrCodePLVContainer = ({ data }: { data: string }) => {
91
93
  });
92
94
  }, [data]);
93
95
 
96
+ useEffect(() => {
97
+ if (PLVrefA4.current || PLVrefA3.current) {
98
+ setIsReady(true);
99
+ } else {
100
+ setIsReady(false);
101
+ }
102
+ }, [PLVrefA4.current, PLVrefA3.current]);
103
+
94
104
  async function printPLV(format: string) {
95
105
  // Chemin du fichier PDF
96
106
  const pdfUrl = `/Movalib_${format}.pdf`;
@@ -156,7 +166,7 @@ export const QrCodePLVContainer = ({ data }: { data: string }) => {
156
166
  const canvas = document.createElement('canvas');
157
167
  const context = canvas.getContext('2d');
158
168
 
159
- const viewport = page.getViewport({ scale: 1.5 });
169
+ const viewport = page.getViewport({ scale: 4});
160
170
  canvas.width = viewport.width;
161
171
  canvas.height = viewport.height;
162
172
 
@@ -267,15 +277,21 @@ export const QrCodePLVContainer = ({ data }: { data: string }) => {
267
277
  </FormControl>
268
278
  </Grid>
269
279
  <Grid item xs={4} marginLeft={3}>
280
+
281
+ {(selectedChoice === 'A3' || selectedChoice === 'A4') && !isReady ? (
282
+ <CircularProgress />
283
+ ) : (
270
284
  <Button
271
285
  startIcon={selectedChoice === 'A3' || selectedChoice === 'A4' ? <DocumentScanner /> : <QrCode2 />}
272
286
  onClick={onClickDownload}
273
287
  variant='outlined'
274
- disabled={!selectedChoice}
288
+ disabled={!selectedChoice || ((selectedChoice === 'A3' || selectedChoice === 'A4') && !isReady)}
275
289
  sx={{ color: darken(theme.palette.primary.main, 0.2), borderRadius: '10rem' }}
276
290
  >
277
291
  {selectedChoice === 'A3' || selectedChoice === 'A4' ? 'Imprimer' : 'Télécharger'}
278
- </Button>
292
+ </Button>
293
+ )}
294
+
279
295
  </Grid>
280
296
  </Grid>
281
297
  <div id='qr-code-container' style={flexCenter}>
@@ -31,9 +31,12 @@ export default class Prestation {
31
31
  state: PrestationState;
32
32
 
33
33
  multipleApplication: boolean;
34
+
35
+ operationsVisible: boolean;
34
36
 
35
37
  constructor(id:number, code: string, name:string, description: string, category:string,
36
- downtime:number, appointmentDelay: number, position: number, active: boolean, state: PrestationState, multipleApplication: boolean, operations?: Operation[]) {
38
+ downtime:number, appointmentDelay: number, position: number, active: boolean, state: PrestationState,
39
+ multipleApplication: boolean, operationsVisible: boolean, operations?: Operation[]) {
37
40
  this.id = id;
38
41
  this.code = code;
39
42
  this.name = name;
@@ -44,6 +47,7 @@ export default class Prestation {
44
47
  this.position = position;
45
48
  this.active = active;
46
49
  this.multipleApplication = multipleApplication;
50
+ this.operationsVisible = operationsVisible;
47
51
  this.operations = operations;
48
52
  this.state = state;
49
53
  }