diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index 0511119b..6c2e1aa4 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -1,8 +1,8 @@ // @flow import * as React from 'react' import { connect } from 'react-redux' +import { useSnackbar } from 'notistack' import { logComponentStack, type Info } from '~/utils/logBoundaries' -import { SharedSnackbarConsumer, type Variant } from '~/components/SharedSnackBar' import { WALLET_ERROR_MSG } from '~/logic/wallets/store/actions' import { getProviderInfo } from '~/logic/wallets/getWeb3' import type { ProviderProps } from '~/logic/wallets/store/model/provider' @@ -14,6 +14,8 @@ import Layout from './component/Layout' import actions, { type Actions } from './actions' import selector, { type SelectorProps } from './selector' +type Variant = 'success' | 'error' | 'warning' | 'info' + type Props = Actions & SelectorProps & { openSnackbar: (message: string, variant: Variant) => void, @@ -116,8 +118,10 @@ const Header = connect( actions, )(HeaderComponent) -const HeaderSnack = () => ( - {({ openSnackbar }) =>
} -) +const HeaderSnack = () => { + const { enqueueSnackbar } = useSnackbar() + + return
+} export default HeaderSnack diff --git a/src/components/SharedSnackBar/index.jsx b/src/components/SharedSnackBar/index.jsx deleted file mode 100644 index c22c9213..00000000 --- a/src/components/SharedSnackBar/index.jsx +++ /dev/null @@ -1,105 +0,0 @@ -// @flow -import * as React from 'react' -import { Snackbar } from '@material-ui/core' -import SnackbarContent from '~/components/SnackbarContent' - -export const SharedSnackbar = () => ( - - {(value) => { - const { - snackbarIsOpen, message, closeSnackbar, variant, - } = value - - return ( - - - - ) - }} - -) - -type SnackbarContext = { - openSnackbar: Function, - closeSnackbar: Function, - snackbarIsOpen: boolean, - message: string, - variant: string, -} - -const SharedSnackbarContext = React.createContext({ - openSnackbar: undefined, - closeSnackbar: undefined, - snackbarIsOpen: false, - message: '', - variant: 'info', -}) - -type Props = { - children: React.Node, -} - -export type Variant = 'success' | 'error' | 'warning' | 'info' - -type State = { - isOpen: boolean, - message: string, - variant: Variant, -} - -export class SharedSnackbarProvider extends React.Component { - constructor(props: Props) { - super(props) - - this.state = { - isOpen: false, - message: '', - variant: 'info', - } - } - - openSnackbar = (message: string, variant: Variant) => { - this.setState({ - message, - variant, - isOpen: true, - }) - } - - closeSnackbar = () => { - this.setState({ - message: '', - isOpen: false, - }) - } - - render() { - const { children } = this.props - const { message, variant, isOpen } = this.state - - return ( - - - {children} - - ) - } -} - -export const SharedSnackbarConsumer = SharedSnackbarContext.Consumer diff --git a/src/components/layout/PageFrame/index.jsx b/src/components/layout/PageFrame/index.jsx index 6159ca41..126e774f 100644 --- a/src/components/layout/PageFrame/index.jsx +++ b/src/components/layout/PageFrame/index.jsx @@ -1,8 +1,9 @@ // @flow import * as React from 'react' -import Header from '~/components/Header' +import { SnackbarProvider } from 'notistack' import SidebarProvider from '~/components/Sidebar' -import { SharedSnackbarProvider } from '~/components/SharedSnackBar' +import Footer from '~/components/Footer' +import Header from '~/components/Header' import styles from './index.scss' type Props = { @@ -10,14 +11,22 @@ type Props = { } const PageFrame = ({ children }: Props) => ( - +
{children}
-
+ ) export default PageFrame diff --git a/src/components/layout/PageFrame/index.scss b/src/components/layout/PageFrame/index.scss index 9727c40e..54ceec03 100644 --- a/src/components/layout/PageFrame/index.scss +++ b/src/components/layout/PageFrame/index.scss @@ -4,3 +4,19 @@ flex: 1 1 auto; max-width: 100%; } + +.success { + background: 'purple'; +} + +.error { + background: 'blue'; +} + +.warning { + background: 'green'; +} + +.info { + background: 'yellow'; +}