import React, { useState } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux';
import CardMedia from '@material-ui/core/CardMedia';
import { Google } from '@styled-icons/bootstrap/Google';
import { Facebook } from '@styled-icons/bootstrap/Facebook';
import Fab from '@material-ui/core/Fab';
// @ts-ignore
import styles from './Login.module.scss';
import { Config } from '../../../helper';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
import ForgotPassword from '../../../user/components/Auth/ForgotPassword';
import PasswordLoginApp from '../../../user/components/Auth/PasswordLoginApp';
import RegisterApp from '../../../user/components/Auth/RegisterApp';
import ResetPassword from '../../../user/components/Auth/ResetPassword';
import { loginUserByOAuth, resetPassword, registerUserByEmail } from '../../../user/reducers/auth/service';
import { useTranslation } from 'react-i18next';
const mapStateToProps = (state: any): any => {
return {};
};
const mapDispatchToProps = (dispatch: Dispatch): any => ({
loginUserByOAuth: bindActionCreators(loginUserByOAuth, dispatch),
resetPassword: bindActionCreators(resetPassword, dispatch),
registerUserByEmail: bindActionCreators(registerUserByEmail, dispatch),
});
interface Props {
auth?: any;
enableFacebookSocial?: boolean;
enableGithubSocial?: boolean;
enableGoogleSocial?: boolean;
loginUserByOAuth?: typeof loginUserByOAuth;
logo: string;
isAddConnection?: boolean;
resetPassword?: typeof resetPassword;
registerUserByEmail?: typeof registerUserByEmail;
}
const FlatSignIn = (props: Props) => {
const [view, setView] = useState('login');
const enableUserPassword = Config.publicRuntimeConfig?.auth ? Config.publicRuntimeConfig.auth.enableUserPassword : false;
const enableGoogleSocial = Config.publicRuntimeConfig?.auth ? Config.publicRuntimeConfig.auth.enableGoogleSocial : false;
const enableFacebookSocial = Config.publicRuntimeConfig?.auth ? Config.publicRuntimeConfig.auth.enableFacebookSocial : false;
const { t } = useTranslation();
const socials = [
enableGoogleSocial,
enableFacebookSocial
];
const socialCount = socials.filter(v => v).length;
const userTabPanel = enableUserPassword &&
{t('social:login.account')} setView('login')}>{t('social:login.login')}
)} >; break; case 'forget-password': component = <>{t('social:login.notHavingAccount')} setView('sign-up')}>{t('social:login.signUp')}
)}>; break; // completeAction={()=>setView('login')} removed from ResetPassword since it failed lintsub case 'reset-password': component = <>{t('social:login.notHavingAccount')} setView('sign-up')}>{t('social:login.signUp')}
)}>; break; } return