@movalib/movalib-commons 1.55.4 → 1.55.6

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/PV_README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # 2. publish this movalib commons lib (public)
6
6
 
7
- ### `npm login`
7
+ ### `npm login` // if you have token in .npmrc this commande is useless
8
8
  ### `npm publish --access=public`
9
9
 
10
10
  # 3. publish this movalib commons lib (private)
package/dist/index.d.ts CHANGED
@@ -51,3 +51,4 @@ export { validatePhoneNumber, validateText, validateEmail } from './src/helpers/
51
51
  export { formatDateByCountryCode, getLongFormattedDateTime } from './src/helpers/DateUtils';
52
52
  export { request, API_BASE_URL } from './src/helpers/ApiHelper';
53
53
  export { RoleType, MovaAppType, DayOfWeek, EventState, EventType, DocumentType, DigitalPassportIndex, DocumentState, Gender, DateFormatTypes, PartsApplicationType, ProductType, OrderPreference, OrderState, SlotAlgorithm, VehiclePlateFormat as VehiclePlateType, SubscriptionPaymentInterval, RegistrationState, PrestationType, PrestationState, CountryCode, SubscriptionState, SubscriptionType, APIMethod, } from './src/helpers/Enums';
54
+ export { openDialogPrint } from './src/utils/DialogPrint';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.formatFrenchVehiclePlate = exports.formatVehicleTire = exports.validateField = exports.deleteCookie = exports.readCookie = exports.VehicleTire = exports.Event = exports.Schedule = exports.Garage = exports.Document = exports.Vehicle = exports.Address = exports.Role = exports.User = exports.Customer = exports.Logger = exports.Operation = exports.Prestation = exports.Product = exports.Supplier = exports.Employee = exports.Absence = exports.Subscription = exports.PrintSize = exports.PLVComponent = exports.QrCodePLVContainer = exports.GenderSelector = exports.ConfirmationDialog = exports.MovaVehicleTireField = exports.MovaCopyright = exports.MovaSignUp = exports.MovaLogin = exports.MovaSnackbar = exports.TestButton = exports.VehiclePlateField = exports.QRCode = exports.MovaDialog = exports.Loader = exports.MovaDigitalPassport = exports.VehicleFullCard = exports.ScheduleFields = exports.AddressFields = exports.AccountValidation = exports.GaragePLV = exports.IbanInput = exports.DialogForgotPassword = exports.UserService = exports.GarageService = exports.AuthenticationService = exports.VehicleService = void 0;
8
- exports.APIMethod = exports.SubscriptionType = exports.SubscriptionState = exports.CountryCode = exports.PrestationState = exports.PrestationType = exports.RegistrationState = exports.SubscriptionPaymentInterval = exports.VehiclePlateType = exports.SlotAlgorithm = exports.OrderState = exports.OrderPreference = exports.ProductType = exports.PartsApplicationType = exports.DateFormatTypes = exports.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.API_BASE_URL = exports.request = exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.getApplicationsShortLabels = exports.isSafariOniOS = exports.getDayOfWeekLabel = exports.findScheduleByDayOfWeek = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.flexLeftRow = exports.capitalizeFirstLetter = exports.getApplicationShortLabel = exports.isEmpty = void 0;
8
+ exports.openDialogPrint = exports.APIMethod = exports.SubscriptionType = exports.SubscriptionState = exports.CountryCode = exports.PrestationState = exports.PrestationType = exports.RegistrationState = exports.SubscriptionPaymentInterval = exports.VehiclePlateType = exports.SlotAlgorithm = exports.OrderState = exports.OrderPreference = exports.ProductType = exports.PartsApplicationType = exports.DateFormatTypes = exports.Gender = exports.DocumentState = exports.DigitalPassportIndex = exports.DocumentType = exports.EventType = exports.EventState = exports.DayOfWeek = exports.MovaAppType = exports.RoleType = exports.API_BASE_URL = exports.request = exports.getLongFormattedDateTime = exports.formatDateByCountryCode = exports.validateEmail = exports.validateText = exports.validatePhoneNumber = exports.getApplicationsShortLabels = exports.isSafariOniOS = exports.getDayOfWeekLabel = exports.findScheduleByDayOfWeek = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.flexLeftRow = exports.capitalizeFirstLetter = exports.getApplicationShortLabel = exports.isEmpty = void 0;
9
9
  // Export des services
