@movalib/movalib-commons 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MovaLogin.d.ts +2 -1
- package/dist/MovaLogin.js +2 -6
- package/package.json +1 -1
- package/src/MovaLogin.tsx +5 -8
package/dist/MovaLogin.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { FunctionComponent } from "react";
|
|
|
2
2
|
import { MovaLoginForm } from "./helpers/Types";
|
|
3
3
|
import { MovaAppType } from "./helpers/Enums";
|
|
4
4
|
interface MovaLoginProps {
|
|
5
|
-
movaAppType: MovaAppType;
|
|
5
|
+
movaAppType: MovaAppType | "GARAGE" | "USER" | "ADMIN";
|
|
6
6
|
onSubmit: (form: MovaLoginForm) => void;
|
|
7
|
+
loading?: boolean;
|
|
7
8
|
}
|
|
8
9
|
declare const MovaLogin: FunctionComponent<MovaLoginProps>;
|
|
9
10
|
export default MovaLogin;
|
package/dist/MovaLogin.js
CHANGED
|
@@ -73,10 +73,10 @@ var initialFormState = {
|
|
|
73
73
|
password: { value: '', isValid: true },
|
|
74
74
|
};
|
|
75
75
|
var MovaLogin = function (_a) {
|
|
76
|
-
var movaAppType = _a.movaAppType, onSubmit = _a.onSubmit;
|
|
76
|
+
var loading = _a.loading, movaAppType = _a.movaAppType, onSubmit = _a.onSubmit;
|
|
77
77
|
var _b = (0, react_1.useState)(initialFormState), form = _b[0], setForm = _b[1];
|
|
78
78
|
var _c = (0, react_1.useState)(""), message = _c[0], setMessage = _c[1];
|
|
79
|
-
|
|
79
|
+
//const [loading, setLoading] = useState(false);
|
|
80
80
|
var handleInputChange = function (e) {
|
|
81
81
|
var _a;
|
|
82
82
|
var fieldName = e.target.name;
|
|
@@ -87,7 +87,6 @@ var MovaLogin = function (_a) {
|
|
|
87
87
|
var handleSubmit = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
88
|
return __generator(this, function (_a) {
|
|
89
89
|
e.preventDefault();
|
|
90
|
-
setLoading(true);
|
|
91
90
|
try {
|
|
92
91
|
if (validateForm() && onSubmit) {
|
|
93
92
|
// Si le formulaire est valide, on appel la function callback transmise en props
|
|
@@ -97,9 +96,6 @@ var MovaLogin = function (_a) {
|
|
|
97
96
|
catch (error) {
|
|
98
97
|
console.error('Error occurred during submission:', error);
|
|
99
98
|
}
|
|
100
|
-
finally {
|
|
101
|
-
setLoading(false);
|
|
102
|
-
}
|
|
103
99
|
return [2 /*return*/];
|
|
104
100
|
});
|
|
105
101
|
}); };
|
package/package.json
CHANGED
package/src/MovaLogin.tsx
CHANGED
|
@@ -24,15 +24,16 @@ const initialFormState = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
interface MovaLoginProps {
|
|
27
|
-
movaAppType: MovaAppType,
|
|
28
|
-
onSubmit: (form: MovaLoginForm) => void
|
|
27
|
+
movaAppType: MovaAppType | "GARAGE" | "USER" | "ADMIN",
|
|
28
|
+
onSubmit: (form: MovaLoginForm) => void,
|
|
29
|
+
loading?: boolean
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ movaAppType, onSubmit }) => {
|
|
32
|
+
const MovaLogin: FunctionComponent<MovaLoginProps> = ({ loading, movaAppType, onSubmit }) => {
|
|
32
33
|
|
|
33
34
|
const [form, setForm] = useState<MovaLoginForm>(initialFormState);
|
|
34
35
|
const [message, setMessage] = useState<string>("");
|
|
35
|
-
const [loading, setLoading] = useState(false);
|
|
36
|
+
//const [loading, setLoading] = useState(false);
|
|
36
37
|
|
|
37
38
|
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
|
|
38
39
|
const fieldName: string = e.target.name;
|
|
@@ -44,8 +45,6 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ movaAppType, onSubmit })
|
|
|
44
45
|
|
|
45
46
|
const handleSubmit = async (e: FormEvent) => {
|
|
46
47
|
e.preventDefault();
|
|
47
|
-
setLoading(true);
|
|
48
|
-
|
|
49
48
|
try {
|
|
50
49
|
if(validateForm() && onSubmit) {
|
|
51
50
|
// Si le formulaire est valide, on appel la function callback transmise en props
|
|
@@ -54,8 +53,6 @@ const MovaLogin: FunctionComponent<MovaLoginProps> = ({ movaAppType, onSubmit })
|
|
|
54
53
|
|
|
55
54
|
}catch (error){
|
|
56
55
|
console.error('Error occurred during submission:', error);
|
|
57
|
-
}finally {
|
|
58
|
-
setLoading(false);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
|