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 ConfirmShare page

Blue Mouseeb8a29c62853
diff --git a/public/locales/en.json b/public/locales/en.json
index 70e2b7d7b..8fdbb9ea2 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -424,6 +424,7 @@
"signin": "Sign in",
"signup": "Sign up",
"verification": "Email verification",
+ "invitation": "Shared project invitation",
"profileSettings": "Profile settings",
"features": "Features",
"dashboard": "Dashboard",
diff --git a/src/App.js b/src/App.js
index 5696c6a50..b1d5be71c 100644
--- a/src/App.js
+++ b/src/App.js
@@ -40,6 +40,7 @@ const ProjectSettings = lazy(() => import('pages/Project/Settings'))
const ViewProject = lazy(() => import('pages/Project/View'))
const Billing = lazy(() => import('pages/Billing'))
const Privacy = lazy(() => import('pages/Privacy'))
+const ConfirmShare = lazy(() => import('pages/Project/ConfirmShare'))
const Terms = lazy(() => import('pages/Terms'))
const NotFound = lazy(() => import('pages/NotFound'))
@@ -101,7 +102,7 @@ const App = () => {
clearInterval(interval)
}
}
- }, [dispatch])
+ }, []) // eslint-disable-line
useEffect(() => {
const loaderEl = document.getElementById('loader')
@@ -127,7 +128,7 @@ const App = () => {
}
}
})()
- }, [dispatch, accessToken, authenticated])
+ }, [accessToken, authenticated]) // eslint-disable-line
useEffect(() => {
if (error) {
@@ -179,6 +180,7 @@ const App = () => {
<Route path={routes.features} component={Features} exact />
<Route path={routes.privacy} component={Privacy} exact />
<Route path={routes.terms} component={Terms} exact />
+ <Route path={routes.confirm_share} component={ConfirmShare} exact />
<Route path='*' component={NotFound} />
</Switch>
</Suspense>
diff --git a/src/api/index.js b/src/api/index.js
index 1e70f4791..883baad07 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -151,6 +151,17 @@ export const verifyEmail = ({ path, id }) =>
: error.response.data.message
})
+export const verifyShare = ({ path, id }) =>
+ api
+ .get(`/project/${path}/${id}`)
+ .then((response) => response.data)
+ .catch((error) => {
+ debug('%s', error)
+ throw _isEmpty(error.response.data?.message)
+ ? error.response.data
+ : error.response.data.message
+ })
+
export const getProjects = () =>
api
.get('/project')
diff --git a/src/pages/Auth/VerifyEmail/index.jsx b/src/pages/Auth/VerifyEmail/index.jsx
index 843d95069..b49450738 100644
--- a/src/pages/Auth/VerifyEmail/index.jsx
+++ b/src/pages/Auth/VerifyEmail/index.jsx
@@ -30,12 +30,14 @@ const VerifyEmail = () => {
},
),
)
- }, [dispatch, id])
+ }, [id]) // eslint-disable-line
if (loading) {
return (
<Title title={t('titles.verification')}>
- <Loader />
+ <div className='min-h-page'>
+ <Loader />
+ </div>
</Title>
)
}
@@ -62,7 +64,7 @@ const VerifyEmail = () => {
}
return (
- <Title title='Email verification'>
+ <Title title={t('titles.verification')}>
<div className='min-h-page bg-gray-50 dark:bg-gray-800'>
<div className='flex justify-center pt-10'>
<div className='rounded-md p-4 w-11/12 bg-green-50 lg:w-4/6'>
diff --git a/src/pages/Project/ConfirmShare/index.jsx b/src/pages/Project/ConfirmShare/index.jsx
new file mode 100644
index 000000000..f78b4633f
--- /dev/null
+++ b/src/pages/Project/ConfirmShare/index.jsx
@@ -0,0 +1,88 @@
+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, XCircleIcon } from '@heroicons/react/solid'
+import _split from 'lodash/split'
+
+import Title from 'components/Title'
+import UIActions from 'redux/actions/ui'
+import Loader from 'ui/Loader'
+
+const ConfirmShare = () => {
+ const { t } = useTranslation('common')
+ const dispatch = useDispatch()
+ const { id } = useParams()
+ const [loading, setLoading] = useState(true)
+ const [error, setError] = useState('')
+
+ useEffect(() => {
+ setLoading(true)
+ const path = _split(window.location.pathname, '/')[1]
+
+ dispatch(
+ UIActions.shareVerifyAsync(
+ { path, id },
+ () => setLoading(false),
+ (verifyError) => {
+ setError(verifyError)
+ setLoading(false)
+ },
+ ),
+ )
+ }, [id]) // eslint-disable-line
+
+ if (loading) {
+ return (
+ <Title title={t('titles.invitation')}>
+ <div className='min-h-page'>
+ <Loader />
+ </div>
+ </Title>
+ )
+ }
+
+ if (error) {
+ return (
+ <Title title={t('titles.invitation')}>
+ <div className='min-h-page bg-gray-50 dark:bg-gray-800'>
+ <div className='flex justify-center pt-10'>
+ <div className='rounded-md p-4 w-11/12 bg-red-50 lg:w-4/6'>
+ <div className='flex'>
+ <div className='flex-shrink-0'>
+ <XCircleIcon className='h-5 w-5 text-red-400' aria-hidden='true' />
+ </div>
+ <div className='ml-3'>
+ <h3 className='text-sm font-medium text-red-800 dark:text-red-500'>{error}</h3>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Title>
+ )
+ }
+
+ return (
+ <Title title={t('titles.invitation')}>
+ <div className='min-h-page bg-gray-50 dark:bg-gray-800'>
+ <div className='flex justify-center pt-10'>
+ <div className='rounded-md p-4 w-11/12 bg-green-50 lg:w-4/6'>
+ <div className='flex'>
+ <div className='flex-shrink-0'>
+ <CheckCircleIcon className='h-5 w-5 text-green-400' aria-hidden='true' />
+ </div>
+ <div className='ml-3'>
+ <h3 className='text-sm font-medium text-green-800 dark:text-green-500'>
+ {t('apiNotifications.acceptInvitation')}
+ </h3>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Title>
+ )
+}
+
+export default memo(ConfirmShare)
diff --git a/src/redux/actions/ui/index.js b/src/redux/actions/ui/index.js
index 1124be596..f3d257ac9 100644
--- a/src/redux/actions/ui/index.js
+++ b/src/redux/actions/ui/index.js
@@ -117,6 +117,11 @@ const setProjectsShareData = (data, id) => ({
},
})
+const shareVerifyAsync = (data, successfulCallback, errorCallback) => ({
+ type: types.SHARE_VERIFY_ASYNC,
+ payload: { data, successfulCallback, errorCallback },
+})
+
const UIActions = {
loadProjects,
setProjects,
@@ -135,6 +140,7 @@ const UIActions = {
setTotalMonthlyEvents,
setShowNoEventsLeftBanner,
setProjectsShareData,
+ shareVerifyAsync,
}
export default UIActions
diff --git a/src/redux/actions/ui/types.js b/src/redux/actions/ui/types.js
index fd80f451f..bcee83b78 100644
--- a/src/redux/actions/ui/types.js
+++ b/src/redux/actions/ui/types.js
@@ -16,4 +16,5 @@ export const types = {
SET_TOTAL_MONTHLY_EVENTS: 'UI_SET_TOTAL_MONTHLY_EVENTS',
SET_SHOW_NO_EVENTS_LEFT: 'UI_SET_SHOW_NO_EVENTS_LEFT',
SET_PROJECTS_SHARE_DATA: 'UI_SET_PROJECTS_SHARE_DATA',
+ SHARE_VERIFY_ASYNC: 'UI_SHARE_VERIFY_ASYNC',
}
diff --git a/src/redux/sagas/ui/index.js b/src/redux/sagas/ui/index.js
index b9f92bad5..7533ccdcf 100644
--- a/src/redux/sagas/ui/index.js
+++ b/src/redux/sagas/ui/index.js
@@ -1,4 +1,4 @@
-import { takeEvery, fork } from 'redux-saga/effects'
+import { takeEvery, fork, takeLatest } from 'redux-saga/effects'
import { types } from '../../actions/ui/types'
import { types as authTypes } from '../../actions/auth/types'
@@ -8,6 +8,7 @@ import liveVisitors from './worker_live_visitors'
// import generalStats from './worker_general_stats'
import setProjectViewPrefs from './set_project_view_prefs'
import isEventsAvailable from './worker_is_events_available'
+import shareVerify from './share_verify'
import logout from './logout'
function* mainUISaga() {
@@ -18,6 +19,7 @@ function* mainUISaga() {
yield takeEvery(types.SET_PROJECT_VIEW_PREFS, setProjectViewPrefs)
yield takeEvery(types.LOAD_PROJECTS, loadProjects)
yield takeEvery(authTypes.LOGOUT, logout)
+ yield takeLatest(types.SHARE_VERIFY_ASYNC, shareVerify)
}
export default mainUISaga
diff --git a/src/redux/sagas/ui/share_verify.js b/src/redux/sagas/ui/share_verify.js
new file mode 100644
index 000000000..9925d6d69
--- /dev/null
+++ b/src/redux/sagas/ui/share_verify.js
@@ -0,0 +1,14 @@
+import { call, put } from 'redux-saga/effects'
+
+import UIActions from 'redux/actions/ui'
+import { verifyShare } from 'api'
+
+export default function* shareVerify({ payload: { data, successfulCallback, errorCallback } }) {
+ try {
+ yield call(verifyShare, data)
+ yield put(UIActions.loadProjects())
+ successfulCallback()
+ } catch (error) {
+ errorCallback(error)
+ }
+}
diff --git a/src/routes.js b/src/routes.js
index 218f887a6..9606095ab 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -3,6 +3,7 @@ const routes = Object.freeze({
signup: '/signup',
reset_password: '/recovery',
new_password_form: '/password-reset/:id',
+ confirm_share: '/share/:id',
main: '/',
dashboard: '/dashboard',
user_settings: '/settings',