@movalib/movalib-commons 1.62.0 → 1.62.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.
@@ -1,7 +1,7 @@
1
- import { AlertColor } from "@mui/material";
2
1
  import { FunctionComponent, ReactNode } from "react";
3
- import { MovaAppType } from "./helpers/Enums";
2
+ import { AlertColor } from "@mui/material";
4
3
  import { MovaLoginForm } from "./helpers/Types";
4
+ import { MovaAppType } from "./helpers/Enums";
5
5
  /**
6
6
  * Propriétés du composant
7
7
  * movaAppType : type d'application Movalib au sein de laquelle le composant est injectée
@@ -51,26 +51,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var jsx_runtime_1 = require("react/jsx-runtime");
54
- var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
55
- var VisibilityOff_1 = __importDefault(require("@mui/icons-material/VisibilityOff"));
56
- var lab_1 = require("@mui/lab");
57
- var material_1 = require("@mui/material");
58
- var InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
59
- var libphonenumber_js_1 = require("libphonenumber-js");
60
54
  var react_1 = require("react");
61
- var react_router_dom_1 = require("react-router-dom");
62
- var DialogForgotPassword_1 = __importDefault(require("./DialogForgotPassword"));
63
- var MovaCopyright_1 = __importDefault(require("./MovaCopyright"));
64
- var leaf_green_large_png_1 = __importDefault(require("./assets/images/leaf_green_large.png"));
65
- var leaf_pink_large_png_1 = __importDefault(require("./assets/images/leaf_pink_large.png"));
66
- var logo_admin_large_png_1 = __importDefault(require("./assets/images/logo/logo_admin_large.png"));
55
+ var lab_1 = require("@mui/lab");
67
56
  var logo_large_border_png_1 = __importDefault(require("./assets/images/logo/logo_large_border.png"));
68
- var logo_large_dm_png_1 = __importDefault(require("./assets/images/logo/logo_large_dm.png"));
69
57
  var logo_pro_large_border_png_1 = __importDefault(require("./assets/images/logo/logo_pro_large_border.png"));
58
+ var logo_admin_large_png_1 = __importDefault(require("./assets/images/logo/logo_admin_large.png"));
59
+ var logo_large_dm_png_1 = __importDefault(require("./assets/images/logo/logo_large_dm.png"));
70
60
  var logo_pro_large_dm_png_1 = __importDefault(require("./assets/images/logo/logo_pro_large_dm.png"));
61
+ var leaf_green_large_png_1 = __importDefault(require("./assets/images/leaf_green_large.png"));
62
+ var leaf_pink_large_png_1 = __importDefault(require("./assets/images/leaf_pink_large.png"));
63
+ var material_1 = require("@mui/material");
64
+ var MovaCopyright_1 = __importDefault(require("./MovaCopyright"));
71
65
  var Enums_1 = require("./helpers/Enums");
72
- var Tools_1 = require("./helpers/Tools");
73
66
  var Validator_1 = require("./helpers/Validator");
67
+ var Tools_1 = require("./helpers/Tools");
68
+ var react_router_dom_1 = require("react-router-dom");
69
+ var InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
70
+ var Visibility_1 = __importDefault(require("@mui/icons-material/Visibility"));
71
+ var VisibilityOff_1 = __importDefault(require("@mui/icons-material/VisibilityOff"));
72
+ var DialogForgotPassword_1 = __importDefault(require("./DialogForgotPassword"));
73
+ var libphonenumber_js_1 = require("libphonenumber-js");
74
74
  // Permet de centrer le contenu de l'application
75
75
  var styles = {
76
76
  display: 'flex',
@@ -233,16 +233,14 @@ var MovaLogin = function (_a) {
233
233
  </Dialog>
234
234
  );
235
235
  } */
