import React from 'react'; import { ToastContainer, toast } from 'react-toastify'; import { faker } from '@faker-js/faker/locale/fr'; import _ from 'lodash'; import { Container, Row, Button, CardBody, Col, CardHeader, Card, CardFooter, Media, FormGroup, CustomInput } from './../../../components'; import { HeaderMain } from "../../components/HeaderMain"; const positions = [ { label: 'top-left', value: 'top-left' }, { label: 'top-right', value: 'top-right' }, { label: 'top-center', value: 'top-center' }, { label: 'bottom-left', value: 'bottom-left' }, { label: 'bottom-right', value: 'bottom-right' }, { label: 'bottom-center', value: 'bottom-center' }, ]; const types = [ { label: 'info', value: 'info' }, { label: 'success', value: 'success' }, { label: 'warning', value: 'warning' }, { label: 'error', value: 'error' }, { label: 'default', value: 'default' }, ]; const initialState = { position: 'top-right', type: 'default' } // ========== Toast Contents: ============ // eslint-disable-next-line react/prop-types const contentSuccess = ({ closeToast }) => ( Success!

You successfully read this important alert message.

); // eslint-disable-next-line react/prop-types const contentError = ({ closeToast }) => ( Danger!

Change a few things up and try submitting.

); // eslint-disable-next-line react/prop-types const contentInfo = ({ closeToast }) => ( Information!

This alert needs your attention, but it's not important.

); // eslint-disable-next-line react/prop-types const contentWarning = ({ closeToast }) => ( Warning!

Better check yourself, you're not looking too good.

); // eslint-disable-next-line react/prop-types const contentDefault = ({ closeToast }) => ( Attention!

This alert needs your attention, but it's not important.

); // ========== Component: ============ export class Notifications extends React.Component { state = _.clone(initialState); render() { return (

React-Toastify allow you to add notification to your app with ease.
Specially written CSS are available in: /app/styles/plugins/_react-toastify.scss

Position
{ _.map(positions, (position) => ( { this.setState({position: position.value}) } } type="radio" key={`pos-${position.value}`} id={`pos-${position.value}`} /> )) }
Type
{ _.map(types, (type) => ( { this.setState({type: type.value}) } } type="radio" key={`pos-${type.value}`} id={`pos-${type.value}`} /> )) }
); } _showHandler = () => { switch(this.state.type) { case 'info': toast.info(contentInfo); break; case 'success': toast.success(contentSuccess); break; case 'warning': toast.warning(contentWarning); break; case 'error': toast.error(contentError); break; default: toast(contentDefault); break; } } _clearHandler = () => { toast.dismiss(); } _resetHandler = () => { this.setState(initialState); } }