UNPKG

1.26 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.Toast = void 0;
7var react_1 = __importDefault(require("react"));
8var polaris_1 = require("@shopify/polaris");
9var react_compose_1 = __importDefault(require("@shopify/react-compose"));
10var toast_1 = require("../store/reducers/embeddedApp/toast");
11var withFeature_1 = __importDefault(require("../withFeature"));
12/**
13 * The UI component for the Toast feature
14 * @public
15 * */
16function Toast(props) {
17 var actions = props.actions, content = props.store.content;
18 return content ? (react_1.default.createElement(polaris_1.Toast, { error: content.error, duration: content.duration, onDismiss: handleToastDismiss, content: content.message })) : null;
19 function handleToastDismiss() {
20 if (!content) {
21 return;
22 }
23 actions.clear({ id: content.id });
24 actions.legacyClear({ id: content.id });
25 }
26}
27exports.Toast = Toast;
28/**
29 * The Toast feature with its reducer, actions and UI component
30 * @public
31 * */
32exports.default = react_compose_1.default(withFeature_1.default(toast_1.feature))(Toast);