Rev 3432 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect, useState } from 'react';
import { Navigate, useParams } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { axios } from '@utils/index.js';
import { addNotification } from '../../redux/notification/notification.actions';
const ActiveAccount = () => {
const [isValidated, setIsValidated] = useState(false);
const dispatch = useDispatch();
const { uuid } = useParams();
useEffect(() => {
const activeAccount = async () => {
try {
const response = await axios.get(`/activate-account/${uuid}`);
const { data, success } = response.data;
if (!success) {
throw new Error(data);
}
dispatch(addNotification({ style: 'success', msg: data }));
} catch (error) {
console.log(error);
dispatch(addNotification({ style: 'danger', msg: error.message }));
} finally {
setIsValidated(true);
}
};
activeAccount();
}, [uuid]);
if (!isValidated) {
return null;
}
return <Navigate to='/signin' />;
};
export default ActiveAccount;