236
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: styles }, { children: [(0, jsx_runtime_1.jsx)("img", { src: leaf_green_large_png_1.default, style: {
237
- position: 'fixed',
236
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: styles }, { children: [(0, jsx_runtime_1.jsx)("img", { src: leaf_green_large_png_1.default, style: { position: 'fixed',
238
237
  float: 'left',
239
238
  width: '250px',
240
239
  height: '400px',
241
240
  top: '-20%',
242
241
  left: '0%',
243
242
  opacity: '0.3',
244
- zIndex: -8
245
- }, alt: 'Feuille Verte Movalib' }), (0, jsx_runtime_1.jsxs)(material_1.Container, __assign({ component: "main", maxWidth: "xs" }, { children: [(0, jsx_runtime_1.jsx)(material_1.CssBaseline, {}), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
243
+ zIndex: -8 }, alt: 'Feuille Verte Movalib' }), (0, jsx_runtime_1.jsxs)(material_1.Container, __assign({ component: "main", maxWidth: "xs" }, { children: [(0, jsx_runtime_1.jsx)(material_1.CssBaseline, {}), (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
246
244
  marginTop: 6,
247
245
  display: 'flex',
248
246
  flexDirection: 'column',
@@ -265,15 +263,13 @@ var MovaLogin = function (_a) {
265
263
  borderColor: darkMode ? 'white' : 'default', // Couleur de la bordure
266
264
  }
267
265
  } }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { value: "remember", color: "primary" }), label: "Se souvenir de moi" }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ loading: loading, type: "submit", fullWidth: true, variant: "contained", sx: { mt: 3, mb: 2, backgroundColor: darkMode ? theme.palette.primary.dark : theme.palette.primary.main } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "Se connecter" }) })), movaAppType === Enums_1.MovaAppType.INDIVIDUAL && (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ fullWidth: true, variant: "outlined", onClick: function (e) { return handleOnClickSignUp(); }, sx: { mb: 2, color: theme.palette.primary.dark } }, { children: (0, jsx_runtime_1.jsx)("span", { children: "CR\u00C9ER MON COMPTE" }) })), alertMessage && alertSeverity && (0, jsx_runtime_1.jsx)(material_1.Alert, __assign({ severity: alertSeverity, sx: { mb: 2 } }, { children: alertMessage })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Link, __assign({ variant: "body2", color: "text.secondary", onClick: function (e) { return handleOnClickForgotPassword(); }, sx: { cursor: 'pointer' } }, { children: "Mot de passe oubli\u00E9 ?" })) })) }))] })), (0, jsx_runtime_1.jsx)(MovaCopyright_1.default, { sx: { mt: 8, mb: 1 } }), version && (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: 'body2', color: theme.palette.grey[200], sx: { textAlign: 'center' } }, { children: version })), openForgotPassword &&
268
- (0, jsx_runtime_1.jsx)(DialogForgotPassword_1.default, { openForgotPassword: openForgotPassword, setOpenForgotPassword: setOpenForgotPassword, movaAppType: movaAppType, form: form, handleInputChange: handleInputChange, handleSubmitForgotPassword: handleSubmitForgotPassword })] })), (0, jsx_runtime_1.jsx)("img", { src: leaf_pink_large_png_1.default, style: {
269
- position: 'fixed',
266
+ (0, jsx_runtime_1.jsx)(DialogForgotPassword_1.default, { openForgotPassword: openForgotPassword, setOpenForgotPassword: setOpenForgotPassword, movaAppType: movaAppType, form: form, handleInputChange: handleInputChange, handleSubmitForgotPassword: handleSubmitForgotPassword })] })), (0, jsx_runtime_1.jsx)("img", { src: leaf_pink_large_png_1.default, style: { position: 'fixed',
270
267
  float: 'right',
271
268
  width: '250px',
272
269
  height: '400px',
273
270
  bottom: '-20%',
274
271
  right: '0%',
275
272
  opacity: '0.3',
276
- zIndex: '-10'
277
- }, alt: 'Feuille Rose Movalib' })] })));
273
+ zIndex: '-10' }, alt: 'Feuille Rose Movalib' })] })));
278
274
  };
279
275
  exports.default = MovaLogin;
@@ -1,4 +1,4 @@
1
- import '../../style/QRCode.css';
1
+ import "../../style/QRCode.css";
2
2
  export declare const getPdfDocument: (url: string) => import("pdfjs-dist/types/src/display/api").PDFDocumentLoadingTask;
