@ssplib/react-components 0.0.44 → 0.0.45
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/components/page/Login.d.ts +4 -1
- package/components/page/Login.js +31 -14
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function Login({ imgURL, name, fields }: {
|
|
2
|
+
export declare function Login({ imgURL, name, fields, loginURL, onSuccess, onFail, }: {
|
|
3
3
|
imgURL?: string;
|
|
4
|
+
loginURL: string;
|
|
4
5
|
fields: JSX.Element | JSX.Element[];
|
|
5
6
|
name?: string;
|
|
7
|
+
onSuccess: () => void;
|
|
8
|
+
onFail: () => void;
|
|
6
9
|
}): JSX.Element;
|
package/components/page/Login.js
CHANGED
|
@@ -27,24 +27,41 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Login = void 0;
|
|
30
|
+
const lab_1 = require("@mui/lab");
|
|
30
31
|
const material_1 = require("@mui/material");
|
|
31
32
|
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
32
|
-
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
33
33
|
const Container_1 = __importDefault(require("@mui/material/Container"));
|
|
34
34
|
const Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
35
35
|
const React = __importStar(require("react"));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} },
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
const react_1 = require("react");
|
|
37
|
+
const FormProvider_1 = __importDefault(require("../providers/FormProvider"));
|
|
38
|
+
function Login({ imgURL = '', name = 'Login', fields, loginURL, onSuccess, onFail, }) {
|
|
39
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
40
|
+
function login(data) {
|
|
41
|
+
fetch(loginURL, {
|
|
42
|
+
method: 'POST',
|
|
43
|
+
body: JSON.stringify(Object.assign(Object.assign({}, data), { cpf: data.cpf.replaceAll(/[.-]/g, '') })),
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
},
|
|
47
|
+
}).then((res) => {
|
|
48
|
+
if (res.ok)
|
|
49
|
+
onSuccess();
|
|
50
|
+
return onFail();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return (React.createElement(FormProvider_1.default, { onSubmit: login },
|
|
54
|
+
React.createElement(Container_1.default, { component: 'main', maxWidth: 'xs' },
|
|
55
|
+
React.createElement(Box_1.default, { sx: {
|
|
56
|
+
marginTop: 8,
|
|
57
|
+
display: 'flex',
|
|
58
|
+
flexDirection: 'column',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
} },
|
|
61
|
+
imgURL && React.createElement("img", { src: imgURL, alt: '', height: 100, width: 100 }),
|
|
62
|
+
React.createElement(Typography_1.default, { component: 'h1', variant: 'h5', paddingY: 3 }, name),
|
|
63
|
+
React.createElement(material_1.Stack, { spacing: 3, width: 300 },
|
|
64
|
+
React.createElement(material_1.Stack, { spacing: 1 }, fields),
|
|
65
|
+
React.createElement(lab_1.LoadingButton, { type: 'submit', fullWidth: true, variant: 'contained', loading: loading }, "Login"))))));
|
|
49
66
|
}
|
|
50
67
|
exports.Login = Login;
|