@blocklet/payment-react
Version:
Reusable react components for payment kit v2
20 lines (19 loc) • 751 B
JavaScript
import { jsx } from "react/jsx-runtime";
import { useSessionContext } from "@blocklet/payment-react-headless";
import { detectScenario } from "../../utils/scenario-detector.js";
import CompositePanel from "./composite-panel.js";
import CreditTopupPanel from "./credit-topup-panel.js";
const SubscriptionPanel = CompositePanel;
export default function ScenarioRouter() {
const { session, items } = useSessionContext();
const scenario = detectScenario(session, items);
switch (scenario) {
case "subscription":
return /* @__PURE__ */ jsx(SubscriptionPanel, {});
case "credit-topup":
return /* @__PURE__ */ jsx(CreditTopupPanel, {});
case "composite":
default:
return /* @__PURE__ */ jsx(CompositePanel, {});
}
}