mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-07 16:32:28 +02:00
feat: add setting to enable/disable email alert
This commit is contained in:
parent
46c41f9b66
commit
6409975a6e
|
@ -0,0 +1,91 @@
|
||||||
|
//Lib
|
||||||
|
import { ToastContainer, toast } from 'react-toastify';
|
||||||
|
import 'react-toastify/dist/ReactToastify.css';
|
||||||
|
import classes from '../UserSettings.module.css';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { SpinnerDotted } from 'spinners-react';
|
||||||
|
|
||||||
|
//Components
|
||||||
|
import Error from '../../../Components/UI/Error/Error';
|
||||||
|
import Switch from '../../../Components/UI/Switch/Switch';
|
||||||
|
|
||||||
|
export default function EmailAlertSettings(props) {
|
||||||
|
//Var
|
||||||
|
const toastOptions = {
|
||||||
|
position: 'top-right',
|
||||||
|
autoClose: 8000,
|
||||||
|
hideProgressBar: false,
|
||||||
|
closeOnClick: true,
|
||||||
|
pauseOnHover: true,
|
||||||
|
draggable: true,
|
||||||
|
progress: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
////State
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [error, setError] = useState();
|
||||||
|
|
||||||
|
////Functions
|
||||||
|
//Form submit Handler for ADD a repo
|
||||||
|
// const formSubmitHandler = async (data) => {
|
||||||
|
// console.log(data);
|
||||||
|
// //Remove old error
|
||||||
|
// setError();
|
||||||
|
// //Loading button on submit to avoid multiple send.
|
||||||
|
// setIsLoading(true);
|
||||||
|
// //POST API to send the new and old password
|
||||||
|
// const response = await fetch('/api/account/updateEmail', {
|
||||||
|
// method: 'PUT',
|
||||||
|
// headers: {
|
||||||
|
// 'Content-type': 'application/json',
|
||||||
|
// },
|
||||||
|
// body: JSON.stringify(data),
|
||||||
|
// });
|
||||||
|
// const result = await response.json();
|
||||||
|
|
||||||
|
// if (!response.ok) {
|
||||||
|
// setIsLoading(false);
|
||||||
|
// reset();
|
||||||
|
// setError(result.message);
|
||||||
|
// setTimeout(() => setError(), 4000);
|
||||||
|
// } else {
|
||||||
|
// reset();
|
||||||
|
// setIsLoading(false);
|
||||||
|
// setInfo(true);
|
||||||
|
// toast.success('Email edited !', {
|
||||||
|
// position: 'top-right',
|
||||||
|
// autoClose: 5000,
|
||||||
|
// hideProgressBar: false,
|
||||||
|
// closeOnClick: true,
|
||||||
|
// pauseOnHover: true,
|
||||||
|
// draggable: true,
|
||||||
|
// progress: undefined,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
const onChangeSwitchHandler = (e) => {
|
||||||
|
console.log(e);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* EMAIL ALERT */}
|
||||||
|
<div className={classes.containerSetting}>
|
||||||
|
<div className={classes.settingCategory}>
|
||||||
|
<h2>Alerting</h2>
|
||||||
|
</div>
|
||||||
|
<div className={classes.setting}>
|
||||||
|
<div className={classes.bwFormWrapper}>
|
||||||
|
<Switch
|
||||||
|
switchName='Email'
|
||||||
|
switchDescription='You will receive an alert every 24H if you have a down status.'
|
||||||
|
onChange={(e) =>
|
||||||
|
onChangeSwitchHandler({ emailAlert: e })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import classes from './UserSettings.module.css';
|
||||||
import EmailSettings from './EmailSettings/EmailSettings';
|
import EmailSettings from './EmailSettings/EmailSettings';
|
||||||
import PasswordSettings from './PasswordSettings/PasswordSettings';
|
import PasswordSettings from './PasswordSettings/PasswordSettings';
|
||||||
import UsernameSettings from './UsernameSettings/UsernameSettings';
|
import UsernameSettings from './UsernameSettings/UsernameSettings';
|
||||||
|
import EmailAlertSettings from './EmailAlertSettings/EmailAlertSettings';
|
||||||
|
|
||||||
export default function UserSettings(props) {
|
export default function UserSettings(props) {
|
||||||
return (
|
return (
|
||||||
|
@ -21,6 +22,7 @@ export default function UserSettings(props) {
|
||||||
<PasswordSettings username={props.data.user.name} />
|
<PasswordSettings username={props.data.user.name} />
|
||||||
<EmailSettings email={props.data.user.email} />
|
<EmailSettings email={props.data.user.email} />
|
||||||
<UsernameSettings username={props.data.user.name} />
|
<UsernameSettings username={props.data.user.name} />
|
||||||
|
<EmailAlertSettings />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue