[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

76 lines
2.4 KiB

import React, { FC, useEffect } from 'react'
import { RouteComponentProps } from 'react-router'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faIdCard, faKey } from '@fortawesome/free-solid-svg-icons'
import classNames from 'classnames'
import PageHeader from 'src/components/page-header'
import TextField from 'src/components/forms/text-field'
import PasswordField from 'src/components/forms/password-field'
import { ClassDictionary } from 'src/types'
export interface Props extends RouteComponentProps {
checked: boolean
authenticated: boolean
name?: string
password?: string
authenticating?: boolean
initForm: () => void
authenticate: (name: string, password: string) => void
}
const Login: FC<Props> = ({
checked,
authenticated,
name = '',
password = '',
authenticating = false,
initForm,
authenticate,
history
}) => {
useEffect(() => {
if (checked && authenticated) history.push('/self')
}, [checked, authenticated])
useEffect(() => {
initForm()
}, [])
const buttonClassDictionary: ClassDictionary = {
button: true,
'is-primary': true,
'is-loading': authenticating,
}
return (
<div>
<PageHeader title="Log In to Flexor" />
<div className="main-content">
<div className="centered-content">
<div className="centered-content-icon has-background-primary">
<span className="icon is-large has-text-white">
<FontAwesomeIcon icon={faKey} size="2x" />
</span>
</div>
<TextField icon={faIdCard} name="name" label="Username" placeholder="Your Username/ID" />
<br />
<PasswordField placeholder="Your password" showStrength={false} />
<br />
<button className={classNames(buttonClassDictionary)} onClick={() => authenticate(name, password)} disabled={authenticating}>
<span className="icon is-small">
<FontAwesomeIcon icon={faKey} />
</span>
<span>Log In</span>
</button>
</div>
</div>
</div>
)
}
export default Login