3
3
  export declare const QrCodePLVContainer: ({ data }: {
4
4
  data: string;
@@ -79,16 +79,16 @@ var icons_material_1 = require("@mui/icons-material");
79
79
  var material_1 = require("@mui/material");
80
80
  require("../../style/QRCode.css");
81
81
  var html2canvas_1 = __importDefault(require("html2canvas"));
82
+ var pdf_lib_1 = require("pdf-lib");
83
+ var pdfjsLib = __importStar(require("pdfjs-dist"));
82
84
  var qr_code_styling_1 = __importDefault(require("qr-code-styling"));
83
85
  var react_1 = require("react");
84
86
  var react_to_print_1 = require("react-to-print");
85
87
  var DownloadedQRCode_1 = require("../../DownloadedQRCode");
86
88
  var leaf_yellow_small_png_1 = __importDefault(require("../../assets/images/leaf_yellow_small.png"));
87
89
  var Tools_1 = require("../../helpers/Tools");
88
- var pdf_lib_1 = require("pdf-lib");
89
90
  var PLVComponent_1 = require("./PLVComponent");
90
- var pdfjsLib = __importStar(require("pdfjs-dist"));
91
- pdfjsLib.GlobalWorkerOptions.workerSrc = '/pdf.worker.min.mjs';
91
+ pdfjsLib.GlobalWorkerOptions.workerSrc = "/pdf.worker.min.mjs";
92
92
  var getPdfDocument = function (url) {
93
93
  return pdfjsLib.getDocument(url);
94
94
  };
@@ -96,26 +96,26 @@ exports.getPdfDocument = getPdfDocument;
96
96
  var QrCodePLVContainer = function (_a) {
97
97
  var data = _a.data;
98
98
  var _b = (0, react_1.useState)(null), selectedChoice = _b[0], setSelectedChoice = _b[1];
99
- var _c = (0, react_1.useState)(''), urlA4 = _c[0], setUrlA4 = _c[1];
100
- var _d = (0, react_1.useState)(''), urlA3 = _d[0], setUrlA3 = _d[1];
99
+ var _c = (0, react_1.useState)(""), urlA4 = _c[0], setUrlA4 = _c[1];
100
+ var _d = (0, react_1.useState)(""), urlA3 = _d[0], setUrlA3 = _d[1];
101
101
  var _e = (0, react_1.useState)(false), isReady = _e[0], setIsReady = _e[1];
102
102
  var qrCodeRef = (0, react_1.useRef)(null);
103
103
  var theme = (0, material_1.useTheme)();
104
104
  var PLVrefA4 = (0, react_1.useRef)(null);
105
105
  var PLVrefA3 = (0, react_1.useRef)(null);
106
- //si sur l'impression des PLV en A4 ou A3 le Qrcode est flou,
106
+ //si sur l'impression des PLV en A4 ou A3 le Qrcode est flou,
107
107
  //il faut modifier la width et height, imageSize du qrCodeOptions et mettre les mêmes valeurs que dans le optionQrcode de la fonction printPLV
108
108
  var qrCodeOptions = (0, react_1.useMemo)(function () { return ({
109
109
  width: 300,
110
110
  height: 300,
111
- type: 'canvas',
111
+ type: "canvas",
112
112
  data: data,
113
113
  image: leaf_yellow_small_png_1.default,
114
114
  margin: 10,
115
115
  qrOptions: {
116
116
  typeNumber: 0,
117
- mode: 'Byte',
118
- errorCorrectionLevel: 'Q',
117
+ mode: "Byte",
118
+ errorCorrectionLevel: "Q",
119
119
  },
120
120
  imageOptions: {
121
121
  hideBackgroundDots: true,
@@ -124,18 +124,18 @@ var QrCodePLVContainer = function (_a) {
124
124
  },
125
125
  dotsOptions: {
126
126
  color: (0, material_1.darken)(theme.palette.primary.main, 0.4),
127
- type: 'square',
127
+ type: "square",
128
128
  },
129
129
  backgroundOptions: {
130
- color: 'white',
130
+ color: "white",
131
131
  },
132
132
  cornersSquareOptions: {
133
133
  color: (0, material_1.darken)(theme.palette.secondary.main, 0.2),
134
- type: 'square',
134
+ type: "square",
135
135
  },
136
136
  cornersDotOptions: {
137
137
  color: (0, material_1.darken)(theme.palette.secondary.main, 0.2),
138
- type: 'square',
138
+ type: "square",
139
139
  },
140
140
  }); }, [data, theme.palette]);
141
141
  var qrCode = (0, react_1.useMemo)(function () { return new qr_code_styling_1.default(qrCodeOptions); }, [qrCodeOptions]);
@@ -145,7 +145,7 @@ var QrCodePLVContainer = function (_a) {
145
145
  }
146
146
  }, [qrCode]);
147
147
  (0, react_1.useEffect)(function () {
148
- var urlA4 = printPLV('A4').then(function (url) {
148
+ var urlA4 = printPLV("A4").then(function (url) {
149
149
  setUrlA4(url);
150
150
  });
151
151
  }, [data]);
@@ -179,12 +179,12 @@ var QrCodePLVContainer = function (_a) {
179
179
  firstPage = pages[0];
180
180
  _a = firstPage.getSize(), width = _a.width, height = _a.height;
181
181
  optionQrcode = {};
182
- if (format === 'A3') {
182
+ if (format === "A3") {
183
183
  optionQrcode = {
184
184
  x: width - 427,
185
185
  y: 88,
186
186
  width: 349,
187
- height: 349
187
+ height: 349,
188
188
  };
189
189
  }
190
190
  else {
@@ -200,7 +200,7 @@ var QrCodePLVContainer = function (_a) {
200
200
  return [4 /*yield*/, pdfDoc.save()];
201
201
  case 7:
202
202
  modifiedPdfBytes = _b.sent();
203
- blob = new Blob([modifiedPdfBytes], { type: 'application/pdf' });
203
+ blob = new Blob([modifiedPdfBytes], { type: "application/pdf" });
204
204
  url = URL.createObjectURL(blob);
205
205
  loadingTask = (0, exports.getPdfDocument)(url);
206
206
  return [4 /*yield*/, loadingTask.promise];
@@ -209,8 +209,8 @@ var QrCodePLVContainer = function (_a) {
209
209
  return [4 /*yield*/, pdf.getPage(1)];
210
210
  case 9:
211
211
  page = _b.sent();
212
- canvas = document.createElement('canvas');
213
- context = canvas.getContext('2d');
212
+ canvas = document.createElement("canvas");
213
+ context = canvas.getContext("2d");
214
214
  viewport = page.getViewport({ scale: 3 });
215
215
  canvas.width = viewport.width;
216
216
  canvas.height = viewport.height;
@@ -221,7 +221,7 @@ var QrCodePLVContainer = function (_a) {
221
221
  return [4 /*yield*/, page.render(renderContext).promise];
222
222
  case 10:
223
223
  _b.sent();
224
- imageUrl = canvas.toDataURL('image/png');
224
+ imageUrl = canvas.toDataURL("image/png");
225
225
  setIsReady(true);
226
226
  return [2 /*return*/, imageUrl];
227
227
  }
@@ -230,31 +230,31 @@ var QrCodePLVContainer = function (_a) {
230
230
  }
231
231
  var downloadQRCodeHeadless = (0, react_1.useCallback)(function () {
232
232
  qrCode.download({
233
- extension: 'png',
234
- name: 'movalib-qr-code',
233
+ extension: "png",
234
+ name: "movalib-qr-code",
235
235
  });
236
236
  }, [qrCode.download]);
237
237
  var downloadQrCodeWithCTA = (0, react_1.useCallback)(function () {
238
238
  // Check if we have everything we need
239
- var qrCodeContainer = document.querySelector('#qr-code-container');
240
- var qrCodeDiv = qrCodeContainer === null || qrCodeContainer === void 0 ? void 0 : qrCodeContainer.querySelector('.qr-code');
241
- var qrCodeCanva = qrCodeDiv === null || qrCodeDiv === void 0 ? void 0 : qrCodeDiv.querySelector('canvas');
242
- var downloadedDiv = document.getElementById('qr-code-downloaded-container');
239
+ var qrCodeContainer = document.querySelector("#qr-code-container");
240
+ var qrCodeDiv = qrCodeContainer === null || qrCodeContainer === void 0 ? void 0 : qrCodeContainer.querySelector(".qr-code");
241
+ var qrCodeCanva = qrCodeDiv === null || qrCodeDiv === void 0 ? void 0 : qrCodeDiv.querySelector("canvas");
242
+ var downloadedDiv = document.getElementById("qr-code-downloaded-container");
243
243
  // If we don't have the QR Code, we can't download it
244
244
  if (!(qrCodeContainer && qrCodeDiv && qrCodeCanva && downloadedDiv)) {
245
245
  return;
246
246
  }
247
247
  var tmpRendered = downloadedDiv.cloneNode(true);
248
- tmpRendered.style.display = 'flex';
249
- var downloadedQrCodeImgContainer = tmpRendered.querySelector('#qr-code-img-container');
248
+ tmpRendered.style.display = "flex";
249
+ var downloadedQrCodeImgContainer = tmpRendered.querySelector("#qr-code-img-container");
250
250
  downloadedQrCodeImgContainer.append(qrCodeCanva);
251
251
  // add it to the document to be able to download it
252
252
  document.body.append(tmpRendered);
253
253
  // create the canva of the tmpRendered div and download it
254
254
  (0, html2canvas_1.default)(tmpRendered).then(function (canvas) {
255
- var a = document.createElement('a');
256
- a.download = 'movalib-qr-code.png';
257
- a.href = canvas.toDataURL('image/png');
255
+ var a = document.createElement("a");
256
+ a.download = "movalib-qr-code.png";
257
+ a.href = canvas.toDataURL("image/png");
258
258
  a.click();
259
259
  });
260
260
  // remove the tmpRendered div
@@ -263,8 +263,8 @@ var QrCodePLVContainer = function (_a) {
263
263
  qrCode.append(qrCodeRef.current);
264
264
  }, [qrCode.append]);
265
265
  var onChangeSelectedChoice = function (e) {
266
- if (e.target.value === 'A3' && !urlA3) {
267
- printPLV('A3').then(function (url) {
266
+ if (e.target.value === "A3" && !urlA3) {
267
+ printPLV("A3").then(function (url) {
268
268
  setUrlA3(url);
269
269
  });
270
270
  }
@@ -272,30 +272,43 @@ var QrCodePLVContainer = function (_a) {
272
272
  };
273
273
  var printA3PLV = (0, react_to_print_1.useReactToPrint)({
274
274
  content: function () { return PLVrefA3.current; },
275
- documentTitle: 'Movalib_PLV_A3',
275
+ documentTitle: "Movalib_PLV_A3",
276
276
  });
277
277
  var printA4PLV = (0, react_to_print_1.useReactToPrint)({
278
278
  content: function () { return PLVrefA4.current; },
279
- documentTitle: 'Movalib_PLV_A4',
279
+ documentTitle: "Movalib_PLV_A4",
280
280
  });
281
281
  var onClickDownload = (0, react_1.useMemo)(function () {
282
282
  switch (selectedChoice) {
283
- case 'A3':
283
+ case "A3":
284
284
  return printA3PLV;
285
- case 'A4':
285
+ case "A4":
286
286
  return printA4PLV;
287
- case 'QR_Headless':
287
+ case "QR_Headless":
288
288
  return downloadQRCodeHeadless;
289
- case 'QR_Google':
289
+ case "QR_Google":
290
290
  return downloadQrCodeWithCTA;
291
291
  default:
292
292
  return function () { };
293
293
  }
294
- }, [selectedChoice, downloadQRCodeHeadless, downloadQrCodeWithCTA, printA3PLV, printA4PLV]);
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: {
296
- height: '300px',
297
- width: '300px',
298
- maxWidth: '300px !important',
299
- }, className: 'qr-code' }) })), (0, jsx_runtime_1.jsx)(DownloadedQRCode_1.DownloadedQRCode, {})] })));
294
+ }, [
295
+ selectedChoice,
296
+ downloadQRCodeHeadless,
297
+ downloadQrCodeWithCTA,
298
+ printA3PLV,
299
+ printA4PLV,
300
+ ]);
301
+ 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 ||
302
+ ((selectedChoice === "A3" || selectedChoice === "A4") &&
303
+ !isReady), sx: {
304
+ color: (0, material_1.darken)(theme.palette.primary.main, 0.2),
305
+ borderRadius: "10rem",
306
+ } }, { children: selectedChoice === "A3" || selectedChoice === "A4"
307
+ ? "Imprimer"
308
+ : "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: {
309
+ height: "300px",
310
+ width: "300px",
311
+ maxWidth: "300px !important",
312
+ }, className: "qr-code" }) })), (0, jsx_runtime_1.jsx)(DownloadedQRCode_1.DownloadedQRCode, {})] })));
300
313
  };
