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!

added eslint configuration & fixed all the errors

Blue Mousec7a13c42310d
diff --git a/package.json b/package.json
index 8abee091e..423811b2c 100644
--- a/package.json
+++ b/package.json
@@ -47,13 +47,70 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
- "analyse": "source-map-explorer 'build/static/js/*.js'"
+ "analyse": "source-map-explorer 'build/static/js/*.js'",
+ "lint": "eslint src"
},
"eslintConfig": {
"extends": [
"react-app",
- "react-app/jest"
- ]
+ "react-app/jest",
+ "airbnb",
+ "eslint:recommended",
+ "plugin:react/recommended"
+ ],
+ "plugins": ["lodash", "react-hooks"],
+ "rules": {
+ "arrow-body-style": "off",
+ "arrow-parens": "off",
+ "import/no-cycle": "off",
+ "import/no-named-as-default": "off",
+ "import/no-named-as-default-member": "off",
+ "import/prefer-default-export": "off",
+ "jsx-a11y/click-events-have-key-events": "off",
+ "jsx-a11y/control-has-associated-label": "off",
+ "jsx-a11y/label-has-for": "off",
+ "jsx-a11y/no-noninteractive-element-interactions": "off",
+ "jsx-a11y/no-static-element-interactions": "off",
+ "jsx-quotes": ["error", "prefer-single"],
+ "linebreak-style": "off",
+ "lines-between-class-members": "off",
+ "lodash/prefer-lodash-method": "warn",
+ "max-len": "off",
+ "no-console": "off",
+ "no-bitwise": "off",
+ "no-continue": "off",
+ "no-empty-function": "off",
+ "no-nested-ternary": "off",
+ "no-plusplus": "off",
+ "no-underscore-dangle": "off",
+ "no-unused-vars": "warn",
+ "react/display-name": "warn",
+ "react/jsx-filename-extension": ["warn", { "extensions": [".js", ".jsx"] }],
+ "react/jsx-props-no-spreading": "off",
+ "react/prefer-stateless-function": "off",
+ "react/prop-types": "warn",
+ "react/state-in-constructor": "off",
+ "react/static-property-placement": "off",
+ "react-hooks/rules-of-hooks": "error",
+ "react/react-in-jsx-scope": "off",
+ "react-hooks/exhaustive-deps": "warn",
+ "react/function-component-definition": "off",
+ "semi": ["error", "never"]
+ },
+ "settings": {
+ "import/resolver": {
+ "node": {
+ "moduleDirectory": [
+ "node_modules",
+ "src"
+ ]
+ }
+ }
+ },
+ "env": {
+ "browser": true,
+ "jest": true
+ }
},
"browserslist": {
"production": [
@@ -70,6 +127,13 @@
"devDependencies": {
"autoprefixer": "^10.4.7",
"cross-env": "^7.0.3",
+ "eslint": "^8.15.0",
+ "eslint-config-airbnb": "^19.0.4",
+ "eslint-config-react-app": "^7.0.1",
+ "eslint-plugin-jsx-a11y": "^6.5.1",
+ "eslint-plugin-lodash": "^7.4.0",
+ "eslint-plugin-react": "^7.29.4",
+ "eslint-plugin-react-hooks": "^4.5.0",
"postcss": "^8.4.13",
"source-map-explorer": "^2.5.2",
"tailwindcss": "^3.0.24"
diff --git a/src/App.js b/src/App.js
index 98cf63bc3..5696c6a50 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,4 +1,6 @@
-import React, { useEffect, lazy, Suspense, useState } from 'react'
+import React, {
+ useEffect, lazy, Suspense, useState,
+} from 'react'
import { Switch, Route, useLocation } from 'react-router-dom'
import routes from 'routes'
import { useDispatch, useSelector } from 'react-redux'
@@ -17,11 +19,11 @@ import ScrollToTop from 'hoc/ScrollToTop'
import Selfhosted from 'hoc/Selfhosted'
import { isSelfhosted } from 'redux/constants'
import { getAccessToken } from 'utils/accessToken'
-import { authMe } from './api'
import { authActions } from 'redux/actions/auth'
import { errorsActions } from 'redux/actions/errors'
import { alertsActions } from 'redux/actions/alerts'
import UIActions from 'redux/actions/ui'
+import { authMe } from './api'
const MainPage = lazy(() => import('pages/MainPage'))
const SignUp = lazy(() => import('pages/Auth/Signup'))
@@ -85,6 +87,7 @@ const App = () => {
const eventCallback = (data) => {
dispatch(UIActions.setPaddleLastEvent(data))
}
+ // eslint-disable-next-line no-use-before-define
const interval = setInterval(paddleSetup, 200)
function paddleSetup() {
@@ -131,7 +134,7 @@ const App = () => {
alert.error(error.toString(), {
onClose: () => {
dispatch(errorsActions.clearErrors())
- }
+ },
})
}
}, [error]) // eslint-disable-line
@@ -142,7 +145,7 @@ const App = () => {
type,
onClose: () => {
dispatch(alertsActions.clearAlerts())
- }
+ },
})
}
}, [message, type]) // eslint-disable-line
@@ -151,6 +154,7 @@ const App = () => {
return (
(!accessToken || !loading) && (
+ // eslint-disable-next-line react/jsx-no-useless-fragment
<Suspense fallback={<></>}>
<Header authenticated={authenticated} theme={theme} />
<ScrollToTop>
diff --git a/src/api/index.js b/src/api/index.js
index cf0d3b8cb..ed558dc2f 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1,3 +1,4 @@
+/* eslint-disable implicit-arrow-linebreak */
import axios from 'axios'
import { store } from 'redux/store'
import Debug from 'debug'
@@ -18,13 +19,14 @@ api.interceptors.request.use(
(config) => {
const token = getAccessToken()
if (token) {
- config.headers['Authorization'] = `Bearer ${token}`
+ // eslint-disable-next-line no-param-reassign
+ config.headers.Authorization = `Bearer ${token}`
}
return config
},
(error) => {
return Promise.reject(error)
- }
+ },
)
api.interceptors.response.use(
@@ -35,7 +37,7 @@ api.interceptors.response.use(
store.dispatch(authActions.logout())
}
return Promise.reject(error)
- }
+ },
)
export const authMe = () =>
@@ -172,7 +174,7 @@ export const getProject = (pid) =>
export const createProject = (data) =>
api
- .post(`/project`, data)
+ .post('/project', data)
.then((response) => response.data)
.catch((error) => {
debug('%s', error)
@@ -214,7 +216,7 @@ export const getProjectData = (
) =>
api
.get(
- `log?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`
+ `log?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`,
)
.then((response) => response.data)
.catch((error) => {
diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx
index d4be06bb9..61a1ec527 100644
--- a/src/components/Header/index.jsx
+++ b/src/components/Header/index.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable jsx-a11y/anchor-is-valid, react/no-unstable-nested-components */
import React, { memo, Fragment } from 'react'
import { Link, NavLink } from 'react-router-dom'
import { HashLink } from 'react-router-hash-link'
@@ -17,7 +18,6 @@ import {
} from 'redux/constants'
import Dropdown from 'ui/Dropdown'
-
const Header = ({ authenticated, theme }) => {
const { t, i18n: { language } } = useTranslation('common')
const dispatch = useDispatch()
@@ -71,13 +71,13 @@ const Header = ({ authenticated, theme }) => {
</div>
<div className='hidden md:flex justify-center items-center flex-wrap ml-1 md:ml-10 space-y-1 sm:space-y-0 space-x-2 md:space-x-4'>
{theme === 'dark' ? (
- <div className="transition-all duration-1000 ease-in-out rotate-180">
- <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
- </div>
+ <div className='transition-all duration-1000 ease-in-out rotate-180'>
+ <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
+ </div>
) : (
- <div className="transition-all duration-1000 ease-in-out">
- <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
- </div>
+ <div className='transition-all duration-1000 ease-in-out'>
+ <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
+ </div>
)}
<Dropdown
items={whitelist}
@@ -126,13 +126,13 @@ const Header = ({ authenticated, theme }) => {
</div>
<div className='md:hidden flex justify-center items-center'>
{theme === 'dark' ? (
- <div className="transition-all duration-1000 ease-in-out rotate-180">
- <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
- </div>
+ <div className='transition-all duration-1000 ease-in-out rotate-180'>
+ <SunIcon onClick={switchTheme} className='h-10 w-10 text-gray-200 hover:text-gray-300 cursor-pointer' />
+ </div>
) : (
- <div className="transition-all duration-1000 ease-in-out">
- <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
- </div>
+ <div className='transition-all duration-1000 ease-in-out'>
+ <MoonIcon onClick={switchTheme} className='h-10 w-10 text-indigo-100 hover:text-indigo-200 cursor-pointer' />
+ </div>
)}
<Popover.Button className='bg-white dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-gray-200 rounded-md p-2 ml-3 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500'>
<span className='sr-only'>
diff --git a/src/components/Title.jsx b/src/components/Title.jsx
index ae0bee4da..443e41a27 100644
--- a/src/components/Title.jsx
+++ b/src/components/Title.jsx
@@ -32,9 +32,9 @@ const Title = ({ title, children }) => {
{/* <meta property='og:title' content={displayTitle} />
<meta name='twitter:title' content={displayTitle} /> */}
{_map(whitelist, (lang) => (
- <link key={lang} rel='alternate' hreflang={lang} href={`${pageURL}?lng=${lang}`} />
+ <link key={lang} rel='alternate' hrefLang={lang} href={`${pageURL}?lng=${lang}`} />
))}
- <link rel='alternate' hreflang='x-default' href={pageURL} />
+ <link rel='alternate' hrefLang='x-default' href={pageURL} />
</Helmet>
{children}
</>
diff --git a/src/hoc/ScrollToTop.jsx b/src/hoc/ScrollToTop.jsx
index 5bc7427bc..027878420 100644
--- a/src/hoc/ScrollToTop.jsx
+++ b/src/hoc/ScrollToTop.jsx
@@ -24,7 +24,7 @@ const ScrollToTop = ({ children }) => {
return unlisten
}, [history])
- return <>{children}</>
+ return children
}
export default ScrollToTop
diff --git a/src/hoc/Selfhosted.jsx b/src/hoc/Selfhosted.jsx
index 444080921..1672a0fb6 100644
--- a/src/hoc/Selfhosted.jsx
+++ b/src/hoc/Selfhosted.jsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react'
+import { useEffect } from 'react'
import { useHistory } from 'react-router-dom'
import _includes from 'lodash/includes'
@@ -14,12 +14,13 @@ const DEFAULT_PAGE = routes.signin
const Selfhosted = ({ children }) => {
const history = useHistory()
+ // eslint-disable-next-line consistent-return
useEffect(() => {
if (isSelfhosted) {
if (_includes(selfHostedBlacklist, window.location.pathname)) {
history.push(DEFAULT_PAGE)
}
-
+
const unlisten = history.listen(({ pathname }) => {
if (_includes(selfHostedBlacklist, pathname)) {
history.push(DEFAULT_PAGE)
@@ -29,7 +30,7 @@ const Selfhosted = ({ children }) => {
}
}, [history])
- return <>{children}</>
+ return children
}
export default Selfhosted
diff --git a/src/hoc/protected.js b/src/hoc/protected.js
index 10d5b43b8..9366b4fcd 100644
--- a/src/hoc/protected.js
+++ b/src/hoc/protected.js
@@ -17,7 +17,7 @@ export const withAuthentication = (WrappedComponent, authParam) => {
const WithAuthentication = (params) => {
const selector = useSelector(authParam.selector)
const history = useHistory()
-
+
if (!selector) {
history.push(authParam.redirectPath)
}
diff --git a/src/i18next.js b/src/i18next.js
index 3cc83f5a7..ea346c016 100644
--- a/src/i18next.js
+++ b/src/i18next.js
@@ -15,10 +15,10 @@ lngDetector.addDetector({
if (_includes(whitelist, lsLang)) {
return lsLang
- } else {
- setItem('language', defaultLanguage)
- setItem('i18nextLng', defaultLanguage)
}
+
+ setItem('language', defaultLanguage)
+ setItem('i18nextLng', defaultLanguage)
}
const language = navigator.language || navigator.userLanguage
@@ -28,7 +28,7 @@ lngDetector.addDetector({
if (_includes(whitelist, subLanguage)) {
return subLanguage
- }
+ }
}
return defaultLanguage
diff --git a/src/index.js b/src/index.js
index f24d7de97..af51e7602 100644
--- a/src/index.js
+++ b/src/index.js
@@ -33,7 +33,7 @@ const options = {
position: positions.BOTTOM_RIGHT,
timeout: 8000,
offset: '30px',
- transition: transitions.SCALE
+ transition: transitions.SCALE,
}
if (process.env.NODE_ENV !== 'production') {
@@ -47,18 +47,18 @@ const root = createRoot(container)
// Possibly it's related to 'Strict Mode has gotten stricter in React 18' -> https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html#updates-to-strict-mode
root.render(
// <React.StrictMode>
- <CrashHandler>
- <AlertProvider template={AlertTemplate} {...options}>
- <Provider store={store}>
- <HelmetProvider>
- <BrowserRouter>
- <I18nextProvider i18n={i18next}>
- <App />
- </I18nextProvider>
- </BrowserRouter>
- </HelmetProvider>
- </Provider>
- </AlertProvider>
- </CrashHandler>
+ <CrashHandler>
+ <AlertProvider template={AlertTemplate} {...options}>
+ <Provider store={store}>
+ <HelmetProvider>
+ <BrowserRouter>
+ <I18nextProvider i18n={i18next}>
+ <App />
+ </I18nextProvider>
+ </BrowserRouter>
+ </HelmetProvider>
+ </Provider>
+ </AlertProvider>
+ </CrashHandler>,
// </React.StrictMode>
)
diff --git a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
index 97d82babe..ff1498c0a 100644
--- a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
+++ b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
@@ -26,6 +26,27 @@ const CreateNewPassword = ({
const [beenSubmitted, setBeenSubmitted] = useState(false)
const [isLoading, setIsLoading] = useState(false)
+ const validate = () => {
+ const allErrors = {}
+
+ if (!isValidPassword(form.password)) {
+ allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
+ }
+
+ if (form.password !== form.repeat || form.repeat === '') {
+ allErrors.repeat = t('auth.common.noMatchError')
+ }
+
+ if (_size(form.password) > 50) {
+ allErrors.password = t('auth.common.passwordTooLong', { amount: MAX_PASSWORD_CHARS })
+ }
+
+ const valid = Object.keys(allErrors).length === 0
+
+ setErrors(allErrors)
+ setValidated(valid)
+ }
+
useEffect(() => {
validate()
}, [form]) // eslint-disable-line
@@ -36,7 +57,7 @@ const CreateNewPassword = ({
try {
const { password } = data
await createNewPassword(id, password)
-
+
newPassword(t('auth.recovery.updated'))
history.push(routes.signin)
} catch (e) {
@@ -47,13 +68,12 @@ const CreateNewPassword = ({
}
}
- const handleInput = event => {
- const t = event.target
- const value = t.type === 'checkbox' ? t.checked : t.value
+ const handleInput = ({ target }) => {
+ const value = target.type === 'checkbox' ? target.checked : target.value
- setForm(form => ({
- ...form,
- [t.name]: value,
+ setForm(oldForm => ({
+ ...oldForm,
+ [target.name]: value,
}))
}
@@ -67,27 +87,6 @@ const CreateNewPassword = ({
}
}
- const validate = () => {
- const allErrors = {}
-
- if (!isValidPassword(form.password)) {
- allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
- }
-
- if (form.password !== form.repeat || form.repeat === '') {
- allErrors.repeat = t('auth.common.noMatchError')
- }
-
- if (_size(form.password) > 50) {
- allErrors.password = t('auth.common.passwordTooLong', { amount: MAX_PASSWORD_CHARS })
- }
-
- const valid = Object.keys(allErrors).length === 0
-
- setErrors(allErrors)
- setValidated(valid)
- }
-
return (
<Title title={t('titles.recovery')}>
<div className='min-h-page bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
diff --git a/src/pages/Auth/ForgotPassword/ForgotPassword.jsx b/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
index eb8d69990..79e31eba0 100644
--- a/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
+++ b/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
@@ -23,6 +23,19 @@ const ForgotPassword = ({
const [beenSubmitted, setBeenSubmitted] = useState(false)
const [isLoading, setIsLoading] = useState(false)
+ const validate = () => {
+ const allErrors = {}
+
+ if (!isValidEmail(form.email)) {
+ allErrors.email = t('auth.common.badEmailError')
+ }
+
+ const valid = Object.keys(allErrors).length === 0
+
+ setErrors(allErrors)
+ setValidated(valid)
+ }
+
useEffect(() => {
validate()
}, [form]) // eslint-disable-line
@@ -33,7 +46,7 @@ const ForgotPassword = ({
try {
await forgotPassword(data)
-
+
newPassword(t('auth.forgot.sent'))
history.push(routes.main)
} catch (e) {
@@ -44,13 +57,12 @@ const ForgotPassword = ({
}
}
- const handleInput = event => {
- const t = event.target
- const value = t.type === 'checkbox' ? t.checked : t.value
+ const handleInput = ({ target }) => {
+ const value = target.type === 'checkbox' ? target.checked : target.value
- setForm(form => ({
- ...form,
- [t.name]: value,
+ setForm(oldForm => ({
+ ...oldForm,
+ [target.name]: value,
}))
}
@@ -64,19 +76,6 @@ const ForgotPassword = ({
}
}
- const validate = () => {
- const allErrors = {}
-
- if (!isValidEmail(form.email)) {
- allErrors.email = t('auth.common.badEmailError')
- }
-
- const valid = Object.keys(allErrors).length === 0
-
- setErrors(allErrors)
- setValidated(valid)
- }
-
return (
<Title title={t('titles.recovery')}>
<div className='min-h-page bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
diff --git a/src/pages/Auth/Signin/Signin.jsx b/src/pages/Auth/Signin/Signin.jsx
index 0c8ff08fc..cfb02528b 100644
--- a/src/pages/Auth/Signin/Signin.jsx
+++ b/src/pages/Auth/Signin/Signin.jsx
@@ -19,13 +19,30 @@ const Signin = ({ login }) => {
const [form, setForm] = useState({
email: '',
password: '',
- keep_signedin: false
+ keep_signedin: false,
})
const [validated, setValidated] = useState(false)
const [errors, setErrors] = useState({})
const [beenSubmitted, setBeenSubmitted] = useState(false)
const [isLoading, setIsLoading] = useState(false)
+ const validate = () => {
+ const allErrors = {}
+
+ if (!isValidEmail(form.email)) {
+ allErrors.email = t('auth.common.badEmailError')
+ }
+
+ if (!isValidPassword(form.password)) {
+ allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
+ }
+
+ const valid = Object.keys(allErrors).length === 0
+
+ setErrors(allErrors)
+ setValidated(valid)
+ }
+
useEffect(() => {
validate()
}, [form]) // eslint-disable-line
@@ -41,13 +58,12 @@ const Signin = ({ login }) => {
}
}
- const handleInput = event => {
- const t = event.target
- const value = t.type === 'checkbox' ? t.checked : t.value
+ const handleInput = ({ target }) => {
+ const value = target.type === 'checkbox' ? target.checked : target.value
- setForm(form => ({
- ...form,
- [t.name]: value,
+ setForm(oldForm => ({
+ ...oldForm,
+ [target.name]: value,
}))
}
@@ -61,23 +77,6 @@ const Signin = ({ login }) => {
}
}
- const validate = () => {
- const allErrors = {}
-
- if (!isValidEmail(form.email)) {
- allErrors.email = t('auth.common.badEmailError')
- }
-
- if (!isValidPassword(form.password)) {
- allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
- }
-
- const valid = Object.keys(allErrors).length === 0
-
- setErrors(allErrors)
- setValidated(valid)
- }
-
return (
<Title title={t('titles.signin')}>
<div className='min-h-page bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
@@ -118,17 +117,17 @@ const Signin = ({ login }) => {
/>
<div className='flex justify-between mt-3'>
<div className='pt-1'>
- {!isSelfhosted && (
- <>
- <Link to={routes.reset_password} className='underline text-blue-600 hover:text-indigo-800 dark:text-blue-400 dark:hover:text-blue-500'>
- {t('auth.signin.forgot')}
- </Link>
- <span className='text-gray-900 dark:text-gray-50'>&nbsp;|&nbsp;</span>
- <Link to={routes.signup} className='underline text-blue-600 hover:text-indigo-800 dark:text-blue-400 dark:hover:text-blue-500'>
- {t('auth.common.signupInstead')}
- </Link>
- </>
- )}
+ {!isSelfhosted && (
+ <>
+ <Link to={routes.reset_password} className='underline text-blue-600 hover:text-indigo-800 dark:text-blue-400 dark:hover:text-blue-500'>
+ {t('auth.signin.forgot')}
+ </Link>
+ <span className='text-gray-900 dark:text-gray-50'>&nbsp;|&nbsp;</span>
+ <Link to={routes.signup} className='underline text-blue-600 hover:text-indigo-800 dark:text-blue-400 dark:hover:text-blue-500'>
+ {t('auth.common.signupInstead')}
+ </Link>
+ </>
+ )}
</div>
<Button type='submit' loading={isLoading} primary large>
{t('auth.signin.button')}
diff --git a/src/pages/Auth/Signin/index.jsx b/src/pages/Auth/Signin/index.jsx
index ad3986851..32520e958 100644
--- a/src/pages/Auth/Signin/index.jsx
+++ b/src/pages/Auth/Signin/index.jsx
@@ -1,3 +1,3 @@
import Signin from './Signin.container'
-export default Signin
\ No newline at end of file
+export default Signin
diff --git a/src/pages/Auth/Signup/BasicSignup.jsx b/src/pages/Auth/Signup/BasicSignup.jsx
index f800e2d65..d65589194 100644
--- a/src/pages/Auth/Signup/BasicSignup.jsx
+++ b/src/pages/Auth/Signup/BasicSignup.jsx
@@ -38,30 +38,6 @@ const BasicSignup = () => {
}
}
- useEffect(() => {
- validate()
- }, [form]) // eslint-disable-line
-
- 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 = {}
@@ -87,6 +63,30 @@ const BasicSignup = () => {
setValidated(valid)
}
+ useEffect(() => {
+ validate()
+ }, [form]) // eslint-disable-line
+
+ const handleInput = (event) => {
+ const { target } = event
+ const value = target.type === 'checkbox' ? target.checked : target.value
+
+ setForm(oldForm => ({
+ ...oldForm,
+ [target.name]: value,
+ }))
+ }
+
+ const handleSubmit = e => {
+ e.preventDefault()
+ e.stopPropagation()
+ setBeenSubmitted(true)
+
+ if (validated) {
+ onSubmit(form)
+ }
+ }
+
return (
<form className='space-y-6' onSubmit={handleSubmit}>
<Input
diff --git a/src/pages/Auth/Signup/Signup.jsx b/src/pages/Auth/Signup/Signup.jsx
index 80e42a7ab..e56289dc6 100644
--- a/src/pages/Auth/Signup/Signup.jsx
+++ b/src/pages/Auth/Signup/Signup.jsx
@@ -31,6 +31,35 @@ const Signup = ({ signup }) => {
const [beenSubmitted, setBeenSubmitted] = useState(false)
const [isLoading, setIsLoading] = useState(false)
+ const validate = () => {
+ const allErrors = {}
+
+ if (!isValidEmail(form.email)) {
+ allErrors.email = t('auth.common.badEmailError')
+ }
+
+ if (!isValidPassword(form.password)) {
+ allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
+ }
+
+ if (form.password !== form.repeat || form.repeat === '') {
+ allErrors.repeat = t('auth.common.noMatchError')
+ }
+
+ if (_size(form.password) > 50) {
+ allErrors.password = t('auth.common.passwordTooLong', { amount: MAX_PASSWORD_CHARS })
+ }
+
+ if (!form.tos) {
+ allErrors.tos = t('auth.common.tosError')
+ }
+
+ const valid = Object.keys(allErrors).length === 0
+
+ setErrors(allErrors)
+ setValidated(valid)
+ }
+
useEffect(() => {
validate()
}, [form]) // eslint-disable-line
@@ -47,12 +76,12 @@ const Signup = ({ signup }) => {
}
const handleInput = event => {
- const t = event.target
- const value = t.type === 'checkbox' ? t.checked : t.value
+ const { target } = event
+ const value = target.type === 'checkbox' ? target.checked : target.value
- setForm(form => ({
- ...form,
- [t.name]: value,
+ setForm(oldForm => ({
+ ...oldForm,
+ [target.name]: value,
}))
}
@@ -66,35 +95,6 @@ const Signup = ({ signup }) => {
}
}
- const validate = () => {
- const allErrors = {}
-
- if (!isValidEmail(form.email)) {
- allErrors.email = t('auth.common.badEmailError')
- }
-
- if (!isValidPassword(form.password)) {
- allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
- }
-
- if (form.password !== form.repeat || form.repeat === '') {
- allErrors.repeat = t('auth.common.noMatchError')
- }
-
- if (_size(form.password) > 50) {
- allErrors.password = t('auth.common.passwordTooLong', { amount: MAX_PASSWORD_CHARS })
- }
-
- if (!form.tos) {
- allErrors.tos = t('auth.common.tosError')
- }
-
- const valid = Object.keys(allErrors).length === 0
-
- setErrors(allErrors)
- setValidated(valid)
- }
-
return (
<Title title={t('titles.signup')}>
<div className='min-h-page bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
@@ -142,7 +142,7 @@ const Signup = ({ signup }) => {
name='tos'
id='tos'
className='mt-4'
- label={
+ label={(
<span>
<Trans
t={t}
@@ -153,7 +153,7 @@ const Signup = ({ signup }) => {
}}
/>
</span>
- }
+ )}
hint={beenSubmitted ? errors.tos : ''}
/>
<div className='flex mt-4'>
diff --git a/src/pages/Auth/Signup/index.jsx b/src/pages/Auth/Signup/index.jsx
index d7b14e9f8..9144b1fd7 100644
--- a/src/pages/Auth/Signup/index.jsx
+++ b/src/pages/Auth/Signup/index.jsx
@@ -1,3 +1,3 @@
import Signup from './Signup.container'
-export default Signup
\ No newline at end of file
+export default Signup
diff --git a/src/pages/Auth/VerifyEmail/index.jsx b/src/pages/Auth/VerifyEmail/index.jsx
index 82eb966c5..67e743c5b 100644
--- a/src/pages/Auth/VerifyEmail/index.jsx
+++ b/src/pages/Auth/VerifyEmail/index.jsx
@@ -2,8 +2,7 @@ import React, { useState, useEffect, memo } from 'react'
import { useDispatch } from 'react-redux'
import { useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
-import { CheckCircleIcon } from '@heroicons/react/solid'
-import { XCircleIcon } from '@heroicons/react/solid'
+import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/solid'
import Title from 'components/Title'
import { authActions } from 'redux/actions/auth'
@@ -20,13 +19,16 @@ const VerifyEmail = () => {
setLoading(true)
const path = window.location.pathname.split('/')[1]
- dispatch(authActions.emailVerifyAsync(
- { path, id },
- () => setLoading(false),
- (error) => {
- setError(error.message)
- setLoading(false)
- }))
+ dispatch(
+ authActions.emailVerifyAsync(
+ { path, id },
+ () => setLoading(false),
+ (verifyError) => {
+ setError(verifyError.message)
+ setLoading(false)
+ },
+ ),
+ )
}, [dispatch, id])
if (loading) {
diff --git a/src/pages/Billing/index.jsx b/src/pages/Billing/index.jsx
index 71bdaea86..f996816d9 100644
--- a/src/pages/Billing/index.jsx
+++ b/src/pages/Billing/index.jsx
@@ -3,10 +3,10 @@ import React, { memo } from 'react'
import { useTranslation, Trans } from 'react-i18next'
import { useSelector } from 'react-redux'
-import Pricing from '../MainPage/Pricing'
import { CONTACT_EMAIL, paddleLanguageMapping } from 'redux/constants'
import { withAuthentication, auth } from 'hoc/protected'
import Title from 'components/Title'
+import Pricing from '../MainPage/Pricing'
const Features = () => {
const { user } = useSelector(state => state.auth)
diff --git a/src/pages/CrashHandler/index.js b/src/pages/CrashHandler/index.js
index f916a8390..af067aca2 100644
--- a/src/pages/CrashHandler/index.js
+++ b/src/pages/CrashHandler/index.js
@@ -30,7 +30,9 @@ class CrashHandler extends React.Component {
<b>
The app crashed, sorry about that.. :(
<br />
- Please, tell us about it at {CONTACT_EMAIL}
+ Please, tell us about it at
+ &nbsp;
+ {CONTACT_EMAIL}
<br />
To continue using the website, please reload the page.
</b>
diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx
index 96bb7ab6c..0c6f2904c 100644
--- a/src/pages/Dashboard/Dashboard.jsx
+++ b/src/pages/Dashboard/Dashboard.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable react/forbid-prop-types */
import React, { memo, useState } from 'react'
import { Link, useHistory } from 'react-router-dom'
import cx from 'clsx'
@@ -57,10 +58,12 @@ const ProjectCart = ({
<p className='h-5 mr-1'>
{overall?.thisWeek}
</p>
- <p className={cx('flex text-xs -ml-1 items-baseline', {
- 'text-green-600': statsDidGrowUp,
- 'text-red-600': !statsDidGrowUp,
- })}>
+ <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' />
@@ -76,7 +79,8 @@ const ProjectCart = ({
</span>
</>
)}
- {overall?.percChange}%
+ {overall?.percChange}
+ %
</p>
</dd>
</div>
@@ -118,7 +122,9 @@ const NoProjects = ({ t }) => (
</div>
)
-const Dashboard = ({ projects, isLoading, error, user }) => {
+const Dashboard = ({
+ projects, isLoading, error, user,
+}) => {
const { t, i18n: { language } } = useTranslation('common')
const [showActivateEmailModal, setShowActivateEmailModal] = useState(false)
const history = useHistory()
@@ -170,7 +176,9 @@ const Dashboard = ({ projects, isLoading, error, user }) => {
) : (
<div className='bg-white shadow overflow-hidden sm:rounded-md mt-10'>
<ul className='divide-y divide-gray-200 dark:divide-gray-500'>
- {_map(_filter(projects, ({ uiHidden }) => !uiHidden), ({ name, id, created, active, overall, live, public: isPublic }) => (
+ {_map(_filter(projects, ({ uiHidden }) => !uiHidden), ({
+ name, id, created, active, overall, live, public: isPublic,
+ }) => (
<ProjectCart
key={id}
t={t}
diff --git a/src/pages/Dashboard/index.jsx b/src/pages/Dashboard/index.jsx
index 784eaa059..52cf8f17a 100644
--- a/src/pages/Dashboard/index.jsx
+++ b/src/pages/Dashboard/index.jsx
@@ -1,3 +1,3 @@
import Dashboard from './Dashboard.container'
-export default Dashboard
\ No newline at end of file
+export default Dashboard
diff --git a/src/pages/Docs/Docs.jsx b/src/pages/Docs/Docs.jsx
index a644e7dcd..fa9dcd56d 100644
--- a/src/pages/Docs/Docs.jsx
+++ b/src/pages/Docs/Docs.jsx
@@ -1,4 +1,4 @@
-/* eslint-disable jsx-a11y/anchor-has-content */
+/* eslint-disable jsx-a11y/anchor-has-content, react/jsx-one-expression-per-line */
import React, { memo, Fragment, useEffect } from 'react'
import _map from 'lodash/map'
import Prism from 'prismjs'
@@ -22,7 +22,7 @@ const contents = (t) => [{
}, {
name: t('docs.titles.int'),
id: 'docs-int',
- }]
+ }],
}, {
name: t('docs.titles.how'),
id: 'docs-ht',
@@ -32,7 +32,7 @@ const contents = (t) => [{
}, {
name: t('docs.titles.ce'),
id: 'docs-ce',
- }]
+ }],
}, {
name: t('docs.titles.api'),
id: 'docs-api',
@@ -45,7 +45,7 @@ const contents = (t) => [{
}, {
name: 'trackViews',
id: 'docs-tv',
- }]
+ }],
}]
const NEXTJS_REPO_URL = 'https://github.com/Swetrix/swetrix-nextjs'
diff --git a/src/pages/Docs/examples.js b/src/pages/Docs/examples.js
index 5da16f90a..7251a5833 100644
--- a/src/pages/Docs/examples.js
+++ b/src/pages/Docs/examples.js
@@ -27,13 +27,13 @@ export const umdBuildExample = `<!-- Put this at the end of the <head> tag -->
</noscript>
`
-export const npmInstall = `npm install swetrix`
-export const npmImport = `import * as Swetrix from 'swetrix'`
+export const npmInstall = 'npm install swetrix'
+export const npmImport = 'import * as Swetrix from \'swetrix\''
export const esExample = `Swetrix.init('YOUR_PROJECT_ID')
Swetrix.trackViews()
`
-export const trackPageView = `swetrix.trackViews()`
+export const trackPageView = 'swetrix.trackViews()'
export const track = `swetrix.track({
// The event identifier you want to track.
diff --git a/src/pages/MainPage/Pricing.jsx b/src/pages/MainPage/Pricing.jsx
index 9f189c26a..99ca8fc88 100644
--- a/src/pages/MainPage/Pricing.jsx
+++ b/src/pages/MainPage/Pricing.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable no-confusing-arrow */
import React, { memo, useState, useEffect } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { Link } from 'react-router-dom'
@@ -9,7 +10,7 @@ import { Trans } from 'react-i18next'
import cx from 'clsx'
import Modal from 'ui/Modal'
-import Spin from '../../ui/icons/Spin'
+import Spin from 'ui/icons/Spin'
import { CONTACT_EMAIL, paddleLanguageMapping } from 'redux/constants'
import { errorsActions } from 'redux/actions/errors'
import { alertsActions } from 'redux/actions/alerts'
@@ -194,10 +195,13 @@ const Pricing = ({ t, language }) => {
const downgrade = planCodeID < userPlancodeID
return (
- <div key={tier.name} className={cx('relative border rounded-lg shadow-sm divide-y divide-gray-200 dark:divide-gray-500', {
- 'border-indigo-400': user.planCode === tier.planCode,
- 'border-gray-200 dark:border-gray-500': user.planCode !== tier.planCode,
- })}>
+ <div
+ key={tier.name}
+ className={cx('relative border rounded-lg shadow-sm divide-y divide-gray-200 dark:divide-gray-500', {
+ 'border-indigo-400': user.planCode === tier.planCode,
+ 'border-gray-200 dark:border-gray-500': user.planCode !== tier.planCode,
+ })}
+ >
{user.planCode === tier.planCode && (
<div className='absolute inset-x-0 top-0 transform translate-y-px'>
<div className='flex justify-center transform -translate-y-1/2'>
@@ -222,7 +226,8 @@ const Pricing = ({ t, language }) => {
) : (
<>
<span className='text-4xl font-extrabold text-gray-900 dark:text-gray-50'>
- ${tier.priceMonthly}
+ $
+ {tier.priceMonthly}
</span>
&nbsp;
<span className='text-base font-medium text-gray-500 dark:text-gray-400'>
diff --git a/src/pages/MainPage/index.jsx b/src/pages/MainPage/index.jsx
index 53208d856..7b6111846 100644
--- a/src/pages/MainPage/index.jsx
+++ b/src/pages/MainPage/index.jsx
@@ -8,9 +8,9 @@ import _map from 'lodash/map'
import routes from 'routes'
// import { nFormatter } from 'utils/generic'
-import { withAuthentication, auth } from '../../hoc/protected'
import { CONTACT_EMAIL } from 'redux/constants'
import Title from 'components/Title'
+import { withAuthentication, auth } from '../../hoc/protected'
import SignUp from '../Auth/Signup/BasicSignup'
import Pricing from './Pricing'
diff --git a/src/pages/Privacy/index.jsx b/src/pages/Privacy/index.jsx
index cb4d2d86b..c0c0ee387 100644
--- a/src/pages/Privacy/index.jsx
+++ b/src/pages/Privacy/index.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable react/no-unescaped-entities */
import React from 'react'
import { HashLink } from 'react-router-hash-link'
@@ -12,61 +13,130 @@ const Features = () => {
<div className='w-11/12 md:w-4/5 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8'>
<h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50 tracking-tight'>Privacy Policy</h1>
<p className='mt-4 text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- This Swetrix Privacy Policy (“Policy”, "Privacy Policy") outlines the personal information that we gather, how we use that personal information, and the options you have to access, correct, or delete such personal information.<br />
+ This Swetrix Privacy Policy (“Policy”, "Privacy Policy") outlines the personal information that we gather, how we use that personal information, and the options you have to access, correct, or delete such personal information.
+ <br />
By visiting swetrix.com and using the Services provided here, you agree to the terms outlined in this Privacy Policy. Unless otherwise defined in this document, the terms used in this Privacy Policy have the same meanings as in our Terms and Conditions.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>1. Policy application</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- This Privacy Policy applies to the following data subjects:<br />
+ This Privacy Policy applies to the following data subjects:
+ <br />
- - <b>Customers:</b> Those who register for an account on Swetrix and to whom Swetrix provides its Services. For purposes of this Policy, “Services” refers to all of the solutions offered, marketed, or sold by us.<br />
- - <b>Website Visitors:</b> Those who visit our Websites, which may optionally provide an email address or other information to receive communications from us, or give us feedback. For the purposes of this Policy, “Websites” refer to swetrix.com as well as any other websites we operate on our own behalf and that link to this Policy. For clarity, “Websites” does not include any sites owned or operated by our Customers.<br />
- - <b>End Users:</b> Those who access or use our Customers websites, networks, APIs, and applications.<br />
+ -
+ &nbsp;
+ <b>Customers:</b>
+ &nbsp;
+ Those who register for an account on Swetrix and to whom Swetrix provides its Services. For purposes of this Policy, “Services” refers to all of the solutions offered, marketed, or sold by us.
+ <br />
+ -
+ &nbsp;
+ <b>Website Visitors:</b>
+ &nbsp;
+ Those who visit our Websites, which may optionally provide an email address or other information to receive communications from us, or give us feedback. For the purposes of this Policy, “Websites” refer to swetrix.com as well as any other websites we operate on our own behalf and that link to this Policy. For clarity, “Websites” does not include any sites owned or operated by our Customers.
+ <br />
+ -
+ &nbsp;
+ <b>End Users:</b>
+ &nbsp;
+ Those who access or use our Customers websites, networks, APIs, and applications.
+ <br />
- This Privacy Policy does not apply to our Customers websites, networks, APIs, and applications, which may have their own terms and privacy policies. Our Customers are solely responsible for establishing policies for and ensuring compliance with all applicable laws and regulations.<br />
+ This Privacy Policy does not apply to our Customers websites, networks, APIs, and applications, which may have their own terms and privacy policies. Our Customers are solely responsible for establishing policies for and ensuring compliance with all applicable laws and regulations.
+ <br />
Swetrix’s Websites and Services are not intended for, nor designed to attract, individuals under the age of eighteen. Swetrix does not knowingly collect personal information from any person under the age of eighteen. You represent that you are at least 18 or that you are the parent or guardian of such a minor and consent to such minor dependent’s use of the Websites and Services.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>2. Information we collect</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- We may collect the following types of data in order to provide and improve our Services:<br />
- - <b>Personal Data:</b> While using our Services, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you. Personally identifiable information may include, but is not limited to your name, email address and billing addresses necessary to process payment and delivery of Services.<br />
- - <b>Payment Information:</b> We do not require our Customers to have payment information on file with us unless they have a paid subscription to our Services.<br />
- When you sign up for one of our paid Subscriptions, you must provide payment and billing information. The information you will need to submit depends on which payment method you choose. For clarity, we do not store full credit card numbers or personal account numbers.<br />
- - <b>Usage Data:</b> When you visit our Websites, we gather certain information and store it in log files to be able to provide you with our Services. This information may include but is not limited to Internet Protocol (IP) addresses, device or system information, URLs of referrer pages, browser information and language preferences.<br />
- For clarity, the purpose of these log files is to enable us to operate and provide you with our Services, and to monitor for overall trends on our Websites and for security. These log files are not shared with third parties.<br />
- - <b>Cookie Data:</b> We use essential cookies on our Websites to provide our Services. Without these cookies, the services that you have asked for cannot be provided, and we only use these cookies to provide you those services.<br />
- These cookies are essential for the functioning of our Websites. For example, we may store actions you do on our Websites to reduce requests sent to our servers.<br />
- You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent.<br />
- At this time, our Websites do not respond to Do Not Track beacons sent by browser plugins.<br />
- - <b>Log Data:</b> We process End Users information on behalf of our Customers. This information is processed when End Users access or use our Customers domains, websites, APIs, applications, devices, endpoints, and networks that use our Services.<br />
- The information processed may include but is not limited to IP addresses, device or system information, and other information about the traffic on our Customers websites, devices, applications, and/or networks (collectively, “Log Data”). You can find more information on the data collected and how we process it <HashLink className='text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' to={`${routes.docs}#docs-tv`}>here</HashLink>.
+ We may collect the following types of data in order to provide and improve our Services:
+ <br />
+ -
+ &nbsp;
+ <b>Personal Data:</b>
+ &nbsp;
+ While using our Services, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you. Personally identifiable information may include, but is not limited to your name, email address and billing addresses necessary to process payment and delivery of Services.
+ <br />
+ -
+ &nbsp;
+ <b>Payment Information:</b>
+ &nbsp;
+ We do not require our Customers to have payment information on file with us unless they have a paid subscription to our Services.
+ <br />
+ When you sign up for one of our paid Subscriptions, you must provide payment and billing information. The information you will need to submit depends on which payment method you choose. For clarity, we do not store full credit card numbers or personal account numbers.
+ <br />
+ -
+ &nbsp;
+ <b>Usage Data:</b>
+ &nbsp;
+ When you visit our Websites, we gather certain information and store it in log files to be able to provide you with our Services. This information may include but is not limited to Internet Protocol (IP) addresses, device or system information, URLs of referrer pages, browser information and language preferences.
+ <br />
+ For clarity, the purpose of these log files is to enable us to operate and provide you with our Services, and to monitor for overall trends on our Websites and for security. These log files are not shared with third parties.
+ <br />
+ -
+ &nbsp;
+ <b>Cookie Data:</b>
+ &nbsp;
+ We use essential cookies on our Websites to provide our Services. Without these cookies, the services that you have asked for cannot be provided, and we only use these cookies to provide you those services.
+ <br />
+ These cookies are essential for the functioning of our Websites. For example, we may store actions you do on our Websites to reduce requests sent to our servers.
+ <br />
+ You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent.
+ <br />
+ At this time, our Websites do not respond to Do Not Track beacons sent by browser plugins.
+ <br />
+ -
+ &nbsp;
+ <b>Log Data:</b>
+ &nbsp;
+ We process End Users information on behalf of our Customers. This information is processed when End Users access or use our Customers domains, websites, APIs, applications, devices, endpoints, and networks that use our Services.
+ <br />
+ The information processed may include but is not limited to IP addresses, device or system information, and other information about the traffic on our Customers websites, devices, applications, and/or networks (collectively, “Log Data”). You can find more information on the data collected and how we process it
+ &nbsp;
+ <HashLink className='text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500' to={`${routes.docs}#docs-tv`}>here</HashLink>
+ &nbsp;
+ .
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>3. How we use information we collect</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- We only processes personal information in a way that is relevant for the purpose for which it was collected or authorized:<br />
- - To enable you to access and use the Websites and Services.<br />
- - To operate and improve the Websites and Services.<br />
- - To send transactional messages, provide customer support, updates, security alerts, and account related messages.<br />
- - To process and complete transactions, and send you related information, including purchase confirmations and invoices.<br />
- - To monitor and analyze overall trends, usage, and activities in connection with the Websites and Services.<br />
- - To create, publish or send marketing emails, news or advertising material. For clarity, we do not send marketing emails without your explicit consent.<br />
- - To comply with legal obligations to investigate and prevent fraudulent transactions, unauthorized access, and other illegal activities.<br />
- - To personalize the Websites and Services.<br />
- - To process your data for other purposes for which we obtain your consent.<br />
- We use and process the Log Data from End Users to fulfill our obligations under our Customer agreements and as may be required by law. We act as a data processor and service provider pursuant to data processing instructions by our Customers.<br />
+ We only processes personal information in a way that is relevant for the purpose for which it was collected or authorized:
+ <br />
+ - To enable you to access and use the Websites and Services.
+ <br />
+ - To operate and improve the Websites and Services.
+ <br />
+ - To send transactional messages, provide customer support, updates, security alerts, and account related messages.
+ <br />
+ - To process and complete transactions, and send you related information, including purchase confirmations and invoices.
+ <br />
+ - To monitor and analyze overall trends, usage, and activities in connection with the Websites and Services.
+ <br />
+ - To create, publish or send marketing emails, news or advertising material. For clarity, we do not send marketing emails without your explicit consent.
+ <br />
+ - To comply with legal obligations to investigate and prevent fraudulent transactions, unauthorized access, and other illegal activities.
+ <br />
+ - To personalize the Websites and Services.
+ <br />
+ - To process your data for other purposes for which we obtain your consent.
+ <br />
+ We use and process the Log Data from End Users to fulfill our obligations under our Customer agreements and as may be required by law. We act as a data processor and service provider pursuant to data processing instructions by our Customers.
+ <br />
We may use the Usage and Log Data to assemble non-personally identifiable web traffic reports and statistics. These reports and statistics may be shared with third parties.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>4. UK and EU residents</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- Please note that the “personal information” referenced in this Privacy Policy means “personal data” as that term is defined under the European Union (“EU”) General Data Protection Regulations (“GDPR”) and its United Kingdom (“UK”) GDPR counterpart. Swetrix is the data controller for the Personal Data of Customers and Website Visitors, but not for the Personal Data of End Users. We process the Personal Data of End Users on behalf of our Customers.<br />
- If you are an individual from the European Economic Area (the “EEA”), the UK or Switzerland, please note that our legal basis for collecting and using your personal information will depend on the personal information collected and the specific context in which we collect it.<br />
- However, we will normally collect personal data from you only (i) where the processing is in our legitimate interests and not overridden by your rights; (ii) where we need the personal data to perform a contract with you or (iii) where we have your consent to do so. In some cases, we may also have a legal obligation to collect personal data from you.<br />
- Please note that in most cases, if you do not provide the requested information, we will not be able to provide the requested service to you. In some cases, we may also have a legal obligation to collect personal information from you, or may need the personal information to protect your vital interests or those of another person.<br />
- Where we rely on your consent to process your personal data, you have the right to withdraw or decline consent at any time. Where we rely on our legitimate interests to process your personal data, you have the right to object.<br />
+ Please note that the “personal information” referenced in this Privacy Policy means “personal data” as that term is defined under the European Union (“EU”) General Data Protection Regulations (“GDPR”) and its United Kingdom (“UK”) GDPR counterpart. Swetrix is the data controller for the Personal Data of Customers and Website Visitors, but not for the Personal Data of End Users. We process the Personal Data of End Users on behalf of our Customers.
+ <br />
+ If you are an individual from the European Economic Area (the “EEA”), the UK or Switzerland, please note that our legal basis for collecting and using your personal information will depend on the personal information collected and the specific context in which we collect it.
+ <br />
+ However, we will normally collect personal data from you only (i) where the processing is in our legitimate interests and not overridden by your rights; (ii) where we need the personal data to perform a contract with you or (iii) where we have your consent to do so. In some cases, we may also have a legal obligation to collect personal data from you.
+ <br />
+ Please note that in most cases, if you do not provide the requested information, we will not be able to provide the requested service to you. In some cases, we may also have a legal obligation to collect personal information from you, or may need the personal information to protect your vital interests or those of another person.
+ <br />
+ Where we rely on your consent to process your personal data, you have the right to withdraw or decline consent at any time. Where we rely on our legitimate interests to process your personal data, you have the right to object.
+ <br />
If you have any questions about or need further information concerning the legal basis on which we collect and use your personal information, please contact us at&nbsp;
<a href={`mailto:${CONTACT_EMAIL}`} className='font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500'>
{CONTACT_EMAIL}
@@ -81,46 +151,107 @@ const Features = () => {
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>6. Retention of data</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- We may retain your information for as long as your account is active or as needed to provide you services, comply with our legal obligations, resolve disputes and enforce our agreements. In certain circumstances we may be required by law to retain your personal information, or may need to retain your personal information in order to continue providing a service.<br />
+ We may retain your information for as long as your account is active or as needed to provide you services, comply with our legal obligations, resolve disputes and enforce our agreements. In certain circumstances we may be required by law to retain your personal information, or may need to retain your personal information in order to continue providing a service.
+ <br />
Even if you delete your account, keep in mind that the deletion by our third party providers may not be immediate and that the deleted information may persist in backup copies for a reasonable period of time.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>7. Transfer of data</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- Your information, including Personal Data, may be transferred to — and maintained on — computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ from those in your jurisdiction. If you are located outside Germany and choose to provide information to us, please note that we transfer the data, including Personal Data, to Germany and process it there.<br />
+ Your information, including Personal Data, may be transferred to — and maintained on — computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ from those in your jurisdiction. If you are located outside Germany and choose to provide information to us, please note that we transfer the data, including Personal Data, to Germany and process it there.
+ <br />
Your consent to this Privacy Policy followed by your submission of such information represents your agreement to that transfer. We will take all steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organization or a country unless there are adequate controls in place including the security of your data and other personal information.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>8. Information sharing</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- We do not rent or sell personal information.<br />
- We may disclose personal information to third parties who help us run the Services and our business (“Service Providers”). These Service Providers may only process personal information pursuant to our instructions and in compliance both with this Privacy Policy and other applicable security measures and regulations.<br />
- The following third parties may be considered our "sub-processors" under GDPR. We only share what's required for their purpose.<br />
- - <b>Paddle:</b> Payment processing;<br />
- - <b>Cloudflare</b>: Security, hosting, cloud infrastructure;<br />
- - <b>Postmark:</b> Transactional and marketing emails;<br />
- - <b>Fastmail:</b> Business emails.<br />
- In addition to sharing with Service Providers as described above, we also may share your information with others in the following circumstances:<br />
- - In the event of a merger, sale, change in control, or reorganization of all or part of our business.<br />
- - When we are required to disclose personal information to respond to subpoenas, court orders, or legal process, or to establish or exercise our legal rights or defend against legal claims.<br />
- - Where we have a good-faith belief sharing is necessary to investigate, prevent or take action regarding illegal activities, suspected fraud, situations involving potential threats to the physical safety of any person, or violations of our Terms and Conditions, or as otherwise required to comply with our legal obligations.<br />
- - Other purposes for which we obtain your consent.
+ We do not rent or sell personal information.
+ <br />
+ We may disclose personal information to third parties who help us run the Services and our business (“Service Providers”). These Service Providers may only process personal information pursuant to our instructions and in compliance both with this Privacy Policy and other applicable security measures and regulations.
+ <br />
+ The following third parties may be considered our "sub-processors" under GDPR. We only share what's required for their purpose.
+ <br />
+ -
+ &nbsp;
+ <b>Paddle:</b>
+ &nbsp;
+ Payment processing;
+ <br />
+ -
+ &nbsp;
+ <b>Cloudflare:</b>
+ &nbsp;
+ Security, hosting, cloud infrastructure;
+ <br />
+ -
+ &nbsp;
+ <b>Postmark:</b>
+ &nbsp;
+ Transactional and marketing emails;
+ <br />
+ -
+ &nbsp;
+ <b>Fastmail:</b>
+ &nbsp;
+ Business emails.
+ <br />
+ In addition to sharing with Service Providers as described above, we also may share your information with others in the following circumstances:
+ <br />
+ - In the event of a merger, sale, change in control, or reorganization of all or part of our business.
+ <br />
+ - When we are required to disclose personal information to respond to subpoenas, court orders, or legal process, or to establish or exercise our legal rights or defend against legal claims.
+ <br />
+ - Where we have a good-faith belief sharing is necessary to investigate, prevent or take action regarding illegal activities, suspected fraud, situations involving potential threats to the physical safety of any person, or violations of our Terms and Conditions, or as otherwise required to comply with our legal obligations.
+ <br />
+ - Other purposes for which we obtain your consent.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>9. Data subject rights</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- We would like to make sure you are fully aware of all of your data protection rights. In certain circumstances, you have the following data protection rights:<br />
- - <b>The right to access:</b> You have the right to request our Company for copies of your personal data.<br />
- - <b>The right to rectification:</b> You have the right to request that our Company corrects any information you believe is inaccurate. You also have the right to request our Company to complete the information you believe is incomplete.<br />
- - <b>The right to erasure:</b> You have the right to request that our Company erases your personal data, under certain conditions.<br />
- - <b>The right to restrict processing:</b> You have the right to request that our Company restricts the processing of your personal data, under certain conditions.<br />
- - <b>The right to object to processing:</b> You have the right to object to our Company's processing of your personal data, under certain conditions.<br />
- - <b>The right to data portability:</b> You have the right to request that our Company transfers the data that we have collected to another organization, or directly to you, under certain conditions.<br />
+ We would like to make sure you are fully aware of all of your data protection rights. In certain circumstances, you have the following data protection rights:
+ <br />
+ -
+ &nbsp;
+ <b>The right to access:</b>
+ &nbsp;
+ You have the right to request our Company for copies of your personal data.
+ <br />
+ -
+ &nbsp;
+ <b>The right to rectification:</b>
+ &nbsp;
+ You have the right to request that our Company corrects any information you believe is inaccurate. You also have the right to request our Company to complete the information you believe is incomplete.
+ <br />
+ -
+ &nbsp;
+ <b>The right to erasure:</b>
+ &nbsp;
+ You have the right to request that our Company erases your personal data, under certain conditions.
+ <br />
+ -
+ &nbsp;
+ <b>The right to restrict processing:</b>
+ &nbsp;
+ You have the right to request that our Company restricts the processing of your personal data, under certain conditions.
+ <br />
+ -
+ &nbsp;
+ <b>The right to object to processing:</b>
+ &nbsp;
+ You have the right to object to our Company's processing of your personal data, under certain conditions.
+ <br />
+ -
+ &nbsp;
+ <b>The right to data portability:</b>
+ &nbsp;
+ You have the right to request that our Company transfers the data that we have collected to another organization, or directly to you, under certain conditions.
+ <br />
If you make a request, we have one month to respond to you. If you would like to exercise any of these rights, please contact us via email at&nbsp;
<a href={`mailto:${CONTACT_EMAIL}`} className='font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-500'>
{CONTACT_EMAIL}
</a>
- . Please note that we may ask you to verify your identity before responding to such requests.<br />
+ . Please note that we may ask you to verify your identity before responding to such requests.
+ <br />
We have no direct relationship with the End Users. Our Customers are solely responsible for ensuring compliance with all applicable laws and regulations with respect to their website users.
</p>
diff --git a/src/pages/Project/Settings/ProjectSettings.jsx b/src/pages/Project/Settings/ProjectSettings.jsx
index e4368a964..0fc4aef85 100644
--- a/src/pages/Project/Settings/ProjectSettings.jsx
+++ b/src/pages/Project/Settings/ProjectSettings.jsx
@@ -1,4 +1,7 @@
-import React, { useState, useEffect, useMemo, memo } from 'react'
+/* eslint-disable react/forbid-prop-types */
+import React, {
+ useState, useEffect, useMemo, memo,
+} from 'react'
import { useLocation, useHistory, useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import _isEmpty from 'lodash/isEmpty'
@@ -114,30 +117,6 @@ const ProjectSettings = ({
}
}
- useEffect(() => {
- validate()
- }, [form]) // eslint-disable-line
-
- 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 = {}
@@ -159,6 +138,30 @@ const ProjectSettings = ({
setValidated(valid)
}
+ useEffect(() => {
+ validate()
+ }, [form]) // eslint-disable-line
+
+ const handleInput = event => {
+ const { target } = event
+ const value = target.type === 'checkbox' ? target.checked : target.value
+
+ setForm(oldForm => ({
+ ...oldForm,
+ [target.name]: value,
+ }))
+ }
+
+ const handleSubmit = e => {
+ e.preventDefault()
+ e.stopPropagation()
+ setBeenSubmitted(true)
+
+ if (validated) {
+ onSubmit(form)
+ }
+ }
+
const onCancel = () => {
history.push(isSettings ? _replace(routes.project, ':id', id) : routes.dashboard)
}
diff --git a/src/pages/Project/View/InteractiveMap.jsx b/src/pages/Project/View/InteractiveMap.jsx
index 99d0855a1..f6b8ba297 100644
--- a/src/pages/Project/View/InteractiveMap.jsx
+++ b/src/pages/Project/View/InteractiveMap.jsx
@@ -31,7 +31,7 @@ const InteractiveMap = ({ data, onClickCountry, total }) => {
<svg id='map' viewBox='0 0 1050 650' className='w-full h-full'>
<g>
{_map(countriesList, (item, index) => {
- const perc = (data[index] / total * 100) || 0
+ const perc = ((data[index] / total) * 100) || 0
const title = `${countries.getName(index, language)}\n${t('project.unique')}: ${data[index] || 0}`
return (
@@ -62,7 +62,7 @@ const InteractiveMap = ({ data, onClickCountry, total }) => {
InteractiveMap.propTypes = {
onClickCountry: PropTypes.func,
- data: PropTypes.object,
+ data: PropTypes.objectOf(PropTypes.number),
total: PropTypes.number,
}
diff --git a/src/pages/Project/View/Panels.jsx b/src/pages/Project/View/Panels.jsx
index cc36e3b09..5a6212dc3 100644
--- a/src/pages/Project/View/Panels.jsx
+++ b/src/pages/Project/View/Panels.jsx
@@ -1,6 +1,10 @@
-import React, { memo, useState, useEffect, useMemo, Fragment } from 'react'
+import React, {
+ memo, useState, useEffect, useMemo, Fragment,
+} from 'react'
import { ArrowSmUpIcon, ArrowSmDownIcon } from '@heroicons/react/solid'
-import { FilterIcon, MapIcon, ViewListIcon, ArrowsExpandIcon } from '@heroicons/react/outline'
+import {
+ FilterIcon, MapIcon, ViewListIcon, ArrowsExpandIcon,
+} from '@heroicons/react/outline'
import cx from 'clsx'
import PropTypes from 'prop-types'
import _keys from 'lodash/keys'
@@ -13,10 +17,10 @@ import _floor from 'lodash/floor'
import _size from 'lodash/size'
import _slice from 'lodash/slice'
import _sum from 'lodash/sum'
-import InteractiveMap from './InteractiveMap'
import Progress from 'ui/Progress'
import PulsatingCircle from 'ui/icons/PulsatingCircle'
import Modal from 'ui/Modal'
+import InteractiveMap from './InteractiveMap'
import { iconClassName } from './ViewProject'
const ENTRIES_PER_PANEL = 5
@@ -25,10 +29,12 @@ const ENTRIES_PER_PANEL = 5
const PanelContainer = ({
name, children, noSwitch, icon, type, openModal, activeFragment, setActiveFragment,
}) => (
- <div className={cx('relative bg-white dark:bg-gray-750 pt-5 px-4 min-h-72 sm:pt-6 sm:px-6 shadow rounded-lg overflow-hidden', {
- 'pb-12': !noSwitch,
- 'pb-5': noSwitch,
- })}>
+ <div
+ className={cx('relative bg-white dark:bg-gray-750 pt-5 px-4 min-h-72 sm:pt-6 sm:px-6 shadow rounded-lg overflow-hidden', {
+ 'pb-12': !noSwitch,
+ 'pb-5': noSwitch,
+ })}
+ >
<div className='flex items-center justify-between mb-2'>
<h3 className='flex items-center text-lg leading-6 font-semibold text-gray-900 dark:text-gray-50'>
{icon && (
@@ -57,7 +63,7 @@ const PanelContainer = ({
/>
<ArrowsExpandIcon
className={cx(iconClassName, 'ml-2 cursor-pointer text-gray-900 dark:text-gray-50', {
- 'hidden': activeFragment === 0,
+ hidden: activeFragment === 0,
})}
onClick={openModal}
/>
@@ -96,7 +102,7 @@ const Overview = ({
let bounceRate = 0
if (pageviews > 0) {
- bounceRate = _round(uniques * 100 / pageviews, 1)
+ bounceRate = _round((uniques * 100) / pageviews, 1)
}
return (
@@ -115,7 +121,10 @@ const Overview = ({
<>
<p className='text-lg font-semibold dark:text-gray-50'>
{t('project.statsFor')}
- <span className='lowercase'> {activePeriod.label}</span>
+ <span className='lowercase'>
+ &nbsp;
+ {activePeriod.label}
+ </span>
</p>
<div className='flex justify-between'>
@@ -163,10 +172,12 @@ const Overview = ({
<p className='h-5 mr-2 text-gray-900 dark:text-gray-50 text-lg'>
{overall.thisWeek}
</p>
- <p className={cx('flex text-sm -ml-1 items-baseline', {
- 'text-green-600': pageviewsDidGrowUp,
- 'text-red-600': !pageviewsDidGrowUp,
- })}>
+ <p
+ className={cx('flex text-sm -ml-1 items-baseline', {
+ 'text-green-600': pageviewsDidGrowUp,
+ 'text-red-600': !pageviewsDidGrowUp,
+ })}
+ >
{pageviewsDidGrowUp ? (
<>
<ArrowSmUpIcon className='self-center flex-shrink-0 h-4 w-4 text-green-500' />
@@ -182,7 +193,8 @@ const Overview = ({
</span>
</>
)}
- {overall.percChange}%
+ {overall.percChange}
+ %
</p>
</dd>
</div>
@@ -195,10 +207,12 @@ const Overview = ({
<p className='h-5 mr-2 text-gray-900 dark:text-gray-50 text-lg'>
{overall.thisWeekUnique}
</p>
- <p className={cx('flex text-sm -ml-1 items-baseline', {
- 'text-green-600': uniqueDidGrowUp,
- 'text-red-600': !uniqueDidGrowUp,
- })}>
+ <p
+ className={cx('flex text-sm -ml-1 items-baseline', {
+ 'text-green-600': uniqueDidGrowUp,
+ 'text-red-600': !uniqueDidGrowUp,
+ })}
+ >
{uniqueDidGrowUp ? (
<>
<ArrowSmUpIcon className='self-center flex-shrink-0 h-4 w-4 text-green-500' />
@@ -214,7 +228,8 @@ const Overview = ({
</span>
</>
)}
- {overall.percChangeUnique}%
+ {overall.percChangeUnique}
+ %
</p>
</dd>
</div>
@@ -234,16 +249,27 @@ const CustomEvents = ({
<thead>
<tr>
<th className='w-4/6 text-left text-gray-900 dark:text-gray-50'>{t('project.event')}</th>
- <th className='w-1/6 text-right text-gray-900 dark:text-gray-50'>{t('project.quantity')}&nbsp;&nbsp;</th>
+ <th className='w-1/6 text-right text-gray-900 dark:text-gray-50'>
+ {t('project.quantity')}
+ &nbsp;&nbsp;
+ </th>
<th className='w-1/6 text-right text-gray-900 dark:text-gray-50'>{t('project.conversion')}</th>
</tr>
</thead>
<tbody>
{_map(keys, (ev) => (
<tr key={ev}>
- <td className='text-left'>{ev}</td>
- <td className='text-right'>{customs[ev]}&nbsp;&nbsp;</td>
- <td className='text-right'>{_round((customs[ev] / uniques) * 100, 2)}%</td>
+ <td className='text-left'>
+ {ev}
+ </td>
+ <td className='text-right'>
+ {customs[ev]}
+ &nbsp;&nbsp;
+ </td>
+ <td className='text-right'>
+ {_round((customs[ev] / uniques) * 100, 2)}
+ %
+ </td>
</tr>
))}
</tbody>
@@ -330,7 +356,7 @@ const Panel = ({
{t('project.noParamData')}
</p>
) : _map(keysToDisplay, key => {
- const perc = _round(data[key] / total * 100, 2)
+ const perc = _round((data[key] / total) * 100, 2)
const rowData = _isFunction(rowMapper) ? rowMapper(key) : key
return (
@@ -365,7 +391,12 @@ const Panel = ({
<span className='ml-3 dark:text-gray-50'>
{data[key]}
&nbsp;
- <span className='text-gray-500 dark:text-gray-200 font-light'>({perc}%)</span>
+ <span className='text-gray-500 dark:text-gray-200 font-light'>
+ (
+ {perc}
+ %
+ )
+ </span>
</span>
</div>
<Progress now={perc} />
@@ -382,6 +413,7 @@ const Panel = ({
})}
role='button'
onClick={onPrevious}
+ tabIndex={0}
>
&lt;
&nbsp;
@@ -394,6 +426,7 @@ const Panel = ({
})}
role='button'
onClick={onNext}
+ tabIndex={0}
>
{t('project.next')}
&nbsp;
@@ -436,4 +469,4 @@ export {
PanelMemo as Panel,
OverviewMemo as Overview,
CustomEventsMemo as CustomEvents,
-}
\ No newline at end of file
+}
diff --git a/src/pages/Project/View/ViewProject.container.jsx b/src/pages/Project/View/ViewProject.container.jsx
index d1f7313c4..b7a1fef2d 100644
--- a/src/pages/Project/View/ViewProject.container.jsx
+++ b/src/pages/Project/View/ViewProject.container.jsx
@@ -27,7 +27,7 @@ const mapDispatchToProps = (dispatch) => ({
},
setLiveStatsForProject: (id, count) => {
dispatch(UIActions.setLiveStatsForProject(id, count))
- }
+ },
})
export default connect(mapStateToProps, mapDispatchToProps)(ViewProject)
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 661a47c5c..6cf476107 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -1,4 +1,7 @@
-import React, { useState, useEffect, useMemo, memo, useRef } from 'react'
+/* eslint-disable react/forbid-prop-types, react/no-unstable-nested-components */
+import React, {
+ useState, useEffect, useMemo, memo, useRef,
+} from 'react'
import { useHistory, useParams, Link } from 'react-router-dom'
import domToImage from 'dom-to-image'
import { saveAs } from 'file-saver'
@@ -42,13 +45,13 @@ import Loader from 'ui/Loader'
import Dropdown from 'ui/Dropdown'
import Checkbox from 'ui/Checkbox'
import FlatPicker from 'ui/Flatpicker'
-import {
- Panel, Overview, CustomEvents,
-} from './Panels'
import routes from 'routes'
import {
getProjectData, getProject, getOverallStats, getLiveVisitors,
} from 'api'
+import {
+ Panel, Overview, CustomEvents,
+} from './Panels'
import './styles.css'
countries.registerLocale(countriesEn)
@@ -60,6 +63,57 @@ countries.registerLocale(countriesUk)
countries.registerLocale(countriesZh)
countries.registerLocale(countriesSv)
+const CCRow = memo(({ rowName, language }) => (
+ <>
+ <Flag
+ className='rounded-sm'
+ country={rowName}
+ size={21}
+ alt=''
+ />
+ &nbsp;&nbsp;
+ {countries.getName(rowName, language)}
+ </>
+))
+
+const RefRow = memo(({ rowName, showIcons }) => {
+ let isUrl = true
+ let url = rowName
+
+ try {
+ url = new URL(rowName)
+ } catch {
+ isUrl = false
+ }
+
+ return (
+ <div>
+ {showIcons && isUrl && !_isEmpty(url.hostname) && (
+ <img
+ className='w-5 h-5 mr-1.5 float-left'
+ src={`https://icons.duckduckgo.com/ip3/${url.hostname}.ico`}
+ alt=''
+ />
+ )}
+ {isUrl ? (
+ <a
+ className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'
+ href={rowName}
+ target='_blank'
+ rel='noopener noreferrer'
+ onClick={(e) => e.stopPropagation()}
+ >
+ {rowName}
+ </a>
+ ) : (
+ <span className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'>
+ {rowName}
+ </span>
+ )}
+ </div>
+ )
+})
+
const getColumns = (chart, showTotal, t) => {
if (showTotal) {
return [
@@ -83,7 +137,7 @@ const getSettings = (chart, timeBucket, showTotal, applyRegions, t) => {
if (applyRegions) {
let regionStart
-
+
if (xAxisSize > 1) {
regionStart = dayjs(chart.x[xAxisSize - 2]).toDate()
} else {
@@ -106,7 +160,7 @@ const getSettings = (chart, timeBucket, showTotal, applyRegions, t) => {
dasharray: '6 2',
},
},
- ]
+ ],
}
}
@@ -200,9 +254,9 @@ const getFormatDate = (date) => {
const yyyy = date.getFullYear()
let mm = date.getMonth() + 1
let dd = date.getDate()
- if (dd < 10) dd = '0' + dd
- if (mm < 10) mm = '0' + mm
- return yyyy + '-' + mm + '-' + dd
+ if (dd < 10) dd = `0${dd}`
+ if (mm < 10) mm = `0${mm}`
+ return `${yyyy}-${mm}-${dd}`
}
const NoEvents = ({ t }) => (
@@ -224,7 +278,9 @@ const NoEvents = ({ t }) => (
</div>
)
-const Filter = ({ column, filter, isExclusive, onRemoveFilter, onChangeExclusive, tnMapping, language, t }) => {
+const Filter = ({
+ column, filter, isExclusive, onRemoveFilter, onChangeExclusive, tnMapping, language, t,
+}) => {
const displayColumn = tnMapping[column]
let displayFilter = filter
@@ -259,7 +315,9 @@ const Filter = ({ column, filter, isExclusive, onRemoveFilter, onChangeExclusive
)
}
-const Filters = ({ filters, onRemoveFilter, onChangeExclusive, language, t, tnMapping }) => (
+const Filters = ({
+ filters, onRemoveFilter, onChangeExclusive, language, t, tnMapping,
+}) => (
<div className='flex justify-center md:justify-start flex-wrap -mt-2'>
{_map(filters, (props) => {
const { column, filter } = props
@@ -371,7 +429,7 @@ const ViewProject = ({
const filterHandler = (column, filter, isExclusive = false) => {
let newFilters
- // temporarily apply only 1 filter per data type
+ // temporarily apply only 1 filter per data type
if (_find(filters, (f) => f.column === column) /* && f.filter === filter) */) {
// selected filter is already included into the filters array -> removing it
newFilters = _filter(filters, (f) => f.column !== column)
@@ -431,7 +489,8 @@ const ViewProject = ({
const days = Math.ceil(Math.abs(rangeDate[1].getTime() - rangeDate[0].getTime()) / (1000 * 3600 * 24))
// setting allowed time buckets for the specified date range (period)
- for (let index in timeBucketToDays) {
+ // eslint-disable-next-line no-restricted-syntax
+ for (const index in timeBucketToDays) {
if (timeBucketToDays[index].lt >= days) {
setTimebucket(timeBucketToDays[index].tb[0])
setPeriodPairs(tbPeriodPairs(t, timeBucketToDays[index].tb, rangeDate))
@@ -445,10 +504,10 @@ const ViewProject = ({
useEffect(() => {
const updateLiveVisitors = async () => {
- const { id } = project
- const result = await getLiveVisitors([id])
+ const { id: pid } = project
+ const result = await getLiveVisitors([pid])
- setLiveStatsForProject(id, result[id])
+ setLiveStatsForProject(pid, result[pid])
}
let interval
@@ -540,7 +599,7 @@ const ViewProject = ({
{
'min-h-min-footer': authenticated,
'min-h-min-footer-ad': !authenticated,
- }
+ },
)}
ref={dashboardRef}
>
@@ -564,7 +623,7 @@ const ViewProject = ({
'rounded-r-md': 1 + index === length,
'z-10 border-indigo-500 text-indigo-600 dark:border-gray-200 dark:text-gray-50': timeBucket === tb,
'text-gray-700 dark:text-gray-50 border-gray-300 dark:border-gray-800 ': timeBucket !== tb,
- }
+ },
)}
>
{t(`project.${tb}`)}
@@ -640,8 +699,8 @@ const ViewProject = ({
{dataLoading && (
<div className='loader bg-transparent static mt-4' id='loader'>
<div className='loader-head'>
- <div className='first'></div>
- <div className='second'></div>
+ <div className='first' />
+ <div className='second' />
</div>
</div>
)}
@@ -669,17 +728,8 @@ const ViewProject = ({
onFilter={filterHandler}
name={panelName}
data={panelsData.data[type]}
- rowMapper={(name) => (
- <>
- <Flag
- className='rounded-sm'
- country={name}
- size={21}
- alt=''
- />
- &nbsp;&nbsp;
- {countries.getName(name, language)}
- </>
+ rowMapper={(rowName) => (
+ <CCRow rowName={rowName} language={language} />
)}
/>
)
@@ -710,43 +760,9 @@ const ViewProject = ({
onFilter={filterHandler}
name={panelName}
data={panelsData.data[type]}
- rowMapper={(name) => {
- let isUrl = true
- let url = name
-
- try {
- url = new URL(name)
- } catch {
- isUrl = false
- }
-
- return (
- <div>
- {showIcons && isUrl && !_isEmpty(url.hostname) && (
- <img
- className='w-5 h-5 mr-1.5 float-left'
- src={`https://icons.duckduckgo.com/ip3/${url.hostname}.ico`}
- alt=''
- />
- )}
- {isUrl ? (
- <a
- className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'
- href={name}
- target='_blank'
- rel='noopener noreferrer'
- onClick={(e) => e.stopPropagation()}
- >
- {name}
- </a>
- ) : (
- <span className='flex label overflow-visible hover:underline text-blue-600 dark:text-blue-500'>
- {name}
- </span>
- )}
- </div>
- )
- }}
+ rowMapper={(rowName) => (
+ <RefRow rowName={rowName} showIcons={showIcons} />
+ )}
/>
)
}
diff --git a/src/pages/Project/View/index.jsx b/src/pages/Project/View/index.jsx
index 72c3942fc..9bb6ff2df 100644
--- a/src/pages/Project/View/index.jsx
+++ b/src/pages/Project/View/index.jsx
@@ -1 +1,3 @@
-export { default } from './ViewProject.container'
\ No newline at end of file
+import ViewProject from './ViewProject.container'
+
+export default ViewProject
diff --git a/src/pages/Terms/index.jsx b/src/pages/Terms/index.jsx
index 590b8b7b8..753affcb9 100644
--- a/src/pages/Terms/index.jsx
+++ b/src/pages/Terms/index.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable react/no-unescaped-entities */
import React from 'react'
import Title from 'components/Title'
@@ -10,15 +11,19 @@ const Features = () => {
<div className='w-11/12 md:w-4/5 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8'>
<h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50 tracking-tight'>Swetrix Terms and Conditions</h1>
<p className='mt-4 text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- These Swetrix Terms and Conditions ("Terms", "Terms and Conditions") govern your relationship with swetrix.com ("Service") operated by Andrii Romasiun ("Swetrix", "Swetrix Analytics", "Company", "us", "we", or "our").<br />
+ These Swetrix Terms and Conditions ("Terms", "Terms and Conditions") govern your relationship with swetrix.com ("Service") operated by Andrii Romasiun ("Swetrix", "Swetrix Analytics", "Company", "us", "we", or "our").
+ <br />
Please read these Terms and Conditions carefully before using the Service.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Acknowledgment</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- These are the Terms and Conditions governing the use of this Service and the agreement that operates between you and us. These Terms and Conditions set out the rights and obligations of all users regarding the use of the Service.<br />
- Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms and Conditions. These Terms and Conditions apply to all visitors, users and others who access or use the Service.<br />
- By accessing or using the Service you agree to be bound by these Terms and Conditions. If you disagree with any part of these Terms and Conditions then you may not access the Service.<br />
+ These are the Terms and Conditions governing the use of this Service and the agreement that operates between you and us. These Terms and Conditions set out the rights and obligations of all users regarding the use of the Service.
+ <br />
+ Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms and Conditions. These Terms and Conditions apply to all visitors, users and others who access or use the Service.
+ <br />
+ By accessing or using the Service you agree to be bound by these Terms and Conditions. If you disagree with any part of these Terms and Conditions then you may not access the Service.
+ <br />
Your access to and use of the Service is also conditioned on your acceptance of and compliance with our Privacy Policy. Our Privacy Policy describes our policies and procedures on the collection, use and disclosure of your personal information when you access our websites or use our Service and tells you about your privacy rights and how the law protects you. Please read Our Privacy Policy carefully before using our Service.
</p>
@@ -44,8 +49,10 @@ const Features = () => {
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Third-party websites</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- The Service may contain links to third-party websites or services that are not owned or controlled by us.<br />
- We have no control over, and assume no responsibility for, the content, privacy policies, or practices of any third party websites or services. You further acknowledge and agree that the Company shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with the use of or reliance on any such content, goods or services available on or through any such websites or services.<br />
+ The Service may contain links to third-party websites or services that are not owned or controlled by us.
+ <br />
+ We have no control over, and assume no responsibility for, the content, privacy policies, or practices of any third party websites or services. You further acknowledge and agree that the Company shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with the use of or reliance on any such content, goods or services available on or through any such websites or services.
+ <br />
We strongly advise you to read the terms and conditions and privacy policies of any third-party websites or services that you visit.
</p>
@@ -71,30 +78,39 @@ const Features = () => {
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Accounts</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- When you create an account with us, you must provide us information that is accurate, complete, and current at all times. Failure to do so constitutes a breach of the Terms, which may result in immediate termination of your account on our Service.<br />
- You are responsible for safeguarding the password that you use to access the Service and for any activities or actions under your password, whether your password is with our Service or a third-party service.<br />
- You agree not to disclose your password to any third party. You must notify us immediately upon becoming aware of any breach of security or unauthorized use of your account.<br />
+ When you create an account with us, you must provide us information that is accurate, complete, and current at all times. Failure to do so constitutes a breach of the Terms, which may result in immediate termination of your account on our Service.
+ <br />
+ You are responsible for safeguarding the password that you use to access the Service and for any activities or actions under your password, whether your password is with our Service or a third-party service.
+ <br />
+ You agree not to disclose your password to any third party. You must notify us immediately upon becoming aware of any breach of security or unauthorized use of your account.
+ <br />
You may not use as a username the name of another person or entity or that is not lawfully available for use, a name or trademark that is subject to any rights of another person or entity other than you without appropriate authorization, or a name that is otherwise offensive, vulgar or obscene.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Subscriptions</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- Some parts of the Service are billed on a subscription basis ("Subscription(s)"). You will be billed in advance on a recurring and periodic basis ("Billing Cycle"). Billing cycles are set either on a monthly or annual basis, depending on the type of subscription plan you select when purchasing a Subscription.<br />
- At the end of each Billing Cycle, your Subscription will automatically renew under the exact same conditions unless you cancel it or we cancel it. You may cancel your Subscription renewal either through your online account management page or by contacting our customer support team.<br />
- A valid payment method, including credit card, is required to process the payment for your Subscription. You shall provide us with accurate and complete billing information including full name, address, state, zip code, telephone number, and a valid payment method information. By submitting such payment information, you automatically authorize us to charge all Subscription fees incurred through your account to any such payment instruments.<br />
+ Some parts of the Service are billed on a subscription basis ("Subscription(s)"). You will be billed in advance on a recurring and periodic basis ("Billing Cycle"). Billing cycles are set either on a monthly or annual basis, depending on the type of subscription plan you select when purchasing a Subscription.
+ <br />
+ At the end of each Billing Cycle, your Subscription will automatically renew under the exact same conditions unless you cancel it or we cancel it. You may cancel your Subscription renewal either through your online account management page or by contacting our customer support team.
+ <br />
+ A valid payment method, including credit card, is required to process the payment for your Subscription. You shall provide us with accurate and complete billing information including full name, address, state, zip code, telephone number, and a valid payment method information. By submitting such payment information, you automatically authorize us to charge all Subscription fees incurred through your account to any such payment instruments.
+ <br />
Should automatic billing fail to occur for any reason, we may issue an electronic invoice indicating that you must proceed manually, within a certain deadline date, with the full payment corresponding to the billing period as indicated on the invoice.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Fee changes</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- We may, at our sole discretion and at any time, modify the Subscription fees for the Subscriptions. Any Subscription fee change will become effective at the end of the then-current Billing Cycle.<br />
- We will provide you with a reasonable prior notice of any change in Subscription fees to give you an opportunity to terminate your Subscription before such change becomes effective.<br />
+ We may, at our sole discretion and at any time, modify the Subscription fees for the Subscriptions. Any Subscription fee change will become effective at the end of the then-current Billing Cycle.
+ <br />
+ We will provide you with a reasonable prior notice of any change in Subscription fees to give you an opportunity to terminate your Subscription before such change becomes effective.
+ <br />
Your continued use of the Service after the Subscription fee change comes into effect constitutes your agreement to pay the modified Subscription fee amount.
</p>
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Refunds</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- To avoid being charged for your Subscription, you must cancel the Subscription before your renewal date. Otherwise, you’ll be charged and will retain access to the Service through the end of the Billing Cycle.<br />
+ To avoid being charged for your Subscription, you must cancel the Subscription before your renewal date. Otherwise, you’ll be charged and will retain access to the Service through the end of the Billing Cycle.
+ <br />
Except when required by law, paid Subscription fees are non-refundable. However, you may contact our support team and at our sole discretion we may issue a refund on a case-by-case basis.
</p>
@@ -117,7 +133,8 @@ const Features = () => {
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Governing Law</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- These Terms shall be governed and construed in accordance with the laws of Ukraine, without regard to its conflict of law provisions.<br />
+ These Terms shall be governed and construed in accordance with the laws of Ukraine, without regard to its conflict of law provisions.
+ <br />
Our failure to enforce any right or provision of these Terms will not be considered a waiver of those rights. If any provision of these Terms is held to be invalid or unenforceable by a court, the remaining provisions of these Terms will remain in effect. These Terms constitute the entire agreement between us regarding our Service, and supersede and replace any prior agreements we might have between us regarding the Service.
</p>
@@ -146,7 +163,6 @@ const Features = () => {
Except as provided herein, the failure to exercise a right or to require performance of an obligation under this Agreement shall not affect a party’s ability to exercise such right or require such performance at any time thereafter, nor shall the waiver of a breach constitute the waiver of any subsequent breach.
</p>
-
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Translation interpretation</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
These Terms and Conditions may have been translated if we have made them available to you on our Service. You agree that the original English text shall prevail in the case of a dispute.
@@ -154,7 +170,8 @@ const Features = () => {
<h3 className='text-2xl font-bold text-gray-900 dark:text-gray-50 tracking-tight mt-4'>Changes to these Terms and Conditions</h3>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
- We reserve the right, at our sole discretion, to modify or replace these Terms and Conditions at any time. If a revision is material we will make reasonable efforts to provide at least 30 days' notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion.<br />
+ We reserve the right, at our sole discretion, to modify or replace these Terms and Conditions at any time. If a revision is material we will make reasonable efforts to provide at least 30 days' notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion.
+ <br />
By continuing to access or use our Service after those revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, in whole or in part, please stop using the website and the Service.
</p>
diff --git a/src/pages/UserSettings/UserSettings.container.jsx b/src/pages/UserSettings/UserSettings.container.jsx
index 3b35cb4f4..6165e2d9c 100644
--- a/src/pages/UserSettings/UserSettings.container.jsx
+++ b/src/pages/UserSettings/UserSettings.container.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable no-param-reassign */
import React, { memo } from 'react'
import { useHistory } from 'react-router-dom'
import { useDispatch } from 'react-redux'
@@ -34,7 +35,7 @@ const UserSettingsContainer = () => {
),
() => history.push(routes.main),
t,
- )
+ ),
)
}
@@ -59,7 +60,8 @@ const UserSettingsContainer = () => {
const onSubmit = (data) => {
delete data.repeat
- for (let key in data) {
+ // eslint-disable-next-line no-restricted-syntax
+ for (const key in data) {
if (data[key] === '') {
delete data[key]
}
@@ -69,10 +71,10 @@ const UserSettingsContainer = () => {
authActions.updateUserProfileAsync(
data,
() => dispatch(
- alertsActions.accountUpdated(t('profileSettings.updated'))
- )
- )
- );
+ alertsActions.accountUpdated(t('profileSettings.updated')),
+ ),
+ ),
+ )
}
const onEmailConfirm = async (errorCallback) => {
diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsx
index 29564f7e6..71511c1a9 100644
--- a/src/pages/UserSettings/UserSettings.jsx
+++ b/src/pages/UserSettings/UserSettings.jsx
@@ -41,6 +41,27 @@ const UserSettings = ({
const [error, setError] = useState(null)
const translatedFrequencies = _map(reportFrequencies, (key) => t(`profileSettings.${key}`)) // useMemo(_map(reportFrequencies, (key) => t(`profileSettings.${key}`)), [t])
+ const validate = () => {
+ const allErrors = {}
+
+ if (!isValidEmail(form.email)) {
+ allErrors.email = t('auth.common.badEmailError')
+ }
+
+ if (_size(form.password) > 0 && !isValidPassword(form.password)) {
+ allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
+ }
+
+ if (form.password !== form.repeat) {
+ allErrors.repeat = t('auth.common.noMatchError')
+ }
+
+ const valid = _isEmpty(Object.keys(allErrors))
+
+ setErrors(allErrors)
+ setValidated(valid)
+ }
+
useEffect(() => {
validate()
}, [form]) // eslint-disable-line
@@ -51,12 +72,12 @@ const UserSettings = ({
}
const handleInput = event => {
- const t = event.target
- const value = t.type === 'checkbox' ? t.checked : t.value
+ const { target } = event
+ const value = target.type === 'checkbox' ? target.checked : target.value
- setForm(form => ({
- ...form,
- [t.name]: value,
+ setForm(prevForm => ({
+ ...prevForm,
+ [target.name]: value,
}))
}
@@ -97,27 +118,6 @@ const UserSettings = ({
}
}
- const validate = () => {
- const allErrors = {}
-
- if (!isValidEmail(form.email)) {
- allErrors.email = t('auth.common.badEmailError')
- }
-
- if (_size(form.password) > 0 && !isValidPassword(form.password)) {
- allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
- }
-
- if (form.password !== form.repeat) {
- allErrors.repeat = t('auth.common.noMatchError')
- }
-
- const valid = _isEmpty(Object.keys(allErrors))
-
- setErrors(allErrors)
- setValidated(valid)
- }
-
return (
<Title title={t('titles.profileSettings')}>
<div className='min-h-min-footer bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>
@@ -194,7 +194,7 @@ const UserSettings = ({
label={t('profileSettings.frequency')}
className='w-full'
items={translatedFrequencies}
- onSelect={(f) => setReportFrequency(reportFrequencies[_findIndex(translatedFrequencies, t => t === f)])}
+ onSelect={(f) => setReportFrequency(reportFrequencies[_findIndex(translatedFrequencies, freq => freq === f)])}
/>
</div>
</div>
diff --git a/src/pages/UserSettings/index.jsx b/src/pages/UserSettings/index.jsx
index 85d6b6853..f15e496b0 100644
--- a/src/pages/UserSettings/index.jsx
+++ b/src/pages/UserSettings/index.jsx
@@ -1 +1,3 @@
-export { default } from './UserSettings.container'
+import UserSettings from './UserSettings.container'
+
+export default UserSettings
diff --git a/src/redux/actions/alerts/index.js b/src/redux/actions/alerts/index.js
index 4a26fd9e0..a92ca0a91 100644
--- a/src/redux/actions/alerts/index.js
+++ b/src/redux/actions/alerts/index.js
@@ -7,21 +7,21 @@ export const alertsActions = {
payload: { message, type },
}
},
-
+
accountUpdated(message, type = 'success') {
return {
type: types.ACCOUNT_UPDATED,
payload: { message, type },
}
},
-
+
newPassword(message, type = 'success') {
return {
type: types.NEW_PASSWORD,
payload: { message, type },
}
},
-
+
newProject(message, type = 'success') {
return {
type: types.CREATE_NEW_PROJECT_SUCCESS,
diff --git a/src/redux/actions/alerts/types.js b/src/redux/actions/alerts/types.js
index 9beb21b99..9e3cf1bc9 100644
--- a/src/redux/actions/alerts/types.js
+++ b/src/redux/actions/alerts/types.js
@@ -8,5 +8,5 @@ export const types = {
DELETE_PROJECT_SUCCESS: 'DELETE_PROJECT_SUCCESS',
// Common
- CLEAR_ALERTS: 'CLEAR_ALERTS'
+ CLEAR_ALERTS: 'CLEAR_ALERTS',
}
diff --git a/src/redux/actions/auth/index.js b/src/redux/actions/auth/index.js
index d9a37e47e..b820ab6fc 100644
--- a/src/redux/actions/auth/index.js
+++ b/src/redux/actions/auth/index.js
@@ -1,33 +1,33 @@
import { removeItem } from 'utils/localstorage'
-import { types } from './types'
import { TOKEN, LS_VIEW_PREFS_SETTING } from 'redux/constants'
+import { types } from './types'
export const authActions = {
// Synchronous
loginSuccess(user) {
return {
type: types.LOGIN_SUCCESSFUL,
- payload: { user }
+ payload: { user },
}
},
emailVerifySuccess() {
return {
- type: types.EMAIL_VERIFY_SUCCESSFUL
+ type: types.EMAIL_VERIFY_SUCCESSFUL,
}
},
signupSuccess(user) {
return {
type: types.SIGNUP_UP_SUCCESSFUL,
- payload: { user }
+ payload: { user },
}
},
updateProfileSuccess(user) {
return {
type: types.UPDATE_USER_PROFILE_SUCCESS,
- payload: { user }
+ payload: { user },
}
},
@@ -36,20 +36,20 @@ export const authActions = {
removeItem(LS_VIEW_PREFS_SETTING)
return {
- type: types.LOGOUT
+ type: types.LOGOUT,
}
},
clearErrors() {
return {
- type: types.CLEAR_ERRORS
+ type: types.CLEAR_ERRORS,
}
},
savePath(path) {
return {
type: types.SAVE_PATH,
- payload: { path }
+ payload: { path },
}
},
@@ -58,13 +58,13 @@ export const authActions = {
removeItem('user_info')
return {
- type: types.DELETE_ACCOUNT_SUCCESS
+ type: types.DELETE_ACCOUNT_SUCCESS,
}
},
finishLoading() {
return {
- type: types.FINISH_LOADING
+ type: types.FINISH_LOADING,
}
},
@@ -90,14 +90,14 @@ export const authActions = {
emailVerifyAsync(data, successfulCallback, errorCallback) {
return {
type: types.EMAIL_VERIFY_ASYNC,
- payload: { data, successfulCallback, errorCallback }
+ payload: { data, successfulCallback, errorCallback },
}
},
updateUserProfileAsync(data, successfulCallback = () => { }) {
return {
type: types.UPDATE_USER_PROFILE_ASYNC,
- payload: { data, successfulCallback }
+ payload: { data, successfulCallback },
}
},
@@ -108,5 +108,5 @@ export const authActions = {
errorCallback, successCallback, t,
},
}
- }
+ },
}
diff --git a/src/redux/actions/errors/index.js b/src/redux/actions/errors/index.js
index 107fb5f35..96ffc791f 100644
--- a/src/redux/actions/errors/index.js
+++ b/src/redux/actions/errors/index.js
@@ -8,7 +8,7 @@ export const errorsActions = {
payload: { error },
}
},
-
+
signupFailed(error) {
return {
type: types.SIGN_UP_FAILED,
diff --git a/src/redux/actions/ui/index.js b/src/redux/actions/ui/index.js
index 0b5eef076..79aa809b7 100644
--- a/src/redux/actions/ui/index.js
+++ b/src/redux/actions/ui/index.js
@@ -92,21 +92,21 @@ const setTheme = (theme) => ({
type: types.SET_THEME,
payload: {
theme,
- }
+ },
})
const setGeneralStats = (stats) => ({
type: types.SET_GENERAL_STATS,
payload: {
stats,
- }
+ },
})
const setPaddleLastEvent = (event) => ({
type: types.SET_PADDLE_LAST_EVENT,
payload: {
event,
- }
+ },
})
const UIActions = {
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index 91a1d25c1..25ff39ad9 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -63,17 +63,17 @@ export const tbPeriodPairs = (t, tbs, dates) => [{
}]
export const timeBucketToDays = [
- { lt: 7, tb: ['hour','day'] }, // 7 days
- { lt: 28, tb: ['day','week'] }, // 4 weeks
- { lt: 366, tb: ['week','month']}, // 12 months
+ { lt: 7, tb: ['hour', 'day'] }, // 7 days
+ { lt: 28, tb: ['day', 'week'] }, // 4 weeks
+ { lt: 366, tb: ['week', 'month'] }, // 12 months
{ lt: 732, tb: ['month'] }, // 24 months
]
export const tbsFormatMapper = {
- 'hour': '%d %B %H:%M',
- 'day': '%d %B',
- 'week': '%d %B',
- 'month': '%d %B %Y',
+ hour: '%d %B %H:%M',
+ day: '%d %B',
+ week: '%d %B',
+ month: '%d %B %Y',
}
export const reportFrequencies = ['weekly', 'monthly', 'never']
@@ -146,5 +146,5 @@ export const languageFlag = {
export const paddleLanguageMapping = {
zh: 'zh-Hans',
uk: 'ru',
- el: 'en',
+ el: 'en',
}
diff --git a/src/redux/reducers/alerts.js b/src/redux/reducers/alerts.js
index 56c2dfca7..bf684dd1d 100644
--- a/src/redux/reducers/alerts.js
+++ b/src/redux/reducers/alerts.js
@@ -2,9 +2,10 @@ import { types } from 'redux/actions/alerts/types'
const initialState = {
message: null,
- type: 'info'
+ type: 'info',
}
+// eslint-disable-next-line default-param-last
const alertsReducer = (state = initialState, { type, payload }) => {
switch (type) {
case types.ACCOUNT_DELETED:
diff --git a/src/redux/reducers/auth.js b/src/redux/reducers/auth.js
index 588f52af1..9476de8c6 100644
--- a/src/redux/reducers/auth.js
+++ b/src/redux/reducers/auth.js
@@ -7,6 +7,7 @@ const initialState = {
user: {},
}
+// eslint-disable-next-line default-param-last
const authReducer = (state = initialState, { type, payload }) => {
switch (type) {
case types.SIGNUP_UP_SUCCESSFUL:
@@ -34,4 +35,4 @@ const authReducer = (state = initialState, { type, payload }) => {
}
}
-export default authReducer
\ No newline at end of file
+export default authReducer
diff --git a/src/redux/reducers/errors.js b/src/redux/reducers/errors.js
index 3adfeb7a9..c17f0acb8 100644
--- a/src/redux/reducers/errors.js
+++ b/src/redux/reducers/errors.js
@@ -1,9 +1,10 @@
import { types } from 'redux/actions/errors/types'
const initialState = {
- error: null
+ error: null,
}
+// eslint-disable-next-line default-param-last
const errorsReducer = (state = initialState, { type, payload }) => {
switch (type) {
case types.GENERIC_ERROR:
diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js
index 6ef0830a3..40fbbbcac 100644
--- a/src/redux/reducers/index.js
+++ b/src/redux/reducers/index.js
@@ -4,4 +4,6 @@ import errors from './errors'
import alerts from './alerts'
import ui from './ui'
-export default combineReducers({ auth, errors, alerts, ui })
+export default combineReducers({
+ auth, errors, alerts, ui,
+})
diff --git a/src/redux/reducers/ui/cache.js b/src/redux/reducers/ui/cache.js
index 65d0fd9bf..51b2d1140 100644
--- a/src/redux/reducers/ui/cache.js
+++ b/src/redux/reducers/ui/cache.js
@@ -30,10 +30,13 @@ const getInitialState = () => {
}
}
+// eslint-disable-next-line default-param-last
const cacheReducer = (state = getInitialState(), { type, payload }) => {
switch (type) {
case types.SET_PROJECT_CACHE: {
- const { pid, period, timeBucket, data } = payload
+ const {
+ pid, period, timeBucket, data,
+ } = payload
// temporarily do not store custom date ranges in cache
if (period === 'custom') {
@@ -64,11 +67,11 @@ const cacheReducer = (state = getInitialState(), { type, payload }) => {
...state,
analytics: {},
}
- } else {
- return {
- ...state,
- analytics: _filter(state.analytics, (project) => project !== pid),
- }
+ }
+
+ return {
+ ...state,
+ analytics: _filter(state.analytics, (project) => project !== pid),
}
}
@@ -82,7 +85,9 @@ const cacheReducer = (state = getInitialState(), { type, payload }) => {
}
case types.SET_PROJECT_VIEW_PREFS: {
- const { pid, period, timeBucket, rangeDate } = payload
+ const {
+ pid, period, timeBucket, rangeDate,
+ } = payload
return {
...state,
diff --git a/src/redux/reducers/ui/index.js b/src/redux/reducers/ui/index.js
index 919a8d968..264ca1e96 100644
--- a/src/redux/reducers/ui/index.js
+++ b/src/redux/reducers/ui/index.js
@@ -4,4 +4,6 @@ import cache from './cache'
import theme from './theme'
import misc from './misc'
-export default combineReducers({ projects, cache, theme, misc })
+export default combineReducers({
+ projects, cache, theme, misc,
+})
diff --git a/src/redux/reducers/ui/misc.js b/src/redux/reducers/ui/misc.js
index 2880c472c..68556ce44 100644
--- a/src/redux/reducers/ui/misc.js
+++ b/src/redux/reducers/ui/misc.js
@@ -15,6 +15,7 @@ const initialState = {
showNoEventsLeftBanner: false,
}
+// eslint-disable-next-line default-param-last
const miscReducer = (state = initialState, { type, payload }) => {
switch (type) {
case types.SET_GENERAL_STATS: {
diff --git a/src/redux/reducers/ui/projects.js b/src/redux/reducers/ui/projects.js
index 37702dd92..95b2c64c1 100644
--- a/src/redux/reducers/ui/projects.js
+++ b/src/redux/reducers/ui/projects.js
@@ -12,6 +12,7 @@ const getInitialState = () => {
}
}
+// eslint-disable-next-line default-param-last
const projectsReducer = (state = getInitialState(), { type, payload }) => {
switch (type) {
case types.SET_PROJECTS: {
@@ -39,7 +40,7 @@ const projectsReducer = (state = getInitialState(), { type, payload }) => {
projects: _map(state.projects, res => ({
...res,
live: data[res.id],
- }))
+ })),
}
}
@@ -54,10 +55,10 @@ const projectsReducer = (state = getInitialState(), { type, payload }) => {
...res,
live: count,
}
- } else {
- return res
}
- })
+
+ return res
+ }),
}
}
@@ -68,12 +69,12 @@ const projectsReducer = (state = getInitialState(), { type, payload }) => {
projects: _findIndex(state.projects, (el) => el.id === project.id) >= 0
? state.projects
: [
- ...state.projects,
- {
- ...project,
- uiHidden: true,
- },
- ],
+ ...state.projects,
+ {
+ ...project,
+ uiHidden: true,
+ },
+ ],
}
}
@@ -89,7 +90,7 @@ const projectsReducer = (state = getInitialState(), { type, payload }) => {
const { pid } = payload
return {
...state,
- projects: _filter(state.projects, (project) => project.id !== pid)
+ projects: _filter(state.projects, (project) => project.id !== pid),
}
}
diff --git a/src/redux/reducers/ui/theme.js b/src/redux/reducers/ui/theme.js
index 16e25c66d..78b7c8b8f 100644
--- a/src/redux/reducers/ui/theme.js
+++ b/src/redux/reducers/ui/theme.js
@@ -41,6 +41,7 @@ const getInitialState = () => {
}
}
+// eslint-disable-next-line default-param-last
const themeReducer = (state = getInitialState(), { type, payload }) => {
switch (type) {
case types.SET_THEME: {
diff --git a/src/redux/sagas/index.js b/src/redux/sagas/index.js
index 14d55e0a2..8287aea30 100644
--- a/src/redux/sagas/index.js
+++ b/src/redux/sagas/index.js
@@ -5,4 +5,4 @@ import uiSaga from './ui'
export default function* rootSaga() {
yield fork(watchAuth)
yield fork(uiSaga)
-}
\ No newline at end of file
+}
diff --git a/src/redux/sagas/ui/load_projects.js b/src/redux/sagas/ui/load_projects.js
index 96320112e..136270dca 100644
--- a/src/redux/sagas/ui/load_projects.js
+++ b/src/redux/sagas/ui/load_projects.js
@@ -3,15 +3,16 @@ import _map from 'lodash/map'
import _isString from 'lodash/isString'
import Debug from 'debug'
+import UIActions from 'redux/actions/ui'
import {
getProjects, getOverallStats, getLiveVisitors,
} from '../../../api'
-import UIActions from 'redux/actions/ui'
const debug = Debug('swetrix:rx:s:load-projects')
export default function* loadProjects() {
try {
+ // eslint-disable-next-line prefer-const
let { results, totalMonthlyEvents } = yield call(getProjects)
const pids = _map(results, result => result.id)
let overall
diff --git a/src/redux/sagas/ui/set_project_view_prefs.js b/src/redux/sagas/ui/set_project_view_prefs.js
index 235a94a45..7bdc3cfa5 100644
--- a/src/redux/sagas/ui/set_project_view_prefs.js
+++ b/src/redux/sagas/ui/set_project_view_prefs.js
@@ -1,14 +1,18 @@
import { LS_VIEW_PREFS_SETTING } from 'redux/constants'
import { getInitialViewPrefs } from 'redux/reducers/ui/cache'
-export default function setProjectViewPrefs({ payload: { pid, period, timeBucket, rangeDate } }) {
+export default function setProjectViewPrefs({
+ payload: {
+ pid, period, timeBucket, rangeDate,
+ },
+}) {
if (typeof window !== 'undefined' && window.localStorage) {
const viewPrefs = {
...getInitialViewPrefs(),
[pid]: rangeDate ? {
period, timeBucket, rangeDate,
} : {
- period, timeBucket,
+ period, timeBucket,
},
}
diff --git a/src/redux/sagas/ui/worker_is_events_available.js b/src/redux/sagas/ui/worker_is_events_available.js
index 5de2e4deb..e88058dba 100644
--- a/src/redux/sagas/ui/worker_is_events_available.js
+++ b/src/redux/sagas/ui/worker_is_events_available.js
@@ -17,7 +17,7 @@ export default function* checkEventsAvailable() {
}
let dataRequests = 0
-
+
while (true) {
if (dataRequests > DATA_REQUEST_ATTEMPTS) {
return
@@ -40,7 +40,7 @@ export default function* checkEventsAvailable() {
const maxEventsCount = yield select(state => state.auth.user.maxEventsCount)
- const eventsUsedPercentage = totalMonthlyEvents * 100 / maxEventsCount
+ const eventsUsedPercentage = (totalMonthlyEvents * 100) / maxEventsCount
if (eventsUsedPercentage >= SHOW_BANNER_AT_PERC) {
yield put(UIActions.setShowNoEventsLeftBanner(true))
diff --git a/src/redux/sagas/ui/worker_live_visitors.js b/src/redux/sagas/ui/worker_live_visitors.js
index db6564cf3..3ff9cd445 100644
--- a/src/redux/sagas/ui/worker_live_visitors.js
+++ b/src/redux/sagas/ui/worker_live_visitors.js
@@ -1,4 +1,6 @@
-import { put, call, delay, select } from 'redux-saga/effects'
+import {
+ put, call, delay, select,
+} from 'redux-saga/effects'
import _map from 'lodash/map'
import _filter from 'lodash/filter'
import _isEmpty from 'lodash/isEmpty'
diff --git a/src/redux/store/index.js b/src/redux/store/index.js
index 687ba2ebb..032f4635e 100644
--- a/src/redux/store/index.js
+++ b/src/redux/store/index.js
@@ -1,14 +1,14 @@
import { createStore, applyMiddleware, compose } from 'redux'
import createSagaMiddleware from 'redux-saga'
-import root_reducer from 'redux/reducers'
-import root_saga from 'redux/sagas'
+import rootReducer from 'redux/reducers'
+import rootSaga from 'redux/sagas'
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const sagaMiddleware = createSagaMiddleware()
export const store = createStore(
- root_reducer,
- composeEnhancers(applyMiddleware(sagaMiddleware))
+ rootReducer,
+ composeEnhancers(applyMiddleware(sagaMiddleware)),
)
-sagaMiddleware.run(root_saga)
\ No newline at end of file
+sagaMiddleware.run(rootSaga)
diff --git a/src/ui/Alert.jsx b/src/ui/Alert.jsx
index 4cf0f26be..2956043b9 100644
--- a/src/ui/Alert.jsx
+++ b/src/ui/Alert.jsx
@@ -6,28 +6,36 @@ import {
CheckCircleIcon, InformationCircleIcon, XCircleIcon, XIcon,
} from '@heroicons/react/solid'
-const AlertTemplate = ({ message, options, className, close }) => {
+const AlertTemplate = ({
+ message, options, className, close,
+}) => {
const { type } = options
const isInfo = type === 'info'
const isSuccess = type === 'success'
const isError = type === 'error'
return (
- <div className={cx('flex justify-between items-center mb-5 mr-2 rounded-md p-4 z-20 shadow-sm w-96 pointer-events-auto', {
- 'bg-green-50': isSuccess,
- 'bg-blue-50': isInfo,
- 'bg-red-50': isError,
- }, className)}>
+ <div
+ className={cx('flex justify-between items-center mb-5 mr-2 rounded-md p-4 z-20 shadow-sm w-96 pointer-events-auto', {
+ 'bg-green-50': isSuccess,
+ 'bg-blue-50': isInfo,
+ 'bg-red-50': isError,
+ }, className)}
+ >
<div className='flex-shrink-0'>
{isInfo && <InformationCircleIcon className='h-5 w-5 mr-2 text-blue-400' />}
{isSuccess && <CheckCircleIcon className='h-5 w-5 mr-2 text-green-400' />}
{isError && <XCircleIcon className='h-6 w-6 mr-2 text-red-400' />}
</div>
- <span className={cx('text-sm font-medium uppercase', {
- 'text-green-800': isSuccess,
- 'text-blue-700': isInfo,
- 'text-red-800': isError,
- })}>{message}</span>
+ <span
+ className={cx('text-sm font-medium uppercase', {
+ 'text-green-800': isSuccess,
+ 'text-blue-700': isInfo,
+ 'text-red-800': isError,
+ })}
+ >
+ {message}
+ </span>
<button
onClick={close}
type='button'
@@ -35,7 +43,8 @@ const AlertTemplate = ({ message, options, className, close }) => {
'bg-green-50 text-green-500 hover:bg-green-100 focus:ring-offset-green-50 focus:ring-green-600': isSuccess,
'bg-blue-50 text-blue-500 hover:bg-blue-100 focus:ring-offset-blue-50 focus:ring-blue-600': isInfo,
'bg-red-50 text-red-500 hover:bg-red-100 focus:ring-offset-red-50 focus:ring-red-600': isError,
- })}>
+ })}
+ >
<span className='sr-only'>Dismiss</span>
<XIcon className='h-5 w-5' />
</button>
@@ -46,7 +55,9 @@ const AlertTemplate = ({ message, options, className, close }) => {
AlertTemplate.propTypes = {
message: PropTypes.string,
className: PropTypes.string,
- options: PropTypes.object,
+ options: PropTypes.shape({
+ type: PropTypes.oneOf(['info', 'success', 'error']),
+ }),
close: PropTypes.func,
}
@@ -57,4 +68,4 @@ AlertTemplate.defaultProps = {
close: () => { },
}
-export default memo(AlertTemplate)
\ No newline at end of file
+export default memo(AlertTemplate)
diff --git a/src/ui/Button.jsx b/src/ui/Button.jsx
index d29606dfd..f2bcd0383 100644
--- a/src/ui/Button.jsx
+++ b/src/ui/Button.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable react/button-has-type */
import React, { memo } from 'react'
import cx from 'clsx'
import PropTypes from 'prop-types'
@@ -60,6 +61,7 @@ Button.defaultProps = {
loading: false,
type: 'button',
className: '',
+ children: null,
}
export default memo(Button)
diff --git a/src/ui/Checkbox.jsx b/src/ui/Checkbox.jsx
index 9dddaabfe..05953f9c2 100644
--- a/src/ui/Checkbox.jsx
+++ b/src/ui/Checkbox.jsx
@@ -33,7 +33,7 @@ const Checkbox = ({
Checkbox.propTypes = {
label: PropTypes.oneOfType([
PropTypes.string, PropTypes.node,
- ]).isRequired,
+ ]),
checked: PropTypes.bool.isRequired,
hint: PropTypes.string,
onChange: PropTypes.func,
diff --git a/src/ui/Dropdown.jsx b/src/ui/Dropdown.jsx
index 63d2fcc19..a55203ffd 100644
--- a/src/ui/Dropdown.jsx
+++ b/src/ui/Dropdown.jsx
@@ -16,10 +16,12 @@ const Dropdown = ({
<p className='mb-2 text-sm text-gray-900'>{desc}</p>
)}
<div>
- <Menu.Button className={cx(buttonClassName ? buttonClassName : 'inline-flex w-full rounded-md border border-gray-300 shadow-sm px-3 md:px-4 py-2 bg-white text-sm font-medium text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500', {
- 'justify-between': aside,
- 'justify-center': !aside,
- })}>
+ <Menu.Button
+ className={cx(buttonClassName || 'inline-flex w-full rounded-md border border-gray-300 shadow-sm px-3 md:px-4 py-2 bg-white text-sm font-medium text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500', {
+ 'justify-between': aside,
+ 'justify-center': !aside,
+ })}
+ >
{title}
<ChevronDownIcon className='-mr-1 ml-2 h-5 w-5' aria-hidden='true' />
</Menu.Button>
@@ -40,7 +42,7 @@ const Dropdown = ({
{_map(items, item => (
<Menu.Item key={keyExtractor ? keyExtractor(item) : item}>
<span
- className={selectItemClassName ? selectItemClassName : 'text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 block px-4 py-2 text-sm cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-600'}
+ className={selectItemClassName || 'text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 block px-4 py-2 text-sm cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-600'}
role='menuitem'
tabIndex='-1'
id='menu-item-0'
@@ -83,6 +85,7 @@ Dropdown.defaultProps = {
keyExtractor: null,
aside: false,
desc: '',
+ items: [],
}
export default memo(Dropdown)
diff --git a/src/ui/Flatpicker.jsx b/src/ui/Flatpicker.jsx
index 2b2d1427e..d56e42830 100644
--- a/src/ui/Flatpicker.jsx
+++ b/src/ui/Flatpicker.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable react/no-unused-class-component-methods, class-methods-use-this */
import React, { memo } from 'react'
import Flatpickr from 'react-flatpickr'
import _size from 'lodash/size'
@@ -20,17 +21,21 @@ class FlatPicker extends React.Component {
}
setCustomDate(dates) {
+ const { onChange } = this.props
+
if (_size(dates) === 2) {
- this.props.onChange(dates)
+ onChange(dates)
}
}
openCalendar = () => {
- this.calendar && this.calendar.current.flatpickr.open()
+ if (this.calendar) {
+ this.calendar.current.flatpickr.open()
+ }
}
removeMonths(date, months) {
- let d = date.getDate()
+ const d = date.getDate()
date.setMonth(date.getMonth() - months)
if (date.getDate() !== d) {
date.setDate(0)
@@ -39,11 +44,13 @@ class FlatPicker extends React.Component {
}
render() {
+ const { value } = this.props
+
return (
<div className='h-0 flatpicker-custom'>
<Flatpickr
id='calendar'
- value={this.props.value}
+ value={value}
options={{
mode: 'range',
maxDate: 'today',
@@ -66,7 +73,7 @@ class FlatPicker extends React.Component {
FlatPicker.propTypes = {
onChange: PropTypes.func,
- value: PropTypes.array,
+ value: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
}
FlatPicker.defaultProps = {
diff --git a/src/ui/Input.jsx b/src/ui/Input.jsx
index 1742c16b1..c4e3d4160 100644
--- a/src/ui/Input.jsx
+++ b/src/ui/Input.jsx
@@ -12,9 +12,11 @@ const Input = ({
return (
<div className={className}>
- <div className={cx({
- 'flex justify-between': label && hint,
- })}>
+ <div
+ className={cx({
+ 'flex justify-between': label && hint,
+ })}
+ >
<label htmlFor={identifier} className='block text-sm font-medium text-gray-700 dark:text-gray-200'>{label}</label>
</div>
<div className='mt-1 relative'>
diff --git a/src/ui/Modal.jsx b/src/ui/Modal.jsx
index 481ea5bd5..2eee53898 100644
--- a/src/ui/Modal.jsx
+++ b/src/ui/Modal.jsx
@@ -2,9 +2,7 @@ import React, { Fragment, memo } from 'react'
import PropTypes from 'prop-types'
import cx from 'clsx'
import { Dialog, Transition } from '@headlessui/react'
-import { CheckIcon } from '@heroicons/react/outline'
-import { ExclamationIcon } from '@heroicons/react/outline'
-import { InformationCircleIcon } from '@heroicons/react/outline'
+import { CheckIcon, ExclamationIcon, InformationCircleIcon } from '@heroicons/react/outline'
const Modal = ({
className, type, title, message, isOpened, onClose, onSubmit, closeText, submitText, submitType, size,
@@ -38,10 +36,12 @@ const Modal = ({
leaveFrom='opacity-100 translate-y-0 sm:scale-100'
leaveTo='opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95'
>
- <div className={cx('inline-block align-bottom bg-white dark:bg-gray-800 rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:px-5 sm:py-4', {
- 'sm:max-w-lg sm:w-full': size === 'regular',
- 'max-w-5xl w-full': size === 'large',
- })}>
+ <div
+ className={cx('inline-block align-bottom bg-white dark:bg-gray-800 rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:px-5 sm:py-4', {
+ 'sm:max-w-lg sm:w-full': size === 'regular',
+ 'max-w-5xl w-full': size === 'large',
+ })}
+ >
<div className='sm:flex sm:items-start'>
{type === 'success' && (
<div className='mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-green-100 sm:mx-0 sm:h-10 sm:w-10'>
@@ -118,7 +118,7 @@ Modal.propTypes = {
closeText: PropTypes.string,
submitText: PropTypes.string,
submitType: PropTypes.oneOf(['regular', 'danger']),
- size: PropTypes.oneOf(['regular', 'large'])
+ size: PropTypes.oneOf(['regular', 'large']),
}
Modal.defaultProps = {
diff --git a/src/ui/Pin.jsx b/src/ui/Pin.jsx
index 4b0218c17..16ca8ffd5 100644
--- a/src/ui/Pin.jsx
+++ b/src/ui/Pin.jsx
@@ -8,7 +8,6 @@ const propTypes = {
}
const defaultProps = {
- label: PropTypes.string.isRequired,
className: '',
}
diff --git a/src/ui/Select.jsx b/src/ui/Select.jsx
index f5f80cfed..f885e1246 100644
--- a/src/ui/Select.jsx
+++ b/src/ui/Select.jsx
@@ -7,70 +7,69 @@ import _map from 'lodash/map'
const Select = ({
title, label, className, items, labelExtractor, keyExtractor, onSelect,
-}) => {
- return (
- <Listbox className={className} value={title} onChange={onSelect}>
- {({ open }) => (
- <>
- <Listbox.Label className='block text-sm whitespace-pre-line font-medium text-gray-700 dark:text-gray-100'>{label}</Listbox.Label>
- <div className='mt-1 relative'>
- <Listbox.Button className='relative w-full bg-white border border-gray-300 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm'>
- <span className='block truncate capitalize'>{title}</span>
- <span className='absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none'>
- <SelectorIcon className='h-5 w-5 text-gray-400' aria-hidden='true' />
- </span>
- </Listbox.Button>
+}) => (
+ <Listbox className={className} value={title} onChange={onSelect}>
+ {({ open }) => (
+ <>
+ <Listbox.Label className='block text-sm whitespace-pre-line font-medium text-gray-700 dark:text-gray-100'>{label}</Listbox.Label>
+ <div className='mt-1 relative'>
+ <Listbox.Button className='relative w-full bg-white border border-gray-300 dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm'>
+ <span className='block truncate capitalize'>{title}</span>
+ <span className='absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none'>
+ <SelectorIcon className='h-5 w-5 text-gray-400' aria-hidden='true' />
+ </span>
+ </Listbox.Button>
- <Transition
- show={open}
- as={Fragment}
- leave='transition ease-in duration-100'
- leaveFrom='opacity-100'
- leaveTo='opacity-0'
+ <Transition
+ show={open}
+ as={Fragment}
+ leave='transition ease-in duration-100'
+ leaveFrom='opacity-100'
+ leaveTo='opacity-0'
+ >
+ <Listbox.Options
+ static
+ className='absolute z-10 mt-1 w-full bg-white dark:bg-gray-700 shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm'
>
- <Listbox.Options
- static
- className='absolute z-10 mt-1 w-full bg-white dark:bg-gray-700 shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm'
- >
- {_map(items, (item) => (
- <Listbox.Option
- key={keyExtractor ? keyExtractor(item) : item}
- className={({ active }) =>
- cx(
- active ? 'text-white bg-indigo-600' : 'text-gray-900',
- 'dark:text-white cursor-default select-none relative py-2 pl-8 pr-4'
- )
- }
- value={labelExtractor ? labelExtractor(item) : item}
- >
- {({ selected, active }) => (
- <>
- <span className={cx(selected ? 'font-semibold' : 'font-normal', 'block truncate capitalize')}>
- {labelExtractor ? labelExtractor(item) : item}
- </span>
+ {_map(items, (item) => (
+ <Listbox.Option
+ key={keyExtractor ? keyExtractor(item) : item}
+ className={({ active }) => cx('dark:text-white cursor-default select-none relative py-2 pl-8 pr-4', {
+ 'text-white bg-indigo-600': active,
+ 'text-gray-900': !active,
+ })}
+ value={labelExtractor ? labelExtractor(item) : item}
+ >
+ {({ selected, active }) => (
+ <>
+ <span className={cx(selected ? 'font-semibold' : 'font-normal', 'block truncate capitalize')}>
+ {labelExtractor ? labelExtractor(item) : item}
+ </span>
- {selected ? (
- <span
- className={cx(
- active ? 'text-white' : 'text-indigo-600',
- 'absolute inset-y-0 left-0 flex items-center pl-1.5'
- )}
- >
- <CheckIcon className='h-5 w-5' aria-hidden='true' />
- </span>
- ) : null}
- </>
- )}
- </Listbox.Option>
- ))}
- </Listbox.Options>
- </Transition>
- </div>
- </>
- )}
- </Listbox>
- )
-}
+ {selected ? (
+ <span
+ className={cx(
+ 'absolute inset-y-0 left-0 flex items-center pl-1.5',
+ {
+ 'text-white': active,
+ 'text-indigo-600': !active,
+ },
+ )}
+ >
+ <CheckIcon className='h-5 w-5' aria-hidden='true' />
+ </span>
+ ) : null}
+ </>
+ )}
+ </Listbox.Option>
+ ))}
+ </Listbox.Options>
+ </Transition>
+ </div>
+ </>
+ )}
+ </Listbox>
+)
Select.propTypes = {
title: PropTypes.string.isRequired,
@@ -89,6 +88,7 @@ Select.defaultProps = {
labelExtractor: null,
keyExtractor: null,
label: '',
+ items: [],
}
export default memo(Select)
diff --git a/src/ui/TimezonePicker.jsx b/src/ui/TimezonePicker.jsx
index 7dbbb9020..1b2159ff5 100644
--- a/src/ui/TimezonePicker.jsx
+++ b/src/ui/TimezonePicker.jsx
@@ -14,19 +14,20 @@ const options = Object.entries(allTimezones)
const tz = now.timezone()
const tzStrings = soft(zone[0])
- let abbr = now.isDST() ? tzStrings[0].daylight?.abbr : tzStrings[0].standard?.abbr
- let altName = now.isDST() ? tzStrings[0].daylight?.name : tzStrings[0].standard?.name
+ const abbr = now.isDST() ? tzStrings[0].daylight?.abbr : tzStrings[0].standard?.abbr
+ const altName = now.isDST() ? tzStrings[0].daylight?.name : tzStrings[0].standard?.name
const min = tz.current.offset * 60
+ // eslint-disable-next-line prefer-template
const hr = `${(min / 60) ^ 0}:` + (min % 60 === 0 ? '00' : Math.abs(min % 60))
const label = `(GMT${hr.includes('-') ? hr : `+${hr}`}) ${zone[1]}`
selectOptions.push({
value: tz.name,
- label: label,
+ label,
offset: tz.current.offset,
abbrev: abbr,
- altName: altName,
+ altName,
})
return selectOptions
@@ -41,18 +42,25 @@ const TimezoneSelect = ({
const keyExtractor = (option) => option?.value
const handleChange = (label) => {
- const tz = _find(options, tz => labelExtractor(tz) === label)
+ const tz = _find(options, timezone => labelExtractor(timezone) === label)
const key = keyExtractor(tz)
onChange(key)
}
const parseTimezone = (zone) => {
- if (typeof zone === 'object' && zone.value && zone.label) return zone
+ if (typeof zone === 'object' && zone.value && zone.label) {
+ return zone
+ }
+
if (typeof zone === 'string') {
return _find(options, tz => tz.value === zone)
- } else if (zone.value && !zone.label) {
+ }
+
+ if (zone.value && !zone.label) {
return _find(options, tz => tz.value === zone.value)
}
+
+ return null
}
return (
diff --git a/src/ui/Tooltip.jsx b/src/ui/Tooltip.jsx
index 816af64d1..525d803a5 100644
--- a/src/ui/Tooltip.jsx
+++ b/src/ui/Tooltip.jsx
@@ -12,7 +12,7 @@ const Tooltip = ({ text, className, tooltipNode }) => (
<span className='opacity-95 relative w-60 z-10 p-2 text-xs leading-none text-white whitespace-no-wrap bg-gray-700 shadow-lg rounded-md'>
{text}
</span>
- <div className='w-3 h-3 -mt-2 rotate-45 bg-gray-700 opacity-95'></div>
+ <div className='w-3 h-3 -mt-2 rotate-45 bg-gray-700 opacity-95' />
</div>
</div>
)
diff --git a/src/ui/icons/PulsatingCircle.jsx b/src/ui/icons/PulsatingCircle.jsx
index b7a2c8498..3f28c4b84 100644
--- a/src/ui/icons/PulsatingCircle.jsx
+++ b/src/ui/icons/PulsatingCircle.jsx
@@ -15,8 +15,8 @@ const types = {
const PulsatingCircle = ({ className, type }) => (
<span className={cx('flex justify-center items-center', types[type]?.pulse, className)}>
- <span className={cx('animate-ping-slow absolute inline-flex rounded-full bg-green-400', types[type]?.pulse)}></span>
- <span className={cx('relative inline-flex rounded-full bg-green-500', types[type]?.base)}></span>
+ <span className={cx('animate-ping-slow absolute inline-flex rounded-full bg-green-400', types[type]?.pulse)} />
+ <span className={cx('relative inline-flex rounded-full bg-green-500', types[type]?.base)} />
</span>
)
diff --git a/src/ui/icons/Spin.jsx b/src/ui/icons/Spin.jsx
index eed71168d..5d0c19659 100644
--- a/src/ui/icons/Spin.jsx
+++ b/src/ui/icons/Spin.jsx
@@ -4,8 +4,8 @@ import PropTypes from 'prop-types'
const Spin = ({ className }) => (
<svg className={cx('animate-spin -ml-1 mr-2 h-4 w-4 text-white', className)} xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'>
- <circle className='opacity-25' cx='12' cy='12' r='10' stroke='currentColor' strokeWidth='4'></circle>
- <path className='opacity-75' fill='currentColor' d='M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z'></path>
+ <circle className='opacity-25' cx='12' cy='12' r='10' stroke='currentColor' strokeWidth='4' />
+ <path className='opacity-75' fill='currentColor' d='M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z' />
</svg>
)
diff --git a/src/utils/accessToken.js b/src/utils/accessToken.js
index 3604e9326..3a6156834 100644
--- a/src/utils/accessToken.js
+++ b/src/utils/accessToken.js
@@ -1,5 +1,5 @@
-import { getItem, setItem, removeItem } from './localstorage'
import { TOKEN } from 'redux/constants'
+import { getItem, setItem, removeItem } from './localstorage'
export const getAccessToken = () => {
const accessToken = getItem(TOKEN)
diff --git a/src/utils/cookie.js b/src/utils/cookie.js
index a755c69a8..c373f62bb 100644
--- a/src/utils/cookie.js
+++ b/src/utils/cookie.js
@@ -1,6 +1,11 @@
export const getCookie = key => {
- const match = document.cookie.match(new RegExp('(^| )' + key + '=([^;]+)'))
- if (match) return match[2]
+ const match = document.cookie.match(new RegExp(`(^| )${key}=([^;]+)`))
+
+ if (match) {
+ return match[2]
+ }
+
+ return null
}
export const setCookie = (key, value, maxAge = 3600, sameSite = 'strict') => {
diff --git a/src/utils/countries.js b/src/utils/countries.js
index 58bd5b9e7..08683ca99 100644
--- a/src/utils/countries.js
+++ b/src/utils/countries.js
@@ -526,7 +526,7 @@ const countries = {
},
ZW: {
d: 'M562.71,527L561.22,526.7L560.27,527.06L558.92,526.55L557.78,526.52L555.99,525.16L553.82,524.7L553,522.8L552.99,521.75L551.79,521.43L548.62,518.18L547.73,516.47L547.17,515.95L546.09,513.6L549.22,513.92L550.13,514.26L551.08,514.19L552.63,512.3L555.07,509.9L556.08,509.68L556.42,508.67L558.01,507.52L560.14,507.12L560.32,508.2L562.66,508.14L563.96,508.75L564.56,509.47L565.9,509.68L567.35,510.62L567.36,514.31L566.81,516.35L566.69,518.55L567.14,519.43L566.83,521.17L566.4,521.44L565.66,523.59z',
- }
+ },
}
export default countries
diff --git a/src/utils/generic.js b/src/utils/generic.js
index f5b39beed..f14637dcb 100644
--- a/src/utils/generic.js
+++ b/src/utils/generic.js
@@ -1,4 +1,7 @@
+import _find from 'lodash/find'
+
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/
+
export const nFormatter = (num, digits) => {
const lookup = [
{ value: 1, symbol: '' },
@@ -7,7 +10,7 @@ export const nFormatter = (num, digits) => {
{ value: 1e9, symbol: 'B' },
]
- const item = lookup.slice().reverse().find((item) => num >= item.value)
+ const item = _find(lookup.slice().reverse(), ({ value }) => num >= value)
return item ? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol : '0'
}