diff --git a/src/App.js b/src/App.js index b66a47b9..f7a49485 100644 --- a/src/App.js +++ b/src/App.js @@ -2,9 +2,10 @@ import { Provider } from "react-redux"; import MainView from "./components/MainView"; import store from './store/store'; export default function App() { + return ( - + diff --git a/src/actions/createAlert.js b/src/actions/createAlert.js new file mode 100644 index 00000000..788530cf --- /dev/null +++ b/src/actions/createAlert.js @@ -0,0 +1,15 @@ +import store from '../store/store'; + +export const createAlert = ( action) => (dispatch) => { + console.log(action) + const notifications = store.getState().notifications + notifications.push({ + message: action.message, + type: action.type, + visible: true + }) + dispatch({ + type: "ADD_NOTIFICATION", + payload: [...notifications] + }); +} \ No newline at end of file diff --git a/src/actions/index.js b/src/actions/index.js index 4293f8cd..72a4866e 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -13,3 +13,5 @@ export * from "./setHistoryOpen"; export * from "./setApiError"; export * from "./errorHandler"; export * from "./setLabels"; +export * from "./createAlert"; +export * from "./removeAlert"; \ No newline at end of file diff --git a/src/actions/removeAlert.js b/src/actions/removeAlert.js new file mode 100644 index 00000000..9ff78a0f --- /dev/null +++ b/src/actions/removeAlert.js @@ -0,0 +1,10 @@ +import store from '../store/store'; + +export const removeAlert = ( index) => (dispatch) => { + let notifications = store.getState().notifications + notifications[index].visible = false; + dispatch({ + type: "REMOVE_NOTIFICATION", + payload: [...notifications] + }); +} \ No newline at end of file diff --git a/src/components/MainView.js b/src/components/MainView.js index 72b9ffa1..5660f6e1 100644 --- a/src/components/MainView.js +++ b/src/components/MainView.js @@ -3,18 +3,21 @@ import LogView from "./LogView"; import StatusBar from "./StatusBar/StatusBar"; import LabelBrowser from "./LabelBrowser/LabelBrowser" import { UpdateStateFromQueryParams } from "./UpdateStateFromQueryParams"; +import { Notification } from "../plugins/notifications"; export default function MainView() { UpdateStateFromQueryParams() + return (
- + +
) } diff --git a/src/components/StatusBar/StatusBar.js b/src/components/StatusBar/StatusBar.js index a1d6673a..b760a2d8 100644 --- a/src/components/StatusBar/StatusBar.js +++ b/src/components/StatusBar/StatusBar.js @@ -5,6 +5,7 @@ import LinkIcon from "@mui/icons-material/Link"; import AdapterDateFns from "@mui/lab/AdapterDateFns"; import LocalizationProvider from "@mui/lab/LocalizationProvider"; import { + createAlert, setApiError, setIsSubmit, setQueryLimit, @@ -25,6 +26,7 @@ import loadLabels from "../../actions/LoadLabels"; import localUrl from "../../services/localUrl"; import setLinksHistory from "../../actions/setLinksHistory"; import { Tooltip } from "@mui/material"; +import { notificationTypes } from "../../plugins/notifications/consts"; export default function StatusBar() { return ( @@ -191,11 +193,10 @@ export function StatusBarSelectors() { dispatch(setLinksHistory(storedUrl)); } - setCopied(true); - setTimeout(() => { - setCopied(false); - dispatch(setIsSubmit(false)); - }, 1500); + dispatch(createAlert({ + type: notificationTypes.success, + message: LINK_COPIED + })) }, function (err) { console.err("error on copy", err); diff --git a/src/plugins/daterangepicker/index.js b/src/plugins/daterangepicker/index.js index 63189513..0f3d230e 100644 --- a/src/plugins/daterangepicker/index.js +++ b/src/plugins/daterangepicker/index.js @@ -232,7 +232,7 @@ useEffect(()=>{ - : undefined + : '' }>