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!

pages/auth/VerifyEmail to ts

kruzhambus41cb017b7039
diff --git a/src/pages/Auth/VerifyEmail/index.jsx b/src/pages/Auth/VerifyEmail/index.tsx
similarity index 87%
rename from src/pages/Auth/VerifyEmail/index.jsx
rename to src/pages/Auth/VerifyEmail/index.tsx
index 9cabb6736..654594d95 100644
--- a/src/pages/Auth/VerifyEmail/index.jsx
+++ b/src/pages/Auth/VerifyEmail/index.tsx
@@ -3,30 +3,38 @@ import { useDispatch } from 'react-redux'
import { useParams, Link } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid'
-import _split from 'lodash/split'
import _isString from 'lodash/isString'
import Title from 'components/Title'
-import { authActions } from 'redux/reducers/auth'
+import sagaActions from 'redux/sagas/actions'
import Loader from 'ui/Loader'
import routes from 'routes'
-const VerifyEmail = () => {
- const { t } = useTranslation('common')
+const VerifyEmail = (): JSX.Element => {
+ const { t }: {
+ t: (key: string, optinions?: {
+ [key: string]: string | number,
+ }) => string,
+ } = useTranslation('common')
const dispatch = useDispatch()
- const { id } = useParams()
- const [loading, setLoading] = useState(true)
- const [error, setError] = useState('')
+ const { id }: {
+ id: string,
+ } = useParams()
+ const [loading, setLoading] = useState<boolean>(true)
+ const [error, setError] = useState<string>('')
useEffect(() => {
setLoading(true)
- const path = _split(window.location.pathname, '/')[1]
dispatch(
- authActions.emailVerifyAsync(
- { path, id },
- () => setLoading(false),
- (verifyError) => {
+ sagaActions.emailVerifyAsync(
+ {
+ id,
+ },
+ () => {
+ setLoading(false)
+ },
+ (verifyError: string | { message: string }) => {
setError(_isString(verifyError) ? verifyError : verifyError.message)
setLoading(false)
},
diff --git a/src/redux/sagas/actions/index.ts b/src/redux/sagas/actions/index.ts
index 263c69b2a..693ebaeaa 100644
--- a/src/redux/sagas/actions/index.ts
+++ b/src/redux/sagas/actions/index.ts
@@ -53,7 +53,7 @@ const signupAsync = (data: {
const emailVerifyAsync = (data: {
id: string,
-}, successfulCallback?: () => {}, errorCallback?: () => {}) => ({
+}, successfulCallback?: () => void, errorCallback?: (e: string) => void) => ({
type: types.EMAIL_VERIFY_ASYNC,
payload: { data, successfulCallback, errorCallback },
})