UNPKG

1.24 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 });
6var react_1 = __importDefault(require("react"));
7var polaris_1 = require("@shopify/polaris");
8var react_compose_1 = __importDefault(require("@shopify/react-compose"));
9var toast_1 = require("../store/reducers/embeddedApp/toast");
10var withFeature_1 = __importDefault(require("../withFeature"));
11/**
12 * The UI component for the Toast feature
13 * @public
14 * */
15function Toast(props) {
16 var actions = props.actions, content = props.store.content;
17 return content ? (react_1.default.createElement(polaris_1.Toast, { error: content.error, duration: content.duration, onDismiss: handleToastDismiss, content: content.message })) : null;
18 function handleToastDismiss() {
19 if (!content) {
20 return;
21 }
22 actions.clear({ id: content.id });
23 actions.legacyClear({ id: content.id });
24 }
25}
26exports.Toast = Toast;
27/**
28 * The Toast feature with its reducer, actions and UI component
29 * @public
30 * */
31exports.default = react_compose_1.default(withFeature_1.default(toast_1.feature))(Toast);