@carlonicora/nextjs-jsonapi 6.10.0 → 6.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1825,7 +1825,6 @@ function ProrationPreview({ preview }) {
1825
1825
  /* @__PURE__ */ jsx24("span", { className: "text-foreground", children: formatCurrency(preview.immediateCharge, preview.currency, fmt) })
1826
1826
  ] }) }),
1827
1827
  preview.lineItems.length > 0 && preview.lineItems[0].period && /* @__PURE__ */ jsx24("div", { className: "text-muted-foreground mt-2 text-xs", children: t("billing.ui.proration.next_invoice", {
1828
- date: formatDate(preview.lineItems[0].period.end, fmt),
1829
1828
  amount: formatCurrency(preview.amountDue, preview.currency, fmt)
1830
1829
  }) })
1831
1830
  ] })
@@ -2587,6 +2586,8 @@ function WizardStepReview({
2587
2586
  const discount = codeDiscount ?? carriedDiscount;
2588
2587
  const discountedPrice = applyDiscount(selectedPrice.unitAmount, discount);
2589
2588
  const discountedImmediateCharge = applyDiscount(prorationPreview?.immediateCharge, discount);
2589
+ const isProrationCredit = !isTrialUpgrade && (discountedImmediateCharge ?? prorationPreview?.immediateCharge ?? 0) < 0;
2590
+ const prorationAmount = /* @__PURE__ */ __name((amount) => isProrationCredit ? Math.abs(amount) : amount, "prorationAmount");
2590
2591
  const getDiscountDescription = /* @__PURE__ */ __name(() => {
2591
2592
  if (!discount) return null;
2592
2593
  if (discount.discountType === "percent_off") {
@@ -2622,13 +2623,13 @@ function WizardStepReview({
2622
2623
  className: `${isTrialUpgrade ? "bg-warning/15 border-warning/30" : "bg-primary/10 border-primary/30"} space-y-2 rounded-lg border p-4`,
2623
2624
  children: [
2624
2625
  /* @__PURE__ */ jsx29("h4", { className: `font-medium ${isTrialUpgrade ? "text-warning" : "text-primary"}`, children: isTrialUpgrade ? t("billing.ui.wizard.review.trial_upgrade") : t("billing.ui.wizard.review.proration_summary") }),
2625
- /* @__PURE__ */ jsx29("p", { className: `text-sm ${isTrialUpgrade ? "text-warning" : "text-foreground"}`, children: isTrialUpgrade ? discountedImmediateCharge !== null ? t("billing.ui.wizard.review.trial_upgrade_description_discounted") : t("billing.ui.wizard.review.trial_upgrade_description") : t("billing.ui.wizard.review.proration_description") }),
2626
+ /* @__PURE__ */ jsx29("p", { className: `text-sm ${isTrialUpgrade ? "text-warning" : "text-foreground"}`, children: isTrialUpgrade ? discountedImmediateCharge !== null ? t("billing.ui.wizard.review.trial_upgrade_description_discounted") : t("billing.ui.wizard.review.trial_upgrade_description") : isProrationCredit ? t("billing.ui.wizard.review.proration_credit_description") : t("billing.ui.wizard.review.proration_description") }),
2626
2627
  /* @__PURE__ */ jsxs26("div", { className: "flex justify-between text-sm", children: [
2627
- /* @__PURE__ */ jsx29("span", { className: `${isTrialUpgrade ? "text-warning" : "text-muted-foreground"}`, children: isTrialUpgrade ? t("billing.ui.wizard.review.charge_now") : t("billing.ui.wizard.review.due_now") }),
2628
+ /* @__PURE__ */ jsx29("span", { className: `${isTrialUpgrade ? "text-warning" : "text-muted-foreground"}`, children: isTrialUpgrade ? t("billing.ui.wizard.review.charge_now") : isProrationCredit ? t("billing.ui.wizard.review.credit_now") : t("billing.ui.wizard.review.due_now") }),
2628
2629
  /* @__PURE__ */ jsx29("span", { className: `font-medium ${isTrialUpgrade ? "text-warning" : "text-foreground"}`, children: discountedImmediateCharge !== null ? /* @__PURE__ */ jsxs26(Fragment6, { children: [
2629
- /* @__PURE__ */ jsx29("span", { className: "line-through text-muted-foreground me-2", children: formatCurrency(prorationPreview.immediateCharge, prorationPreview.currency, fmt) }),
2630
- /* @__PURE__ */ jsx29("span", { className: "text-success", children: formatCurrency(discountedImmediateCharge, prorationPreview.currency, fmt) })
2631
- ] }) : formatCurrency(prorationPreview.immediateCharge, prorationPreview.currency, fmt) })
2630
+ /* @__PURE__ */ jsx29("span", { className: "line-through text-muted-foreground me-2", children: formatCurrency(prorationAmount(prorationPreview.immediateCharge), prorationPreview.currency, fmt) }),
2631
+ /* @__PURE__ */ jsx29("span", { className: "text-success", children: formatCurrency(prorationAmount(discountedImmediateCharge), prorationPreview.currency, fmt) })
2632
+ ] }) : formatCurrency(prorationAmount(prorationPreview.immediateCharge), prorationPreview.currency, fmt) })
2632
2633
  ] })
2633
2634
  ]
2634
2635
  }