@movalib/movalib-commons 1.62.0 → 1.62.2
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/dist/src/MovaLogin.d.ts +2 -2
- package/dist/src/MovaLogin.js +18 -22
- package/dist/src/components/QrCodePLVContainer/QrCodePLVContainer.d.ts +1 -1
- package/dist/src/components/QrCodePLVContainer/QrCodePLVContainer.js +58 -45
- package/dist/src/helpers/Enums.d.ts +8 -1
- package/dist/src/helpers/Enums.js +9 -1
- package/dist/src/helpers/Tools.d.ts +1 -0
- package/dist/src/helpers/Tools.js +26 -1
- package/dist/src/helpers/Validator.js +1 -1
- package/dist/src/models/Document.d.ts +5 -1
- package/dist/src/models/Document.js +9 -1
- package/dist/src/models/Event.d.ts +6 -1
- package/dist/src/models/Event.js +38 -1
- package/package.json +1 -1
- package/src/helpers/Tools.ts +25 -0
- package/src/helpers/Validator.ts +2 -2
package/dist/src/MovaLogin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AlertColor } from "@mui/material";
|
|
2
1
|
import { FunctionComponent, ReactNode } from "react";
|
|
3
|
-
import {
|
|
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
|
package/dist/src/MovaLogin.js
CHANGED
|
@@ -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
|
|
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;
|
|
@@ -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
|
-
|
|
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)(
|
|
100
|
-
var _d = (0, react_1.useState)(
|
|
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:
|
|
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:
|
|
118
|
-
errorCorrectionLevel:
|
|
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:
|
|
127
|
+
type: "square",
|
|
128
128
|
},
|
|
129
129
|
backgroundOptions: {
|
|
130
|
-
color:
|
|
130
|
+
color: "white",
|
|
131
131
|
},
|
|
132
132
|
cornersSquareOptions: {
|
|
133
133
|
color: (0, material_1.darken)(theme.palette.secondary.main, 0.2),
|
|
134
|
-
type:
|
|
134
|
+
type: "square",
|
|
135
135
|
},
|
|
136
136
|
cornersDotOptions: {
|
|
137
137
|
color: (0, material_1.darken)(theme.palette.secondary.main, 0.2),
|
|
138
|
-
type:
|
|
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(
|
|
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 ===
|
|
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:
|
|
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(
|
|
213
|
-
context = canvas.getContext(
|
|
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(
|
|
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:
|
|
234
|
-
name:
|
|
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(
|
|
240
|
-
var qrCodeDiv = qrCodeContainer === null || qrCodeContainer === void 0 ? void 0 : qrCodeContainer.querySelector(
|
|
241
|
-
var qrCodeCanva = qrCodeDiv === null || qrCodeDiv === void 0 ? void 0 : qrCodeDiv.querySelector(
|
|
242
|
-
var downloadedDiv = document.getElementById(
|
|
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 =
|
|
249
|
-
var downloadedQrCodeImgContainer = tmpRendered.querySelector(
|
|
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(
|
|
256
|
-
a.download =
|
|
257
|
-
a.href = canvas.toDataURL(
|
|
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 ===
|
|
267
|
-
printPLV(
|
|
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:
|
|
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:
|
|
279
|
+
documentTitle: "Movalib_PLV_A4",
|
|
280
280
|
});
|
|
281
281
|
var onClickDownload = (0, react_1.useMemo)(function () {
|
|
282
282
|
switch (selectedChoice) {
|
|
283
|
-
case
|
|
283
|
+
case "A3":
|
|
284
284
|
return printA3PLV;
|
|
285
|
-
case
|
|
285
|
+
case "A4":
|
|
286
286
|
return printA4PLV;
|
|
287
|
-
case
|
|
287
|
+
case "QR_Headless":
|
|
288
288
|
return downloadQRCodeHeadless;
|
|
289
|
-
case
|
|
289
|
+
case "QR_Google":
|
|
290
290
|
return downloadQrCodeWithCTA;
|
|
291
291
|
default:
|
|
292
292
|
return function () { };
|
|
293
293
|
}
|
|
294
|
-
}, [
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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";
|
|
@@ -7,6 +7,7 @@ export declare const getApplicationsShortLabels: (applications: PartsApplication
|
|
|
7
7
|
export declare const flexStart: CSSProperties;
|
|
8
8
|
export declare const isSafariOniOS: () => boolean;
|
|
9
9
|
export declare const isInvalidMobileNumber: (phoneNumber?: string) => boolean;
|
|
10
|
+
export declare const isInvalidPhoneNumber: (phoneNumber?: string) => boolean;
|
|
10
11
|
export declare const FR_WEEK_DAYS: string[];
|
|
11
12
|
export declare const getDayOfWeekLabel: (day: DayOfWeek) => string | undefined;
|
|
12
13
|
export declare const getDayOfWeekIndex: (day: DayOfWeek) => number;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateField = exports.formatVehicleTireStr = exports.formatVehicleTire = exports.formatFrenchVehiclePlate = exports.isEmpty = exports.flexCenter = exports.flexEnd = exports.getApplicationShortLabel = exports.capitalizeFirstLetter = exports.flexLeftRow = exports.getFrenchDayLabel = exports.getDayOfWeek = exports.findScheduleByDayOfWeek = exports.formatTime = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.getDayOfWeekIndex = exports.getDayOfWeekLabel = exports.FR_WEEK_DAYS = exports.isInvalidMobileNumber = exports.isSafariOniOS = exports.flexStart = exports.getApplicationsShortLabels = void 0;
|
|
6
|
+
exports.validateField = exports.formatVehicleTireStr = exports.formatVehicleTire = exports.formatFrenchVehiclePlate = exports.isEmpty = exports.flexCenter = exports.flexEnd = exports.getApplicationShortLabel = exports.capitalizeFirstLetter = exports.flexLeftRow = exports.getFrenchDayLabel = exports.getDayOfWeek = exports.findScheduleByDayOfWeek = exports.formatTime = exports.getFormattedIntervals = exports.getFormattedSchedule = exports.formatPhoneNumber = exports.getDayOfWeekIndex = exports.getDayOfWeekLabel = exports.FR_WEEK_DAYS = exports.isInvalidPhoneNumber = exports.isInvalidMobileNumber = exports.isSafariOniOS = exports.flexStart = exports.getApplicationsShortLabels = void 0;
|
|
7
7
|
var max_1 = __importDefault(require("libphonenumber-js/max"));
|
|
8
8
|
var Enums_1 = require("./Enums");
|
|
9
9
|
var getApplicationsShortLabels = function (applications) {
|
|
@@ -53,6 +53,31 @@ var isInvalidMobileNumber = function (phoneNumber) {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
exports.isInvalidMobileNumber = isInvalidMobileNumber;
|
|
56
|
+
var isInvalidPhoneNumber = function (phoneNumber) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (phoneNumber === void 0) { phoneNumber = ""; }
|
|
59
|
+
if (!phoneNumber || typeof phoneNumber !== "string")
|
|
60
|
+
return true;
|
|
61
|
+
// Nettoyage : supprime les espaces et convertit "00..." en "+..."
|
|
62
|
+
var cleaned = phoneNumber.replace(/\s+/g, "").replace(/^00/, "+");
|
|
63
|
+
// Si le numéro ne commence pas par +, on assume que c'est un numéro local français
|
|
64
|
+
var cleanedPhoneNumber = cleaned.startsWith("+")
|
|
65
|
+
? cleaned
|
|
66
|
+
: "+33".concat(cleaned.replace(/^0/, ""));
|
|
67
|
+
try {
|
|
68
|
+
var parsed = (0, max_1.default)(cleanedPhoneNumber);
|
|
69
|
+
var type = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.getType) === null || _a === void 0 ? void 0 : _a.call(parsed);
|
|
70
|
+
console.log(type);
|
|
71
|
+
console.log(parsed === null || parsed === void 0 ? void 0 : parsed.isValid());
|
|
72
|
+
console.log(["MOBILE", "MOBILE_OR_FIXED_LINE"].includes(type || ""));
|
|
73
|
+
return !((parsed === null || parsed === void 0 ? void 0 : parsed.isValid()) &&
|
|
74
|
+
["MOBILE", "MOBILE_OR_FIXED_LINE", "FIXED_LINE"].includes(type || ""));
|
|
75
|
+
}
|
|
76
|
+
catch (_b) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.isInvalidPhoneNumber = isInvalidPhoneNumber;
|
|
56
81
|
exports.FR_WEEK_DAYS = [
|
|
57
82
|
"Lundi",
|
|
58
83
|
"Mardi",
|
|
@@ -35,7 +35,7 @@ function validatePhoneNumber(phoneNumber) {
|
|
|
35
35
|
if (phoneNumber === null || phoneNumber === undefined || phoneNumber === "") {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
|
-
return !(0, Tools_1.
|
|
38
|
+
return !(0, Tools_1.isInvalidPhoneNumber)(phoneNumber);
|
|
39
39
|
}
|
|
40
40
|
exports.validatePhoneNumber = validatePhoneNumber;
|
|
41
41
|
function validateText(text) {
|
|
@@ -13,6 +13,10 @@ export default class Document {
|
|
|
13
13
|
reference?: string;
|
|
14
14
|
rejectReason?: string;
|
|
15
15
|
validateToken?: string;
|
|
16
|
-
|
|
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
|
-
|
|
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 {};
|
package/dist/src/models/Event.js
CHANGED
|
@@ -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
package/src/helpers/Tools.ts
CHANGED
|
@@ -58,6 +58,31 @@ export const isInvalidMobileNumber = (phoneNumber = "") => {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
export const isInvalidPhoneNumber = (phoneNumber = "") => {
|
|
62
|
+
if (!phoneNumber || typeof phoneNumber !== "string") return true;
|
|
63
|
+
|
|
64
|
+
// Nettoyage : supprime les espaces et convertit "00..." en "+..."
|
|
65
|
+
const cleaned = phoneNumber.replace(/\s+/g, "").replace(/^00/, "+");
|
|
66
|
+
// Si le numéro ne commence pas par +, on assume que c'est un numéro local français
|
|
67
|
+
const cleanedPhoneNumber = cleaned.startsWith("+")
|
|
68
|
+
? cleaned
|
|
69
|
+
: `+33${cleaned.replace(/^0/, "")}`;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const parsed = parsePhoneNumberFromString(cleanedPhoneNumber);
|
|
73
|
+
const type = parsed?.getType?.();
|
|
74
|
+
console.log(type);
|
|
75
|
+
console.log(parsed?.isValid());
|
|
76
|
+
console.log(["MOBILE", "MOBILE_OR_FIXED_LINE"].includes(type || ""));
|
|
77
|
+
return !(
|
|
78
|
+
parsed?.isValid() &&
|
|
79
|
+
["MOBILE", "MOBILE_OR_FIXED_LINE", "FIXED_LINE"].includes(type || "")
|
|
80
|
+
);
|
|
81
|
+
} catch {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
61
86
|
export const FR_WEEK_DAYS: string[] = [
|
|
62
87
|
"Lundi",
|
|
63
88
|
"Mardi",
|
package/src/helpers/Validator.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isInvalidPhoneNumber } from "./Tools";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Un email valide
|
|
@@ -41,7 +41,7 @@ export function validatePhoneNumber(phoneNumber: string): boolean {
|
|
|
41
41
|
if (phoneNumber === null || phoneNumber === undefined || phoneNumber === "") {
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
|
-
return !
|
|
44
|
+
return !isInvalidPhoneNumber(phoneNumber);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function validateText(text: string): boolean {
|