@movalib/movalib-commons 1.1.88 → 1.1.91

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/devIndex.tsx CHANGED
@@ -74,7 +74,7 @@ const App = () => {
74
74
  const getQRCodeData = ():string => {
75
75
  // On renvoie les données pour le QR Code, l'url change selon l'environnement (variables d'environnement)
76
76
  //return `https://app.movalib.com/#/garage/2?redirect=garage`;
77
- return `https://app.movalib.com/#/garage/4`;
77
+ return `https://app.movalib.com/#/garage/9`;
78
78
  }
79
79
 
80
80
  const handleScheduleChange = (schedule: DaySchedule[]) => {
@@ -194,7 +194,7 @@ const App = () => {
194
194
  </Box>
195
195
 
196
196
 
197
- {openAccountValidation && <AccountValidation smsValidation={true} resetPassword={false} movaAppType={MovaAppType.GARAGE}
197
+ {openAccountValidation && <AccountValidation smsValidation={false} resetPassword={false} movaAppType={MovaAppType.INDIVIDUAL}
198
198
  onSubmit={function (success: boolean, message: string): void {
199
199
  throw new Error('Function not implemented.');
200
200
  } } onResendSecurityCode={function (success: boolean, message: string): void {
package/dist/devIndex.js CHANGED
@@ -100,7 +100,7 @@ var App = function () {
100
100
  var getQRCodeData = function () {
101
101
  // On renvoie les données pour le QR Code, l'url change selon l'environnement (variables d'environnement)
102
102
  //return `https://app.movalib.com/#/garage/2?redirect=garage`;
103
- return "https://app.movalib.com/#/garage/4";
103
+ return "https://app.movalib.com/#/garage/9";
104
104
  };
105
105
  var handleScheduleChange = function (schedule) {
106
106
  if (schedule) {
@@ -160,7 +160,7 @@ var App = function () {
160
160
  throw new Error('Function not implemented.');
161
161
  } }), (0, jsx_runtime_1.jsx)("br", {}), " ", (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(IbanInput_1.default, { onIbanChange: function (iban) {
162
162
  throw new Error('Function not implemented.');
163
- } })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ style: Tools_1.flexCenter }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: function () { return setOpenAccountValidation(!openAccountValidation); } }, { children: "Validation de compte" })) })), openAccountValidation && (0, jsx_runtime_1.jsx)(AccountValidation_1.default, { smsValidation: true, resetPassword: false, movaAppType: Enums_1.MovaAppType.GARAGE, onSubmit: function (success, message) {
163
+ } })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ style: Tools_1.flexCenter }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ onClick: function () { return setOpenAccountValidation(!openAccountValidation); } }, { children: "Validation de compte" })) })), openAccountValidation && (0, jsx_runtime_1.jsx)(AccountValidation_1.default, { smsValidation: false, resetPassword: false, movaAppType: Enums_1.MovaAppType.INDIVIDUAL, onSubmit: function (success, message) {
164
164
  throw new Error('Function not implemented.');
165
165
  }, onResendSecurityCode: function (success, message) {
166
166
  throw new Error('Function not implemented.');
@@ -36,13 +36,18 @@ var initialFormState = {
36
36
  confirmation: { value: '', isValid: true },
37
37
  securityCode: { value: '', isValid: true },
38
38
  phoneNumber: { value: '', isValid: true },
39
+ acceptsTerms: { value: false, isValid: true },
39
40
  };
41
+ // ATTENTION : s'assurer de la présence des documents suivants à la racine du composant porteur (dossier 'public')
42
+ var CGUPath = "/Movalib_CGU.pdf";
43
+ var proCGUPath = "/Movalib_Pro_CGU.pdf";
44
+ var proCGVPath = "/Movalib_Pro_CGV.pdf";
40
45
  var AccountValidation = function (_a) {
41
46
  var _b, _c, _d, _e;
42
47
  var movaAppType = _a.movaAppType, smsValidation = _a.smsValidation, resetPassword = _a.resetPassword, onSubmit = _a.onSubmit, onResendSecurityCode = _a.onResendSecurityCode;
43
48
  var _f = (0, react_1.useState)(true), loading = _f[0], setLoading = _f[1];
44
49
  var _g = (0, react_1.useState)(initialFormState), validationForm = _g[0], setValidationForm = _g[1];
45
- var location = (0, react_router_dom_1.useLocation)();
50
+ //const location = useLocation();
46
51
  var history = (0, react_router_dom_1.useHistory)();
47
52
  var theme = (0, material_1.useTheme)();
48
53
  var _h = (0, react_1.useState)(false), emptyPwd = _h[0], setEmptyPwd = _h[1];
@@ -50,17 +55,19 @@ var AccountValidation = function (_a) {
50
55
  var _k = (0, react_1.useState)(false), openPhoneNumberInput = _k[0], setOpenPhoneNumberInput = _k[1];
51
56
  var isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
52
57
  (0, react_1.useEffect)(function () {
53
- var params = new URLSearchParams(location.search);
54
- var token = params.get('token');
55
- // Si cette variable est transmise, cela signifie que le compte a été créé sans mot de passe
56
- var localEmptyPwd = Boolean(params.get('emptyPwd'));
57
- setEmptyPwd(localEmptyPwd);
58
- if (token && !resetPassword) {
59
- if (!localEmptyPwd) {
60
- var req = {
61
- token: token
62
- };
63
- activateUserAccount(req);
58
+ var params = location !== undefined ? new URLSearchParams(location.search) : undefined;
59
+ if (params !== undefined) {
60
+ var token = params.get('token');
61
+ // Si cette variable est transmise, cela signifie que le compte a été créé sans mot de passe
62
+ var localEmptyPwd = Boolean(params.get('emptyPwd'));
63
+ setEmptyPwd(localEmptyPwd);
64
+ if (token && !resetPassword) {
65
+ if (!localEmptyPwd) {
66
+ var req = {
67
+ token: token
68
+ };
69
+ activateUserAccount(req);
70
+ }
64
71
  }
65
72
  }
66
73
  }, [location]);
@@ -125,6 +132,13 @@ var AccountValidation = function (_a) {
125
132
  setValidationForm(__assign(__assign({}, validationForm), newField));
126
133
  }
127
134
  };
135
+ var handleCheckboxChange = function (e, checked) {
136
+ var _a;
137
+ var fieldName = e.target.name;
138
+ var fieldValue = checked;
139
+ var newField = (_a = {}, _a[fieldName] = { value: fieldValue, isValid: true }, _a);
140
+ setValidationForm(__assign(__assign({}, validationForm), newField));
141
+ };
128
142
  var validateForm = function () {
129
143
  var newForm = __assign({}, validationForm);
130
144
  // Validator pour les champs obligatoires
@@ -139,8 +153,11 @@ var AccountValidation = function (_a) {
139
153
  // Validator pour le code de sécurité
140
154
  if (smsValidation)
141
155
  newForm.securityCode = (0, Tools_1.validateField)(validationForm.securityCode, function (value) { return value.length === 6; }, "Le code doit contenir 6 chiffres");
156
+ // Validator pour les CGU
157
+ newForm.acceptsTerms = (0, Tools_1.validateField)(validationForm.acceptsTerms, function (value) { return Boolean(value); }, movaAppType == Enums_1.MovaAppType.GARAGE ? 'Vous devez accepter les termes de nos CGU et de nos CGV' : 'Vous devez accepter les termes de nos CGU');
142
158
  setValidationForm(newForm);
143
- return newForm.password.isValid && newForm.confirmation.isValid && (smsValidation ? newForm.securityCode.isValid : true);
159
+ return newForm.password.isValid && newForm.confirmation.isValid && (smsValidation ? newForm.securityCode.isValid : true) &&
160
+ newForm.acceptsTerms.isValid;
144
161
  };
145
162
  var handleValidateAccount = function () {
146
163
  if (validateForm()) {
@@ -214,8 +231,8 @@ var AccountValidation = function (_a) {
214
231
  });
215
232
  }
216
233
  };
217
- return ((0, jsx_runtime_1.jsxs)("div", { children: [(emptyPwd || smsValidation || resetPassword) &&
218
- (0, jsx_runtime_1.jsx)(MovaDialog_1.default, __assign({ leafImageColor: 'pink', titleStyle: getTitleStyle(), fullScreen: isMobile, open: emptyPwd || smsValidation || resetPassword, closable: false, onClose: function () {
234
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(emptyPwd || smsValidation || resetPassword || true) &&
235
+ (0, jsx_runtime_1.jsx)(MovaDialog_1.default, __assign({ leafImageColor: 'pink', titleStyle: getTitleStyle(), fullScreen: isMobile, open: emptyPwd || smsValidation || resetPassword || true, closable: false, onClose: function () {
219
236
  throw new Error('Function not implemented.');
220
237
  }, actions: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, __assign({ type: "submit", onClick: handleValidateAccount, fullWidth: true, variant: "contained", sx: { mt: 4, mb: 0 } }, { children: resetPassword ? (0, jsx_runtime_1.jsx)("span", { children: "R\u00E9initialiser mon mot de passe" }) : (0, jsx_runtime_1.jsx)("span", { children: "Activer mon compte" }) })) }, { children: (0, jsx_runtime_1.jsxs)(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.jsxs)(material_1.Box, __assign({ sx: {
221
238
  display: 'flex',
@@ -232,7 +249,8 @@ var AccountValidation = function (_a) {
232
249
  endAdornment: ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, __assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "end", onClick: function (e) { return setShowPassword(function (prev) { return !prev; }); } }, { children: showPassword ? (0, jsx_runtime_1.jsx)(VisibilityOff_1.default, {}) : (0, jsx_runtime_1.jsx)(Visibility_1.default, {}) })) }))),
233
250
  } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", required: true, fullWidth: true, name: "confirmation", label: "Confirmation mot de passe", type: showPassword ? 'text' : 'password', id: "confirmation", onChange: function (e) { return handleInputChange(e); }, value: validationForm.confirmation.value, error: !validationForm.confirmation.isValid, helperText: Boolean(validationForm.confirmation.error) ? validationForm.confirmation.error : "", InputProps: {
234
251
  endAdornment: ((0, jsx_runtime_1.jsx)(InputAdornment_1.default, __assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ edge: "end", onClick: function (e) { return setShowPassword(function (prev) { return !prev; }); } }, { children: showPassword ? (0, jsx_runtime_1.jsx)(VisibilityOff_1.default, {}) : (0, jsx_runtime_1.jsx)(Visibility_1.default, {}) })) }))),
235
- } }) }))] })) })), loading &&
252
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12, sx: { mt: 2, display: 'flex', justifyContent: 'start' } }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, __assign({ error: !validationForm.acceptsTerms.isValid }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { name: "acceptsTerms", color: "primary", checked: validationForm.acceptsTerms.value, onChange: function (e, checked) { return handleCheckboxChange(e, checked); }, sx: { pr: 4 } }), label: (0, jsx_runtime_1.jsxs)("span", { children: ["J'accepte ", movaAppType === Enums_1.MovaAppType.GARAGE ? "sans réserve" : '', " les", ' ', (0, jsx_runtime_1.jsx)("a", __assign({ href: movaAppType === Enums_1.MovaAppType.GARAGE ? proCGUPath : CGUPath, target: "_blank", style: { color: theme.palette.primary.main } }, { children: "Conditions G\u00E9n\u00E9rales d'Utilisation" })), movaAppType === Enums_1.MovaAppType.GARAGE &&
253
+ (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["\u00A0", (0, jsx_runtime_1.jsx)("br", {}), "et les ", ' ', (0, jsx_runtime_1.jsx)("a", __assign({ href: proCGVPath, target: "_blank", style: { color: theme.palette.primary.main } }, { children: "Conditions G\u00E9n\u00E9rales de Vente" }))] })] }) }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, { children: validationForm.acceptsTerms.error })] })) }))] })) })), loading &&
236
254
  (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ display: "flex", justifyContent: "center", alignItems: "center", minHeight: "100vh" }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, {}) })), openPhoneNumberInput && (0, jsx_runtime_1.jsx)(ConfirmationDialog_1.default, { open: openPhoneNumberInput, confirmLabel: "Envoyer", closeLabel: "Annuler", onClose: function () { return setOpenPhoneNumberInput(false); }, onConfirm: resendCode, message: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { children: [(0, jsx_runtime_1.jsx)("b", { children: "Indique nous ton num\u00E9ro de t\u00E9l\u00E9phone" }), (0, jsx_runtime_1.jsx)("br", {})] }), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { margin: "normal", fullWidth: true, required: true, id: "phoneNumber", label: "N\u00B0 de t\u00E9l\u00E9phone", name: "phoneNumber", autoComplete: "tel", onChange: function (e) { return handleInputChange(e); }, value: validationForm.phoneNumber.value, error: Boolean(validationForm.phoneNumber.error), helperText: validationForm.phoneNumber.error }) }))] }) })] }));
