2020-03-16 20:57:12 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { SnackbarList } from 'wordpress-components';
|
|
|
|
import { useStoreNotices } from '@woocommerce/base-hooks';
|
2020-04-29 15:45:29 +00:00
|
|
|
import { useEditorContext } from '@woocommerce/base-context';
|
2020-03-16 20:57:12 +00:00
|
|
|
|
|
|
|
const NoticesContainer = () => {
|
2020-04-29 15:45:29 +00:00
|
|
|
const { isEditor } = useEditorContext();
|
2020-03-16 20:57:12 +00:00
|
|
|
const { notices, removeNotice } = useStoreNotices();
|
|
|
|
const snackbarNotices = notices.filter(
|
|
|
|
( notice ) => notice.type === 'snackbar'
|
|
|
|
);
|
2020-04-29 15:45:29 +00:00
|
|
|
|
|
|
|
if ( isEditor ) {
|
|
|
|
return null;
|
|
|
|
}
|
2020-03-16 20:57:12 +00:00
|
|
|
return (
|
|
|
|
<SnackbarList
|
|
|
|
notices={ snackbarNotices }
|
2020-06-17 09:53:42 +00:00
|
|
|
className={ 'wc-block-components-notices__snackbar' }
|
2020-03-16 20:57:12 +00:00
|
|
|
onRemove={ removeNotice }
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default NoticesContainer;
|