From fe1beef165fd9f5bbd3247abfd55afcd77093fa3 Mon Sep 17 00:00:00 2001 From: whooaami Date: Sat, 28 Oct 2023 15:26:42 +0300 Subject: [PATCH] Add toast alert for error --- FrontEnd/package-lock.json | 21 +++++++++++++++++++ FrontEnd/package.json | 1 + .../ResendActivationFormContent.js | 12 +++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/FrontEnd/package-lock.json b/FrontEnd/package-lock.json index a9835af6c..6c5b1a51d 100644 --- a/FrontEnd/package-lock.json +++ b/FrontEnd/package-lock.json @@ -25,6 +25,7 @@ "react-router-dom": "^6.4.1", "react-router-hash-link": "^2.4.3", "react-scripts": "5.0.1", + "react-toastify": "^9.1.3", "swr": "^2.2.2", "validator": "^13.11.0", "web-vitals": "^2.1.4" @@ -15725,6 +15726,26 @@ "node": ">=10" } }, + "node_modules/react-toastify": { + "version": "9.1.3", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.3.tgz", + "integrity": "sha512-fPfb8ghtn/XMxw3LkxQBk3IyagNpF/LIKjOBflbexr2AWxAH1MJgvnESwEwBn9liLFXgTKWgBSdZpw9m4OTHTg==", + "dependencies": { + "clsx": "^1.1.1" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, + "node_modules/react-toastify/node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", diff --git a/FrontEnd/package.json b/FrontEnd/package.json index 004f671c5..bb34c1a41 100644 --- a/FrontEnd/package.json +++ b/FrontEnd/package.json @@ -20,6 +20,7 @@ "react-router-dom": "^6.4.1", "react-router-hash-link": "^2.4.3", "react-scripts": "5.0.1", + "react-toastify": "^9.1.3", "swr": "^2.2.2", "validator": "^13.11.0", "web-vitals": "^2.1.4" diff --git a/FrontEnd/src/components/SignUp/components/signup/signup-form/ResendActivationFormContent.js b/FrontEnd/src/components/SignUp/components/signup/signup-form/ResendActivationFormContent.js index bc95b3c8e..ce66fb9d5 100644 --- a/FrontEnd/src/components/SignUp/components/signup/signup-form/ResendActivationFormContent.js +++ b/FrontEnd/src/components/SignUp/components/signup/signup-form/ResendActivationFormContent.js @@ -1,7 +1,8 @@ import { useEffect } from 'react'; import { useForm } from 'react-hook-form'; import { useNavigate } from 'react-router-dom'; - +import { toast, ToastContainer } from 'react-toastify'; +import 'react-toastify/dist/ReactToastify.css'; import axios from 'axios'; import styles from './ResendActivationFormContent.module.css'; @@ -44,7 +45,9 @@ export function ResendActivationFormContentComponent({ setIsValid }) { setIsValid(true); navigate('/login'); }) - .catch((error) => console.log(error)); + .catch(() => { + toast.error('Activation failed. Please try again.'); + }); }; return ( @@ -88,6 +91,11 @@ export function ResendActivationFormContentComponent({ setIsValid }) { + ); } + +ResendActivationFormContentComponent.propTypes = { + setIsValid: PropTypes.func.isRequired, +};