import React, { Component } from 'react'; // @ts-ignore import { Field, reduxForm } from 'redux-form'; import { History, LocationState } from 'history'; import Login from '../../../HOC/login/Login'; import routes from '../../../constants/routes.json'; type MyComponentProps = { history: History; auth: any; firstLogin: (formValues: object, callBack: () => void) => void; handleSubmit: (submitHandle: any) => any; }; class FirstLogin extends Component { componentDidMount(): void { const { auth, history } = this.props; if (auth.authenticateStore) { history.push(routes.USERS_LOGIN); } } renderInput = (reduxProps: any) => { const { icon, type, placeholder, name, input, meta, focus } = reduxProps; const styleClass = meta.touched && meta.error ? 'input-group input-lg' : 'input-group no-border input-lg'; return ( <>
); }; submitHandle = (formValues: any) => { const { firstLogin, history } = this.props; firstLogin(formValues, () => { history.push(routes.USERS_LOGIN); }); }; renderError() { const { auth } = this.props; if (auth.errorMessage) { return (
{auth.errorMessage}
); } return ''; } render() { const { handleSubmit } = this.props; return (
{this.renderError()}
{/*
*/} {/* Forgot password? */} {/*
*/}
); } } const validate = (formValues: any) => { const error = { username: '', password: '', }; if (!formValues.username) { error.username = 'you must enter email'; } if (!formValues.password) { error.password = 'you must enter the password'; } return error; }; export default reduxForm({ form: 'signIn', validate })(FirstLogin);