📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Added ForgotPassword page
Blaumaus802c0c0e9984
diff --git a/src/App.js b/src/App.jsindex 26958d722..8eb22462d 100644--- a/src/App.js+++ b/src/App.js@@ -6,6 +6,8 @@ import Header from 'components/Header'import MainPage from 'pages/MainPage'import SignUp from 'pages/Auth/Signup'import SignIn from 'pages/Auth/Signin'+import ForgotPassword from 'pages/Auth/ForgotPassword'+import Dashboard from 'pages/Dashboard'export default () => {return (@@ -14,7 +16,9 @@ export default () => {<Switch><Route path={routes.signin} component={SignIn} exact /><Route path={routes.signup} component={SignUp} exact />+ <Route path={routes.recovery} component={ForgotPassword} exact /><Route path={routes.main} component={MainPage} exact />+ <Route path={routes.dashboard} component={Dashboard} exact /><Redirect to={routes.main} /></Switch></>diff --git a/src/pages/Auth/ForgotPassword/ForgotPassword.container.jsx b/src/pages/Auth/ForgotPassword/ForgotPassword.container.jsxnew file mode 100644index 000000000..6710b9bc5--- /dev/null+++ b/src/pages/Auth/ForgotPassword/ForgotPassword.container.jsx@@ -0,0 +1,11 @@+import ForgotPassword from './ForgotPassword'++export default () => {+ const onSubmit = data => {+ console.log(data)+ }++ return (+ <ForgotPassword onSubmit={onSubmit} />+ )+}\ No newline at end of filediff --git a/src/pages/Auth/ForgotPassword/ForgotPassword.jsx b/src/pages/Auth/ForgotPassword/ForgotPassword.jsxnew file mode 100644index 000000000..71febcf32--- /dev/null+++ b/src/pages/Auth/ForgotPassword/ForgotPassword.jsx@@ -0,0 +1,86 @@+import React, { useState, useEffect } from 'react'+import { Link } from 'react-router-dom'+import Form from 'react-bootstrap/Form'++import routes from 'routes'+import { isValidEmail, isValidPassword } from 'utils/validator'++export default ({ onSubmit }) => {+ const [form, setForm] = useState({+ email: '',+ })+ const [validated, setValidated] = useState(false)+ const [errors, setErrors] = useState({})+ const [beenSubmitted, setBeenSubmitted] = useState(false)++ useEffect(() => {+ validate()+ }, [form])++ const handleInput = event => {+ const t = event.target+ const value = t.type === 'checkbox' ? t.checked : t.value++ setForm(form => ({+ ...form,+ [t.name]: value,+ }))+ }++ const handleSubmit = e => {+ e.preventDefault()+ e.stopPropagation()+ setBeenSubmitted(true)++ if (validated) {+ onSubmit(form)+ }+ }++ const validate = () => {+ const allErrors = {}++ if (!isValidEmail(form.email)) {+ allErrors.email = 'Please provide a valid email.'+ }++ const valid = Object.keys(allErrors).length === 0++ setErrors(allErrors)+ setValidated(valid)+ }++ return (+ <div className="container">+ <h4 className="mb-3">Account recovery</h4>+ <Form validated={validated} onSubmit={handleSubmit} noValidate>+ <Form.Group className="mb-3 has-validation">+ <Form.Label htmlFor="email">Email</Form.Label>+ <Form.Control+ type="email"+ value={form.email}+ placeholder="[email protected]"+ id="email"+ className="form-control"+ name="email"+ onChange={handleInput}+ isValid={!errors.hasOwnProperty('email')}+ isInvalid={beenSubmitted && errors.hasOwnProperty('email')}+ required+ />+ <Form.Control.Feedback type="invalid">+ {errors.email}+ </Form.Control.Feedback>+ </Form.Group>+ </Form>+ <div className="d-flex align-items-center mb-3">+ <Link to={routes.signin} className="btn btn-link">+ Sign in+ </Link>+ <button type="submit" className="btn btn-primary ml-auto">+ Reset password+ </button>+ </div>+ </div>+ )+}\ No newline at end of filediff --git a/src/pages/Auth/ForgotPassword/index.jsx b/src/pages/Auth/ForgotPassword/index.jsxindex e69de29bb..b35507343 100644--- a/src/pages/Auth/ForgotPassword/index.jsx+++ b/src/pages/Auth/ForgotPassword/index.jsx@@ -0,0 +1,3 @@+import ForgotPassword from './ForgotPassword.container'++export default ForgotPassword\ No newline at end of filediff --git a/src/pages/Auth/Signin/Signin.jsx b/src/pages/Auth/Signin/Signin.jsxindex 0923f5f61..0799106fa 100644--- a/src/pages/Auth/Signin/Signin.jsx+++ b/src/pages/Auth/Signin/Signin.jsx@@ -102,6 +102,10 @@ export default ({ onSubmit }) => {</Form.Label></Form.Group><div className="d-flex align-items-center mb-3">+ <Link to={routes.reset_password} className="btn btn-link">+ Forgot password?+ </Link>+ <span> | </span><Link to={routes.signup} className="btn btn-link">Sign up instead</Link>diff --git a/src/pages/Dashboard/Dashboard.container.jsx b/src/pages/Dashboard/Dashboard.container.jsxnew file mode 100644index 000000000..52222edba--- /dev/null+++ b/src/pages/Dashboard/Dashboard.container.jsx@@ -0,0 +1,3 @@+import Dashboard from './Dashboard'++export default Dashboard\ No newline at end of filediff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsxnew file mode 100644index 000000000..3e5f7df4c--- /dev/null+++ b/src/pages/Dashboard/Dashboard.jsx@@ -0,0 +1,8 @@+import React from 'react'++export default () => {++ return (+ <h1>Dashboard page</h1>+ )+}\ No newline at end of filediff --git a/src/pages/Dashboard/index.jsx b/src/pages/Dashboard/index.jsxnew file mode 100644index 000000000..784eaa059--- /dev/null+++ b/src/pages/Dashboard/index.jsx@@ -0,0 +1,3 @@+import Dashboard from './Dashboard.container'++export default Dashboard\ No newline at end of filediff --git a/src/routes.js b/src/routes.jsindex f488bdd85..1ef8f3a4d 100644--- a/src/routes.js+++ b/src/routes.js@@ -1,5 +1,7 @@export default Object.freeze({signin: '/login',signup: '/signup',+ reset_password: '/recovery',main: '/',+ dashboard: '/dashboard'})\ No newline at end of file