@movalib/movalib-commons 1.59.9 → 1.59.11
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/index.d.ts +1 -0
- package/dist/index.js +4 -2
- package/dist/src/AccountValidation.js +11 -4
- package/dist/src/MovaSignUp.d.ts +2 -0
- package/dist/src/MovaSignUp.js +44 -19
- package/dist/src/components/singup/ActivateAccount.d.ts +10 -0
- package/dist/src/components/singup/ActivateAccount.js +188 -0
- package/dist/src/helpers/ApiHelper.js +5 -5
- package/dist/src/models/Garage.d.ts +3 -1
- package/dist/src/models/Garage.js +3 -1
- package/dist/src/models/Subscription.d.ts +25 -1
- package/dist/src/models/Subscription.js +9 -1
- package/dist/src/services/UserService.d.ts +6 -1
- package/dist/src/services/UserService.js +16 -0
- package/index.ts +1 -0
- package/package.json +1 -1
- package/src/AccountValidation.tsx +9 -2
- package/src/MovaSignUp.tsx +48 -20
- package/src/components/singup/ActivateAccount.tsx +273 -0
- package/src/helpers/ApiHelper.ts +5 -5
- package/src/models/Garage.ts +7 -1
- package/src/models/Subscription.ts +72 -35
- package/src/services/UserService.ts +19 -1
|
@@ -48,6 +48,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
48
48
|
const [showPassword, setShowPassword] = useState(false);
|
|
49
49
|
const [openPhoneNumberInput, setOpenPhoneNumberInput] = useState<boolean>(false);
|
|
50
50
|
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
|
|
51
|
+
const [loadingBtn, setLoadingBtn] = useState<boolean>(false);
|
|
51
52
|
|
|
52
53
|
useEffect(() => {
|
|
53
54
|
|
|
@@ -99,6 +100,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
99
100
|
|
|
100
101
|
const resetUserPassword = (req: any) => {
|
|
101
102
|
if(req){
|
|
103
|
+
setLoadingBtn(true);
|
|
102
104
|
|
|
103
105
|
UserService.reestPassword(req)
|
|
104
106
|
.then(response => {
|
|
@@ -120,13 +122,15 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
120
122
|
if(onSubmit){
|
|
121
123
|
onSubmit(false, error);
|
|
122
124
|
}
|
|
125
|
+
}).finally(() => {
|
|
126
|
+
setLoadingBtn(false);
|
|
123
127
|
});
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
const activateUserAccount = (req: any) => {
|
|
128
132
|
if(req){
|
|
129
|
-
|
|
133
|
+
setLoadingBtn(true);
|
|
130
134
|
UserService.validateAccount(req)
|
|
131
135
|
.then(response => {
|
|
132
136
|
|
|
@@ -134,7 +138,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
134
138
|
|
|
135
139
|
if(response.success){
|
|
136
140
|
if(onSubmit){
|
|
137
|
-
onSubmit(response.success,
|
|
141
|
+
onSubmit(response.success, 'Le compte a été activé avec succès.');
|
|
138
142
|
}
|
|
139
143
|
}else{
|
|
140
144
|
if(onSubmit){
|
|
@@ -147,6 +151,8 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
147
151
|
if(onSubmit){
|
|
148
152
|
onSubmit(false, error);
|
|
149
153
|
}
|
|
154
|
+
}).finally(() => {
|
|
155
|
+
setLoadingBtn(false);
|
|
150
156
|
});
|
|
151
157
|
}
|
|
152
158
|
}
|
|
@@ -311,6 +317,7 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
311
317
|
}}
|
|
312
318
|
actions={
|
|
313
319
|
<LoadingButton
|
|
320
|
+
loading={loadingBtn}
|
|
314
321
|
type="submit"
|
|
315
322
|
onClick={handleValidateAccount}
|
|
316
323
|
fullWidth
|
package/src/MovaSignUp.tsx
CHANGED
|
@@ -22,6 +22,8 @@ import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
|
22
22
|
import InfoIcon from '@mui/icons-material/Info';
|
|
23
23
|
import isValid from 'date-fns/isValid';
|
|
24
24
|
import Logger from "./helpers/Logger";
|
|
25
|
+
import User from "./models/User";
|
|
26
|
+
import UserService from "./services/UserService";
|
|
25
27
|
|
|
26
28
|
// ATTENTION : s'assurer de la présence des documents suivants à la racine du composant porteur (dossier 'public')
|
|
27
29
|
const CGUPath:string = "/Movalib_CGU.pdf";
|
|
@@ -33,17 +35,6 @@ const styles: CSSProperties = {
|
|
|
33
35
|
alignItems: 'center'
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
const initialUserFormState = {
|
|
37
|
-
firstname: { value: '', isValid: true },
|
|
38
|
-
lastname: { value: '', isValid: true },
|
|
39
|
-
email: { value: '', isValid: true },
|
|
40
|
-
phoneNumber: { value: '', isValid: true },
|
|
41
|
-
password: { value: '', isValid: true },
|
|
42
|
-
gender: { value: '', isValid: true },
|
|
43
|
-
birthDate: { value: null, isValid: true },
|
|
44
|
-
acceptsTerms: { value: false, isValid: true },
|
|
45
|
-
};
|
|
46
|
-
|
|
47
38
|
/**
|
|
48
39
|
* Propriétés du composant
|
|
49
40
|
* movaAppType : type d'application Movalib au sein de laquelle le composant est injectée
|
|
@@ -66,6 +57,7 @@ interface MovaSignUpProps {
|
|
|
66
57
|
showLoginButton?: boolean,
|
|
67
58
|
disableGutters?: boolean,
|
|
68
59
|
usePhoneNumber?: boolean
|
|
60
|
+
userToEdit?: User,
|
|
69
61
|
}
|
|
70
62
|
|
|
71
63
|
/**
|
|
@@ -73,16 +65,28 @@ interface MovaSignUpProps {
|
|
|
73
65
|
* ATTENTION : le lien de consultation des CGU doit pointer vers "/terms-and-conditions"
|
|
74
66
|
*/
|
|
75
67
|
const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType, onSubmit, darkMode = false, alertMessage, alertSeverity, headerText,
|
|
76
|
-
showHeaderLogo = true, showLeafs= true, showCopyright = true, showLoginButton = true, disableGutters = false, usePhoneNumber = true}) => {
|
|
77
|
-
|
|
78
|
-
const [userForm, setUserForm] = useState<MovaUserSignUpForm>(
|
|
68
|
+
showHeaderLogo = true, showLeafs= true, showCopyright = true, showLoginButton = true, disableGutters = false, usePhoneNumber = true, userToEdit = null}) => {
|
|
69
|
+
|
|
70
|
+
const [userForm, setUserForm] = useState<MovaUserSignUpForm>(
|
|
71
|
+
{
|
|
72
|
+
firstname: { value: userToEdit?.firstname ?? '', isValid: true },
|
|
73
|
+
lastname: { value: userToEdit?.lastname ?? '', isValid: true },
|
|
74
|
+
email: { value: userToEdit?.email ?? '', isValid: true },
|
|
75
|
+
phoneNumber: { value: userToEdit?.phoneNumber ?? '', isValid: true },
|
|
76
|
+
password: { value: '', isValid: true },
|
|
77
|
+
gender: { value: '', isValid: true },
|
|
78
|
+
birthDate: { value: null, isValid: true },
|
|
79
|
+
acceptsTerms: { value: false, isValid: true },
|
|
80
|
+
}
|
|
81
|
+
);
|
|
79
82
|
const history = useHistory();
|
|
80
83
|
const [message, setMessage] = useState<string>("");
|
|
81
84
|
const theme = useTheme();
|
|
82
85
|
const [showPassword, setShowPassword] = useState(false);
|
|
83
86
|
const [openEmailInfo, setOpenEmailInfo] = useState(false);
|
|
84
87
|
const [openPhoneNumberInfo, setOpenPhoneNumberInfo] = useState(false);
|
|
85
|
-
|
|
88
|
+
const [userExist, setUserExist] = useState<boolean>(false);
|
|
89
|
+
const [userIsAlreadyActive, setUserIsAlreadyActive] = useState<boolean>(false);
|
|
86
90
|
const handleDateChange = (name: string, date: Date | null) => {
|
|
87
91
|
|
|
88
92
|
if(name && date){
|
|
@@ -106,6 +110,25 @@ const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType,
|
|
|
106
110
|
if (fieldValue.length > 10) {
|
|
107
111
|
fieldValue = fieldValue.substring(0, 10);
|
|
108
112
|
}
|
|
113
|
+
if (fieldValue.length === 10){
|
|
114
|
+
UserService.existsByPhoneNumber(fieldValue).then((response) => {
|
|
115
|
+
if(response && response.data){
|
|
116
|
+
if(response.data.isActive === false){
|
|
117
|
+
setUserExist(true);
|
|
118
|
+
setUserIsAlreadyActive(false);
|
|
119
|
+
} else if (response.data.isActive === true){
|
|
120
|
+
setUserIsAlreadyActive(true);
|
|
121
|
+
setUserExist(false);
|
|
122
|
+
} else {
|
|
123
|
+
setUserExist(false);
|
|
124
|
+
setUserIsAlreadyActive(false);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
} else {
|
|
129
|
+
setUserExist(false);
|
|
130
|
+
setUserIsAlreadyActive(false);
|
|
131
|
+
}
|
|
109
132
|
}
|
|
110
133
|
|
|
111
134
|
// Capitalisation automatique du prénom
|
|
@@ -285,24 +308,28 @@ const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType,
|
|
|
285
308
|
id="phoneNumber"
|
|
286
309
|
label="N° de téléphone"
|
|
287
310
|
name="phoneNumber"
|
|
288
|
-
autoComplete="tel"
|
|
311
|
+
autoComplete="tel"
|
|
312
|
+
disabled={userToEdit && userToEdit.phoneNumber ? true : false}
|
|
289
313
|
onChange={e => handleInputChange(e)}
|
|
290
314
|
value={userForm.phoneNumber.value}
|
|
291
315
|
error={Boolean(userForm.phoneNumber.error)}
|
|
292
316
|
helperText={userForm.phoneNumber.error}
|
|
293
317
|
InputProps={{
|
|
294
318
|
endAdornment: (
|
|
295
|
-
|
|
296
|
-
|
|
319
|
+
<InputAdornment position="end">
|
|
320
|
+
{!userExist && <IconButton
|
|
297
321
|
edge="end"
|
|
298
322
|
onClick={() => setOpenPhoneNumberInfo(!openPhoneNumberInfo)}
|
|
299
323
|
><InfoIcon />
|
|
300
|
-
</IconButton>
|
|
324
|
+
</IconButton>}
|
|
301
325
|
</InputAdornment>
|
|
302
326
|
),
|
|
303
327
|
}}
|
|
304
328
|
/>
|
|
305
|
-
{openPhoneNumberInfo && <Alert severity="info" variant='standard'>Entrez le numéro de téléphone que vous avez utilisé pour réserver, afin de suivre facilement vos rendez-vous.</Alert>}
|
|
329
|
+
{openPhoneNumberInfo && !userExist && <Alert severity="info" variant='standard'>Entrez le numéro de téléphone que vous avez utilisé pour réserver, afin de suivre facilement vos rendez-vous.</Alert>}
|
|
330
|
+
{userExist && <Alert severity="success" variant='standard'>Rendez-vous trouvé(s) pour ce numéro ! Vous pourrez le(s) consulter après avoir créé votre compte.</Alert>}
|
|
331
|
+
{userIsAlreadyActive && <Alert severity="error" sx={{marginTop: '5px'}} variant='standard'>Il semble qu’un compte existe déjà avec ce numéro. Connectez-vous ou utilisez "Mot de passe oublié" pour y accéder facilement.</Alert>}
|
|
332
|
+
|
|
306
333
|
</>
|
|
307
334
|
}
|
|
308
335
|
<TextField
|
|
@@ -313,6 +340,7 @@ const MovaSignUp: FunctionComponent<MovaSignUpProps> = ({ loading, movaAppType,
|
|
|
313
340
|
label="Adresse email"
|
|
314
341
|
name="email"
|
|
315
342
|
autoComplete="email"
|
|
343
|
+
disabled={userToEdit && userToEdit.email ? true : false}
|
|
316
344
|
onChange={e => handleInputChange(e)}
|
|
317
345
|
value={userForm.email.value}
|
|
318
346
|
error={!userForm.email.isValid}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { CSSProperties, FunctionComponent, useEffect, useState } from 'react';
|
|
2
|
+
import { useHistory, useLocation, useParams } from 'react-router-dom';
|
|
3
|
+
import UserService from '../../services/UserService';
|
|
4
|
+
import { AlertColor, Box, Button, Checkbox, CircularProgress, FormControl, FormControlLabel, FormHelperText, Grid, IconButton, Link, SelectChangeEvent, TextField, Typography, colors, darken, useMediaQuery, useTheme } from '@mui/material';
|
|
5
|
+
import Logger from '../../helpers/Logger';
|
|
6
|
+
import { MovaAppType } from '../../helpers/Enums';
|
|
7
|
+
import { MovaFormField, MovaUserSignUpForm, MovaValidationForm } from '../../helpers/Types';
|
|
8
|
+
import { flexStart, validateField } from '../../helpers/Tools';
|
|
9
|
+
import User from '../../models/User';
|
|
10
|
+
import { set } from 'date-fns';
|
|
11
|
+
import MovaSignUp from '../../MovaSignUp';
|
|
12
|
+
import { validatePhoneNumber } from '../../helpers/Validator';
|
|
13
|
+
|
|
14
|
+
interface RouteParams {
|
|
15
|
+
code: string; // Définissez ici les paramètres de route attendus
|
|
16
|
+
}
|
|
17
|
+
interface ActivateAccountProps {
|
|
18
|
+
movaAppType: MovaAppType,
|
|
19
|
+
smsValidation: boolean,
|
|
20
|
+
onSubmit: (success: boolean, message: string) => void,
|
|
21
|
+
onResendSecurityCode?: (success: boolean, message: string) => void,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const ActivateAccount: FunctionComponent<ActivateAccountProps> = ({ movaAppType, smsValidation, onSubmit, onResendSecurityCode }) => {
|
|
26
|
+
const { code } = useParams<RouteParams>();
|
|
27
|
+
const location = useLocation();
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
const [alertMessage, setAlertMessage] = useState<string>("");
|
|
30
|
+
// La sévérité est initialiée à "error" par défaut
|
|
31
|
+
const [alertSeverity, setAlertSeverity] = useState<AlertColor>('error');
|
|
32
|
+
const [loading, setLoading] = useState(false);
|
|
33
|
+
const [currentUser, setCurrentUser] = useState<User | null>(null);
|
|
34
|
+
const [expiredCode, setExpiredCode] = useState(false);
|
|
35
|
+
const [unknowCode, setUnknowCode] = useState(false);
|
|
36
|
+
const [validationForm, setValidationForm] = useState<any>({ phoneNumber: { value: '', isValid: true } });
|
|
37
|
+
|
|
38
|
+
const history = useHistory();
|
|
39
|
+
// ajout d'un load pour le chargement de la page
|
|
40
|
+
const getUserByTokenOrCode = () => {
|
|
41
|
+
setExpiredCode(false);
|
|
42
|
+
setUnknowCode(false);
|
|
43
|
+
const params = location !== undefined ? new URLSearchParams(location.search) : undefined;
|
|
44
|
+
let req = {
|
|
45
|
+
token: !smsValidation ? params?.get('token') : null,
|
|
46
|
+
securityCode: smsValidation ? code : null,
|
|
47
|
+
demoGarage: Boolean(params?.get('demoGarage'))
|
|
48
|
+
}
|
|
49
|
+
UserService.validateAccount(req).then(response => {
|
|
50
|
+
if (response.success) {
|
|
51
|
+
setCurrentUser(response.data as User);
|
|
52
|
+
} else {
|
|
53
|
+
const data = response.data as { expiredCode?: boolean, unknownCode?: boolean };
|
|
54
|
+
if (data?.expiredCode) {
|
|
55
|
+
setExpiredCode(true);
|
|
56
|
+
}
|
|
57
|
+
if (data?.unknownCode) {
|
|
58
|
+
setUnknowCode(true);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
getUserByTokenOrCode();
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
const updateActivateUseronSubmit = (form: MovaUserSignUpForm) => {
|
|
69
|
+
// appelle api pour mettre a jour l'utilisateur + auto activate en fonction du movaAPPType
|
|
70
|
+
if (movaAppType === MovaAppType.INDIVIDUAL && currentUser) {
|
|
71
|
+
setLoading(true);
|
|
72
|
+
try {
|
|
73
|
+
|
|
74
|
+
// On prépare la query
|
|
75
|
+
let query = {
|
|
76
|
+
code: code,
|
|
77
|
+
email: form.email.value,
|
|
78
|
+
password: form.password.value,
|
|
79
|
+
firstname: form.firstname.value,
|
|
80
|
+
lastname: form.lastname.value,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
UserService.editUser(query, currentUser.id)
|
|
84
|
+
.then(response => {
|
|
85
|
+
//success or Error this is parent component responsability
|
|
86
|
+
Logger.info(response);
|
|
87
|
+
if (response.success) {
|
|
88
|
+
onSubmit(response.success, response.data ?? 'Le compte a été mis à jour et activé avec succès');
|
|
89
|
+
history.push('/login');
|
|
90
|
+
} else {
|
|
91
|
+
onSubmit(response.success, response.error ?? 'Erreur lors de la mise à jour du compte');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}).catch(error => {
|
|
95
|
+
onSubmit(false, 'Erreur lors de la mise à jour du compte');
|
|
96
|
+
Logger.error(error);
|
|
97
|
+
setAlertMessage(error);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('Error occurred during submission:', error);
|
|
102
|
+
} finally {
|
|
103
|
+
setLoading(false);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
const controlPhoneNumber = (): boolean => {
|
|
110
|
+
|
|
111
|
+
let newForm: MovaValidationForm = validationForm;
|
|
112
|
+
let newField: MovaFormField;
|
|
113
|
+
|
|
114
|
+
newForm.phoneNumber = validateField(validationForm.phoneNumber, value => !!value, 'Champ obligatoire');
|
|
115
|
+
|
|
116
|
+
// Validator 'phoneNumber'
|
|
117
|
+
if (newForm.phoneNumber?.value) {
|
|
118
|
+
if (newForm.phoneNumber?.value.length < 10) {
|
|
119
|
+
newField = { value: validationForm.phoneNumber?.value, error: "Le n° de téléphone est invalide." };
|
|
120
|
+
} else {
|
|
121
|
+
newField = { value: validationForm.phoneNumber?.value, error: '' };
|
|
122
|
+
}
|
|
123
|
+
newForm = { ...newForm, ...{ phoneNumber: newField } };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setValidationForm(newForm);
|
|
127
|
+
|
|
128
|
+
return !Boolean(newForm.phoneNumber?.error);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | null): void => {
|
|
133
|
+
if (e) {
|
|
134
|
+
const fieldName: string = e.target.name;
|
|
135
|
+
const fieldValue: string = e.target.value;
|
|
136
|
+
const newField: MovaFormField = { [fieldName]: { value: fieldValue, isValid: true } };
|
|
137
|
+
|
|
138
|
+
if (fieldName == "phoneNumber") {
|
|
139
|
+
if (!validatePhoneNumber(fieldValue))
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
setValidationForm({ ...validationForm, ...newField });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const resendCode = () => {
|
|
148
|
+
|
|
149
|
+
if (controlPhoneNumber() && onResendSecurityCode) {
|
|
150
|
+
|
|
151
|
+
let req = {
|
|
152
|
+
phoneNumber: validationForm.phoneNumber?.value
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
UserService.resendActivationAccount(req)
|
|
156
|
+
.then(response => {
|
|
157
|
+
|
|
158
|
+
Logger.info(response);
|
|
159
|
+
|
|
160
|
+
if (response.success) {
|
|
161
|
+
onResendSecurityCode(response.success, response.data ?? '');
|
|
162
|
+
} else {
|
|
163
|
+
onResendSecurityCode(response.success, response.error ?? '');
|
|
164
|
+
}
|
|
165
|
+
history.push('/login');
|
|
166
|
+
|
|
167
|
+
}).catch(error => {
|
|
168
|
+
Logger.error(error);
|
|
169
|
+
if (onSubmit) {
|
|
170
|
+
onSubmit(false, error);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<>
|
|
178
|
+
{currentUser !== null && <MovaSignUp
|
|
179
|
+
movaAppType={movaAppType}
|
|
180
|
+
onSubmit={updateActivateUseronSubmit}
|
|
181
|
+
alertMessage={alertMessage}
|
|
182
|
+
alertSeverity={alertSeverity}
|
|
183
|
+
userToEdit={currentUser}
|
|
184
|
+
loading={loading} />}
|
|
185
|
+
{expiredCode && (
|
|
186
|
+
<Box sx={{ width: '99vw', height: '99vh', display: 'flex' }}>
|
|
187
|
+
<Box
|
|
188
|
+
sx={{
|
|
189
|
+
display: 'block',
|
|
190
|
+
margin: 'auto',
|
|
191
|
+
textAlign: 'center',
|
|
192
|
+
padding: 3,
|
|
193
|
+
borderRadius: 2,
|
|
194
|
+
boxShadow: 3,
|
|
195
|
+
maxWidth: 400,
|
|
196
|
+
backgroundColor: 'white',
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
<Typography variant="h6" color="error" gutterBottom>
|
|
200
|
+
Code de validation expiré
|
|
201
|
+
</Typography>
|
|
202
|
+
<Typography><b>Indiquez nous votre numéro de téléphone.</b><br />Nous allons renvoyer un SMS d'activation de compte</Typography>
|
|
203
|
+
<Grid item xs={6}>
|
|
204
|
+
<TextField
|
|
205
|
+
margin="normal"
|
|
206
|
+
fullWidth
|
|
207
|
+
required
|
|
208
|
+
id="phoneNumber"
|
|
209
|
+
label="N° de téléphone"
|
|
210
|
+
name="phoneNumber"
|
|
211
|
+
autoComplete="tel"
|
|
212
|
+
onChange={e => handleInputChange(e)}
|
|
213
|
+
value={validationForm.phoneNumber.value}
|
|
214
|
+
error={Boolean(validationForm.phoneNumber.error)}
|
|
215
|
+
helperText={validationForm.phoneNumber.error}
|
|
216
|
+
/>
|
|
217
|
+
</Grid>
|
|
218
|
+
<Button
|
|
219
|
+
onClick={resendCode}
|
|
220
|
+
sx={{ cursor: 'pointer', textAlign: 'center', width: '100%', mt: 1 }}
|
|
221
|
+
>
|
|
222
|
+
Renvoyer le code
|
|
223
|
+
</Button>
|
|
224
|
+
</Box>
|
|
225
|
+
</Box>
|
|
226
|
+
)}
|
|
227
|
+
{unknowCode && (
|
|
228
|
+
<Box sx={{ width: '99vw', height: '99vh', display: 'flex' }}>
|
|
229
|
+
<Box
|
|
230
|
+
sx={{
|
|
231
|
+
display: 'flex',
|
|
232
|
+
flexDirection: 'column',
|
|
233
|
+
alignItems: 'center',
|
|
234
|
+
justifyContent: 'center',
|
|
235
|
+
height: '100%',
|
|
236
|
+
width: '100%',
|
|
237
|
+
margin: 'auto',
|
|
238
|
+
textAlign: 'center',
|
|
239
|
+
padding: 3,
|
|
240
|
+
borderRadius: 2,
|
|
241
|
+
boxShadow: 3,
|
|
242
|
+
backgroundColor: 'white',
|
|
243
|
+
}}
|
|
244
|
+
>
|
|
245
|
+
<Typography variant="h6" color="error" gutterBottom>
|
|
246
|
+
Code de validation invalide
|
|
247
|
+
</Typography>
|
|
248
|
+
<Typography variant="body1" color="textSecondary" gutterBottom>
|
|
249
|
+
Le code de validation fourni ne correspond à aucun utilisateur (ou votre compte a déjà été activé). <br />
|
|
250
|
+
Essayez de vous connecter avec votre numéro de téléphone.
|
|
251
|
+
<br />
|
|
252
|
+
Si le problème persiste, veuillez nous contacter à{' '}
|
|
253
|
+
<b>support@movalib.com</b>.
|
|
254
|
+
</Typography>
|
|
255
|
+
<Button
|
|
256
|
+
variant="contained"
|
|
257
|
+
color="primary"
|
|
258
|
+
onClick={(e) => history.push('/login')}
|
|
259
|
+
sx={{ marginTop: 2 }}
|
|
260
|
+
>
|
|
261
|
+
Retour à la connexion
|
|
262
|
+
</Button>
|
|
263
|
+
</Box>
|
|
264
|
+
</Box>
|
|
265
|
+
)}
|
|
266
|
+
|
|
267
|
+
</>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export default ActivateAccount;
|
|
272
|
+
|
|
273
|
+
|
package/src/helpers/ApiHelper.ts
CHANGED
|
@@ -55,16 +55,16 @@ function handleResponse(response: Response): Promise<APIResponse<any>> {
|
|
|
55
55
|
|
|
56
56
|
switch(response.status){
|
|
57
57
|
case 403:
|
|
58
|
-
errorMsg = 'Accès non autorisé
|
|
58
|
+
errorMsg = 'Accès non autorisé'; break;
|
|
59
59
|
case 404:
|
|
60
|
-
errorMsg = 'La ressource demandée est introuvable
|
|
60
|
+
errorMsg = (typeof data === 'string') ? data : 'La ressource demandée est introuvable'; break;
|
|
61
61
|
case 500:
|
|
62
|
-
errorMsg = 'Une erreur interne du serveur est survenue
|
|
62
|
+
errorMsg = 'Une erreur interne du serveur est survenue'; break;
|
|
63
63
|
default:
|
|
64
|
-
errorMsg = (typeof data === 'string') ? data : `Une erreur est survenue
|
|
64
|
+
errorMsg = (typeof data === 'string') ? data : `Une erreur est survenue`; break;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
return { success: false, error: errorMsg };
|
|
67
|
+
return { success: false, error: errorMsg, data: data };
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
return { success: true, data };
|
package/src/models/Garage.ts
CHANGED
|
@@ -17,6 +17,7 @@ export default class Garage {
|
|
|
17
17
|
name:string;
|
|
18
18
|
address:Address;
|
|
19
19
|
workforce: number;
|
|
20
|
+
partialWorkforce?: number;
|
|
20
21
|
contactPhone: string;
|
|
21
22
|
prestationCategories: CategoryPrestation[];
|
|
22
23
|
prestations: Prestation[];
|
|
@@ -43,6 +44,7 @@ export default class Garage {
|
|
|
43
44
|
teamManagementActive?: boolean;
|
|
44
45
|
documents?: Document[];
|
|
45
46
|
subscriptions?: Subscription[];
|
|
47
|
+
subscription?: Subscription;
|
|
46
48
|
supportPhoneNumber?: string;
|
|
47
49
|
operatorsActive?: boolean;
|
|
48
50
|
employees?: Employee[];
|
|
@@ -67,7 +69,9 @@ export default class Garage {
|
|
|
67
69
|
documents?: Document[],
|
|
68
70
|
subscriptions?: Subscription[],
|
|
69
71
|
loanerVehicleActive?: boolean,
|
|
70
|
-
loanerVehicleRequestActive?: boolean
|
|
72
|
+
loanerVehicleRequestActive?: boolean,
|
|
73
|
+
subscription?: Subscription,
|
|
74
|
+
partialWorkforce?: number
|
|
71
75
|
) {
|
|
72
76
|
this.id = id;
|
|
73
77
|
this.adminId = adminId;
|
|
@@ -86,5 +90,7 @@ export default class Garage {
|
|
|
86
90
|
this.vehicles = vehicles;
|
|
87
91
|
this.loanerVehicleActive = loanerVehicleActive;
|
|
88
92
|
this.loanerVehicleRequestActive = loanerVehicleRequestActive;
|
|
93
|
+
this.subscription = subscription;
|
|
94
|
+
this.partialWorkforce = partialWorkforce;
|
|
89
95
|
}
|
|
90
96
|
}
|
|
@@ -1,40 +1,77 @@
|
|
|
1
1
|
import { SubscriptionPaymentInterval, SubscriptionState, SubscriptionType } from "../helpers/Enums";
|
|
2
|
-
|
|
2
|
+
interface roiInterface {
|
|
3
|
+
period: string,
|
|
4
|
+
turnover: number,
|
|
5
|
+
nbInvoice: number,
|
|
6
|
+
nbQuote: number,
|
|
7
|
+
nbNoShow: number,
|
|
8
|
+
nbLostQuote: number,
|
|
9
|
+
moRateOne: number,
|
|
10
|
+
moRateTwo: number,
|
|
11
|
+
moRateThree: number,
|
|
12
|
+
moOne: number,
|
|
13
|
+
moTwo: number,
|
|
14
|
+
moThree: number,
|
|
15
|
+
comment: string
|
|
16
|
+
}
|
|
3
17
|
export default class Subscription {
|
|
4
18
|
|
|
5
|
-
// Properties
|
|
6
|
-
id: string;
|
|
7
|
-
garageId: string;
|
|
8
|
-
type: SubscriptionType;
|
|
9
|
-
state: SubscriptionState;
|
|
10
|
-
companyName: string;
|
|
11
|
-
companyEmail: string;
|
|
12
|
-
companySiren: string;
|
|
13
|
-
companyLegalForm: string;
|
|
14
|
-
trialDays: number;
|
|
15
|
-
startDate: Date;
|
|
16
|
-
activationDate: Date;
|
|
17
|
-
cancellationDate: Date;
|
|
18
|
-
paymentInterval: SubscriptionPaymentInterval;
|
|
19
|
-
paymentIban: string;
|
|
20
|
-
|
|
21
|
-
constructor(id: string, garageId: string, type: SubscriptionType, state: SubscriptionState, companyName: string,
|
|
22
|
-
companyEmail: string, companySiren: string, companyLegalForm: string, trialDays: number, startDate: Date, activationDate: Date,
|
|
23
|
-
cancellationDate: Date, paymentInterval: SubscriptionPaymentInterval, paymentIban : string) {
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
// Properties
|
|
21
|
+
id: string;
|
|
22
|
+
garageId: string;
|
|
23
|
+
type: SubscriptionType;
|
|
24
|
+
state: SubscriptionState;
|
|
25
|
+
companyName: string;
|
|
26
|
+
companyEmail: string;
|
|
27
|
+
companySiren: string;
|
|
28
|
+
companyLegalForm: string;
|
|
29
|
+
trialDays: number;
|
|
30
|
+
startDate: Date;
|
|
31
|
+
activationDate: Date;
|
|
32
|
+
cancellationDate: Date;
|
|
33
|
+
paymentInterval: SubscriptionPaymentInterval;
|
|
34
|
+
paymentIban: string;
|
|
35
|
+
roi: roiInterface;
|
|
36
|
+
additionalFormationQuantity: number;
|
|
37
|
+
additionalFormationFree: boolean;
|
|
38
|
+
webPage: boolean;
|
|
39
|
+
plvQuantity: number;
|
|
40
|
+
plvFree: boolean;
|
|
41
|
+
trainingOptionalOne: Date;
|
|
42
|
+
trainingOptionalTwo: Date;
|
|
43
|
+
|
|
44
|
+
constructor(id: string, garageId: string, type: SubscriptionType, state: SubscriptionState, companyName: string,
|
|
45
|
+
companyEmail: string, companySiren: string, companyLegalForm: string, trialDays: number, startDate: Date, activationDate: Date,
|
|
46
|
+
cancellationDate: Date, paymentInterval: SubscriptionPaymentInterval, paymentIban: string, roi: roiInterface, additionalFormationQuantity: number,
|
|
47
|
+
additionalFormationFree: boolean,
|
|
48
|
+
webPage: boolean,
|
|
49
|
+
plvQuantity: number,
|
|
50
|
+
plvFree: boolean,
|
|
51
|
+
trainingOptionalOne: Date,
|
|
52
|
+
trainingOptionalTwo: Date
|
|
53
|
+
) {
|
|
54
|
+
this.id = id;
|
|
55
|
+
this.garageId = garageId;
|
|
56
|
+
this.type = type;
|
|
57
|
+
this.state = state;
|
|
58
|
+
this.companyName = companyName;
|
|
59
|
+
this.companyEmail = companyEmail;
|
|
60
|
+
this.companySiren = companySiren;
|
|
61
|
+
this.companyLegalForm = companyLegalForm;
|
|
62
|
+
this.trialDays = trialDays;
|
|
63
|
+
this.startDate = startDate;
|
|
64
|
+
this.activationDate = activationDate;
|
|
65
|
+
this.cancellationDate = cancellationDate;
|
|
66
|
+
this.paymentInterval = paymentInterval;
|
|
67
|
+
this.paymentIban = paymentIban;
|
|
68
|
+
this.roi = roi;
|
|
69
|
+
this.webPage = webPage;
|
|
70
|
+
this.additionalFormationQuantity = additionalFormationQuantity;
|
|
71
|
+
this.additionalFormationFree = additionalFormationFree;
|
|
72
|
+
this.plvQuantity = plvQuantity;
|
|
73
|
+
this.plvFree = plvFree;
|
|
74
|
+
this.trainingOptionalOne = trainingOptionalOne;
|
|
75
|
+
this.trainingOptionalTwo = trainingOptionalTwo;
|
|
76
|
+
}
|
|
40
77
|
}
|
|
@@ -38,6 +38,15 @@ export default class UserService {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
static resendActivationAccount(req: any): Promise<APIResponse<string>> {
|
|
42
|
+
return request({
|
|
43
|
+
url: `${API_BASE_URL}/user/resend-activation-link`,
|
|
44
|
+
method: APIMethod.POST,
|
|
45
|
+
appType: MovaAppType.INDIVIDUAL,
|
|
46
|
+
body: JSON.stringify(req)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
static getSalesGarages(salesId: string,): Promise<APIResponse<Garage[]>> {
|
|
42
51
|
return request({
|
|
43
52
|
url: `${API_BASE_URL}/sales/${salesId}/garages`,
|
|
@@ -46,7 +55,7 @@ export default class UserService {
|
|
|
46
55
|
});
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
static validateAccount(req: any): Promise<APIResponse<
|
|
58
|
+
static validateAccount(req: any): Promise<APIResponse<User | {expiredCode?:boolean, unknowCode?: boolean}>> {
|
|
50
59
|
return request({
|
|
51
60
|
url: `${API_BASE_URL}/user/validate-account`,
|
|
52
61
|
method: APIMethod.POST,
|
|
@@ -55,6 +64,15 @@ export default class UserService {
|
|
|
55
64
|
});
|
|
56
65
|
}
|
|
57
66
|
|
|
67
|
+
static editUser(req: any, userId: string): Promise<APIResponse<string>> {
|
|
68
|
+
return request({
|
|
69
|
+
url: `${API_BASE_URL}/user/${userId}/complete`,
|
|
70
|
+
method: APIMethod.PATCH,
|
|
71
|
+
appType: MovaAppType.INDIVIDUAL,
|
|
72
|
+
body: JSON.stringify(req)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
58
76
|
/**
|
|
59
77
|
* @param email
|
|
60
78
|
* @param password
|