Esta fue la versión 0.5.0
This commit is contained in:
parent
6fc5c172ce
commit
40b936c807
2 changed files with 41 additions and 41 deletions
|
@ -1,7 +1,7 @@
|
||||||
import {useEffect} from "react";
|
import { useEffect } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import {useSelector,useDispatch} from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import {Navigate,useLocation} from "react-router-dom";
|
import { Navigate, useLocation } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Container,
|
Container,
|
||||||
|
@ -17,21 +17,21 @@ import {
|
||||||
Toolbar,
|
Toolbar,
|
||||||
Link
|
Link
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import {Email,Lock} from "@mui/icons-material";
|
import { Email, Lock } from "@mui/icons-material";
|
||||||
import {Form} from "react-final-form";
|
import { Form } from "react-final-form";
|
||||||
import {TextField} from "mui-rff";
|
import { TextField } from "@chimera-pe/mui-rff";
|
||||||
import {useTranslate} from "react-polyglot";
|
import { useTranslate } from "react-polyglot";
|
||||||
import {requestToken} from "../redux";
|
import { requestToken } from "../redux";
|
||||||
import {useCheckLogin,useNotificar} from "../hooks";
|
import { useCheckLogin, useNotificar } from "../hooks";
|
||||||
|
|
||||||
const FormularioLogin=({devURL}) => {
|
const FormularioLogin = ({ devURL }) => {
|
||||||
const dispatch=useDispatch();
|
const dispatch = useDispatch();
|
||||||
const translate=useTranslate();
|
const translate = useTranslate();
|
||||||
const notificar=useNotificar();
|
const notificar = useNotificar();
|
||||||
const {cargando,error}=useSelector(store => store.login);
|
const { cargando, error } = useSelector(store => store.login);
|
||||||
const instancia=useSelector(store => store.aplicacion.instancia);
|
const instancia = useSelector(store => store.aplicacion.instancia);
|
||||||
|
|
||||||
const submit=values => {
|
const submit = values => {
|
||||||
dispatch(requestToken({
|
dispatch(requestToken({
|
||||||
devURL: devURL,
|
devURL: devURL,
|
||||||
clientCredentials: instancia.clientCredentials,
|
clientCredentials: instancia.clientCredentials,
|
||||||
|
@ -42,29 +42,29 @@ const FormularioLogin=({devURL}) => {
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const validate=values => {
|
const validate = values => {
|
||||||
const errors={correo: undefined,password: undefined};
|
const errors = { correo: undefined, password: undefined };
|
||||||
|
|
||||||
if(!values.correo) {
|
if (!values.correo) {
|
||||||
errors.correo=translate("saas.login.validacion.correo");
|
errors.correo = translate("saas.login.validacion.correo");
|
||||||
}
|
}
|
||||||
if(!values.password) {
|
if (!values.password) {
|
||||||
errors.password=translate("saas.login.validacion.password");
|
errors.password = translate("saas.login.validacion.password");
|
||||||
}
|
}
|
||||||
return errors;
|
return errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(error) {
|
if (error) {
|
||||||
notificar("saas.login.error","error");
|
notificar("saas.login.error", "error");
|
||||||
}
|
}
|
||||||
},[notificar,error]);
|
}, [notificar, error]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
onSubmit={submit}
|
onSubmit={submit}
|
||||||
validate={validate}
|
validate={validate}
|
||||||
render={({handleSubmit}) => (
|
render={({ handleSubmit }) => (
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<TextField
|
<TextField
|
||||||
id="correo"
|
id="correo"
|
||||||
|
@ -121,18 +121,18 @@ const FormularioLogin=({devURL}) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
FormularioLogin.propTypes={
|
FormularioLogin.propTypes = {
|
||||||
devURL: PropTypes.string
|
devURL: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
const Login=({devURL}) => {
|
const Login = ({ devURL }) => {
|
||||||
const instancia=useSelector(store => store.aplicacion.instancia);
|
const instancia = useSelector(store => store.aplicacion.instancia);
|
||||||
const translate=useTranslate();
|
const translate = useTranslate();
|
||||||
const location=useLocation();
|
const location = useLocation();
|
||||||
const autenticado=useCheckLogin(devURL);
|
const autenticado = useCheckLogin(devURL);
|
||||||
const {from}=location.state || {from: {pathname: "/"}};
|
const { from } = location.state || { from: { pathname: "/" } };
|
||||||
|
|
||||||
if(!instancia.requiereLogin || autenticado) {
|
if (!instancia.requiereLogin || autenticado) {
|
||||||
return <Navigate to={from} />;
|
return <Navigate to={from} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +168,8 @@ const Login=({devURL}) => {
|
||||||
<Container maxWidth="md">
|
<Container maxWidth="md">
|
||||||
<Grid container spacing={3}>
|
<Grid container spacing={3}>
|
||||||
<Grid item xs={12} lg={5} align="center">
|
<Grid item xs={12} lg={5} align="center">
|
||||||
<img src={instancia.logo} alt={instancia.nombre} style={{maxWidth: "100%"}} />
|
<img src={instancia.logo} alt={instancia.nombre} style={{ maxWidth: "100%" }} />
|
||||||
<Typography variant="h3" align="center">{translate("aplicacion.nombre",{smart_count: 1})}</Typography>
|
<Typography variant="h3" align="center">{translate("aplicacion.nombre", { smart_count: 1 })}</Typography>
|
||||||
<Typography variant="h5" align="center">{instancia.nombre}</Typography>
|
<Typography variant="h5" align="center">{instancia.nombre}</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} lg={7} sx={{
|
<Grid item xs={12} lg={7} sx={{
|
||||||
|
@ -179,7 +179,7 @@ const Login=({devURL}) => {
|
||||||
zIndex: 5
|
zIndex: 5
|
||||||
}}>
|
}}>
|
||||||
<Card elevation={5}>
|
<Card elevation={5}>
|
||||||
<CardHeader title={translate("saas.login.titulo")} titleTypographyProps={{align: "center"}} />
|
<CardHeader title={translate("saas.login.titulo")} titleTypographyProps={{ align: "center" }} />
|
||||||
<CardContent sx={{
|
<CardContent sx={{
|
||||||
"& .MuiTextField-root": {
|
"& .MuiTextField-root": {
|
||||||
mb: 2
|
mb: 2
|
||||||
|
@ -193,7 +193,7 @@ const Login=({devURL}) => {
|
||||||
</Container>
|
</Container>
|
||||||
</Box>
|
</Box>
|
||||||
<AppBar position="static" color="primary">
|
<AppBar position="static" color="primary">
|
||||||
<Toolbar sx={{justifyContent: "center"}}>
|
<Toolbar sx={{ justifyContent: "center" }}>
|
||||||
<Typography variant="caption">
|
<Typography variant="caption">
|
||||||
{translate("saas.copy")}
|
{translate("saas.copy")}
|
||||||
<Link href="//chimera.com.pe" color="inherit" target="_blank" rel="noreferrer">Chimera Software</Link>
|
<Link href="//chimera.com.pe" color="inherit" target="_blank" rel="noreferrer">Chimera Software</Link>
|
||||||
|
@ -204,7 +204,7 @@ const Login=({devURL}) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Login.propTypes={
|
Login.propTypes = {
|
||||||
devURL: PropTypes.string
|
devURL: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default defineConfig({
|
||||||
"axios",
|
"axios",
|
||||||
"date-fns/locale",
|
"date-fns/locale",
|
||||||
"jwt-decode",
|
"jwt-decode",
|
||||||
"mui-rff",
|
"@chimera-pe/mui-rff",
|
||||||
"navigator-languages",
|
"navigator-languages",
|
||||||
"node-polyglot",
|
"node-polyglot",
|
||||||
"react-polyglot",
|
"react-polyglot",
|
||||||
|
@ -61,7 +61,7 @@ export default defineConfig({
|
||||||
"axios": "Axios",
|
"axios": "Axios",
|
||||||
"date-fns/locale": "DateFNSLocale",
|
"date-fns/locale": "DateFNSLocale",
|
||||||
"jwt-decode": "JWTDecode",
|
"jwt-decode": "JWTDecode",
|
||||||
"mui-rff": "MUIRFF",
|
"@chimera-pe/mui-rff": "MUIRFF",
|
||||||
"navigator-languages": "NavigatorLanguages",
|
"navigator-languages": "NavigatorLanguages",
|
||||||
"node-polyglot": "NodePolyglot",
|
"node-polyglot": "NodePolyglot",
|
||||||
"react-polyglot": "ReactPolyglot",
|
"react-polyglot": "ReactPolyglot",
|
||||||
|
|
Loading…
Add table
Reference in a new issue