237
255
  };
238
256
  exports.default = AccountValidation;
@@ -1,4 +1,4 @@
1
- import { SxProps, Theme } from '@mui/material';
1
+ import { SxProps, Theme, Breakpoint } from '@mui/material';
2
2
  import type { CSSProperties, FC } from 'react';
3
3
  import React from 'react';
4
4
  interface MovaDialogProps {
@@ -14,6 +14,7 @@ interface MovaDialogProps {
14
14
  title?: string;
15
15
  titleStyle?: CSSProperties;
16
16
  sx?: SxProps<Theme>;
17
+ maxWidth?: Breakpoint | false;
17
18
  }
18
19
  declare const MovaDialog: FC<MovaDialogProps>;
19
20
  export default MovaDialog;
@@ -22,7 +22,7 @@ var leaf_green_large_png_1 = __importDefault(require("./assets/images/leaf_green
22
22
  var leaf_yellow_large_png_1 = __importDefault(require("./assets/images/leaf_yellow_large.png"));
23
23
  var leaf_pink_large_png_1 = __importDefault(require("./assets/images/leaf_pink_large.png"));
24
24
  var MovaDialog = function (_a) {
25
- var fullScreen = _a.fullScreen, open = _a.open, onClose = _a.onClose, _b = _a.closable, closable = _b === void 0 ? true : _b, children = _a.children, title = _a.title, titleStyle = _a.titleStyle, message = _a.message, leafImageColor = _a.leafImageColor, transition = _a.transition, actions = _a.actions, sx = _a.sx;
25
+ var fullScreen = _a.fullScreen, open = _a.open, onClose = _a.onClose, _b = _a.closable, closable = _b === void 0 ? true : _b, children = _a.children, title = _a.title, titleStyle = _a.titleStyle, message = _a.message, leafImageColor = _a.leafImageColor, transition = _a.transition, actions = _a.actions, sx = _a.sx, maxWidth = _a.maxWidth;
26
26
  var getTransition = function () {
27
27
  switch (transition) {
28
28
  case "fade":
@@ -51,7 +51,7 @@ var MovaDialog = function (_a) {
51
51
  onClose();
52
52
  }
53
53
  };
54
- return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, __assign({ fullScreen: fullScreen, fullWidth: true, TransitionComponent: getTransition(), open: open, "aria-labelledby": "garage-dialog-title", "aria-describedby": "garage-dialog-description", onClose: handleOnClose, sx: __assign(__assign({}, sx), { textAlign: 'center' }) }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getLeafImage(), style: {
54
+ return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, __assign({ fullScreen: fullScreen, fullWidth: true, TransitionComponent: getTransition(), open: open, "aria-labelledby": "garage-dialog-title", "aria-describedby": "garage-dialog-description", onClose: handleOnClose, maxWidth: maxWidth, sx: __assign(__assign({}, sx), { textAlign: 'center' }) }, { children: [(0, jsx_runtime_1.jsx)("img", { src: getLeafImage(), style: {
55
55
  position: 'absolute',
56
56
  float: 'left',
57
57
  width: '150px',
@@ -213,6 +213,6 @@ var ScheduleFields = function (_a) {
213
213
  sx: { display: 'none' },
214
214
  },
215
215
  } }) }), (intervalIndex + 1) * Math.random()), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 1, sx: { pl: 0 }, style: { display: 'flex', justifyContent: 'center', alignItems: 'start' } }, { children: intervalIndex > 0 &&
216
- (0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: 'Supprimer intervalle' }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: deleteInterval(dayIndex, intervalIndex), disabled: !daySchedule.checked, sx: { ml: 2 } }, { children: (0, jsx_runtime_1.jsx)(DeleteRounded_1.default, {}) })) })) }), (dayIndex + 1) * Math.random()), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: interval.error && (0, jsx_runtime_1.jsx)(material_1.FormHelperText, __assign({ error: true, sx: { mb: 1 } }, { children: interval.error })) }), (intervalIndex + 1) * Math.random())] }), intervalIndex + 1)); }) }), (dayIndex + 1) * Math.random()), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true, xs: 1, sx: { pl: 0 }, style: { display: 'flex', justifyContent: 'center', alignItems: 'start' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: 'Dupliquer' }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: copySchedule(dayIndex), disabled: !daySchedule.checked }, { children: (0, jsx_runtime_1.jsx)(ContentCopy_1.default, {}) })) })), (0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: 'Ajouter intervalle' }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: addInterval(dayIndex), disabled: !daySchedule.checked }, { children: (0, jsx_runtime_1.jsx)(AddRounded_1.default, {}) })) }))] }), (dayIndex + 1) * Math.random()), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 1 })] })); }) })));
216
+ (0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: 'Supprimer intervalle', placement: 'top' }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: deleteInterval(dayIndex, intervalIndex), disabled: !daySchedule.checked, sx: { ml: 2 } }, { children: (0, jsx_runtime_1.jsx)(DeleteRounded_1.default, {}) })) })) }), (dayIndex + 1) * Math.random()), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: interval.error && (0, jsx_runtime_1.jsx)(material_1.FormHelperText, __assign({ error: true, sx: { mb: 1 } }, { children: interval.error })) }), (intervalIndex + 1) * Math.random())] }), intervalIndex + 1)); }) }), (dayIndex + 1) * Math.random()), (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ item: true, xs: 1, sx: { pl: 0 }, style: { display: 'flex', justifyContent: 'center', alignItems: 'start' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: 'Dupliquer', placement: 'top' }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: copySchedule(dayIndex), disabled: !daySchedule.checked }, { children: (0, jsx_runtime_1.jsx)(ContentCopy_1.default, {}) })) })), (0, jsx_runtime_1.jsx)(material_1.Tooltip, __assign({ title: 'Ajouter intervalle', placement: 'top' }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ onClick: addInterval(dayIndex), disabled: !daySchedule.checked }, { children: (0, jsx_runtime_1.jsx)(AddRounded_1.default, {}) })) }))] }), (dayIndex + 1) * Math.random()), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 1 })] })); }) })));
217
217
  };
