
* Extract useDashboardNotification Play with config to make app-sdk working in monorepo bump pnpm remove local locks unify deps Changesets Replace appBridge.dispatch(Notification()) with shared useDashboardNotification package Fix build Update klaviyo packages update deps update deps - root next version * update and ix * Restore logic in cms
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import { useCallback } from "react";
|
|
import { actions, useAppBridge } from "@saleor/app-sdk/app-bridge";
|
|
|
|
export const useDashboardNotification = () => {
|
|
const { appBridge } = useAppBridge();
|
|
|
|
return {
|
|
notifySuccess: useCallback(
|
|
(title: string, text?: string) => {
|
|
appBridge?.dispatch(
|
|
actions.Notification({
|
|
status: "success",
|
|
title,
|
|
text,
|
|
})
|
|
);
|
|
},
|
|
[appBridge]
|
|
),
|
|
notifyError: useCallback(
|
|
(title: string, text?: string, apiMessage?: string) => {
|
|
appBridge?.dispatch(
|
|
actions.Notification({
|
|
status: "error",
|
|
title,
|
|
text,
|
|
apiMessage: apiMessage,
|
|
})
|
|
);
|
|
},
|
|
[appBridge]
|
|
),
|
|
notifyWarning: useCallback(
|
|
(title: string, text?: string) => {
|
|
appBridge?.dispatch(
|
|
actions.Notification({
|
|
status: "warning",
|
|
title,
|
|
text,
|
|
})
|
|
);
|
|
},
|
|
[appBridge]
|
|
),
|
|
notifyInfo: useCallback(
|
|
(title: string, text?: string) => {
|
|
appBridge?.dispatch(
|
|
actions.Notification({
|
|
status: "info",
|
|
title,
|
|
text,
|
|
})
|
|
);
|
|
},
|
|
[appBridge]
|
|
),
|
|
};
|
|
};
|