Skip to content

📈 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!

Improved mobile layout, fixed ESLint issues & added mock Docs page

Blue Mouse940b9d75cad9
diff --git a/src/App.js b/src/App.js
index a23600c43..d7ebdd6d4 100644
--- a/src/App.js
+++ b/src/App.js
@@ -11,6 +11,7 @@ import SignIn from 'pages/Auth/Signin'
import ForgotPassword from 'pages/Auth/ForgotPassword'
import CreateNewPassword from 'pages/Auth/CreateNewPassword'
import Dashboard from 'pages/Dashboard'
+import Docs from 'pages/Docs'
import UserSettings from 'pages/UserSettings'
import VerifyEmail from 'pages/Auth/VerifyEmail'
import ProjectSettings from 'pages/Project/Settings'
@@ -63,7 +64,7 @@ const App = () => {
}
})
}
- }, [error])
+ }, [error]) // eslint-disable-line
useEffect(() => {
if (message && type) {
@@ -74,7 +75,7 @@ const App = () => {
}
})
}
- }, [message, type])
+ }, [message, type]) // eslint-disable-line
return (
(!accessToken || !loading) && (
@@ -93,6 +94,7 @@ const App = () => {
<Route path={routes.new_project} component={ProtectedProjectSettings} exact />
<Route path={routes.project_settings} component={ProtectedProjectSettings} exact />
<Route path={routes.project} component={ProtectedViewProject} exact />
+ <Route path={routes.docs} component={Docs} exact />
<Redirect to={routes.main} />
</Switch>
</>
@@ -100,4 +102,4 @@ const App = () => {
)
}
-export default App
\ No newline at end of file
+export default App
diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx
index f5d5eaec3..5c7e1f9f6 100644
--- a/src/components/Header/index.jsx
+++ b/src/components/Header/index.jsx
@@ -1,5 +1,6 @@
-import React from 'react'
-import { Link } from 'react-router-dom'
+import React, { memo } from 'react'
+import cx from 'classnames'
+import { Link, useLocation } from 'react-router-dom'
import { useDispatch } from 'react-redux'
import routes from 'routes'
@@ -7,6 +8,11 @@ import { authActions } from 'redux/actions/auth'
const Header = ({ authenticated }) => {
const dispatch = useDispatch()
+ const { pathname } = useLocation()
+
+ const logoutHandler = () => {
+ dispatch(authActions.logout())
+ }
return (
<header className='bg-indigo-600'>
@@ -18,18 +24,28 @@ const Header = ({ authenticated }) => {
<img className='h-10 w-auto' src='https://tailwindui.com/img/logos/workflow-mark.svg?color=white' alt='' />
</Link>
<div className='hidden ml-10 space-x-1 lg:block'>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Features'>Features</Link>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</Link>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</Link>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' key='Docs'>Docs</Link>
+ <Link to='/' className={cx('text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.NON_EXISTENT_YET,
+ })} key='Features'>Features</Link>
+ <Link to='/' className={cx('text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.NON_EXISTENT_YET,
+ })} key='Pricing'>Pricing</Link>
+ <Link to='/' className={cx('text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.NON_EXISTENT_YET,
+ })} key='FAQs'>FAQs</Link>
+ <Link to={routes.docs} className={cx('text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.docs,
+ })} key='Docs'>Docs</Link>
</div>
</div>
<div className='ml-10 space-x-4'>
{authenticated ? (
<>
- <Link to={routes.user_settings} className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md'>You</Link>
+ <Link to={routes.user_settings} className={cx('text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.user_settings,
+ })}>You</Link>
<Link to={routes.dashboard} className='inline-block bg-white py-2 px-4 border border-transparent rounded-md text-base font-medium text-indigo-600 hover:bg-indigo-50'>Dashboard</Link>
- <Link to='#' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' onClick={() => dispatch(authActions.logout())}>Logout</Link>
+ <Link to='#' className='text-base font-medium text-white hover:text-indigo-50 py-2 px-3 hover:bg-indigo-500 rounded-md' onClick={logoutHandler}>Logout</Link>
</>
) : (
<>
@@ -40,14 +56,22 @@ const Header = ({ authenticated }) => {
</div>
</div>
<div className='py-4 flex flex-wrap justify-center space-x-2 lg:hidden'>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Features'>Features</Link>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Pricing'>Pricing</Link>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='FAQs'>FAQs</Link>
- <Link to='/' className='text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md' key='Docs'>Docs</Link>
+ <Link to='/' className={cx('text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.NON_EXISTENT_YET,
+ })} key='Features'>Features</Link>
+ <Link to='/' className={cx('text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.NON_EXISTENT_YET,
+ })} key='Pricing'>Pricing</Link>
+ <Link to='/' className={cx('text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.NON_EXISTENT_YET,
+ })} key='FAQs'>FAQs</Link>
+ <Link to='/' className={cx('text-base font-medium text-white hover:text-indigo-50 py-1 px-3 hover:bg-indigo-500 rounded-md', {
+ 'bg-indigo-700 hover:bg-indigo-700': pathname === routes.docs,
+ })} key='Docs'>Docs</Link>
</div>
</nav>
</header>
)
}
-export default React.memo(Header)
\ No newline at end of file
+export default memo(Header)
diff --git a/src/pages/Auth/CreateNewPassword/CreateNewPassword.container.jsx b/src/pages/Auth/CreateNewPassword/CreateNewPassword.container.jsx
index 3829944c0..f80e74c8d 100644
--- a/src/pages/Auth/CreateNewPassword/CreateNewPassword.container.jsx
+++ b/src/pages/Auth/CreateNewPassword/CreateNewPassword.container.jsx
@@ -7,7 +7,7 @@ import { errorsActions } from 'redux/actions/errors'
import { alertsActions } from 'redux/actions/alerts'
import routes from 'routes'
-export default () => {
+const CreateNewPasswordContainer = () => {
const dispatch = useDispatch()
const history = useHistory()
const { id } = useParams()
@@ -27,4 +27,6 @@ export default () => {
return (
<CreateNewPassword onSubmit={onSubmit} />
)
-}
\ No newline at end of file
+}
+
+export default CreateNewPasswordContainer
diff --git a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
index f8150d9c3..91a8e4fb7 100644
--- a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
+++ b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react'
+import React, { useState, useEffect, memo } from 'react'
import { Link } from 'react-router-dom'
import routes from 'routes'
@@ -6,7 +6,7 @@ import Input from 'ui/Input'
import Button from 'ui/Button'
import { isValidPassword } from 'utils/validator'
-export default ({ onSubmit }) => {
+const CreateNewPassword = ({ onSubmit }) => {
const [form, setForm] = useState({
password: '',
repeat: '',
@@ -17,7 +17,7 @@ export default ({ onSubmit }) => {
useEffect(() => {
validate()
- }, [form])
+ }, [form]) // eslint-disable-line
const handleInput = event => {
const t = event.target
@@ -96,4 +96,6 @@ export default ({ onSubmit }) => {
</form>
</div>
)
-}
\ No newline at end of file
+}
+
+export default memo(CreateNewPassword)
diff --git a/src/pages/Auth/ForgotPassword/ForgotPassword.container.jsx b/src/pages/Auth/ForgotPassword/ForgotPassword.container.jsx
index 9bfe37b7f..868fa85c7 100644
--- a/src/pages/Auth/ForgotPassword/ForgotPassword.container.jsx
+++ b/src/pages/Auth/ForgotPassword/ForgotPassword.container.jsx
@@ -7,7 +7,7 @@ import { errorsActions } from 'redux/actions/errors'
import { alertsActions } from 'redux/actions/alerts'
import routes from 'routes'
-export default () => {
+const ForgotPasswordContainer = () => {
const dispatch = useDispatch()
const history = useHistory()
@@ -25,4 +25,6 @@ export default () => {
return (
<ForgotPassword onSubmit={onSubmit} />
)
-}
\ No newline at end of file
+}
+
+export default ForgotPasswordContainer
diff --git a/src/pages/Auth/ForgotPassword/ForgotPassword.jsx b/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
index aca167ab0..46c867ceb 100644
--- a/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
+++ b/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
@@ -1,12 +1,12 @@
-import React, { useState, useEffect } from 'react'
+import React, { useState, useEffect, memo } from 'react'
import { Link } from 'react-router-dom'
import routes from 'routes'
import Input from 'ui/Input'
import Button from 'ui/Button'
-import { isValidEmail, isValidPassword } from 'utils/validator'
+import { isValidEmail } from 'utils/validator'
-export default ({ onSubmit }) => {
+const ForgotPassword = ({ onSubmit }) => {
const [form, setForm] = useState({
email: '',
})
@@ -16,7 +16,7 @@ export default ({ onSubmit }) => {
useEffect(() => {
validate()
- }, [form])
+ }, [form]) // eslint-disable-line
const handleInput = event => {
const t = event.target
@@ -79,4 +79,6 @@ export default ({ onSubmit }) => {
</form>
</div>
)
-}
\ No newline at end of file
+}
+
+export default memo(ForgotPassword)
diff --git a/src/pages/Auth/Signin/Signin.container.jsx b/src/pages/Auth/Signin/Signin.container.jsx
index 5531856dc..0fa4ce5b1 100644
--- a/src/pages/Auth/Signin/Signin.container.jsx
+++ b/src/pages/Auth/Signin/Signin.container.jsx
@@ -2,7 +2,7 @@ import Signin from './Signin'
import { useDispatch } from 'react-redux'
import { authActions } from 'redux/actions/auth'
-export default () => {
+const SigninContainer = () => {
const dispatch = useDispatch()
const onSubmit = data => {
@@ -12,4 +12,6 @@ export default () => {
return (
<Signin onSubmit={onSubmit} />
)
-}
\ No newline at end of file
+}
+
+export default SigninContainer
diff --git a/src/pages/Auth/Signin/Signin.jsx b/src/pages/Auth/Signin/Signin.jsx
index 5ad171586..92527baaa 100644
--- a/src/pages/Auth/Signin/Signin.jsx
+++ b/src/pages/Auth/Signin/Signin.jsx
@@ -1,5 +1,6 @@
-import React, { useState, useEffect } from 'react'
+import React, { useState, useEffect, memo } from 'react'
import { Link } from 'react-router-dom'
+import PropTypes from 'prop-types'
import routes from 'routes'
import Input from 'ui/Input'
@@ -7,7 +8,7 @@ import Button from 'ui/Button'
import Checkbox from 'ui/Checkbox'
import { isValidEmail, isValidPassword } from 'utils/validator'
-export default ({ onSubmit }) => {
+const Signin = ({ onSubmit }) => {
const [form, setForm] = useState({
email: '',
password: '',
@@ -19,7 +20,7 @@ export default ({ onSubmit }) => {
useEffect(() => {
validate()
- }, [form])
+ }, [form]) // eslint-disable-line
const handleInput = event => {
const t = event.target
@@ -112,4 +113,10 @@ export default ({ onSubmit }) => {
</form>
</div>
)
-}
\ No newline at end of file
+}
+
+Signin.propTypes = {
+ onSubmit: PropTypes.func.isRequired,
+}
+
+export default memo(Signin)
diff --git a/src/pages/Auth/Signup/Signup.container.jsx b/src/pages/Auth/Signup/Signup.container.jsx
index ec9f5971b..002e936d0 100644
--- a/src/pages/Auth/Signup/Signup.container.jsx
+++ b/src/pages/Auth/Signup/Signup.container.jsx
@@ -2,7 +2,7 @@ import Signup from './Signup'
import { useDispatch } from 'react-redux'
import { authActions } from 'redux/actions/auth'
-export default () => {
+const SignupContainer = () => {
const dispatch = useDispatch()
const onSubmit = data => {
@@ -13,4 +13,6 @@ export default () => {
return (
<Signup onSubmit={onSubmit} />
)
-}
\ No newline at end of file
+}
+
+export default SignupContainer
diff --git a/src/pages/Auth/Signup/Signup.jsx b/src/pages/Auth/Signup/Signup.jsx
index dc3857577..1ecacfac0 100644
--- a/src/pages/Auth/Signup/Signup.jsx
+++ b/src/pages/Auth/Signup/Signup.jsx
@@ -1,5 +1,6 @@
-import React, { useState, useEffect } from 'react'
+import React, { useState, useEffect, memo } from 'react'
import { Link } from 'react-router-dom'
+import PropTypes from 'prop-types'
import routes from 'routes'
import Input from 'ui/Input'
@@ -7,7 +8,7 @@ import Checkbox from 'ui/Checkbox'
import Button from 'ui/Button'
import { isValidEmail, isValidPassword } from 'utils/validator'
-export default ({ onSubmit }) => {
+const Signup = ({ onSubmit }) => {
const [form, setForm] = useState({
email: '',
password: '',
@@ -21,7 +22,7 @@ export default ({ onSubmit }) => {
useEffect(() => {
validate()
- }, [form])
+ }, [form]) // eslint-disable-line
const handleInput = event => {
const t = event.target
@@ -135,4 +136,10 @@ export default ({ onSubmit }) => {
</form>
</div>
)
-}
\ No newline at end of file
+}
+
+Signup.propTypes = {
+ onSubmit: PropTypes.func.isRequired,
+}
+
+export default memo(Signup)
diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx
index ae228e18c..331a790ed 100644
--- a/src/pages/Dashboard/Dashboard.jsx
+++ b/src/pages/Dashboard/Dashboard.jsx
@@ -37,36 +37,36 @@ const ProjectCart = ({ name, url, created, active, overall }) => {
</div>
<div className='mt-2 sm:flex sm:justify-between'>
<div className='sm:flex flex-col'>
- <p className='flex items-center mt-2 text-sm text-gray-500'>
+ <div className='flex items-center mt-2 text-sm text-gray-500'>
<EyeIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />
Pageviews:&nbsp;
- <dd class="flex items-baseline">
- <p class="h-5 w-5 text-gray-500">
+ <dd className='flex items-baseline'>
+ <p className='h-5 w-5 text-gray-500'>
{overall.thisWeek}
</p>
- <p class={cx('flex text-xs -ml-1 items-baseline', {
+ <p className={cx('flex text-xs -ml-1 items-baseline', {
'text-green-600': statsDidGrowUp,
'text-red-600': !statsDidGrowUp,
})}>
{statsDidGrowUp ? (
<>
<ArrowSmUpIcon className='self-center flex-shrink-0 h-4 w-4 text-green-500' />
- <span class="sr-only">
+ <span className='sr-only'>
Increased by
- </span>
+ </span>
</>
) : (
<>
<ArrowSmDownIcon className='self-center flex-shrink-0 h-4 w-4 text-red-500' />
- <span class="sr-only">
+ <span className='sr-only'>
Descreased by
- </span>
+ </span>
</>
)}
{overall.percChange}%
- </p>
+ </p>
</dd>
- </p>
+ </div>
{/* <p className='mt-2 flex items-center text-sm text-gray-500 sm:mt-0'>
<ChartBarIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />
Average load time
@@ -75,7 +75,7 @@ const ProjectCart = ({ name, url, created, active, overall }) => {
<div className='mt-2 flex items-center text-sm text-gray-500'>
<CalendarIcon className='flex-shrink-0 mr-1.5 h-5 w-5 text-gray-400' />
<p>
- Created at <time datetime='2020-01-07'>{dayjs(created).format('MMMM D, YYYY')}</time>
+ Created at <time dateTime={dayjs(created).format('YYYY-MM-DD')}>{dayjs(created).format('MMMM D, YYYY')}</time>
</p>
</div>
</div>
@@ -104,14 +104,14 @@ const NoProjects = () => (
const Dashboard = ({ projects, isLoading, error }) => {
if (error && !isLoading) {
return (
- <div className="flex justify-center pt-10">
- <div className="rounded-md bg-red-50 p-4 w-11/12 lg:w-4/6">
- <div className="flex">
- <div className="flex-shrink-0">
- <XCircleIcon className="h-5 w-5 text-red-400" aria-hidden="true" />
+ <div className='flex justify-center pt-10'>
+ <div className='rounded-md bg-red-50 p-4 w-11/12 lg:w-4/6'>
+ <div className='flex'>
+ <div className='flex-shrink-0'>
+ <XCircleIcon className='h-5 w-5 text-red-400' aria-hidden='true' />
</div>
- <div className="ml-3">
- <h3 className="text-sm font-medium text-red-800">{error}</h3>
+ <div className='ml-3'>
+ <h3 className='text-sm font-medium text-red-800'>{error}</h3>
</div>
</div>
</div>
@@ -121,7 +121,7 @@ const Dashboard = ({ projects, isLoading, error }) => {
if (!isLoading) {
return (
- <div className='min-h-page bg-gray-50 flex flex-col py-6 sm:px-6 lg:px-8'>
+ <div className='min-h-page bg-gray-50 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
<div className='max-w-7xl w-full mx-auto'>
<div className='flex justify-between'>
<h2 className='mt-2 text-3xl font-extrabold text-gray-900'>Dashboard</h2>
diff --git a/src/pages/Docs/Docs.container.jsx b/src/pages/Docs/Docs.container.jsx
new file mode 100644
index 000000000..3da0e4e21
--- /dev/null
+++ b/src/pages/Docs/Docs.container.jsx
@@ -0,0 +1,5 @@
+// Container is needed just in case if the react-redux will be ever used in this component
+// so it would be easy to integrate connect() here
+import Docs from './Docs'
+
+export default Docs
diff --git a/src/pages/Docs/Docs.jsx b/src/pages/Docs/Docs.jsx
new file mode 100644
index 000000000..e429a5249
--- /dev/null
+++ b/src/pages/Docs/Docs.jsx
@@ -0,0 +1,11 @@
+import React from 'react'
+
+const Docs = () => {
+ return (
+ <div className='flex justify-center'>
+ Docs page
+ </div>
+ )
+}
+
+export default Docs
diff --git a/src/pages/Docs/index.jsx b/src/pages/Docs/index.jsx
new file mode 100644
index 000000000..490b1c39a
--- /dev/null
+++ b/src/pages/Docs/index.jsx
@@ -0,0 +1,3 @@
+import Docs from './Docs.container'
+
+export default Docs
diff --git a/src/pages/MainPage/index.jsx b/src/pages/MainPage/index.jsx
index 17bf37bd4..3c803125e 100644
--- a/src/pages/MainPage/index.jsx
+++ b/src/pages/MainPage/index.jsx
@@ -1,14 +1,16 @@
import React from 'react'
-export default () => {
+const Main = () => {
return (
<>
- <div className="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
- <h1 className="display-4">Analytics</h1>
- <p className="lead">
+ <div className='pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center'>
+ <h1 className='display-4'>Analytics</h1>
+ <p className='lead'>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
</p>
</div>
</>
)
-}
\ No newline at end of file
+}
+
+export default Main
diff --git a/src/pages/Project/Settings/ProjectSettings.jsx b/src/pages/Project/Settings/ProjectSettings.jsx
index 00072e4cf..128571d4b 100644
--- a/src/pages/Project/Settings/ProjectSettings.jsx
+++ b/src/pages/Project/Settings/ProjectSettings.jsx
@@ -19,7 +19,7 @@ const ProjectSettings = ({
}) => {
const { pathname } = useLocation()
const { id } = useParams()
- const project = useMemo(() => _find(projects, p => p.id === id) || {}, [projects])
+ const project = useMemo(() => _find(projects, p => p.id === id) || {}, [projects, id])
const isSettings = !_isEmpty(id) && (_replace(routes.project_settings, ':id', id) === pathname)
const history = useHistory()
const [form, setForm] = useState({
@@ -33,6 +33,7 @@ const ProjectSettings = ({
const [showDelete, setShowDelete] = useState(false)
useEffect(() => {
+ console.log('rerender')
if (!isLoading && isSettings) {
if (_isEmpty(project)) {
showError('The selected project does not exist')
@@ -41,7 +42,7 @@ const ProjectSettings = ({
setForm(project)
}
}
- }, [project, isLoading, isSettings])
+ }, [project, isLoading, isSettings, history, showError])
const onSubmit = async (data) => {
try {
@@ -76,7 +77,7 @@ const ProjectSettings = ({
useEffect(() => {
validate()
- }, [form])
+ }, [form]) // eslint-disable-line
const handleInput = event => {
const t = event.target
@@ -120,7 +121,7 @@ const ProjectSettings = ({
}
return (
- <div className='min-h-page bg-gray-50 flex flex-col py-6 sm:px-6 lg:px-8'>
+ <div className='min-h-page bg-gray-50 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
<form className='max-w-7xl w-full mx-auto' onSubmit={handleSubmit}>
<h2 className='mt-2 text-3xl font-extrabold text-gray-900'>
{isSettings ? `${form.name} settings` : 'Create a new project'}
@@ -215,4 +216,4 @@ ProjectSettings.propTypes = {
isLoading: PropTypes.bool.isRequired,
}
-export default ProjectSettings
\ No newline at end of file
+export default ProjectSettings
diff --git a/src/pages/Project/View/Panels.jsx b/src/pages/Project/View/Panels.jsx
index d1f8d953a..ac454f8b9 100644
--- a/src/pages/Project/View/Panels.jsx
+++ b/src/pages/Project/View/Panels.jsx
@@ -18,7 +18,7 @@ const Panel = ({ name, data }) => {
const currentIndex = page * ENTRIES_PER_PANEL
const keys = useMemo(() => _keys(data).sort((a, b) => data[b] - data[a]), [data])
const keysToDisplay = useMemo(() => _slice(keys, currentIndex, currentIndex + 5), [keys, currentIndex])
- const total = useMemo(() => _reduce(keys, (prev, curr) => prev + data[curr], 0), [keys])
+ const total = useMemo(() => _reduce(keys, (prev, curr) => prev + data[curr], 0), [keys]) // eslint-disable-line
const canGoPrev = () => page > 0
const canGoNext = () => page < _floor(_size(keys) / ENTRIES_PER_PANEL)
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 6687f582b..77d912bf6 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -6,9 +6,6 @@ import * as d3 from 'd3'
import dayjs from 'dayjs'
import _keys from 'lodash/keys'
import _map from 'lodash/map'
-import _reduce from 'lodash/reduce'
-import _size from 'lodash/size'
-import _isNull from 'lodash/isNull'
import _includes from 'lodash/includes'
import _last from 'lodash/last'
import _isEmpty from 'lodash/isEmpty'
@@ -51,7 +48,7 @@ const ViewProject = ({
}) => {
const { id } = useParams()
const history = useHistory()
- const project = useMemo(() => _find(projects, p => p.id === id) || {}, [projects])
+ const project = useMemo(() => _find(projects, p => p.id === id) || {}, [projects, id])
const [panelsData, setPanelsData] = useState({})
const [analyticsLoading, setAnalyticsLoading] = useState(true)
const [period, setPeriod] = useState(tbPeriodPairs[1].period)
@@ -124,7 +121,7 @@ const ViewProject = ({
useEffect(() => {
loadAnalytics()
- }, [project, period, timeBucket])
+ }, [project, period, timeBucket]) // eslint-disable-line
const updatePeriod = (newPeriod) => {
const newPeriodFull = _find(tbPeriodPairs, (el) => el.period === newPeriod)
@@ -148,7 +145,7 @@ const ViewProject = ({
if (!isLoading) {
return (
- <div className='min-h-page bg-gray-50 py-6 sm:px-6 lg:px-8'>
+ <div className='min-h-page bg-gray-50 py-6 px-4 sm:px-6 lg:px-8'>
<div className='flex flex-col md:flex-row items-center md:items-start justify-between h-10 mb-10 pb-10'>
<h2 className='text-3xl font-extrabold text-gray-900 break-words'>{name}</h2>
<div className='flex mt-3 md:mt-0'>
diff --git a/src/pages/UserSettings/UserSettings.container.jsx b/src/pages/UserSettings/UserSettings.container.jsx
index efffa4bf4..6ecbac8c2 100644
--- a/src/pages/UserSettings/UserSettings.container.jsx
+++ b/src/pages/UserSettings/UserSettings.container.jsx
@@ -9,7 +9,7 @@ import { confirmEmail, exportUserData } from 'api'
import UserSettings from './UserSettings'
-export default () => {
+const UserSettingsContainer = () => {
const dispatch = useDispatch()
const onDelete = () => {
@@ -76,6 +76,8 @@ export default () => {
onExport={onExport}
onSubmit={onSubmit}
onEmailConfirm={onEmailConfirm}
- />
+ />
)
-}
\ No newline at end of file
+}
+
+export default UserSettingsContainer
diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsx
index 7df1c621b..1cea7020b 100644
--- a/src/pages/UserSettings/UserSettings.jsx
+++ b/src/pages/UserSettings/UserSettings.jsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react'
+import React, { useState, useEffect, memo } from 'react'
import { useSelector } from 'react-redux'
import { MailIcon } from '@heroicons/react/outline'
@@ -24,7 +24,7 @@ const UserSettings = ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
useEffect(() => {
validate()
- }, [form])
+ }, [form]) // eslint-disable-line
const handleInput = event => {
const t = event.target
@@ -68,7 +68,7 @@ const UserSettings = ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
}
return (
- <div className='min-h-page bg-gray-50 flex flex-col py-6 sm:px-6 lg:px-8'>
+ <div className='min-h-page bg-gray-50 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
<form className='max-w-7xl w-full mx-auto' onSubmit={handleSubmit}>
<h2 className='mt-2 text-3xl font-extrabold text-gray-900'>
Profile settings
@@ -82,7 +82,7 @@ const UserSettings = ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
placeholder='[email protected]'
className='mt-4'
onChange={handleInput}
- error={beenSubmitted && errors.email}
+ error={beenSubmitted ? errors.email : null}
/>
<div className='grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6 mt-4'>
<Input
@@ -95,7 +95,7 @@ const UserSettings = ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
placeholder='Password'
className='sm:col-span-3'
onChange={handleInput}
- error={beenSubmitted && errors.password}
+ error={beenSubmitted ? errors.password : null}
/>
<Input
name='repeat'
@@ -106,7 +106,7 @@ const UserSettings = ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
placeholder='Repeat password'
className='sm:col-span-3'
onChange={handleInput}
- error={beenSubmitted && errors.repeat}
+ error={beenSubmitted ? errors.repeat : null}
/>
</div>
<Button className='mt-4' type='submit' primary large>
@@ -171,4 +171,4 @@ const UserSettings = ({ onDelete, onExport, onSubmit, onEmailConfirm }) => {
)
}
-export default React.memo(UserSettings)
\ No newline at end of file
+export default memo(UserSettings)
diff --git a/src/redux/actions/ui/index.js b/src/redux/actions/ui/index.js
index ef10123f2..cd290c70f 100644
--- a/src/redux/actions/ui/index.js
+++ b/src/redux/actions/ui/index.js
@@ -25,9 +25,11 @@ const setProjectsLoading = (isLoading) => ({
}
})
-export default {
+const UIActions = {
loadProjects,
setProjects,
setProjectsError,
setProjectsLoading,
}
+
+export default UIActions
diff --git a/src/redux/reducers/alerts.js b/src/redux/reducers/alerts.js
index 111daf40a..56c2dfca7 100644
--- a/src/redux/reducers/alerts.js
+++ b/src/redux/reducers/alerts.js
@@ -5,7 +5,7 @@ const initialState = {
type: 'info'
}
-export default (state = initialState, { type, payload }) => {
+const alertsReducer = (state = initialState, { type, payload }) => {
switch (type) {
case types.ACCOUNT_DELETED:
case types.ACCOUNT_UPDATED:
@@ -21,3 +21,5 @@ export default (state = initialState, { type, payload }) => {
return state
}
}
+
+export default alertsReducer
diff --git a/src/redux/reducers/auth.js b/src/redux/reducers/auth.js
index dd488ff9c..202fcb485 100644
--- a/src/redux/reducers/auth.js
+++ b/src/redux/reducers/auth.js
@@ -7,29 +7,31 @@ const initialState = {
user: null
}
-export default (state = initialState, { type, payload }) => {
+const authReducer = (state = initialState, { type, payload }) => {
switch (type) {
case types.SIGNUP_UP_SUCCESSFUL:
- case types.LOGIN_SUCCESSFUL:
- return { ...state, user: payload.user, authenticated: true }
-
- case types.UPDATE_USER_PROFILE_SUCCESS:
- return { ...state, user: payload.user }
-
- case types.EMAIL_VERIFY_SUCCESSFUL:
- return { ...state, user: { ...state.user, isActive: true }}
-
- case types.SAVE_PATH:
- return { ...state, redirectPath: payload.path }
-
- case types.LOGOUT:
- case types.DELETE_ACCOUNT_SUCCESS:
- return { ...state, authenticated: false, user: null }
-
- case types.FINISH_LOADING:
- return { ...state, loading: false }
-
- default:
- return state
+ case types.LOGIN_SUCCESSFUL:
+ return { ...state, user: payload.user, authenticated: true }
+
+ case types.UPDATE_USER_PROFILE_SUCCESS:
+ return { ...state, user: payload.user }
+
+ case types.EMAIL_VERIFY_SUCCESSFUL:
+ return { ...state, user: { ...state.user, isActive: true } }
+
+ case types.SAVE_PATH:
+ return { ...state, redirectPath: payload.path }
+
+ case types.LOGOUT:
+ case types.DELETE_ACCOUNT_SUCCESS:
+ return { ...state, authenticated: false, user: null }
+
+ case types.FINISH_LOADING:
+ return { ...state, loading: false }
+
+ default:
+ return state
}
-}
\ No newline at end of file
+}
+
+export default authReducer
\ No newline at end of file
diff --git a/src/redux/reducers/errors.js b/src/redux/reducers/errors.js
index 97caa4613..4d8629d93 100644
--- a/src/redux/reducers/errors.js
+++ b/src/redux/reducers/errors.js
@@ -4,7 +4,7 @@ const initialState = {
error: null
}
-export default (state = initialState, { type, payload }) => {
+const errorsReducer = (state = initialState, { type, payload }) => {
switch (type) {
case types.GENERIC_ERROR:
case types.LOGIN_FAILED:
@@ -24,3 +24,5 @@ export default (state = initialState, { type, payload }) => {
return state
}
}
+
+export default errorsReducer
diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js
index dd4e6b276..6ef0830a3 100644
--- a/src/redux/reducers/index.js
+++ b/src/redux/reducers/index.js
@@ -4,4 +4,4 @@ import errors from './errors'
import alerts from './alerts'
import ui from './ui'
-export default combineReducers({ auth, errors, alerts, ui })
\ No newline at end of file
+export default combineReducers({ auth, errors, alerts, ui })
diff --git a/src/redux/reducers/ui/projects.js b/src/redux/reducers/ui/projects.js
index 0469dd0c7..02bf4ff19 100644
--- a/src/redux/reducers/ui/projects.js
+++ b/src/redux/reducers/ui/projects.js
@@ -4,11 +4,11 @@ const getInitialState = () => {
return {
projects: [],
isLoading: true,
- error: null,
+ error: null,
}
}
-export default (state = getInitialState(), { type, payload }) => {
+const projectsReducer = (state = getInitialState(), { type, payload }) => {
switch (type) {
case types.SET_PROJECTS: {
const { projects } = payload
@@ -23,7 +23,7 @@ export default (state = getInitialState(), { type, payload }) => {
const { error } = payload
return {
...state,
- error,
+ error,
}
}
@@ -39,3 +39,5 @@ export default (state = getInitialState(), { type, payload }) => {
return state
}
}
+
+export default projectsReducer
diff --git a/src/redux/sagas/auth/workers/deleteUserAccount.js b/src/redux/sagas/auth/workers/deleteUserAccount.js
index 700bc9087..ddf90c89d 100644
--- a/src/redux/sagas/auth/workers/deleteUserAccount.js
+++ b/src/redux/sagas/auth/workers/deleteUserAccount.js
@@ -1,8 +1,9 @@
import { call, put } from 'redux-saga/effects'
+
import { authActions } from 'redux/actions/auth'
import { deleteUser } from 'api'
-export default function* ({ payload: { errorCallback } }) {
+export default function* deleteUserAccountWorker({ payload: { errorCallback } }) {
try {
yield call(deleteUser)
yield put(authActions.deleteAccountSuccess())
diff --git a/src/redux/sagas/auth/workers/signin.js b/src/redux/sagas/auth/workers/signin.js
index 5d7a05b75..a11d058a1 100644
--- a/src/redux/sagas/auth/workers/signin.js
+++ b/src/redux/sagas/auth/workers/signin.js
@@ -6,7 +6,7 @@ import UIActions from 'redux/actions/ui'
import { setAccessToken } from 'utils/accessToken'
import { login } from 'api'
-export default function* ({ payload: { credentials } }) {
+export default function* singinWorker({ payload: { credentials } }) {
try {
const response = yield call(login, credentials)
diff --git a/src/redux/sagas/auth/workers/signup.js b/src/redux/sagas/auth/workers/signup.js
index 53fbd199c..c03177ba8 100644
--- a/src/redux/sagas/auth/workers/signup.js
+++ b/src/redux/sagas/auth/workers/signup.js
@@ -6,7 +6,7 @@ import UIActions from 'redux/actions/ui'
import { setAccessToken } from 'utils/accessToken'
import { signup } from 'api'
-export default function* ({ payload: { data, resetRecaptcha = () => {} } }) {
+export default function* signupWorder({ payload: { data, resetRecaptcha = () => {} } }) {
try {
const response = yield call(signup, data)
diff --git a/src/redux/sagas/auth/workers/updateUserProfile.js b/src/redux/sagas/auth/workers/updateUserProfile.js
index 95888acf5..b6f3ba4af 100644
--- a/src/redux/sagas/auth/workers/updateUserProfile.js
+++ b/src/redux/sagas/auth/workers/updateUserProfile.js
@@ -1,9 +1,10 @@
import { call, put } from 'redux-saga/effects'
+
import { authActions } from 'redux/actions/auth'
import { errorsActions } from 'redux/actions/errors'
import { changeUserDetails } from 'api'
-export default function* ({ payload: { data, successfulCallback } }) {
+export default function* updateUserProfileWorker({ payload: { data, successfulCallback } }) {
try {
const user = yield call(changeUserDetails, data)
diff --git a/src/redux/sagas/auth/workers/verifyEmail.js b/src/redux/sagas/auth/workers/verifyEmail.js
index 71950dede..5ca09fdb8 100644
--- a/src/redux/sagas/auth/workers/verifyEmail.js
+++ b/src/redux/sagas/auth/workers/verifyEmail.js
@@ -1,8 +1,9 @@
import { call, put } from 'redux-saga/effects'
+
import { authActions } from 'redux/actions/auth'
-import { verifyEmail } from "api"
+import { verifyEmail } from 'api'
-export default function* ({ payload: { data, successfulCallback, errorCallback } }) {
+export default function* verifyEmailWorker({ payload: { data, successfulCallback, errorCallback } }) {
try {
yield call(verifyEmail, data)
yield put(authActions.emailVerifySuccess())
diff --git a/src/redux/sagas/ui/index.js b/src/redux/sagas/ui/index.js
index 335aa2820..a5d3c2562 100644
--- a/src/redux/sagas/ui/index.js
+++ b/src/redux/sagas/ui/index.js
@@ -4,7 +4,9 @@ import { types } from '../../actions/ui/types'
import loadProjects from './load_projects'
import initialise from './initialise'
-export default function* () {
+function* mainUISaga() {
yield fork(initialise)
yield takeEvery(types.LOAD_PROJECTS, loadProjects)
}
+
+export default mainUISaga
diff --git a/src/redux/sagas/ui/initialise.js b/src/redux/sagas/ui/initialise.js
index fb912b67e..046b4d7d8 100644
--- a/src/redux/sagas/ui/initialise.js
+++ b/src/redux/sagas/ui/initialise.js
@@ -6,7 +6,7 @@ import UIActions from 'redux/actions/ui'
const debug = Debug('analytics:rx:s:initialise')
-export default function* () {
+export default function* initialise() {
try {
const token = yield call(getAccessToken)
diff --git a/src/redux/sagas/ui/load_projects.js b/src/redux/sagas/ui/load_projects.js
index 1a37e0a3d..a9a38544e 100644
--- a/src/redux/sagas/ui/load_projects.js
+++ b/src/redux/sagas/ui/load_projects.js
@@ -7,7 +7,7 @@ import UIActions from 'redux/actions/ui'
const debug = Debug('analytics:rx:s:load-projects')
-export default function* () {
+export default function* loadProjects() {
try {
let { results } = yield call(getProjects)
const pids = _map(results, result => result.id)
diff --git a/src/routes.js b/src/routes.js
index d1255067c..7d8d80830 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -11,4 +11,5 @@ export default Object.freeze({
new_project: '/projects/new',
project_settings: '/projects/settings/:id',
project: '/projects/:id',
+ docs: '/docs',
})
\ No newline at end of file
diff --git a/src/ui/Checkbox.jsx b/src/ui/Checkbox.jsx
index 9eae6c1d1..e36977df5 100644
--- a/src/ui/Checkbox.jsx
+++ b/src/ui/Checkbox.jsx
@@ -21,7 +21,7 @@ const Checkbox = ({
/>
</div>
<div className='ml-3 text-sm'>
- <label for={identifier} className='font-medium text-gray-700 cursor-pointer'>{label}</label>
+ <label htmlFor={identifier} className='font-medium text-gray-700 cursor-pointer'>{label}</label>
{hint && (
<p id={`${identifier}-description`} className='text-gray-500'>{hint}</p>
)}
diff --git a/src/ui/Dropdown.jsx b/src/ui/Dropdown.jsx
index f4ecd81fd..ba0748207 100644
--- a/src/ui/Dropdown.jsx
+++ b/src/ui/Dropdown.jsx
@@ -3,7 +3,6 @@ import { Menu, Transition } from '@headlessui/react'
import { ChevronDownIcon } from '@heroicons/react/solid'
import cx from 'classnames'
import _map from 'lodash/map'
-import _isObject from 'lodash/isObject'
import PropTypes from 'prop-types'
const Dropdown = ({
diff --git a/src/ui/Input.jsx b/src/ui/Input.jsx
index 249f95075..e935b85e9 100644
--- a/src/ui/Input.jsx
+++ b/src/ui/Input.jsx
@@ -15,7 +15,7 @@ const Input = ({
<div className={cx({
'flex justify-between': label && hint,
})}>
- <label for={identifier} className='block text-sm font-medium text-gray-700'>{label}</label>
+ <label htmlFor={identifier} className='block text-sm font-medium text-gray-700'>{label}</label>
<span className='text-sm text-gray-500' id={`${identifier}-optional`}>{hint}</span>
</div>
<div className='mt-1 relative'>
diff --git a/src/ui/Modal.jsx b/src/ui/Modal.jsx
index 1d35c15f1..e6cbd5712 100644
--- a/src/ui/Modal.jsx
+++ b/src/ui/Modal.jsx
@@ -5,7 +5,7 @@ import { Dialog, Transition } from '@headlessui/react'
import { CheckIcon } from '@heroicons/react/outline'
import { ExclamationIcon } from '@heroicons/react/outline'
-// todo: onClose, onSubmit, closeText, submitText
+// todo: onClose, onSubmit, closeText, submitText, create a redux endpoint to operate all the modals
const Modal = ({ className, type, title, message }) => {
const [open, setOpen] = useState(true)
@@ -42,8 +42,8 @@ const Modal = ({ className, type, title, message }) => {
<div>
{type === 'success' && (
<div className='mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-green-100'>
- <CheckIcon className='h-6 w-6 text-green-600' aria-hidden='true' />
- </div>
+ <CheckIcon className='h-6 w-6 text-green-600' aria-hidden='true' />
+ </div>
)}
{type === 'error' && (
<div className="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
diff --git a/src/ui/Pin.jsx b/src/ui/Pin.jsx
index c82cace11..5b6c223fa 100644
--- a/src/ui/Pin.jsx
+++ b/src/ui/Pin.jsx
@@ -24,13 +24,23 @@ const InactivePin = ({ label, className }) => (
</p>
)
+const WarningPin = ({ label, className }) => (
+ <p className={cx('px-2 inline-flex text-sm leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-600', className)}>
+ {label}
+ </p>
+)
+
ActivePin.propTypes = propTypes
ActivePin.defaultProps = defaultProps
+WarningPin.propTypes = propTypes
+WarningPin.defaultProps = defaultProps
+
InactivePin.propTypes = propTypes
InactivePin.defaultProps = defaultProps
export {
ActivePin,
InactivePin,
+ WarningPin,
}