Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop Messages component
dominik-zeglenad9ea01513da
diff --git a/saleor/static/dashboard-next/mutations.tsx b/saleor/static/dashboard-next/mutations.tsxindex 8464684f90..b4689bfeab 100644--- a/saleor/static/dashboard-next/mutations.tsx+++ b/saleor/static/dashboard-next/mutations.tsx@@ -8,7 +8,7 @@ import {MutationUpdaterFn} from "react-apollo";-import Messages from "./components/messages";+import useNotifier from "./hooks/useNotifier";import i18n from "./i18n";export interface TypedMutationInnerProps<TData, TVariables> {@@ -27,6 +27,7 @@ export function TypedMutation<TData, TVariables>() {class StrictTypedMutation extends Mutation<TData, TVariables> {}return (props: TypedMutationInnerProps<TData, TVariables>) => {+ const notify = useNotifier();// Obviously, this is workaround to the problem described here:// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/32588const {@@ -39,27 +40,23 @@ export function TypedMutation<TData, TVariables>(typeof props>;return (- <Messages>- {pushMessage => (- <StrictTypedMutation- mutation={mutation}- onCompleted={onCompleted}- onError={err => {- const msg = i18n.t("Something went wrong: {{ message }}", {- message: err.message- });- pushMessage({ text: msg });- if (onError) {- onError(err);- }- }}- variables={variables}- update={update}- >- {children}- </StrictTypedMutation>- )}- </Messages>+ <StrictTypedMutation+ mutation={mutation}+ onCompleted={onCompleted}+ onError={err => {+ const msg = i18n.t("Something went wrong: {{ message }}", {+ message: err.message+ });+ notify({ text: msg });+ if (onError) {+ onError(err);+ }+ }}+ variables={variables}+ update={update}+ >+ {children}+ </StrictTypedMutation>);};}diff --git a/saleor/static/dashboard-next/storybook/stories/components/messages.tsx b/saleor/static/dashboard-next/storybook/stories/components/messages.tsxindex 4e28a934a8..7f65735f46 100644--- a/saleor/static/dashboard-next/storybook/stories/components/messages.tsx+++ b/saleor/static/dashboard-next/storybook/stories/components/messages.tsx@@ -2,36 +2,36 @@ import Button from "@material-ui/core/Button";import { storiesOf } from "@storybook/react";import * as React from "react";-import Messages from "../../../components/messages";+import useNotifier from "../../../hooks/useNotifier";import Decorator from "../../Decorator";storiesOf("Generics / Global messages", module).addDecorator(Decorator)- .add("default", () => (- <Messages>- {pushMessage => (- <Button- color="primary"- variant="contained"- onClick={() => pushMessage({ text: "This is message" })}- >- Push message- </Button>- )}- </Messages>- ))- .add("with undo action", () => (- <Messages>- {pushMessage => (- <Button- color="primary"- variant="contained"- onClick={() =>- pushMessage({ text: "This is message", onUndo: undefined })- }- >- Push message- </Button>- )}- </Messages>- ));+ .add("default", () => {+ const pushMessage = useNotifier();++ return (+ <Button+ color="primary"+ variant="contained"+ onClick={() => pushMessage({ text: "This is message" })}+ >+ Push message+ </Button>+ );+ })+ .add("with undo action", () => {+ const pushMessage = useNotifier();++ return (+ <Button+ color="primary"+ variant="contained"+ onClick={() =>+ pushMessage({ text: "This is message", onUndo: undefined })+ }+ >+ Push message+ </Button>+ );+ });