10
10
  var VehicleService_1 = require("./src/services/VehicleService");
11
11
  Object.defineProperty(exports, "VehicleService", { enumerable: true, get: function () { return __importDefault(VehicleService_1).default; } });
@@ -153,3 +153,6 @@ Object.defineProperty(exports, "CountryCode", { enumerable: true, get: function
153
153
  Object.defineProperty(exports, "SubscriptionState", { enumerable: true, get: function () { return Enums_1.SubscriptionState; } });
154
154
  Object.defineProperty(exports, "SubscriptionType", { enumerable: true, get: function () { return Enums_1.SubscriptionType; } });
155
155
  Object.defineProperty(exports, "APIMethod", { enumerable: true, get: function () { return Enums_1.APIMethod; } });
156
+ // Export des utils
157
+ var DialogPrint_1 = require("./src/utils/DialogPrint");
158
+ Object.defineProperty(exports, "openDialogPrint", { enumerable: true, get: function () { return DialogPrint_1.openDialogPrint; } });
@@ -13,4 +13,7 @@ type PLVComponentProps = {
13
13
  export declare class PLVComponent extends React.Component<PLVComponentProps> {
14
14
  render(): import("react/jsx-runtime").JSX.Element;
15
15
  }
16
+ export declare class PLVComponentV2 extends React.Component<PLVComponentProps> {
17
+ render(): import("react/jsx-runtime").JSX.Element;
18
+ }
16
19
  export {};
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.PLVComponent = exports.PrintSize = void 0;
32
+ exports.PLVComponentV2 = exports.PLVComponent = exports.PrintSize = void 0;
33
33
  var jsx_runtime_1 = require("react/jsx-runtime");
34
34
  var material_1 = require("@mui/material");
35
35
  var react_1 = __importDefault(require("react"));
@@ -138,8 +138,22 @@ var PLVComponent = /** @class */ (function (_super) {
138
138
  return PLVComponent;
139
139
  }(react_1.default.Component));
140
140
  exports.PLVComponent = PLVComponent;
141
+ var PLVComponentV2 = /** @class */ (function (_super) {
142
+ __extends(PLVComponentV2, _super);
143
+ function PLVComponentV2() {
144
+ return _super !== null && _super.apply(this, arguments) || this;
145
+ }
146
+ PLVComponentV2.prototype.render = function () {
147
+ return ((0, jsx_runtime_1.jsx)("div", __assign({ className: 'printable-content', style: {
148
+ width: this.props.printSize === PrintSize.A4 ? '210mm' : this.props.printSize === PrintSize.A3 ? '297mm' : '0mm',
149
+ height: this.props.printSize === PrintSize.A4 ? '297mm' : this.props.printSize === PrintSize.A3 ? '420mm' : '0mm',
150
+ } }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)("img", { src: this.props.url, style: { display: 'block', width: '100%', height: '100%', objectFit: 'cover' } }) })) })) })));
151
+ };
152
+ return PLVComponentV2;
153
+ }(react_1.default.Component));
154
+ exports.PLVComponentV2 = PLVComponentV2;
141
155
  // CSS pour cacher le contenu à l'écran mais le rendre imprimable
142
- var css = "\n .highlight {\n background-color: #BCD46C; /* Couleur de surlignage */\n margin: 4px 4px; /* Espacement autour du texte surlign\u00E9 */\n padding-left : 8px;\n padding-right: 8px;\n font-weight: 500;\n color: white;\n }\n .not-highlight {\n margin: 4px 4px; /* Espacement autour du texte surlign\u00E9 */\n padding-left : 8px;\n padding-right: 8px;\n color: #BCD46C;\n }\n\n .printable-content {\n visibility: hidden;\n position: absolute;\n left: -10000px;\n top: -10000px;\n }\n @media print {\n .printable-content {\n visibility: visible;\n position: static;\n }\n }\n";
156
+ var css = "\nbody {\n margin: 0;\n }\n .highlight {\n background-color: #BCD46C; /* Couleur de surlignage */\n margin: 4px 4px; /* Espacement autour du texte surlign\u00E9 */\n padding-left : 8px;\n padding-right: 8px;\n font-weight: 500;\n color: white;\n }\n .not-highlight {\n margin: 4px 4px; /* Espacement autour du texte surlign\u00E9 */\n padding-left : 8px;\n padding-right: 8px;\n color: #BCD46C;\n }\n\n .printable-content {\n margin: 0;\n padding: 0;\n visibility: hidden;\n position: absolute;\n left: -10000px;\n top: -10000px;\n\n }\n @media print {\n body {\n margin: 0;\n }\n .printable-content {\n margin: 0;\n padding: 0;\n visibility: visible;\n position: static;\n }\n }\n";
143
157
  var styleSheet = document.createElement('style');
