2020-06-24 11:44:35 +00:00
|
|
|
import { IMessage } from "@saleor/components/messages";
|
|
|
|
import { useAlert } from "react-alert";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2020-06-24 11:44:35 +00:00
|
|
|
export type UseNotifierResult = (options: IMessage) => void;
|
2019-06-19 14:40:52 +00:00
|
|
|
function useNotifier(): UseNotifierResult {
|
2020-06-24 11:44:35 +00:00
|
|
|
const alert = useAlert();
|
|
|
|
const notify = (options: IMessage) => {
|
|
|
|
alert.show(options, options.autohide && { timeout: options.autohide });
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
return notify;
|
|
|
|
}
|
|
|
|
export default useNotifier;
|