@movalib/movalib-commons 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,8 +2,7 @@ import { FunctionComponent } from 'react';
|
|
|
2
2
|
import { MovaAppType } from './helpers/Enums';
|
|
3
3
|
interface AccountValidationProps {
|
|
4
4
|
movaAppType: MovaAppType;
|
|
5
|
-
|
|
6
|
-
onError: () => void;
|
|
5
|
+
onSubmit: (success: boolean, message: string) => void;
|
|
7
6
|
}
|
|
8
7
|
declare const AccountValidation: FunctionComponent<AccountValidationProps>;
|
|
9
8
|
export default AccountValidation;
|
|
@@ -32,7 +32,7 @@ var initialFormState = {
|
|
|
32
32
|
confirmation: { value: '', isValid: true },
|
|
33
33
|
};
|
|
34
34
|
var AccountValidation = function (_a) {
|
|
35
|
-
var movaAppType = _a.movaAppType,
|
|
35
|
+
var movaAppType = _a.movaAppType, onSubmit = _a.onSubmit;
|
|
36
36
|
var _b = (0, react_1.useState)(true), loading = _b[0], setLoading = _b[1];
|
|
37
37
|
var _c = (0, react_1.useState)(initialFormState), passwordForm = _c[0], setPasswordForm = _c[1];
|
|
38
38
|
var location = (0, react_router_dom_1.useLocation)();
|
|
@@ -58,18 +58,24 @@ var AccountValidation = function (_a) {
|
|
|
58
58
|
}, [location]);
|
|
59
59
|
var activateAccount = function (req) {
|
|
60
60
|
if (req) {
|
|
61
|
-
Logger_1.default.info(req);
|
|
62
61
|
UserService_1.default.validateAccount(req)
|
|
63
62
|
.then(function (response) {
|
|
64
|
-
|
|
63
|
+
var _a, _b;
|
|
65
64
|
Logger_1.default.info(response);
|
|
66
|
-
if (
|
|
67
|
-
|
|
65
|
+
if (response.success) {
|
|
66
|
+
if (onSubmit) {
|
|
67
|
+
onSubmit(response.success, (_a = response.data) !== null && _a !== void 0 ? _a : '');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (onSubmit) {
|
|
72
|
+
onSubmit(response.success, (_b = response.error) !== null && _b !== void 0 ? _b : '');
|
|
73
|
+
}
|
|
68
74
|
}
|
|
69
75
|
}).catch(function (error) {
|
|
70
76
|
Logger_1.default.error(error);
|
|
71
|
-
if (
|
|
72
|
-
|
|
77
|
+
if (onSubmit) {
|
|
78
|
+
onSubmit(false, error);
|
|
73
79
|
}
|
|
74
80
|
});
|
|
75
81
|
}
|
|
@@ -102,7 +102,9 @@ var ScheduleFields = function (_a) {
|
|
|
102
102
|
newSchedule[dayIndex].checked = event.target.checked;
|
|
103
103
|
// On réinitialise aussi les intervals
|
|
104
104
|
newSchedule[dayIndex].intervals = [{ startTime: null, endTime: null, countryCode: 'fr', error: null }];
|
|
105
|
-
onChange
|
|
105
|
+
// L'activation ne doit pas déclencher le onChange
|
|
106
|
+
if (!event.target.checked)
|
|
107
|
+
onChange(newSchedule);
|
|
106
108
|
setSchedule(newSchedule);
|
|
107
109
|
}; };
|
|
108
110
|
var handleAllDayChecked = function (e, value, dayIndex) { return function (event) {
|
|
@@ -124,7 +126,6 @@ var ScheduleFields = function (_a) {
|
|
|
124
126
|
var sortedIntervals = __spreadArray([], intervals, true).sort(function (a, b) {
|
|
125
127
|
return a.startTime && b.startTime ? a.startTime.toISOString().localeCompare(b.startTime.toISOString()) : 0;
|
|
126
128
|
});
|
|
127
|
-
console.log(sortedIntervals);
|
|
128
129
|
for (var i = 0; i < sortedIntervals.length; i++) {
|
|
129
130
|
if (((_a = sortedIntervals[i].startTime) === null || _a === void 0 ? void 0 : _a.toString().localeCompare((_b = sortedIntervals[i].endTime) === null || _b === void 0 ? void 0 : _b.toString())) >= 0 ||
|
|
130
131
|
(i < sortedIntervals.length - 1 &&
|
|
@@ -146,7 +147,9 @@ var ScheduleFields = function (_a) {
|
|
|
146
147
|
newSchedule[dayIndex].intervals[intervalIndex].error = validateIntervals(newSchedule[dayIndex].intervals);
|
|
147
148
|
}
|
|
148
149
|
setSchedule(newSchedule);
|
|
149
|
-
|
|
150
|
+
// On invoque la callback de mise à jour uniquement sur l'intervalle de fin
|
|
151
|
+
if (type === 'endTime')
|
|
152
|
+
onChange(newSchedule);
|
|
150
153
|
};
|
|
151
154
|
};
|
|
152
155
|
var addInterval = function (dayIndex) { return function () {
|
package/package.json
CHANGED
|
@@ -19,11 +19,10 @@ const initialFormState = {
|
|
|
19
19
|
|
|
20
20
|
interface AccountValidationProps {
|
|
21
21
|
movaAppType: MovaAppType,
|
|
22
|
-
|
|
23
|
-
onError: () => void,
|
|
22
|
+
onSubmit: (success:boolean, message:string) => void,
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppType,
|
|
25
|
+
const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppType, onSubmit }) => {
|
|
27
26
|
|
|
28
27
|
const [loading, setLoading] = useState(true);
|
|
29
28
|
const [passwordForm, setPasswordForm] = useState<MovaPasswordForm>(initialFormState);
|
|
@@ -60,21 +59,25 @@ const AccountValidation: FunctionComponent<AccountValidationProps> = ({ movaAppT
|
|
|
60
59
|
const activateAccount = (req: any) => {
|
|
61
60
|
if(req){
|
|
62
61
|
|
|
63
|
-
Logger.info(req);
|
|
64
|
-
|
|
65
62
|
UserService.validateAccount(req)
|
|
66
63
|
.then(response => {
|
|
67
64
|
|
|
68
|
-
// Affichage notification utilisateur
|
|
69
65
|
Logger.info(response);
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
|
|
67
|
+
if(response.success){
|
|
68
|
+
if(onSubmit){
|
|
69
|
+
onSubmit(response.success, response.data ?? '');
|
|
70
|
+
}
|
|
71
|
+
}else{
|
|
72
|
+
if(onSubmit){
|
|
73
|
+
onSubmit(response.success, response.error ?? '');
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
}).catch(error => {
|
|
75
78
|
Logger.error(error);
|
|
76
|
-
if(
|
|
77
|
-
|
|
79
|
+
if(onSubmit){
|
|
80
|
+
onSubmit(false, error);
|
|
78
81
|
}
|
|
79
82
|
});
|
|
80
83
|
}
|
package/src/ScheduleFields.tsx
CHANGED
|
@@ -116,7 +116,10 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
|
|
|
116
116
|
newSchedule[dayIndex].checked = event.target.checked;
|
|
117
117
|
// On réinitialise aussi les intervals
|
|
118
118
|
newSchedule[dayIndex].intervals = [{startTime: null, endTime: null, countryCode: 'fr', error: null}];
|
|
119
|
-
onChange
|
|
119
|
+
// L'activation ne doit pas déclencher le onChange
|
|
120
|
+
if(!event.target.checked)
|
|
121
|
+
onChange(newSchedule);
|
|
122
|
+
|
|
120
123
|
setSchedule(newSchedule);
|
|
121
124
|
};
|
|
122
125
|
|
|
@@ -142,7 +145,6 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
|
|
|
142
145
|
const sortedIntervals = [...intervals].sort((a, b) =>
|
|
143
146
|
a.startTime && b.startTime ? a.startTime.toISOString().localeCompare(b.startTime.toISOString()) : 0);
|
|
144
147
|
|
|
145
|
-
console.log(sortedIntervals)
|
|
146
148
|
for (let i = 0; i < sortedIntervals.length; i++) {
|
|
147
149
|
if (
|
|
148
150
|
sortedIntervals[i].startTime?.toString().localeCompare(sortedIntervals[i].endTime?.toString()!)! >= 0 ||
|
|
@@ -177,7 +179,10 @@ const ScheduleFields: FunctionComponent<ScheduleFieldsProps> = ({ timePickerStep
|
|
|
177
179
|
}
|
|
178
180
|
|
|
179
181
|
setSchedule(newSchedule);
|
|
180
|
-
|
|
182
|
+
|
|
183
|
+
// On invoque la callback de mise à jour uniquement sur l'intervalle de fin
|
|
184
|
+
if(type === 'endTime')
|
|
185
|
+
onChange(newSchedule);
|
|
181
186
|
};
|
|
182
187
|
|
|
183
188
|
const addInterval = (dayIndex: number) => () => {
|