@adyen/adyen-platform-experience-web
Version:

37 lines (36 loc) • 1.76 kB
JavaScript
var u = Object.defineProperty;
var h = (o, e, t) => e in o ? u(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
var r = (o, e, t) => h(o, typeof e != "symbol" ? e + "" : e, t);
import { jsx as R } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { isCapitalRegionSupported as v } from "../../internal/CapitalHeader/helpers.js";
import { UIElement as g } from "../UIElement/UIElement.js";
import { CapitalOverview as x } from "./components/CapitalOverview/CapitalOverview.js";
import w from "../../../core/ConfigContext/session/utils/sessionReady.js";
import { EMPTY_OBJECT as l } from "../../../utils/value/constants.js";
import { noop as d } from "../../../utils/common.js";
class y extends g {
constructor(t) {
super(t);
r(this, "componentToRender", () => /* @__PURE__ */ R(x, { ...this.props, ref: (t) => void (this.componentRef = t) }));
this.customClassNames = "adyen-pe-capital-overview-component", this.componentToRender = this.componentToRender.bind(this);
}
async getState() {
var c, m;
const { session: t } = this.props.core;
await w(t);
const { getDynamicGrantOffersConfiguration: i, getGrants: s } = t.context.endpoints, f = (c = t.context.extraConfig) == null ? void 0 : c.legalEntity;
if (!v(f))
return { state: "isInUnsupportedRegion" };
const [a, p] = await Promise.all([
i == null ? void 0 : i(l).catch(d),
s == null ? void 0 : s(l).catch(d)
]);
let n = "isUnqualified";
return p && ((m = p.data) == null ? void 0 : m.length) > 0 ? n = "hasRequestedGrants" : a && a.minAmount && (n = "isPreQualified"), { state: n };
}
}
r(y, "type", "capitalOverview");
export {
y as CapitalOverviewElement,
y as default
};