301
314
  exports.QrCodePLVContainer = QrCodePLVContainer;
@@ -193,7 +193,8 @@ export declare enum EventType {
193
193
  UNAVAILABILITY = "UNAVAILABILITY",
194
194
  NOTE = "NOTE",
195
195
  PENDING_APPOINTMENT = "PENDING_APPOINTMENT",
196
- WAITING_VEHICLE = "WAITING_VEHICLE"
196
+ WAITING_VEHICLE = "WAITING_VEHICLE",
197
+ QUOTE = "QUOTE"
197
198
  }
198
199
  export declare enum DayOfWeek {
199
200
  MONDAY = "MONDAY",
@@ -209,6 +210,12 @@ export declare enum DocumentState {
209
210
  APPROVED = "APPROVED",
210
211
  REJECTED = "REJECTED"
211
212
  }
213
+ export declare enum QuoteState {
214
+ QUOTE_DRAFT = "QUOTE_DRAFT",
215
+ QUOTE_SENT = "QUOTE_SENT",
216
+ QUOTE_ACCEPTED = "QUOTE_ACCEPTED",
217
+ QUOTE_REJECTED = "QUOTE_REJECTED"
218
+ }
212
219
  export declare enum DocumentType {
213
220
  USER_BANK_DETAILS = "USER_BANK_DETAILS",
214
221
  USER_APPOINTMENT_QUOTE = "USER_APPOINTMENT_QUOTE",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoleType = exports.MovaAppType = exports.DocumentType = exports.DocumentState = exports.DayOfWeek = exports.EventType = exports.EventState = exports.DigitalPassportIndex = exports.Gender = exports.DateFormatTypes = exports.APIMethod = exports.PartsApplicationType = exports.ProductType = exports.OrderPreference = exports.OrderState = exports.SlotAlgorithm = exports.VehiclePlateFormat = exports.RegistrationState = exports.SubscriptionPaymentInterval = exports.PrestationType = exports.PrestationState = exports.CountryCode = exports.SubscriptionState = exports.SubscriptionType = exports.CustomerType = void 0;
3
+ exports.RoleType = exports.MovaAppType = exports.DocumentType = exports.QuoteState = exports.DocumentState = exports.DayOfWeek = exports.EventType = exports.EventState = exports.DigitalPassportIndex = exports.Gender = exports.DateFormatTypes = exports.APIMethod = exports.PartsApplicationType = exports.ProductType = exports.OrderPreference = exports.OrderState = exports.SlotAlgorithm = exports.VehiclePlateFormat = exports.RegistrationState = exports.SubscriptionPaymentInterval = exports.PrestationType = exports.PrestationState = exports.CountryCode = exports.SubscriptionState = exports.SubscriptionType = exports.CustomerType = void 0;
4
4
  var CustomerType;
5
5
  (function (CustomerType) {
6
6
  CustomerType["INDIVIDUAL"] = "INDIVIDUAL";
@@ -217,6 +217,7 @@ var EventType;
217
217
  EventType["NOTE"] = "NOTE";
218
218
  EventType["PENDING_APPOINTMENT"] = "PENDING_APPOINTMENT";
219
219
  EventType["WAITING_VEHICLE"] = "WAITING_VEHICLE";
220
+ EventType["QUOTE"] = "QUOTE";
220
221
  })(EventType = exports.EventType || (exports.EventType = {}));
221
222
  var DayOfWeek;
222
223
  (function (DayOfWeek) {
@@ -234,6 +235,13 @@ var DocumentState;
234
235
  DocumentState["APPROVED"] = "APPROVED";
235
236
  DocumentState["REJECTED"] = "REJECTED";
236
237
  })(DocumentState = exports.DocumentState || (exports.DocumentState = {}));
238
+ var QuoteState;
239
+ (function (QuoteState) {
240
+ QuoteState["QUOTE_DRAFT"] = "QUOTE_DRAFT";
241
+ QuoteState["QUOTE_SENT"] = "QUOTE_SENT";
242
+ QuoteState["QUOTE_ACCEPTED"] = "QUOTE_ACCEPTED";
243
+ QuoteState["QUOTE_REJECTED"] = "QUOTE_REJECTED";
244
+ })(QuoteState = exports.QuoteState || (exports.QuoteState = {}));
237
245
  var DocumentType;
238
246
  (function (DocumentType) {
239
247
  DocumentType["USER_BANK_DETAILS"] = "USER_BANK_DETAILS";
@@ -13,6 +13,10 @@ export default class Document {
13
13
  reference?: string;
14
14
  rejectReason?: string;
15
15
  validateToken?: string;
16
- constructor(id: string, ownerId: number, state: DocumentState, fileName: string, originalFileName: string, fileType: string, fileSignedUrl: string, type: DocumentType, creationDate?: Date, updateDate?: Date, reference?: string, validateToken?: string);
16
+ remindersCount?: number;
17
+ totalAmountInclVat?: number;
18
+ lastSendingTime?: Date;
19
+ firstSendingTime?: Date;
20
+ constructor(id: string, ownerId: number, state: DocumentState, fileName: string, originalFileName: string, fileType: string, fileSignedUrl: string, type: DocumentType, creationDate?: Date, updateDate?: Date, reference?: string, validateToken?: string, remindersCount?: number, totalAmountInclVat?: number, lastSendingTime?: Date, firstSendingTime?: Date);
17
21
  static findByTypeAndReference(documents: Document[], type: DocumentType, reference: string): Document | undefined;
18
22
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Document = /** @class */ (function () {
4
- function Document(id, ownerId, state, fileName, originalFileName, fileType, fileSignedUrl, type, creationDate, updateDate, reference, validateToken) {
4
+ function Document(id, ownerId, state, fileName, originalFileName, fileType, fileSignedUrl, type, creationDate, updateDate, reference, validateToken, remindersCount, totalAmountInclVat, lastSendingTime, firstSendingTime) {
5
5
  this.id = id;
6
6
  this.state = state;
7
7
  this.ownerId = ownerId;
@@ -14,6 +14,14 @@ var Document = /** @class */ (function () {
14
14
  this.updateDate = updateDate;
15
15
  this.reference = reference;
16
16
  this.validateToken = validateToken;
17
+ this.remindersCount = remindersCount;
18
+ this.totalAmountInclVat = totalAmountInclVat;
19
+ this.lastSendingTime = lastSendingTime
20
+ ? new Date(lastSendingTime)
21
+ : undefined;
22
+ this.firstSendingTime = firstSendingTime
23
+ ? new Date(firstSendingTime)
24
+ : undefined;
17
25
  }
18
26
  Document.findByTypeAndReference = function (documents, type, reference) {
19
27
  if (documents && type && reference) {
@@ -77,7 +77,12 @@ export default class Event {
77
77
  origin?: string;
78
78
  quoteLastSendingTime?: Date;
79
79
  invoiceSendingDate?: Date;
80
- constructor(id: string, ownerId: number, type: EventType, title: string, garageName: string, garageId: number, color: string, state: EventState, garageAddress?: Address, start?: Date, end?: Date, prestations?: Prestation[], operations?: Operation[], products?: Product[], guestsId?: string[], vehicleId?: number, quoteId?: number, notes?: string, vehicleAvailableNotified?: boolean, editable?: boolean, resourceId?: number, garageVehicleId?: number, garageVehicleRequest?: boolean, vehicleAvailableNotificationTime?: Date, interventionEndTime?: Date, quoteLastSendingTime?: Date, invoiceSendingDate?: Date, orders?: order[]);
80
+ creationDate?: Date;
81
+ updatedDate?: Date;
82
+ quoteFirstSendingTime?: Date;
83
+ lastQuoteCreationDate?: Date;
84
+ constructor(id: string, ownerId: number, type: EventType, title: string, garageName: string, garageId: number, color: string, state: EventState, garageAddress?: Address, start?: Date, end?: Date, prestations?: Prestation[], operations?: Operation[], products?: Product[], guestsId?: string[], vehicleId?: number, quoteId?: number, notes?: string, vehicleAvailableNotified?: boolean, editable?: boolean, resourceId?: number, garageVehicleId?: number, garageVehicleRequest?: boolean, vehicleAvailableNotificationTime?: Date, interventionEndTime?: Date, quoteLastSendingTime?: Date, invoiceSendingDate?: Date, orders?: order[], creationDate?: Date, updatedDate?: Date, lastQuoteCreationDate?: Date, quoteFirstSendingTime?: Date);
81
85
  static getPrestationsList(event: Event): string[];
86
+ static getCurrentQuote(event: Event): Document | null;
82
87
  }
83
88
  export {};
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Enums_1 = require("../helpers/Enums");
3
4
  var Event = /** @class */ (function () {
4
- function Event(id, ownerId, type, title, garageName, garageId, color, state, garageAddress, start, end, prestations, operations, products, guestsId, vehicleId, quoteId, notes, vehicleAvailableNotified, editable, resourceId, garageVehicleId, garageVehicleRequest, vehicleAvailableNotificationTime, interventionEndTime, quoteLastSendingTime, invoiceSendingDate, orders) {
5
+ function Event(id, ownerId, type, title, garageName, garageId, color, state, garageAddress, start, end, prestations, operations, products, guestsId, vehicleId, quoteId, notes, vehicleAvailableNotified, editable, resourceId, garageVehicleId, garageVehicleRequest, vehicleAvailableNotificationTime, interventionEndTime, quoteLastSendingTime, invoiceSendingDate, orders, creationDate, updatedDate, lastQuoteCreationDate, quoteFirstSendingTime) {
5
6
  this.id = id;
6
7
  this.notes = notes;
7
8
  this.ownerId = ownerId;
@@ -38,6 +39,14 @@ var Event = /** @class */ (function () {
38
39
  ? new Date(invoiceSendingDate)
39
40
  : undefined;
40
41
  this.orders = orders;
42
+ this.creationDate = creationDate ? new Date(creationDate) : undefined;
43
+ this.updatedDate = updatedDate ? new Date(updatedDate) : undefined;
44
+ this.lastQuoteCreationDate = lastQuoteCreationDate
45
+ ? new Date(lastQuoteCreationDate)
46
+ : undefined;
47
+ this.quoteFirstSendingTime = quoteFirstSendingTime
48
+ ? new Date(quoteFirstSendingTime)
49
+ : undefined;
41
50
  }
42
51
  Event.getPrestationsList = function (event) {
43
52
  if (event && event.prestations) {
@@ -45,6 +54,34 @@ var Event = /** @class */ (function () {
45
54
  }
46
55
  return [];
47
56
  };
57
+ Event.getCurrentQuote = function (event) {
58
+ var _a, _b, _c, _d;
59
+ if (event.documents) {
60
+ var quoteDocument = event.documents.filter(function (doc) { return doc.type === Enums_1.DocumentType.USER_APPOINTMENT_QUOTE; });
61
+ if (event.type === Enums_1.EventType.QUOTE) {
62
+ var state = event.state;
63
+ if (state === Enums_1.QuoteState.QUOTE_DRAFT ||
64
+ state === Enums_1.QuoteState.QUOTE_SENT) {
65
+ return ((_a = quoteDocument.find(function (doc) { return doc.state === Enums_1.DocumentState.PENDING; })) !== null && _a !== void 0 ? _a : null);
66
+ }
67
+ else if (state === Enums_1.QuoteState.QUOTE_REJECTED) {
68
+ return ((_b = quoteDocument
69
+ .filter(function (doc) { return doc.state === Enums_1.DocumentState.REJECTED; })
70
+ .sort(function (a, b) {
71
+ return new Date(b.creationDate).getTime() -
72
+ new Date(a.creationDate).getTime();
73
+ })[0]) !== null && _b !== void 0 ? _b : null);
74
+ }
75
+ else if (state === Enums_1.QuoteState.QUOTE_ACCEPTED) {
76
+ return ((_c = quoteDocument.find(function (doc) { return doc.state === Enums_1.DocumentState.APPROVED; })) !== null && _c !== void 0 ? _c : null);
77
+ }
78
+ }
79
+ else {
80
+ return ((_d = quoteDocument.find(function (doc) { return doc.state === Enums_1.DocumentState.APPROVED; })) !== null && _d !== void 0 ? _d : null);
81
+ }
82
+ }
83
+ return null;
84
+ };
48
85
  return Event;
49
86
  }());
50
87
  exports.default = Event;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.62.0",
3
+ "version": "1.62.1",
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",