UNPKG

autumn-js

Version:
159 lines (155 loc) 4.78 kB
"use client"; // src/libraries/react/components/checkout-dialog/lib/checkout-content.tsx import { jsx, jsxs } from "react/jsx-runtime"; var getCheckoutContent = (checkoutResult) => { const { product, current_product, next_cycle } = checkoutResult; const { is_one_off, is_free, has_trial, updateable } = product.properties; const scenario = product.scenario; const nextCycleAtStr = next_cycle ? new Date(next_cycle.starts_at).toLocaleDateString() : void 0; const productName = product.name; if (is_one_off) { return { title: /* @__PURE__ */ jsxs("p", { children: [ "Purchase ", productName ] }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, you will purchase ", productName, " and your card will be charged immediately." ] }) }; } if (scenario == "active" && updateable) { if (updateable) { return { title: /* @__PURE__ */ jsx("p", { children: "Update Plan" }), message: /* @__PURE__ */ jsx("p", { children: "Update your prepaid quantity. You'll be charged or credited the prorated difference based on your current billing cycle." }) }; } } if (has_trial) { return { title: /* @__PURE__ */ jsxs("p", { children: [ "Start trial for ", productName ] }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, you will start a free trial of ", productName, " ", "which ends on ", nextCycleAtStr, "." ] }) }; } switch (scenario) { case "scheduled": return { title: /* @__PURE__ */ jsxs("p", { children: [ productName, " product already scheduled" ] }), message: /* @__PURE__ */ jsxs("p", { children: [ "You are currently on product ", current_product.name, " and are scheduled to start ", productName, " on ", nextCycleAtStr, "." ] }) }; case "active": return { title: /* @__PURE__ */ jsx("p", { children: "Product already active" }), message: /* @__PURE__ */ jsx("p", { children: "You are already subscribed to this product." }) }; case "new": if (is_free) { return { title: /* @__PURE__ */ jsxs("p", { children: [ "Enable ", productName ] }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, ", productName, " will be enabled immediately." ] }) }; } return { title: /* @__PURE__ */ jsxs("p", { children: [ "Subscribe to ", productName ] }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, you will be subscribed to ", productName, " and your card will be charged immediately." ] }) }; case "renew": return { title: /* @__PURE__ */ jsx("p", { children: "Renew" }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, you will renew your subscription to", " ", productName, "." ] }) }; case "upgrade": return { title: /* @__PURE__ */ jsxs("p", { children: [ "Upgrade to ", productName ] }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, you will upgrade to ", productName, " and your payment method will be charged immediately." ] }) }; case "downgrade": return { title: /* @__PURE__ */ jsxs("p", { children: [ "Downgrade to ", productName ] }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, your current subscription to", " ", current_product.name, " will be cancelled and a new subscription to", " ", productName, " will begin on ", nextCycleAtStr, "." ] }) }; case "cancel": return { title: /* @__PURE__ */ jsx("p", { children: "Cancel" }), message: /* @__PURE__ */ jsxs("p", { children: [ "By clicking confirm, your subscription to ", current_product.name, " ", "will end on ", nextCycleAtStr, "." ] }) }; default: return { title: /* @__PURE__ */ jsx("p", { children: "Change Subscription" }), message: /* @__PURE__ */ jsx("p", { children: "You are about to change your subscription." }) }; } }; export { getCheckoutContent };