refactor: toast notification for settings

This commit is contained in:
bsourisse 2023-01-18 11:20:28 +01:00
parent c9e13316e2
commit dd3956c6bb
3 changed files with 7 additions and 34 deletions

View file

@ -1,5 +1,5 @@
//Lib
import { ToastContainer, toast } from 'react-toastify';
import { toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import classes from '../UserSettings.module.css';
import { useState } from 'react';
@ -25,7 +25,6 @@ export default function EmailSettings(props) {
const {
register,
handleSubmit,
control,
reset,
formState: { errors, isSubmitting, isValid },
} = useForm({ mode: 'onChange' });
@ -61,15 +60,7 @@ export default function EmailSettings(props) {
reset();
setIsLoading(false);
setInfo(true);
toast.success('Email edited !', {
position: 'top-right',
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
toast.success('Email edited !', toastOptions);
}
};
return (

View file

@ -1,5 +1,5 @@
//Lib
import { ToastContainer, toast } from 'react-toastify';
import { toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import classes from '../UserSettings.module.css';
import { useState } from 'react';
@ -13,7 +13,7 @@ export default function PasswordSettings(props) {
//Var
const toastOptions = {
position: 'top-right',
autoClose: 8000,
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
@ -24,7 +24,6 @@ export default function PasswordSettings(props) {
const {
register,
handleSubmit,
control,
reset,
formState: { errors, isSubmitting, isValid },
} = useForm({ mode: 'onChange' });
@ -60,15 +59,7 @@ export default function PasswordSettings(props) {
} else {
reset();
setIsLoading(false);
toast.success('🔑 Password edited !', {
position: 'top-right',
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
toast.success('🔑 Password edited !', toastOptions);
}
};
return (

View file

@ -1,5 +1,5 @@
//Lib
import { ToastContainer, toast } from 'react-toastify';
import { toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import classes from '../UserSettings.module.css';
import { useState } from 'react';
@ -25,7 +25,6 @@ export default function UsernameSettings(props) {
const {
register,
handleSubmit,
control,
reset,
formState: { errors, isSubmitting, isValid },
} = useForm({ mode: 'onChange' });
@ -61,15 +60,7 @@ export default function UsernameSettings(props) {
reset();
setIsLoading(false);
setInfo(true);
toast.success('Username edited !', {
position: 'top-right',
autoClose: 5000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
toast.success('Username edited !', toastOptions);
}
};
return (