autumn-js
Version:
Autumn JS Library
182 lines (179 loc) • 6.42 kB
JavaScript
"use client";
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/libraries/react/components/checkout-dialog/lib/checkout-content.tsx
var checkout_content_exports = {};
__export(checkout_content_exports, {
getCheckoutContent: () => getCheckoutContent
});
module.exports = __toCommonJS(checkout_content_exports);
var import_jsx_runtime = require("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__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"Purchase ",
productName
] }),
message: /* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsx)("p", { children: "Update Plan" }),
message: /* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"Start trial for ",
productName
] }),
message: /* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
productName,
" product already scheduled"
] }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"You are currently on product ",
current_product.name,
" and are scheduled to start ",
productName,
" on ",
nextCycleAtStr,
"."
] })
};
case "active":
return {
title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Product already active" }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "You are already subscribed to this product." })
};
case "new":
if (is_free) {
return {
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"Enable ",
productName
] }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"By clicking confirm, ",
productName,
" will be enabled immediately."
] })
};
}
return {
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"Subscribe to ",
productName
] }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"By clicking confirm, you will be subscribed to ",
productName,
" and your card will be charged immediately."
] })
};
case "renew":
return {
title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Renew" }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"By clicking confirm, you will renew your subscription to",
" ",
productName,
"."
] })
};
case "upgrade":
return {
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"Upgrade to ",
productName
] }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"By clicking confirm, you will upgrade to ",
productName,
" and your payment method will be charged immediately."
] })
};
case "downgrade":
return {
title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"Downgrade to ",
productName
] }),
message: /* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsx)("p", { children: "Cancel" }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
"By clicking confirm, your subscription to ",
current_product.name,
" ",
"will end on ",
nextCycleAtStr,
"."
] })
};
default:
return {
title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Change Subscription" }),
message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "You are about to change your subscription." })
};
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getCheckoutContent
});