144
158
  styleSheet.innerText = css;
145
159
  document.head.appendChild(styleSheet);
@@ -10,6 +10,65 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
13
72
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
73
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
74
  };
@@ -26,14 +85,21 @@ var react_to_print_1 = require("react-to-print");
26
85
  var DownloadedQRCode_1 = require("../../DownloadedQRCode");
27
86
  var leaf_yellow_small_png_1 = __importDefault(require("../../assets/images/leaf_yellow_small.png"));
28
87
  var Tools_1 = require("../../helpers/Tools");
88
+ var pdf_lib_1 = require("pdf-lib");
29
89
  var PLVComponent_1 = require("./PLVComponent");
90
+ var pdfjsLib = __importStar(require("pdfjs-dist"));
91
+ pdfjsLib.GlobalWorkerOptions.workerSrc = '/pdf.worker.mjs';
30
92
  var QrCodePLVContainer = function (_a) {
31
93
  var data = _a.data;
32
94
  var _b = (0, react_1.useState)(null), selectedChoice = _b[0], setSelectedChoice = _b[1];
95
+ var _c = (0, react_1.useState)(''), urlA4 = _c[0], setUrlA4 = _c[1];
96
+ var _d = (0, react_1.useState)(''), urlA3 = _d[0], setUrlA3 = _d[1];
33
97
  var qrCodeRef = (0, react_1.useRef)(null);
98
+ var theme = (0, material_1.useTheme)();
34
99
  var PLVrefA4 = (0, react_1.useRef)(null);
35
100
  var PLVrefA3 = (0, react_1.useRef)(null);
36
- var theme = (0, material_1.useTheme)();
101
+ //si sur l'impression des PLV en A4 ou A3 le Qrcode est flou,
102
+ //il faut modifier la width et height, imageSize du qrCodeOptions et mettre les mêmes valeurs que dans le optionQrcode de la fonction printPLV
37
103
  var qrCodeOptions = (0, react_1.useMemo)(function () { return ({
38
104
  width: 300,
39
105
  height: 300,
@@ -73,14 +139,91 @@ var QrCodePLVContainer = function (_a) {
73
139
  qrCode.append(qrCodeRef.current);
74
140
  }
75
141
  }, [qrCode]);
76
- var printA4PLV = (0, react_to_print_1.useReactToPrint)({
77
- content: function () { return PLVrefA4.current; },
78
- documentTitle: 'Movalib_PLV_A4',
79
- });
80
- var printA3PLV = (0, react_to_print_1.useReactToPrint)({
81
- content: function () { return PLVrefA3.current; },
82
- documentTitle: 'Movalib_PLV_A3',
83
- });
142
+ (0, react_1.useEffect)(function () {
143
+ var urlA4 = printPLV('A4').then(function (url) {
144
+ setUrlA4(url);
145
+ });
146
+ var urlA3 = printPLV('A3').then(function (url) {
147
+ setUrlA3(url);
148
+ });
149
+ }, [data]);
150
+ function printPLV(format) {
151
+ return __awaiter(this, void 0, void 0, function () {
152
+ 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;
153
+ return __generator(this, function (_b) {
154
+ switch (_b.label) {
155
+ case 0:
156
+ pdfUrl = "/Movalib_".concat(format, ".pdf");
157
+ return [4 /*yield*/, fetch(pdfUrl)];
158
+ case 1:
159
+ response = _b.sent();
160
+ return [4 /*yield*/, response.arrayBuffer()];
161
+ case 2:
162
+ existingPdfBytes = _b.sent();
163
+ return [4 /*yield*/, pdf_lib_1.PDFDocument.load(existingPdfBytes)];
164
+ case 3:
165
+ pdfDoc = _b.sent();
166
+ return [4 /*yield*/, qrCode.getRawData("png")];
167
+ case 4:
168
+ qrCodeBlob = _b.sent();
169
+ return [4 /*yield*/, (qrCodeBlob === null || qrCodeBlob === void 0 ? void 0 : qrCodeBlob.arrayBuffer())];
170
+ case 5:
171
+ qrImageBytes = _b.sent();
172
+ return [4 /*yield*/, pdfDoc.embedPng(qrImageBytes)];
173
+ case 6:
174
+ qrImage = _b.sent();
175
+ pages = pdfDoc.getPages();
176
+ firstPage = pages[0];
177
+ _a = firstPage.getSize(), width = _a.width, height = _a.height;
178
+ optionQrcode = {};
179
+ if (format === 'A3') {
180
+ optionQrcode = {
181
+ x: width - 427,
182
+ y: 88,
183
+ width: 349,
184
+ height: 349
185
+ };
186
+ }
187
+ else {
188
+ optionQrcode = {
189
+ x: width - 303,
190
+ y: 54,
191
+ width: 245,
192
+ height: 245,
193
+ };
194
+ }
195
+ // AJouter le QR code à la première page du PDF
196
+ firstPage.drawImage(qrImage, optionQrcode);
197
+ return [4 /*yield*/, pdfDoc.save()];
198
+ case 7:
199
+ modifiedPdfBytes = _b.sent();
200
+ blob = new Blob([modifiedPdfBytes], { type: 'application/pdf' });
201
+ url = URL.createObjectURL(blob);
202
+ loadingTask = pdfjsLib.getDocument(url);
203
+ return [4 /*yield*/, loadingTask.promise];
204
+ case 8:
205
+ pdf = _b.sent();
206
+ return [4 /*yield*/, pdf.getPage(1)];
207
+ case 9:
208
+ page = _b.sent();
209
+ canvas = document.createElement('canvas');
210
+ context = canvas.getContext('2d');
211
+ viewport = page.getViewport({ scale: 1.5 });
212
+ canvas.width = viewport.width;
213
+ canvas.height = viewport.height;
214
+ renderContext = {
215
+ canvasContext: context,
216
+ viewport: viewport,
217
+ };
218
+ return [4 /*yield*/, page.render(renderContext).promise];
219
+ case 10:
220
+ _b.sent();
221
+ imageUrl = canvas.toDataURL('image/png');
222
+ return [2 /*return*/, imageUrl];
223
+ }
224
+ });
225
+ });
226
+ }
84
227
  var downloadQRCodeHeadless = (0, react_1.useCallback)(function () {
85
228
  qrCode.download({
86
229
  extension: 'png',
@@ -118,6 +261,14 @@ var QrCodePLVContainer = function (_a) {
118
261
  var onChangeSelectedChoice = function (e) {
119
262
  setSelectedChoice(e.target.value);
120
263
  };
264
+ var printA3PLV = (0, react_to_print_1.useReactToPrint)({
265
+ content: function () { return PLVrefA3.current; },
266
+ documentTitle: 'Movalib_PLV_A3',
267
+ });
268
+ var printA4PLV = (0, react_to_print_1.useReactToPrint)({
269
+ content: function () { return PLVrefA4.current; },
270
+ documentTitle: 'Movalib_PLV_A4',
271
+ });
121
272
  var onClickDownload = (0, react_1.useMemo)(function () {
122
273
  switch (selectedChoice) {
123
274
  case 'A3':
@@ -131,8 +282,8 @@ var QrCodePLVContainer = function (_a) {
131
282
  default:
132
283
  return function () { };
133
284
  }
134
- }, [selectedChoice, printA3PLV, printA4PLV, downloadQRCodeHeadless, downloadQrCodeWithCTA]);
135
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '24px' }, { children: [(0, jsx_runtime_1.jsx)(PLVComponent_1.PLVComponent, { ref: PLVrefA4, url: data, printSize: PLVComponent_1.PrintSize.A4 }), (0, jsx_runtime_1.jsx)(PLVComponent_1.PLVComponent, { ref: PLVrefA3, url: data, 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: 'A3' }, { children: "\uD83E\uDDFE\u00A0\u00A0PLV format A4" })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: 'A4' }, { 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: {
285
+ }, [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: {
136
287
  height: '300px',
137
288
  width: '300px',
138
289
  maxWidth: '300px !important',
@@ -19,7 +19,6 @@ function handleResponse(response) {
19
19
  var contentType = response.headers.get("content-type");
20
20
  var isJson = contentType && contentType.includes("application/json");
21
21
  var dataPromise = isJson ? response.json() : response.text();
22
- var location = response.headers.get('location');
23
22
  return dataPromise.then(function (data) {
24
23
  if (!response.ok) {
25
24
  Logger_1.default.error(data);
@@ -40,7 +39,7 @@ function handleResponse(response) {
40
39
  }
41
40
  return { success: false, error: errorMsg };
42
41
  }
43
- return { success: true, data: data, location: location };
42
+ return { success: true, data: data };
44
43
  });
45
44
  }
46
45
  /**
@@ -1,3 +1,4 @@
1
+ /// <reference types="date-fns" />
1
2
  import { DateFormatTypes } from './Enums';
2
3
  export declare const countryTimeZones: {
3
4
  [key: string]: string;
@@ -0,0 +1 @@
1
+ export declare function openDialogPrint(url: string): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openDialogPrint = void 0;
4
+ function openDialogPrint(url) {
5
+ // Créer un iframe pour charger le document Blob => url
6
+ var iframe = document.createElement('iframe');
7
+ iframe.style.position = 'absolute';
8
+ iframe.style.width = '0px';
9
+ iframe.style.height = '0px';
10
+ iframe.src = url;
11
+ document.body.appendChild(iframe);
12
+ // Ouvrir la boîte de dialogue d'impression lorsque l'iframe est chargée
13
+ iframe.onload = function () {
14
+ var _a;
15
+ (_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.print();
16
+ };
17
+ // Supprimer l'iframe une fois lque la dialog est fermer
18
+ iframe.onclose = function () {
19
+ document.body.removeChild(iframe);
20
+ URL.revokeObjectURL(url);
21
+ };
22
+ }
23
+ exports.openDialogPrint = openDialogPrint;
package/index.ts CHANGED
@@ -111,3 +111,6 @@ export {
111
111
  SubscriptionType,
112
112
  APIMethod,
113
113
  } from './src/helpers/Enums';
114
+
115
+ // Export des utils
116
+ export { openDialogPrint } from './src/utils/DialogPrint';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.55.4",
3
+ "version": "1.55.6",
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",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@emotion/react": "^11.11.1",
20
20
  "@emotion/styled": "^11.11.0",
21
- "@mui/icons-material": "^5.11.16",
21
+ "@mui/icons-material": "^5.11.17",
22
22
  "@mui/lab": "^5.0.0-alpha.134",
23
23
  "@mui/material": "^5.13.5",
24
24
  "@mui/x-date-pickers": "^6.9.1",
@@ -30,6 +30,8 @@
30
30
  "file-loader": "^6.2.0",
31
31
  "html2canvas": "^1.4.1",
32
32
  "js-cookie": "^3.0.5",
33
+ "pdf-lib": "^1.17.1",
34
+ "pdfjs-dist": "^4.6.82",
33
35
  "qr-code-styling": "^1.4.4",
34
36
  "react": "^18.2.0",
35
37
  "react-dom": "^18.2.0",
@@ -40,10 +42,13 @@
40
42
  "typescript": "^4.9.5"
41
43
  },
42
44
  "eslintConfig": {
43
- "extends": ["react-app"]
45
+ "extends": [
46
+ "react-app"
47
+ ]
44
48
  },
45
49
  "devDependencies": {
46
50
  "@types/js-cookie": "^3.0.4",
51
+ "@types/pdfjs-dist": "^2.10.377",
47
52
  "@types/react-input-mask": "^3.0.5",
48
53
  "html-webpack-plugin": "^5.5.3",
49
54
  "ts-loader": "^9.4.4",
Binary file
Binary file