2017-12-25 17:45:28 +01:00
|
|
|
import React from 'react'
|
2018-01-01 11:10:39 +01:00
|
|
|
import { Helmet } from 'react-helmet'
|
2017-12-25 17:45:28 +01:00
|
|
|
|
2019-08-25 12:50:42 +02:00
|
|
|
import { history } from '../../index'
|
|
|
|
import { isRegistrationAllowed } from '../../utils'
|
|
|
|
|
2017-12-25 17:45:28 +01:00
|
|
|
export default function Form (props) {
|
|
|
|
return (
|
|
|
|
<div>
|
2018-01-01 11:10:39 +01:00
|
|
|
<Helmet>
|
2018-06-07 14:45:43 +02:00
|
|
|
<title>FitTrackee - {props.formType}</title>
|
2018-01-01 11:10:39 +01:00
|
|
|
</Helmet>
|
2018-06-12 12:51:23 +02:00
|
|
|
<h1 className="page-title">
|
|
|
|
{`${props.formType.charAt(0).toUpperCase()}${props.formType.slice(1)}`}
|
|
|
|
</h1>
|
2017-12-25 20:11:10 +01:00
|
|
|
<div className="container">
|
2019-08-25 12:50:42 +02:00
|
|
|
<div className="row">
|
|
|
|
<div className="col-md-3" />
|
|
|
|
<div className="col-md-6">
|
|
|
|
<hr /><br />
|
|
|
|
{props.formType === 'register' && !isRegistrationAllowed ? (
|
|
|
|
<div className="card">
|
|
|
|
<div className="card-body">Registration is disabled.</div>
|
|
|
|
<div className="card-body">
|
|
|
|
<button
|
|
|
|
type="submit"
|
|
|
|
className="btn btn-secondary btn-lg btn-block"
|
|
|
|
onClick={() => history.go(-1)}
|
|
|
|
>Back
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<form onSubmit={event =>
|
|
|
|
props.handleUserFormSubmit(event, props.formType)}
|
|
|
|
>
|
|
|
|
{props.formType === 'register' &&
|
|
|
|
<div className="form-group">
|
|
|
|
<input
|
|
|
|
className="form-control input-lg"
|
|
|
|
name="username"
|
|
|
|
placeholder="Enter a username"
|
|
|
|
required
|
|
|
|
type="text"
|
|
|
|
value={props.userForm.username}
|
|
|
|
onChange={props.onHandleFormChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
<div className="form-group">
|
|
|
|
<input
|
|
|
|
className="form-control input-lg"
|
|
|
|
name="email"
|
|
|
|
placeholder="Enter an email address"
|
|
|
|
required
|
|
|
|
type="email"
|
|
|
|
value={props.userForm.email}
|
|
|
|
onChange={props.onHandleFormChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="form-group">
|
|
|
|
<input
|
|
|
|
className="form-control input-lg"
|
|
|
|
name="password"
|
|
|
|
placeholder="Enter a password"
|
|
|
|
required
|
|
|
|
type="password"
|
|
|
|
value={props.userForm.password}
|
|
|
|
onChange={props.onHandleFormChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{props.formType === 'register' &&
|
|
|
|
<div className="form-group">
|
|
|
|
<input
|
|
|
|
className="form-control input-lg"
|
|
|
|
name="password_conf"
|
|
|
|
placeholder="Enter the password confirmation"
|
|
|
|
required
|
|
|
|
type="password"
|
|
|
|
value={props.userForm.password_conf}
|
|
|
|
onChange={props.onHandleFormChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
<input
|
|
|
|
type="submit"
|
|
|
|
className="btn btn-primary btn-lg btn-block"
|
|
|
|
value="Submit"
|
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
<div className="col-md-3" />
|
2017-12-25 17:45:28 +01:00
|
|
|
</div>
|
2017-12-25 20:11:10 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2017-12-25 17:45:28 +01:00
|
|
|
)
|
|
|
|
}
|