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