"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
module.exports = StatusFeedback;
var _react = require("react");
var _context = require("@arcblock/ux/lib/Locale/context");
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function StatusFeedback({
  status,
  context,
  onReset
}) {
  const {
    t
  } = (0, _context.useLocaleContext)();
  const prevStatusRef = (0, _react.useRef)(status);
  (0, _react.useEffect)(() => {
    if (status === prevStatusRef.current) return;
    prevStatusRef.current = status;
    if (status === "failed" && context?.type === "error") {
      if (context.code === "CUSTOMER_LIMITED" || context.code === "STOP_ACCEPTING_ORDERS") return;
      _Toast.default.error(context.message || "Payment failed");
      onReset();
    }
  }, [status, context, t, onReset]);
  return null;
}