218
218
  exports.default = ScheduleFields;
@@ -3,6 +3,7 @@ import { MovaFormField, MovaInterval } from "./Types";
3
3
  import { CSSProperties } from "react";
4
4
  import { DayOfWeek, PartsApplicationType } from "./Enums";
5
5
  import Schedule from "../models/Schedule";
6
+ export declare const flexStart: CSSProperties;
6
7
  export declare const isSafariOniOS: () => boolean;
7
8
  export declare const FR_WEEK_DAYS: string[];
8
9
  export declare const getDayOfWeekLabel: (day: DayOfWeek) => string | undefined;
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.isSafariOniOS = void 0;
3
+ 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.isSafariOniOS = exports.flexStart = void 0;
4
4
  var Enums_1 = require("./Enums");
5
+ exports.flexStart = {
6
+ display: 'flex',
7
+ justifyContent: 'start',
8
+ alignItems: 'center'
9
+ };
5
10
  var isSafariOniOS = function () {
6
11
  var userAgent = window.navigator.userAgent;
7
12
  var iOS = !!userAgent.match(/iPad/i) || !!userAgent.match(/iPhone/i) || !!userAgent.match(/iPod/i);
@@ -3,6 +3,7 @@ export type MovaValidationForm = {
3
3
  confirmation: MovaFormField;
4
4
  securityCode: MovaFormField;
5
5
  phoneNumber: MovaFormField;
6
+ acceptsTerms: MovaFormField;
6
7
  };
7
8
  export type AddressFieldName = 'streetName' | 'additional' | 'postalCode' | 'cityName';
8
9
  export type MovaVehicleForm = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movalib/movalib-commons",
3
- "version": "1.1.88",
3
+ "version": "1.1.91",
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",
Binary file
Binary file
Binary file
@@ -1,7 +1,7 @@
1
1
  import { CSSProperties, FunctionComponent, useEffect, useState } from 'react';
2
2
  import { useHistory, useLocation } from 'react-router-dom';
3
3
  import UserService from './services/UserService';
4
- import { Box, CircularProgress, Grid, IconButton, Link, TextField, Typography, darken, useMediaQuery, useTheme } from '@mui/material';
4
+ import { Box, Checkbox, CircularProgress, FormControl, FormControlLabel, FormHelperText, Grid, IconButton, Link, SelectChangeEvent, TextField, Typography, colors, darken, useMediaQuery, useTheme } from '@mui/material';
5
5
  import Logger from './helpers/Logger';
6
6
  import InputAdornment from '@mui/material/InputAdornment';
7
7
  import Visibility from '@mui/icons-material/Visibility';
@@ -9,7 +9,7 @@ import VisibilityOff from '@mui/icons-material/VisibilityOff';
9
9
  import { LoadingButton } from '@mui/lab';
10
10
  import { MovaAppType } from './helpers/Enums';
11
11
  import { MovaFormField, MovaValidationForm } from './helpers/Types';
12
- import { validateField } from './helpers/Tools';
12
+ import { flexStart, validateField } from './helpers/Tools';
13
13
  import MovaDialog from './MovaDialog';
14
14
  import LogoLarge from './assets/images/logo/logo_large.png';
15
15
  import LogoProLarge from './assets/images/logo/logo_pro_large.png';
@@ -21,6 +21,7 @@ const initialFormState = {
21
21
  confirmation: { value: '', isValid: true },
22
22
  securityCode: { value: '', isValid: true },
23
23
  phoneNumber: { value: '', isValid: true },
24
+ acceptsTerms: { value: false, isValid: true },
24
25
  }
25
26
 
26
27
  interface AccountValidationProps {
@@ -31,11 +32,16 @@ interface AccountValidationProps {
31
32
  onResendSecurityCode?: (success:boolean, message:string) => void,
32
33
  }
33
34
 
35
+ // ATTENTION : s'assurer de la présence des documents suivants à la racine du composant porteur (dossier 'public')
36
+ const CGUPath:string = "/Movalib_CGU.pdf";
37
+ const proCGUPath:string = "/Movalib_Pro_CGU.pdf";
38
+ const proCGVPath:string = "/Movalib_Pro_CGV.pdf";
39
+
34
40
  const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppType, smsValidation, resetPassword, onSubmit, onResendSecurityCode }) => {
35
41
 
36
42
  const [loading, setLoading] = useState(true);
37
43
  const [validationForm, setValidationForm] = useState<MovaValidationForm>(initialFormState);
38
- const location = useLocation();
44
+ //const location = useLocation();
39
45
  const history = useHistory();
40
46
  const theme = useTheme();
41
47
  const [emptyPwd, setEmptyPwd] = useState<boolean>(false);
@@ -45,22 +51,25 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
45
51
 
46
52
  useEffect(() => {
47
53
 
48
- const params = new URLSearchParams(location.search);
49
- const token = params.get('token');
50
-
51
- // Si cette variable est transmise, cela signifie que le compte a été créé sans mot de passe
52
- let localEmptyPwd = Boolean(params.get('emptyPwd'));
53
- setEmptyPwd(localEmptyPwd);
54
+ const params = location !== undefined ? new URLSearchParams(location.search) : undefined;
54
55
 
55
- if (token && !resetPassword) {
56
+ if(params !== undefined){
57
+ const token = params.get('token');
56
58
 
57
- if(!localEmptyPwd){
58
-
59
- let req = {
60
- token: token
59
+ // Si cette variable est transmise, cela signifie que le compte a été créé sans mot de passe
60
+ let localEmptyPwd = Boolean(params.get('emptyPwd'));
61
+ setEmptyPwd(localEmptyPwd);
62
+
63
+ if (token && !resetPassword) {
64
+
65
+ if(!localEmptyPwd){
66
+
67
+ let req = {
68
+ token: token
69
+ }
70
+
71
+ activateUserAccount(req);
61
72
  }
62
-
63
- activateUserAccount(req);
64
73
  }
65
74
  }
66
75
 
@@ -135,6 +144,15 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
135
144
  }
136
145
  }
137
146
 
147
+ const handleCheckboxChange = (e: SelectChangeEvent<string>, checked: boolean): void => {
148
+
149
+ const fieldName: string = e.target.name;
150
+ const fieldValue: boolean = checked;
151
+ const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
152
+
153
+ setValidationForm({ ...validationForm, ...newField});
154
+ }
155
+
138
156
  const validateForm = () => {
139
157
  let newForm: MovaValidationForm = { ...validationForm };
140
158
 
@@ -157,9 +175,14 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
157
175
  if(smsValidation)
158
176
  newForm.securityCode = validateField(validationForm.securityCode, value => value.length === 6, "Le code doit contenir 6 chiffres");
159
177
 
178
+ // Validator pour les CGU
179
+ newForm.acceptsTerms = validateField(validationForm.acceptsTerms, value => Boolean(value),
180
+ movaAppType == MovaAppType.GARAGE ? 'Vous devez accepter les termes de nos CGU et de nos CGV' : 'Vous devez accepter les termes de nos CGU');
181
+
160
182
  setValidationForm(newForm);
161
183
 
162
- return newForm.password.isValid && newForm.confirmation.isValid && (smsValidation ? newForm.securityCode.isValid : true);
184
+ return newForm.password.isValid && newForm.confirmation.isValid && (smsValidation ? newForm.securityCode.isValid : true) &&
185
+ newForm.acceptsTerms.isValid;
163
186
  }
164
187
 
165
188
 
@@ -252,12 +275,12 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
252
275
 
253
276
  return (
254
277
  <div>
255
- {(emptyPwd || smsValidation || resetPassword) &&
278
+ {(emptyPwd || smsValidation || resetPassword || true) &&
256
279
  <MovaDialog
257
280
  leafImageColor='pink'
258
281
  titleStyle={getTitleStyle()}
259
282
  fullScreen={isMobile}
260
- open={emptyPwd || smsValidation || resetPassword}
283
+ open={emptyPwd || smsValidation || resetPassword || true}
261
284
  closable={false}
262
285
  onClose={function (): void {
263
286
  throw new Error('Function not implemented.');
@@ -380,6 +403,39 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
380
403
  }}
381
404
  />
382
405
  </Grid>
406
+ <Grid item xs={12} sx={{mt: 2, display:'flex', justifyContent:'start'}} >
407
+ <FormControl error={!validationForm.acceptsTerms.isValid} >
408
+ <FormControlLabel
409
+ control={
410
+ <Checkbox
411
+ name="acceptsTerms"
412
+ color="primary"
413
+ checked={validationForm.acceptsTerms.value}
414
+ onChange={(e, checked) => handleCheckboxChange(e, checked)}
415
+ sx={{pr: 4}}
416
+ />
417
+ }
418
+ label={
419
+ <span>
420
+ J'accepte {movaAppType === MovaAppType.GARAGE ? "sans réserve" : ''} les{' '}
421
+ <a href={movaAppType === MovaAppType.GARAGE ? proCGUPath : CGUPath} target="_blank"
422
+ style={{ color:theme.palette.primary.main}}>
423
+ Conditions Générales d'Utilisation
424
+ </a>
425
+ {movaAppType === MovaAppType.GARAGE &&
426
+ <>
427
+ &nbsp;<br />et les {' '}
428
+ <a href={proCGVPath} target="_blank" style={{ color:theme.palette.primary.main}}>
429
+ Conditions Générales de Vente
430
+ </a>
431
+ </>
432
+ }
433
+ </span>
434
+ }
435
+ />
436
+ <FormHelperText>{validationForm.acceptsTerms.error}</FormHelperText>
437
+ </FormControl>
438
+ </Grid>
383
439
  </Grid>
384
440
  </MovaDialog>}
385
441
 
@@ -1,4 +1,4 @@
1
- import { Alert, AppBar, Dialog, DialogActions, DialogContent, DialogTitle, Fade, IconButton, Toolbar, Typography, SxProps, Theme } from '@mui/material';
1
+ import { Alert, AppBar, Dialog, DialogActions, DialogContent, DialogTitle, Fade, IconButton, Toolbar, Typography, SxProps, Theme, Breakpoint } from '@mui/material';
2
2
  import type { CSSProperties, FC } from 'react';
3
3
  import BackIcon from '@mui/icons-material/ArrowBackIosNewRounded';
4
4
  import React from 'react';
@@ -20,10 +20,11 @@ interface MovaDialogProps {
20
20
  title?: string,
21
21
  titleStyle?: CSSProperties;
22
22
  sx?: SxProps<Theme>;
23
+ maxWidth? : Breakpoint | false;
23
24
  }
24
25
 
25
26
  const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, closable = true, children, title, titleStyle,
26
- message, leafImageColor, transition, actions, sx}) => {
27
+ message, leafImageColor, transition, actions, sx, maxWidth}) => {
27
28
 
28
29
  const getTransition = () => {
29
30
  switch(transition){
@@ -74,6 +75,7 @@ const MovaDialog: FC<MovaDialogProps> = ({fullScreen, open, onClose, closable =
74
75
  aria-labelledby="garage-dialog-title"
75
76
  aria-describedby="garage-dialog-description"
76
77
  onClose={handleOnClose}
78
+ maxWidth={maxWidth}
77
79
  sx={{ ...sx, textAlign:'center'}}
78
80
  >
79
81
  <img src={getLeafImage()} style={{
@@ -305,7 +305,7 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
305
305
  </Grid>
306
306
  <Grid item xs={1} key={(dayIndex+1)*Math.random()} sx={{ pl: 0 }} style={{ display: 'flex', justifyContent: 'center', alignItems: 'start' }}>
307
307
  {intervalIndex > 0 &&
308
- <Tooltip title='Supprimer intervalle'>
308
+ <Tooltip title='Supprimer intervalle' placement='top' >
309
309
  <IconButton onClick={deleteInterval(dayIndex, intervalIndex)} disabled={!daySchedule.checked} sx={{ ml: 2 }}>
310
310
  <DeleteIcon />
311
311
  </IconButton>
@@ -321,12 +321,12 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
321
321
  </Grid>
322
322
 
323
323
  <Grid item xs={1} key={(dayIndex+1)*Math.random()} sx={{ pl: 0 }} style={{ display: 'flex', justifyContent: 'center', alignItems: 'start' }}>
324
- <Tooltip title='Dupliquer'>
324
+ <Tooltip title='Dupliquer' placement='top'>
325
325
  <IconButton onClick={copySchedule(dayIndex)} disabled={!daySchedule.checked}>
326
326
  <ContentCopyIcon />
327
327
  </IconButton>
328
328
  </Tooltip>
329
- <Tooltip title='Ajouter intervalle'>
329
+ <Tooltip title='Ajouter intervalle' placement='top'>
330
330
  <IconButton onClick={addInterval(dayIndex)} disabled={!daySchedule.checked}>
331
331
  <AddIcon />
332
332
  </IconButton>
@@ -5,6 +5,12 @@ import { CSSProperties } from "react";
5
5
  import { DayOfWeek, PartsApplicationType, VehiclePlateFormat } from "./Enums";
6
6
  import Schedule from "../models/Schedule";
7
7
 
8
+ export const flexStart:CSSProperties = {
9
+ display: 'flex',
10
+ justifyContent: 'start',
11
+ alignItems: 'center'
12
+ }
13
+
8
14
  export const isSafariOniOS = ():boolean => {
9
15
  const userAgent = window.navigator.userAgent;
10
16
  const iOS = !!userAgent.match(/iPad/i) || !!userAgent.match(/iPhone/i) || !!userAgent.match(/iPod/i);
@@ -2,7 +2,8 @@ export type MovaValidationForm = {
2
2
  password: MovaFormField,
3
3
  confirmation: MovaFormField,
4
4
  securityCode: MovaFormField,
5
- phoneNumber: MovaFormField
5
+ phoneNumber: MovaFormField,
6
+ acceptsTerms: MovaFormField,
6
7
  }
7
8
 
8
9
  export type AddressFieldName = 'streetName' | 'additional' | 'postalCode' | 'cityName';