📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Fixed alerts
Blaumaus9d42cb0abcb2
diff --git a/package.json b/package.jsonindex d1fa628b1..3f52b3162 100644--- a/package.json+++ b/package.json@@ -11,6 +11,8 @@"bootstrap": "^4.6.0","node-sass": "^5.0.0","react": "^17.0.1",+ "react-alert": "^7.0.2",+ "react-alert-template-basic": "^1.0.0","react-bootstrap": "^1.5.2","react-dom": "^17.0.1","react-redux": "^7.2.2",diff --git a/src/App.js b/src/App.jsindex 38fbae7b3..fbd717043 100644--- a/src/App.js+++ b/src/App.js@@ -2,6 +2,7 @@ import React, { useEffect } from 'react'import { Switch, Route, Redirect } from 'react-router-dom'import routes from 'routes'import { useDispatch, useSelector } from 'react-redux'+import { useAlert } from 'react-alert'import Header from 'components/Header'import MainPage from 'pages/MainPage'@@ -15,7 +16,8 @@ import VerifyEmail from 'pages/Auth/VerifyEmail'import { isAuthenticated, notAuthenticated } from './hoc/protected'import { getAccessToken } from 'utils/accessToken'import { authMe } from './api'-import { authActions } from "actions/auth"+import { authActions } from 'actions/auth'+import { errorsActions } from 'actions/errors'const ProtectedSignIn = notAuthenticated(SignIn)const ProtectedSignUp = notAuthenticated(SignUp)@@ -25,6 +27,7 @@ const ProtectedUserSettings = isAuthenticated(UserSettings)const App = () => {const dispatch = useDispatch()+ const alert = useAlert()const { loading, authenticated } = useSelector(state => state.auth)const { error } = useSelector(state => state.errors)const accessToken = getAccessToken()@@ -40,6 +43,16 @@ const App = () => {})()}, [dispatch, accessToken])+ useEffect(() => {+ if (error) {+ alert.error(error, {+ onClose: () => {+ dispatch(errorsActions.clearErrors())+ }+ })+ }+ }, [error])+return ((!accessToken || !loading) && (<>diff --git a/src/index.js b/src/index.jsindex 65ffdc418..7ad115431 100644--- a/src/index.js+++ b/src/index.js@@ -3,18 +3,29 @@ import ReactDOM from 'react-dom'import { BrowserRouter } from 'react-router-dom'import { store } from 'store'import { Provider } from 'react-redux'+import { transitions, positions, Provider as AlertProvider } from 'react-alert'+import AlertTemplate from 'react-alert-template-basic'import './index.scss'import 'bootstrap/dist/css/bootstrap.min.css'import App from './App'// import reportWebVitals from './reportWebVitals'+const options = {+ position: positions.BOTTOM_RIGHT,+ timeout: 7000,+ offset: '30px',+ transition: transitions.SCALE+}+ReactDOM.render(<React.StrictMode>- <Provider store={store}>- <BrowserRouter>- <App />- </BrowserRouter>- </Provider>+ <AlertProvider template={AlertTemplate} {...options}>+ <Provider store={store}>+ <BrowserRouter>+ <App />+ </BrowserRouter>+ </Provider>+ </AlertProvider></React.StrictMode>,document.getElementById('root'))diff --git a/src/sagas/auth/workers/signin.js b/src/sagas/auth/workers/signin.jsindex 3a569c48c..2a13d201c 100644--- a/src/sagas/auth/workers/signin.js+++ b/src/sagas/auth/workers/signin.js@@ -11,7 +11,7 @@ export default function* ({ payload: { credentials } }) {yield put(authActions.loginSuccess(response.user))yield call(setAccessToken, JSON.stringify(response.access_token))} catch (error) {- yield put(errorsActions.loginFailed(`serverErrors.${error.message}`))+ yield put(errorsActions.loginFailed(error.message))} finally {yield put(authActions.finishLoading())}diff --git a/src/sagas/auth/workers/signup.js b/src/sagas/auth/workers/signup.jsindex 1c17c0a00..227542e8a 100644--- a/src/sagas/auth/workers/signup.js+++ b/src/sagas/auth/workers/signup.js@@ -4,14 +4,14 @@ import { errorsActions } from 'actions/errors'import { setAccessToken } from "utils/accessToken"import { signup } from 'api'-export default function* ({ payload: { data, resetRecaptcha } }) {+export default function* ({ payload: { data, resetRecaptcha = () => {} } }) {try {const response = yield call(signup, data)yield put(authActions.signupSuccess(response.user))yield call(setAccessToken, JSON.stringify(response.access_token))} catch (error) {- yield put(errorsActions.signupFailed(`serverErrors.${error.message || (typeof error === 'string' ? error : error[0])}`))+ yield put(errorsActions.signupFailed(error.message || (typeof error === 'string' ? error : error[0])))resetRecaptcha()} finally {yield put(authActions.finishLoading())