import Breadcrumb from "../components/Breadcrumbs"; import { Box, Button, Container, TextField, Typography, useMediaQuery } from "@mui/material"; import UnstyledButtonCustom from "../components/MainButton"; import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'; import {useState} from "react"; import Link from "react-router-dom/es/Link"; import {connect} from 'react-redux'; import {actionFullLogin, actionFullRegister} from "../actions/ActionLogin"; import Redirect from "react-router-dom/es/Redirect"; const MyAccountPage = ({auth, promise, user, onLogin, onRegister}) => { const matches = useMediaQuery('(max-width:899px)') const [status, setStatus] = useState('login') const Form = ({title, target, onClickEvent, children}) => { const matches2 = useMediaQuery('(max-width:450px)') const [valueLogin, setValueLogin] = useState('') const [valuePassword, setValuePassword] = useState('') const [flagLogin, setFlagLog] = useState(false) const [flagPassword, setFlagPass] = useState(false) return ( {title} {setValueLogin(e.target.value); setFlagLog(true)}} error={flagLogin && (valueLogin.length < 3 || valueLogin.length > 20)} sx={{marginBottom: '20px'}} /> {setValuePassword(e.target.value); setFlagPass(true)}} error={flagPassword && (valuePassword.length < 3 || valuePassword.length > 20)} sx={{marginBottom: '30px'}} /> {children} { if(valuePassword.length >= 3 && valuePassword.length <= 20 && valueLogin.length >= 3 && valueLogin.length <= 20) { onClickEvent(valueLogin, valuePassword) } }} text={title} /> ) } return ( <>
{(auth?.payload && Object.keys(user).length !== 0) ? : status === 'login' ?
{promise?.login?.status === "RESOLVED" && This user does not exist } }/> : Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our privacy policy . {promise?.register?.status === "RESOLVED" && Such user already exists } }/> }
) } const CLoginForm = connect(state => ({auth: state.auth, promise: state.promise, user: state.user}), {onLogin: actionFullLogin, onRegister: actionFullRegister})(MyAccountPage) export default CLoginForm